コード例 #1
0
    while (list($number, $row) = each($mount_points)) {
        if (($number + 1) % 2 == 0) {
            $tpl->assign(array('ITEM_CLASS' => 'content'));
        } else {
            $tpl->assign(array('ITEM_CLASS' => 'content2'));
        }
        $tpl->assign(array('MOUNT' => $row['mount'], 'TYPE' => $row['fstype'], 'PARTITION' => $row['disk'], 'PERCENT' => $row['percent'], 'FREE' => make_hr($row['free'] * 1014), 'USED' => make_hr($row['used'] * 1024), 'SIZE' => make_hr($row['size'] * 1024)));
        $tpl->parse('DISK_LIST_ITEM', '.disk_list_item');
    }
    $tpl->parse('DISK_LIST', 'disk_list');
}
/*
 *
 * static page messages.
 *
 */
gen_admin_menu($tpl);
gen_mount_point($tpl);
$kernel = kernel();
$uptime = uptime();
$load = loadavg();
$cpu = cpu_info();
$mem = memory();
$tpl->assign(array('TR_SYSTEM_INFO_TITLE' => tr('System info'), 'TR_SYSTEM_INFO' => tr('Vital system info'), 'TR_CPU_SYSTEM_INFO' => tr('CPU system Info'), 'TR_CPU_MODEL' => tr('CPU model'), 'TR_CPU_MHZ' => tr('CPU MHz'), 'TR_CPU_CACHE' => tr('CPU cache'), 'TR_CPU_BOGOMIPS' => tr('CPU bogomips'), 'CPU_MODEL' => $cpu['model'], 'CPU_MHZ' => $cpu['mhz'], 'CPU_CACHE' => $cpu['cache'], 'CPU_BOGOMIPS' => $cpu['bogomips'], 'TR_MEMRY_SYSTEM_INFO' => tr('Memory system info'), 'TR_RAM' => tr('RAM'), 'TR_TOTAL' => tr('Total'), 'TR_USED' => tr('Used'), 'TR_FREE' => tr('Free'), 'TR_SWAP' => tr('Swap'), 'TR_UPTIME' => tr('Up time'), 'UPTIME' => $uptime, 'TR_KERNEL' => tr('Kernel'), 'KERNEL' => $kernel, 'TR_LOAD' => tr('Load'), 'LOAD' => $load[0] . ' ' . $load[1] . '  ' . $load[0], 'RAM' => tr('RAM'), 'RAM_TOTAL' => format_bytesize($mem['ram']['total']), 'RAM_USED' => format_bytesize($mem['ram']['used']), 'RAM_FREE' => format_bytesize($mem['ram']['free']), 'SWAP_TOTAL' => format_bytesize($mem['swap']['total']), 'SWAP_USED' => format_bytesize($mem['swap']['used']), 'SWAP_FREE' => format_bytesize($mem['swap']['free']), 'TR_FILE_SYSTEM_INFO' => tr('Filesystem system Info'), 'TR_MOUNT' => tr('Mount'), 'TR_TYPE' => tr('Type'), 'TR_PARTITION' => tr('Partition'), 'TR_PERCENT' => tr('Percent'), 'TR_SIZE' => tr('Size')));
gen_page_message($tpl);
$tpl->parse('PAGE', 'page');
$tpl->prnt();
if (isset($cfg['DUMP_GUI_DEBUG'])) {
    dump_gui_debug();
}
unset_messages();
コード例 #2
0
    <table width='100%' border='1' cellspacing='0' cellpadding='1'>
		<tr><td align='center'>
		<table class='main' border='0' width='402'>
    <tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>";
    $perc = get_server_load();
    $percent = min(100, $perc);
    if ($percent <= 70) $pic = "loadbargreen.gif";
    elseif ($percent <= 90) $pic = "loadbaryellow.gif";
    else $pic = "loadbarred.gif";
    $width = $percent * 4;
    $HTMLOUT .="<img height='15' width='$width' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='$percent&#37;' /><br />{$lang['index_load_curr']}{$percent}{$lang['index_load_cpu']}<br /></td></tr></table></td></tr></table></div><br />";
    //==End
*/
//==Server Load linux
$HTMLOUT .= "\n    <div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>\n    <div style='background:transparent;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_serverload']}</span></div>\n    <br />\n    <table width='100%' border='1' cellspacing='0' cellpadding='1'>\n\t\t\t<tr><td align='center'>\n\t\t    <table class='main' border='0' width='402'>\n    \t\t\t<tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>";
$percent = min(100, round(exec('ps ax | grep -c apache') / 256 * 100));
if ($percent <= 70) {
    $pic = "loadbargreen.gif";
} elseif ($percent <= 90) {
    $pic = "loadbaryellow.gif";
} else {
    $pic = "loadbarred.gif";
}
$width = $percent * 4;
$HTMLOUT .= "<img height='15' width='{$width}' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='{$percent}&#37;' /><br />{$lang['index_load_curr']}{$percent}{$lang['index_load_cpu']}<br />";
//==End graphic
$HTMLOUT .= "{$lang['index_load_uptime1']}" . uptime() . "";
$loadinfo = loadavg(true);
$HTMLOUT .= "<br />\n    {$lang['index_load_pastmin']}" . $loadinfo["last1"] . "<br />\n    {$lang['index_load_pastmin5']}" . $loadinfo["last5"] . "<br />\n    {$lang['index_load_pastmin15']}" . $loadinfo["last15"] . "<br />\n    {$lang['index_load_numtsk']}" . $loadinfo["tasks"] . "<br />\n    {$lang['index_load_numproc']}" . $loadinfo["processes"] . "<br />\n   {$lang['index_load_pid']}" . $loadinfo["lastpid"] . "<br />\n    </td></tr></table></td></tr></table></div><br />";
//==End
echo stdhead($lang['index_serverload']) . $HTMLOUT . stdfoot();
コード例 #3
0
ファイル: exec.watchdog.php プロジェクト: rsd/artica-1.5
include_once(dirname(__FILE__)."/framework/frame.class.inc");
//server-syncronize-64.png

