'/', "KTC (/x/eng/ktc)" => '/x/eng/ktc'); #Config END $VERSION = "1.0.8"; $host = trim(`hostname`); $uptime = timespan(file_get_contents("/proc/uptime")); $timestamp = date("Y-m-d G:m:s"); function row($k='',$v='') { if (strlen($k) && strlen($v)) { echo "$k:$v\n"; } elseif (strlen($k)) { echo "$k\n"; } else { echo " \n"; } } ?> Status of '<?=$host?>'
System report

Status of ''

Time: · Up:

$dir) { $free = disk_free_space($dir); $total = disk_total_space($dir); row("   - $name",sprintf("%.1f / %.1f GB (%.1f%%)",$free/(1024*1024*1024),$total/(1024*1024*1024),100*$free/$total)); } row(); } $mdstat = @file_get_contents("/proc/mdstat"); if (strstr($mdstat,"active")) { row("RAID status (mdstat)","
".htmlspecialchars(trim($mdstat))."
"); row(); } $t = read_kvp("/proc/acpi/thermal_zone/THRM/temperature","/:\s*/"); if ($t && $t['temperature']) { row("Temperature",$t['temperature']); } #print_r($m); #row( ?>
$ ".htmlspecialchars($s)."\n"; print htmlspecialchars(preg_replace("/\e.*?m/","",`$s`)); } function timespan($s) { if ($s>24*60*60) { $d = intval($s/(24*60*60)); $s -= $d*24*60*60; } if ($s> 60*60) { $h = intval($s/( 60*60)); $s -= $h *60*60; } if ($s> 60) { $m = intval($s/( 60)); $s -= $m *60; } if ($d) return sprintf("%d days %dh %02dm %02ds",$d,$h,$m,$s); if ($h) return sprintf("%dh %02dm %02ds",$h,$m,$s); if ($m) return sprintf("%dm %02ds",$m,$s); return sprintf("%ds",$s); } function read_kvp($file,$delim="/=/") { $fp = @fopen($file,"r"); if (!$fp) return; while ($line = fgets($fp)) { list($key,$value) = preg_split($delim,$line); $value = trim($value,"'\"\n \t"); $h[$key] = $value; } fclose($fp); #print_r($h); return $h; } function get_os() { $os = trim(@file_get_contents("/etc/redhat-release")); if ($os) return $os; if ($d = read_kvp("/etc/lsb-release")) { if ($d['DISTRIB_DESCRIPTION']) return $d['DISTRIB_DESCRIPTION']; elseif ($d['DISTRIB_ID'] && $d['DISTRIB_RELEASE']) return $d['DISTRIB_ID'] .' '. $d['DISTRIB_RELEASE']; } $os = trim(@file_get_contents("/etc/issue")); if (!preg_match("/\n/",$os)) { # if it's multiline, it's less likely to be the OS and more likely to be a custom message $os = trim(preg_replace("/\\\\./",'',$os)); return $os; } $os = trim(@file_get_contents("/etc/issue.net")); if (!preg_match("/\n/",$os)) { # if it's multiline, it's less likely to be the OS and more likely to be a custom message $os = trim(preg_replace("/\\\\./",'',$os)); return $os; } return; } function update_check() { # ubuntu specific for now $fp = @fopen("/var/run/updates-available","r"); if (!$fp) return; while ($line = fgets($fp)) { if (preg_match("/(\d+) packages? can be updated/",$line,$m)) $h['packages'] = $m[1]; if (preg_match("/(\d+) .*security/",$line,$m)) $h['security'] = $m[1]; } fclose($fp); if (strlen($h['packages']) && strlen($h['security'])) return $h; else return; } ?>