--- sysindex.php 2005-06-27 18:29:18.000000000 +0300 +++ sysindex-nb.php 2005-07-02 20:49:19.000000000 +0300 @@ -45,21 +45,25 @@ $return = array(); - $return["count"] = ((count($result) % 2) == 0) ? count($result) / 2 : "n/a"; - $return["model"] = ($result[0] != "") ? trim($result[0]) : "n/a"; - $return["mhz"] = ($result[1] != "") ? trim($result[1]) : "n/a"; + $return["count"] = exec("sysctl -n hw.ncpu"); + $return["model"] = exec("sysctl -n hw.model"); + $return["mhz"] = exec("dmesg | grep '[M|G]Hz' | awk -v FS=, '{print $2}' | awk '{print $1}'"); return $return; } function GetMemory($swap = FALSE) { - exec("egrep '" . (($swap == TRUE) ? "SwapTotal|SwapFree" : "MemTotal|MemFree") . "' /proc/meminfo | gawk '{ print $2 }'",$result); +// if ($swap == TRUE) +// return array("total" => 0, "used" => 0, "free" => 0); + + $mem = ($swap == FALSE) ? exec("vmstat | egrep -v '[a-z]' | awk '{print $4,$5}'") : exec("pstat -T | grep swap | awk '{print $1}' | sed 's/\// /'"); + $result = explode(" ",$mem); $return = array(); - $return["total"] = (is_numeric($result[0])) ? trim($result[0]) : "n/a"; - $return["free"] = (is_numeric($result[1])) ? trim($result[1]) : "n/a"; - $return["used"] = (is_numeric($return["total"]) && is_numeric($return["free"])) ? $return["total"] - $return["free"] : "n/a"; + $return["total"] = ($swap == FALSE) ? exec("sysctl -n hw.usermem") / 1024 : $result[1]; + $return["free"] = ($swap == FALSE) ? $result[1] : ($result[1] - $result[0]); + $return["used"] = $result[0]; return $return; } @@ -69,13 +73,13 @@ } function GetUptime() { - $result = exec("cat /proc/uptime | gawk '{print $1}'"); + $result = exec("cat /kern/boottime"); - return (is_numeric($result)) ? $result : "n/a"; + return time() - $result; } function GetLoad() { - $result = explode(" ",exec("cat /proc/loadavg | gawk '{print $1,$2,$3}'")); + $result = explode(",",exec("uptime | awk -v FS='averages:' '{print $2}' | sed 's/ //g'")); foreach ($result as $key => $val) if (!is_numeric($val)) @@ -116,7 +120,7 @@ } function GetFileSystems() { - exec("df -P | grep '^/' | gawk ' { print $1,$3,$4,$6}'",$result); + exec("df -P | grep '^/' | awk ' { print $1,$3,$4,$6}'",$result); foreach ($result as $key => $val) { $fs = array(); @@ -154,13 +158,13 @@ } function GetNetwork() { - exec("/sbin/ifconfig | gawk -v ORS=' ' '/Link/ { print $1 } /addr:[0-9]/ { print $2 } /bytes:/ { print $2,$6,\"\\n\" }' | sed -re 's/bytes:|addr:|inet6 //g'",$result); + $result = explode(",",exec("ifconfig -avu | awk -v ORS=' ' '/flags/ {print $1} /input/ {print$4} /output/ {print $4} /inet/ {print $2\",\"}' | sed 's/://g'")); foreach ($result as $key => $val) if (trim($val) != "") { $if = array(); - list($name,$addr,$rx,$tx) = explode(" ",trim($val)); + list($name,$rx,$tx,$addr) = explode(" ",trim($val)); $if["name"] = ($name != "") ? $name : "n/a"; $if["addr"] = (preg_match("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/",$addr) > 0) ? $addr : "n/a"; @@ -545,7 +549,7 @@
  • net: {SINGLE:GetConnectionCount} connections, {DELAYED:SINGLE:GetNetworkCount} interface(s), {DELAYED:MULTI:GetNetworkTotals}{LIST:GetNetwork}