if(preg_match("#--verbose#",implode(" ",$argv))){$GLOBALS["VERBOSE"]=true;}
if(preg_match("#--force#",implode(" ",$argv))){$GLOBALS["FORCE"]=true;}


$unix=new unix();
$pidfile="/etc/artica-postfix/".basename(__FILE__)."pid";
$currentpid=trim(@file_get_contents($pidefile));
if($unix->process_exists($currentpid)){die();}

@file_put_contents($pidfile,getmypid());


if($argv[1]=="--loadavg"){loadavg();exit;}
if($argv[1]=="--mem"){loadmem();exit;}
if($argv[1]=="--cpu"){loadcpu();exit;}
if($argv[1]=="--queues"){ParseLoadQeues();exit;}



checkProcess1();

function checkProcess1(){
	
	$unix=new unix();
	$pid=$unix->PIDOF_PATTERN("bin/process1");
	if($pid<5){return null;}
	$process1=$unix->PROCCESS_TIME_MIN($pid);
	$mem=$unix->PROCESS_MEMORY($pid);
コード例 #4
0
ファイル: exec.watchdog.php プロジェクト: brucewu16899/artica
include_once dirname(__FILE__) . '/ressources/class.artica.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . "/framework/frame.class.inc";
//server-syncronize-64.png
if (preg_match("#--verbose#", implode(" ", $argv))) {
    $GLOBALS["VERBOSE"] = true;
}
if (preg_match("#--force#", implode(" ", $argv))) {
    $GLOBALS["FORCE"] = true;
}
if (!Build_pid_func(__FILE__, "MAIN")) {
    Myevents(basename(__FILE__) . ":Already executed.. aborting the process");
    die;
}
if ($argv[1] == "--loadavg") {
    loadavg();
    exit;
}
if ($argv[1] == "--mem") {
    loadmem();
    exit;
}
if ($argv[1] == "--cpu") {
    loadcpu();
    exit;
}
checkProcess1();
function checkProcess1()
{
    $unix = new unix();
    $pid = $unix->PIDOF_PATTERN("bin/process1");
コード例 #5
0
ファイル: scrd.php プロジェクト: nikkiii/php-scrd
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, 0, 12909) or die('Could not bind to address');
socket_listen($sock);

echo "Listening\n";

while(true) {
	$client = socket_accept($sock);
	$addr = "";
	socket_getpeername($client, $addr);
	echo "Socket opened: $addr\n";
	if(in_array($addr, $conf['white'])) {
		$resp = array();
		$resp['hostname'] = hostname();
		$resp['who'] = who();
		$resp['uplo'] = array_merge(array("uptime" => uptime()), loadavg());
		$resp['ram'] = memory();
		$resp['ips'] = ip_addresses();
		$reps['disk'] = diskusage();
		socket_write($client, json_encode($resp));
	} else {
		socket_write($client, json_encode(array("error" => "Unauthorized")));
	}
	socket_close($client);
}

socket_close($sock);

function hostname() {
	return trim(file_get_contents("/proc/sys/kernel/hostname"));
}
コード例 #6
0
ファイル: stats.php プロジェクト: startrekfinalfrontier/UI
    if ($fd = fopen('/proc/cpuinfo', 'r')) {
        $results = array();
        $results['cores'] = 0;
        while ($buf = fgets($fd, 512)) {
            if (stristr($buf, "model name")) {
                strtok($buf, ':');
                $results['model'] = strtok(':');
                $results['cores']++;
            }
        }
        fclose($fd);
    }
    return $results;
}
// loadavg
$loadavg = loadavg();
// uptime
$uptime = uptime();
// free ram
$results = memory();
// cpu type
$cpu = cpu();
for ($t = 0; $t < 13; $t++) {
    $r_tmp = $db->queryrow('SELECT COUNT(user_id) AS num FROM user WHERE user_race=' . $t . ' AND user_auth_level=1');
    $race['racecount_' . $t] = $r_tmp['num'];
}
$t_percent = $db->queryrow('SELECT COUNT(user_id) AS num FROM user WHERE user_auth_level=1');
for ($t = 0; $t < 13; $t++) {
    $race['racepercent_' . $t] = round(100 / $t_percent['num'] * $race['racecount_' . $t], 0);
}
for ($t = 0; $t < 13; $t++) {