|
发表于 2011-9-15 21:44:00
|
显示全部楼层
[ol] document.write('= 0.95) { echo '繁忙 ['.$loadaverage.']'; } elseif ($loadaverage >= 0.35) { echo '正常 ['.$loadaverage.']'; } else echo '空闲 ['.$loadaverage.']';}// LOAD AVGif (false === ($str = @file("/proc/loadavg"))) return false;$str = explode(" ", implode("", $str));$str = array_chunk($str, 4);$loadAvg = implode(" ", $str[0]);echo "
平均 : " . $loadAvg;// UPTIMEif (false === ($str = @file("/proc/uptime"))) return false;$str = explode(" ", implode("", $str));$str = trim($str[0]);$min = $str / 60;$hours = $min / 60;$days = floor($hours / 24);$hours = floor($hours - ($days * 24));$min = floor($min - ($days * 60 * 24) - ($hours * 60));if ($days !== 0) $uptime = $days."天";if ($hours !== 0) $uptime .= $hours."小时";$uptime .= $min."分钟";echo "
在线 : " . $uptime;// MEMORYif (false === ($str = @file("/proc/meminfo"))) return false;$str = implode("", $str);preg_match_all("/MemTotal\s{0,}\:+\s{0,}([\d\.]+).+?MemFree\s{0,}\:+\s{0,}([\d\.]+).+?Cached\s{0,}\:+\s{0,}([\d\.]+).+?SwapTotal\s{0,}\:+\s{0,}([\d\.]+).+?SwapFree\s{0,}\:+\s{0,}([\d\.]+)/s", $str, $buf);$memTotal = round($buf[1][0]/1024, 2);$memFree = round($buf[2][0]/1024, 2);$memUsed = ($memTotal-$memFree);echo '
内存 : ' . $memUsed . 'M[' .$memFree . "M]";?>');[/ol]复制代码 |
|