Ejemplo n.º 1
0
$users_out = substr($update_out[2], strrpos($update_out[2], ' ') + 1);
$uptime_out = substr($update_out[2], 0, strrpos($update_out[2], ' ') - 2);
$load_out = str_replace(', ', ', <small>', $update_out[4]) . str_repeat('</small>', 2);
#HDD info
$harddrive = explode(' ', preg_replace('/\\s\\s+/', ' ', exec('df /dev/xvda1')));
$harddrive_out = format_bytes(kb2bytes($harddrive[2])) . '<small> / ' . format_bytes(kb2bytes($harddrive[1])) . ' <small>(' . calculate_percentage(kb2bytes($harddrive[2]), kb2bytes($harddrive[1])) . '% Free)</small></small>';
#bandwidth info
$vnstat = explode(';', shell_exec('vnstat --oneline'));
$vnstat[8] = '&#8595; ' . $vnstat[8];
$vnstat[9] = ' <small>&#8593; ' . $vnstat[9];
$vnstat[10] = ' <small>&#8597; ' . $vnstat[10];
$vnstat[11] = ' @ ~' . $vnstat[11];
#ram and swap
$memory = array('Total RAM' => 'MemTotal', 'Free RAM' => 'MemFree', 'Cached RAM' => 'Cached', 'Total Swap' => 'SwapTotal', 'Free Swap' => 'SwapFree');
foreach ($memory as $key => $value) {
    $memory[$key] = kb2bytes(numbers_only(exec('grep -E "^' . $value . '" /proc/meminfo')));
}
$memory['Used Swap'] = $memory['Total Swap'] - $memory['Free Swap'];
$memory['Used RAM'] = $memory['Total RAM'] - $memory['Free RAM'] - $memory['Cached RAM'];
$memory['RAM Percent Free'] = calculate_percentage($memory['Used RAM'], $memory['Total RAM']);
$memory['Swap Percent Free'] = calculate_percentage($memory['Used Swap'], $memory['Total Swap']);
$memory_out = format_bytes($memory['Used RAM']) . '<small> / ' . format_bytes($memory['Total RAM']) . ' <small> *' . format_bytes($memory['Cached RAM']) . ' Cached (' . $memory['RAM Percent Free'] . '% Free)</small></small>';
$swap_out = 'swap<span>' . format_bytes($memory['Used Swap']) . '<small> / ' . format_bytes($memory['Total Swap']) . ' <small>(' . $memory['Swap Percent Free'] . '% Free)</small></small></span>';
?>
<!DOCTYPE html>
<html>
	<head>
		<title>#/g/tv - Shell Server</title>
		<meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noodp" /> <!-- I f*****g hate robots... -->
		<meta name="description" content="Status page for #/g/tv shell server." />
		<meta charset="UTF-8" />
Ejemplo n.º 2
0
$users_out = substr($update_out[2], strrpos($update_out[2], ' ') + 1);
$uptime_out = substr($update_out[2], 0, strrpos($update_out[2], ' ') - 2);
// Array containing the three load averages
$load_out = explode(", ", $update_out[4]);
// Hard drive percentage
$hd = explode(" ", exec("df /"));
$hd_out = 100 - calculate_percentage($hd[2], $hd[1]);
$memory = array('Total RAM' => 'MemTotal', 'Free RAM' => 'MemFree', 'Cached RAM' => 'Cached', 'Total Swap' => 'SwapTotal', 'Free Swap' => 'SwapFree');
foreach ($memory as $key => $value) {
    $memory[$key] = kb2bytes(numbers_only(exec('grep -E "^' . $value . '" /proc/meminfo')));
}
$memory['Used Swap'] = $memory['Total Swap'] - $memory['Free Swap'];
$memory['Used RAM'] = $memory['Total RAM'] - $memory['Free RAM'] - $memory['Cached RAM'];
$memory['RAM Percent Free'] = calculate_percentage($memory['Used RAM'], $memory['Total RAM']);
$memory['Swap Percent Free'] = calculate_percentage($memory['Used Swap'], $memory['Total Swap']);
$temp = exec('acpi -t');
$temp = str_replace("Thermal 0: ok, ", "", $temp);
$cpu = exec('cat /proc/cpuinfo | grep "cpu MHz"');
$cpu_ar = explode(" ", $cpu);
$cpu_out = (int) $cpu_ar[2];
define('GREEN', "#3DB015");
define('YELLOW', "#FAFC4F");
define('RED', "#C9362E");
// Since we can't specify checking of any arbitrary process from the AJAX request (injection risk), we pre-define the processes here.
$processes = array("apache" => "", "mysql" => "", "craftbukkit" => "");
foreach ($processes as $key => $value) {
    $processes[$key] = checkProcess($key);
}
$result = array("uptime" => $uptime_out, "temp" => $temp, "load" => array($load_out[0], $load_out[1], $load_out[2]), "proc" => $cpu_out, "disk" => array($hd_out, format_bytes(kb2bytes($hd[2])), format_bytes(kb2bytes($hd[1]))), "memory" => array($memory["RAM Percent Free"], $memory["Used RAM"], $memory["Total RAM"], format_bytes($memory["Used RAM"]), format_bytes($memory["Total RAM"])), "service" => array("apache" => $processes["apache"], "mysql" => $processes["mysql"], "craftbukkit" => $processes["craftbukkit"]));
header("Content-type: application/json");
echo json_encode($result);