/web/acc/phpsysinfo/includes/os/class.WINNT.inc.php |
---|
0,0 → 1,344 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// WINNT implementation written by Carl C. Longnecker, longneck@iname.com |
// $Id: class.WINNT.inc.php,v 1.25 2007/03/07 20:21:27 bigmichi1 Exp $ |
class sysinfo { |
// $wmi holds the COM object that we pull all the WMI data from |
var $wmi; |
// $wmidevices holds all devices, which are in the system |
var $wmidevices; |
// this constructor initialis the $wmi object |
function sysinfo () |
{ |
// don't set this params for local connection, it will not work |
$strHostname = ''; |
$strUser = ''; |
$strPassword = ''; |
// initialize the wmi object |
$objLocator = new COM("WbemScripting.SWbemLocator"); |
if($strHostname == "") { |
$this->wmi = $objLocator->ConnectServer(); |
} else{ |
$this->wmi = $objLocator->ConnectServer($strHostname, "rootcimv2", "$strHostname\$strUser", $strPassword); |
} |
} |
// private function for getting a list of values in the specified context, optionally filter this list, based on the list from second parameter |
function _GetWMI($strClass, $strValue = array() ) { |
$objWEBM = $this->wmi->Get($strClass); |
if( PHP_VERSION < 5 ) { |
$objProp = $objWEBM->Properties_; |
$arrProp = $objProp->Next($objProp->Count); |
$objWEBMCol = $objWEBM->Instances_(); |
$arrWEBMCol = $objWEBMCol->Next($objWEBMCol->Count); |
} else { |
$arrProp = $objWEBM->Properties_; |
$arrWEBMCol = $objWEBM->Instances_(); |
} |
foreach($arrWEBMCol as $objItem) |
{ |
@reset($arrProp); |
$arrInstance = array(); |
foreach($arrProp as $propItem) |
{ |
eval("\$value = \$objItem->" .$propItem->Name .";"); |
if( empty( $strValue ) ) { |
$arrInstance[$propItem->Name] = trim($value); |
} else { |
if( in_array( $propItem->Name, $strValue ) ) { |
$arrInstance[$propItem->Name] = trim($value); |
} |
} |
} |
$arrData[] = $arrInstance; |
} |
return $arrData; |
} |
// private function for getting different device types from the system |
function _devicelist ( $strType ) { |
if( empty( $this->wmidevices ) ) { |
$this->wmidevices = $this->_GetWMI( "Win32_PnPEntity", array( "Name", "PNPDeviceID" ) ); |
} |
$list = array(); |
foreach ( $this->wmidevices as $device ) { |
if ( substr( $device["PNPDeviceID"], 0, strpos( $device["PNPDeviceID"], "\\" ) + 1 ) == ( $strType . "\\" ) ) { |
$list[] = $device["Name"]; |
} |
} |
return $list; |
} |
// get our apache SERVER_NAME or vhost |
function vhostname () { |
if (! ($result = getenv('SERVER_NAME'))) { |
$result = 'N.A.'; |
} |
return $result; |
} |
// get the IP address of our vhost name |
function vip_addr () { |
return gethostbyname($this->vhostname()); |
} |
// get our canonical hostname |
function chostname () |
{ |
$buffer = $this->_GetWMI( "Win32_ComputerSystem", array( "Name" ) ); |
$result = $buffer[0]["Name"]; |
return gethostbyaddr(gethostbyname($result)); |
} |
// get the IP address of our canonical hostname |
function ip_addr () |
{ |
$buffer = $this->_GetWMI( "Win32_ComputerSystem", array( "Name" ) ); |
$result = $buffer[0]["Name"]; |
return gethostbyname($result); |
} |
function kernel () |
{ |
$buffer = $this->_GetWMI( "Win32_OperatingSystem", array( "Version", "ServicePackMajorVersion" ) ); |
$result = $buffer[0]["Version"]; |
if( $buffer[0]["ServicePackMajorVersion"] > 0 ) { |
$result .= " SP" . $buffer[0]["ServicePackMajorVersion"]; |
} |
return $result; |
} |
// get the time the system is running |
function uptime () |
{ |
$result = 0; |
$buffer = $this->_GetWMI( "Win32_OperatingSystem", array( "LastBootUpTime", "LocalDateTime" ) ); |
$byear = intval(substr($buffer[0]["LastBootUpTime"], 0, 4)); |
$bmonth = intval(substr($buffer[0]["LastBootUpTime"], 4, 2)); |
$bday = intval(substr($buffer[0]["LastBootUpTime"], 6, 2)); |
$bhour = intval(substr($buffer[0]["LastBootUpTime"], 8, 2)); |
$bminute = intval(substr($buffer[0]["LastBootUpTime"], 10, 2)); |
$bseconds = intval(substr($buffer[0]["LastBootUpTime"], 12, 2)); |
$lyear = intval(substr($buffer[0]["LocalDateTime"], 0, 4)); |
$lmonth = intval(substr($buffer[0]["LocalDateTime"], 4, 2)); |
$lday = intval(substr($buffer[0]["LocalDateTime"], 6, 2)); |
$lhour = intval(substr($buffer[0]["LocalDateTime"], 8, 2)); |
$lminute = intval(substr($buffer[0]["LocalDateTime"], 10, 2)); |
$lseconds = intval(substr($buffer[0]["LocalDateTime"], 12, 2)); |
$boottime = mktime($bhour, $bminute, $bseconds, $bmonth, $bday, $byear); |
$localtime = mktime($lhour, $lminute, $lseconds, $lmonth, $lday, $lyear); |
$result = $localtime - $boottime; |
return $result; |
} |
// count the users, which are logged in |
function users () |
{ |
if( stristr( $this->kernel(), "2000 P" ) ) return "N.A."; |
$buffer = $this->_GetWMI( "Win32_PerfRawData_TermService_TerminalServices", array( "TotalSessions" ) ); |
return $buffer[0]["TotalSessions"]; |
} |
// get the load of the processors |
function loadavg ($bar = false) |
{ |
$buffer = $this->_GetWMI( "Win32_Processor", array( "LoadPercentage" ) ); |
$cpuload = array(); |
for( $i = 0; $i < count( $buffer ); $i++ ) { |
$cpuload['avg'][] = $buffer[$i]["LoadPercentage"]; |
} |
if ($bar) { |
$cpuload['cpupercent'] = array_sum( $cpuload['avg'] ) / count( $buffer ); |
} |
return $cpuload; |
} |
// get some informations about the cpu's |
function cpu_info () |
{ |
$buffer = $this->_GetWMI( "Win32_Processor", array( "Name", "L2CacheSize", "CurrentClockSpeed", "ExtClock" ) ); |
$results["cpus"] = 0; |
foreach ($buffer as $cpu) { |
$results["cpus"]++; |
$results["model"] = $cpu["Name"]; |
$results["cache"] = $cpu["L2CacheSize"]; |
$results["cpuspeed"] = $cpu["CurrentClockSpeed"]; |
$results["busspeed"] = $cpu["ExtClock"]; |
} |
return $results; |
} |
// get the pci devices from the system |
function pci () |
{ |
$pci = $this->_devicelist( "PCI" ); |
return $pci; |
} |
// get the ide devices from the system |
function ide () |
{ |
$buffer = $this->_devicelist( "IDE" ); |
$ide = array(); |
foreach ( $buffer as $device ) { |
$ide[]['model'] = $device; |
} |
return $ide; |
} |
// get the scsi devices from the system |
function scsi () |
{ |
$scsi = $this->_devicelist( "SCSI" ); |
return $scsi; |
} |
// get the usb devices from the system |
function usb () |
{ |
$usb = $this->_devicelist( "USB" ); |
return $usb; |
} |
// get the sbus devices from the system - currently not called |
function sbus () |
{ |
$sbus = $this->_devicelist( "SBUS" ); |
return $sbus; |
} |
// get the netowrk devices and rx/tx bytes |
function network () { |
$results = array(); |
$buffer = $this->_GetWMI( "Win32_PerfRawData_Tcpip_NetworkInterface" ); |
foreach( $buffer as $device ) { |
$dev_name = $device["Name"]; |
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_perfrawdata_tcpip_networkinterface.asp |
// there is a possible bug in the wmi interfaceabout uint32 and uint64: http://www.ureader.com/message/1244948.aspx, so that |
// magative numbers would occour, try to calculate the nagative value from total - positive number |
if( $device["BytesSentPersec"] < 0) { |
$results[$dev_name]['tx_bytes'] = $device["BytesTotalPersec"] - $device["BytesReceivedPersec"]; |
} else { |
$results[$dev_name]['tx_bytes'] = $device["BytesSentPersec"]; |
} |
if( $device["BytesReceivedPersec"] < 0 ) { |
$results[$dev_name]['rx_bytes'] = $device["BytesTotalPersec"] - $device["BytesSentPersec"]; |
} else { |
$results[$dev_name]['rx_bytes'] = $device["BytesReceivedPersec"]; |
} |
$results[$dev_name]['rx_packets'] = $device["PacketsReceivedPersec"]; |
$results[$dev_name]['tx_packets'] = $device["PacketsSentPersec"]; |
$results[$dev_name]['rx_errs'] = $device["PacketsReceivedErrors"]; |
$results[$dev_name]['rx_drop'] = $device["PacketsReceivedDiscarded"]; |
$results[$dev_name]['errs'] = $device["PacketsReceivedErrors"]; |
$results[$dev_name]['drop'] = $device["PacketsReceivedDiscarded"]; |
} |
return $results; |
} |
function memory () |
{ |
$buffer = $this->_GetWMI( "Win32_LogicalMemoryConfiguration", array( "TotalPhysicalMemory" ) ); |
$results['ram']['total'] = $buffer[0]["TotalPhysicalMemory"]; |
$buffer = $this->_GetWMI( "Win32_PerfRawData_PerfOS_Memory", array( "AvailableKBytes" ) ); |
$results['ram']['free'] = $buffer[0]["AvailableKBytes"]; |
$results['ram']['used'] = $results['ram']['total'] - $results['ram']['free']; |
$results['ram']['percent'] = ceil( ( $results['ram']['used'] * 100 ) / $results['ram']['total'] ); |
$results['swap']['total'] = 0; |
$results['swap']['used'] = 0; |
$results['swap']['free'] = 0; |
$buffer = $this->_GetWMI( "Win32_PageFileUsage" ); // no need to filter, using nearly everything from output |
$k = 0; |
foreach ($buffer as $swapdevice) { |
$results['devswap'][$k]['dev'] = $swapdevice["Name"]; |
$results['devswap'][$k]['total'] = $swapdevice["AllocatedBaseSize"] * 1024; |
$results['devswap'][$k]['used'] = $swapdevice["CurrentUsage"] * 1024; |
$results['devswap'][$k]['free'] = ( $swapdevice["AllocatedBaseSize"] - $swapdevice["CurrentUsage"] ) * 1024; |
$results['devswap'][$k]['percent'] = ceil( $swapdevice["CurrentUsage"] / $swapdevice["AllocatedBaseSize"] ); |
$results['swap']['total'] += $results['devswap'][$k]['total']; |
$results['swap']['used'] += $results['devswap'][$k]['used']; |
$results['swap']['free'] += $results['devswap'][$k]['free']; |
$k += 1; |
} |
$results['swap']['percent'] = ceil( $results['swap']['used'] / $results['swap']['total'] * 100 ); |
return $results; |
} |
// get the filesystem informations |
function filesystems () |
{ |
$typearray = array("Unknown", "No Root Directory", "Removeable Disk", |
"Local Disk", "Network Drive", "Compact Disc", "RAM Disk"); |
$floppyarray = array("Unknown", "5 1/4 in.", "3 1/2 in.", "3 1/2 in.", |
"3 1/2 in.", "3 1/2 in.", "5 1/4 in.", "5 1/4 in.", "5 1/4 in.", |
"5 1/4 in.", "5 1/4 in.", "Other", "HD", "3 1/2 in.", "3 1/2 in.", |
"5 1/4 in.", "5 1/4 in.", "3 1/2 in.", "3 1/2 in.", "5 1/4 in.", |
"3 1/2 in.", "3 1/2 in.", "8 in."); |
$buffer = $this->_GetWMI( "Win32_LogicalDisk" , array( "Name", "Size", "FreeSpace", "FileSystem", "DriveType", "MediaType" ) ); |
$k = 0; |
foreach ( $buffer as $filesystem ) { |
if ( hide_mount( $filesystem["Name"] ) ) { |
continue; |
} |
$results[$k]['mount'] = $filesystem["Name"]; |
$results[$k]['size'] = $filesystem["Size"] / 1024; |
$results[$k]['used'] = ( $filesystem["Size"] - $filesystem["FreeSpace"] ) / 1024; |
$results[$k]['free'] = $filesystem["FreeSpace"] / 1024; |
@$results[$k]['percent'] = ceil( $results[$k]['used'] / $results[$k]['size'] * 100 ); // silence this line, nobody is having a floppy in the drive everytime |
$results[$k]['fstype'] = $filesystem["FileSystem"]; |
$results[$k]['disk'] = $typearray[$filesystem["DriveType"]]; |
if ( $filesystem["MediaType"] != "" && $filesystem["DriveType"] == 2 ) $results[$k]['disk'] .= " (" . $floppyarray[$filesystem["MediaType"]] . ")"; |
$k += 1; |
} |
return $results; |
} |
function distro () |
{ |
$buffer = $this->_GetWMI( "Win32_OperatingSystem", array( "Caption" ) ); |
return $buffer[0]["Caption"]; |
} |
function distroicon () |
{ |
return 'xp.gif'; |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.NetBSD.inc.php |
---|
0,0 → 1,111 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.NetBSD.inc.php,v 1.18 2006/04/18 16:57:32 bigmichi1 Exp $ |
if (!defined('IN_PHPSYSINFO')) { |
die("No Hacking"); |
} |
require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php'); |
class sysinfo extends bsd_common { |
var $cpu_regexp; |
var $scsi_regexp; |
// Our contstructor |
// this function is run on the initialization of this class |
function sysinfo () { |
$this->bsd_common(); |
$this->cpu_regexp = "^cpu(.*)\, (.*) MHz"; |
$this->scsi_regexp1 = "^(.*) at scsibus.*: <(.*)> .*"; |
$this->scsi_regexp2 = "^(da[0-9]): (.*)MB "; |
$this->cpu_regexp2 = "/user = (.*), nice = (.*), sys = (.*), intr = (.*), idle = (.*)/"; |
$this->pci_regexp1 = '/(.*) at pci[0-9] dev [0-9]* function [0-9]*: (.*)$/'; |
$this->pci_regexp2 = '/"(.*)" (.*).* at [.0-9]+ irq/'; |
} |
function get_sys_ticks () { |
$a = $this->grab_key('kern.boottime'); |
$sys_ticks = time() - $a; |
return $sys_ticks; |
} |
function network () { |
$netstat_b = execute_program('netstat', '-nbdi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"'); |
$netstat_n = execute_program('netstat', '-ndi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"'); |
$lines_b = explode("\n", $netstat_b); |
$lines_n = explode("\n", $netstat_n); |
$results = array(); |
for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) { |
$ar_buf_b = preg_split("/\s+/", $lines_b[$i]); |
$ar_buf_n = preg_split("/\s+/", $lines_n[$i]); |
if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) { |
$results[$ar_buf_b[0]] = array(); |
$results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3]; |
$results[$ar_buf_b[0]]['rx_packets'] = $ar_buf_n[3]; |
$results[$ar_buf_b[0]]['rx_errs'] = $ar_buf_n[4]; |
$results[$ar_buf_b[0]]['rx_drop'] = $ar_buf_n[8]; |
$results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4]; |
$results[$ar_buf_b[0]]['tx_packets'] = $ar_buf_n[5]; |
$results[$ar_buf_b[0]]['tx_errs'] = $ar_buf_n[6]; |
$results[$ar_buf_b[0]]['tx_drop'] = $ar_buf_n[8]; |
$results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6]; |
$results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8]; |
} |
} |
return $results; |
} |
// get the ide device information out of dmesg |
function ide () { |
$results = array(); |
$s = 0; |
for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) { |
$buf = $this->dmesg[$i]; |
if (preg_match('/^(.*) at (pciide|wdc|atabus|atapibus)[0-9] (.*): <(.*)>/', $buf, $ar_buf)) { |
$s = $ar_buf[1]; |
$results[$s]['model'] = $ar_buf[4]; |
$results[$s]['media'] = 'Hard Disk'; |
// now loop again and find the capacity |
for ($j = 0, $max1 = count($this->read_dmesg()); $j < $max1; $j++) { |
$buf_n = $this->dmesg[$j]; |
if (preg_match("/^($s): (.*), (.*), (.*)MB, .*$/", $buf_n, $ar_buf_n)) { |
$results[$s]['capacity'] = $ar_buf_n[4] * 2048 * 1.049; |
} elseif (preg_match("/^($s): (.*) MB, (.*), (.*), .*$/", $buf_n, $ar_buf_n)) { |
$results[$s]['capacity'] = $ar_buf_n[2] * 2048; |
} |
} |
} |
} |
asort($results); |
return $results; |
} |
function distroicon () { |
$result = 'NetBSD.png'; |
return($result); |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.BSD.common.inc.php |
---|
0,0 → 1,300 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.BSD.common.inc.php,v 1.52 2006/06/13 18:31:52 bigmichi1 Exp $ |
if (!defined('IN_PHPSYSINFO')) { |
die("No Hacking"); |
} |
require_once(APP_ROOT . '/includes/os/class.parseProgs.inc.php'); |
class bsd_common { |
var $dmesg; |
var $parser; |
// Our constructor |
// this function is run on the initialization of this class |
function bsd_common () { |
$this->parser = new Parser(); |
$this->parser->df_param = ""; |
} |
// read /var/run/dmesg.boot, but only if we haven't already. |
function read_dmesg () { |
if (! $this->dmesg) { |
if( PHP_OS == "Darwin" ) { |
$this->dmesg = array(); |
} else { |
$parts = explode("rebooting", rfts( '/var/run/dmesg.boot' ) ); |
$this->dmesg = explode("\n", $parts[count($parts) - 1]); |
} |
} |
return $this->dmesg; |
} |
// grabs a key from sysctl(8) |
function grab_key ($key) { |
return execute_program('sysctl', "-n $key"); |
} |
// get our apache SERVER_NAME or vhost |
function hostname () { |
if (!($result = getenv('SERVER_NAME'))) { |
$result = "N.A."; |
} |
return $result; |
} |
// get our canonical hostname |
function chostname () { |
return execute_program('hostname'); |
} |
// get the IP address of our canonical hostname |
function ip_addr () { |
if (!($result = getenv('SERVER_ADDR'))) { |
$result = gethostbyname($this->chostname()); |
} |
return $result; |
} |
function kernel () { |
$s = $this->grab_key('kern.version'); |
$a = explode(':', $s); |
return $a[0] . $a[1] . ':' . $a[2]; |
} |
function uptime () { |
$result = $this->get_sys_ticks(); |
return $result; |
} |
function users () { |
return execute_program('who', '| wc -l'); |
} |
function loadavg ($bar = false) { |
$s = $this->grab_key('vm.loadavg'); |
$s = ereg_replace('{ ', '', $s); |
$s = ereg_replace(' }', '', $s); |
$results['avg'] = explode(' ', $s); |
if ($bar) { |
if ($fd = $this->grab_key('kern.cp_time')) { |
// Find out the CPU load |
// user + sys = load |
// total = total |
preg_match($this->cpu_regexp2, $fd, $res ); |
$load = $res[2] + $res[3] + $res[4]; // cpu.user + cpu.sys |
$total = $res[2] + $res[3] + $res[4] + $res[5]; // cpu.total |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour) |
sleep(1); |
$fd = $this->grab_key('kern.cp_time'); |
preg_match($this->cpu_regexp2, $fd, $res ); |
$load2 = $res[2] + $res[3] + $res[4]; |
$total2 = $res[2] + $res[3] + $res[4] + $res[5]; |
$results['cpupercent'] = (100*($load2 - $load)) / ($total2 - $total); |
} |
} |
return $results; |
} |
function cpu_info () { |
$results = array(); |
$ar_buf = array(); |
$results['model'] = $this->grab_key('hw.model'); |
$results['cpus'] = $this->grab_key('hw.ncpu'); |
for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) { |
$buf = $this->dmesg[$i]; |
if (preg_match("/$this->cpu_regexp/", $buf, $ar_buf)) { |
$results['cpuspeed'] = round($ar_buf[2]); |
break; |
} |
} |
return $results; |
} |
// get the scsi device information out of dmesg |
function scsi () { |
$results = array(); |
$ar_buf = array(); |
for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) { |
$buf = $this->dmesg[$i]; |
if (preg_match("/$this->scsi_regexp1/", $buf, $ar_buf)) { |
$s = $ar_buf[1]; |
$results[$s]['model'] = $ar_buf[2]; |
$results[$s]['media'] = 'Hard Disk'; |
} elseif (preg_match("/$this->scsi_regexp2/", $buf, $ar_buf)) { |
$s = $ar_buf[1]; |
$results[$s]['capacity'] = $ar_buf[2] * 2048 * 1.049; |
} |
} |
// return array_values(array_unique($results)); |
// 1. more useful to have device names |
// 2. php 4.1.1 array_unique() deletes non-unique values. |
asort($results); |
return $results; |
} |
// get the pci device information out of dmesg |
function pci () { |
$results = array(); |
if( !( is_array($results = $this->parser->parse_lspci()) || is_array($results = $this->parser->parse_pciconf() ))) { |
for ($i = 0, $s = 0; $i < count($this->read_dmesg()); $i++) { |
$buf = $this->dmesg[$i]; |
if(!isset($this->pci_regexp1) && !isset($this->pci_regexp2)) { |
$this->pci_regexp1 = '/(.*): <(.*)>(.*) pci[0-9]$/'; |
$this->pci_regexp2 = '/(.*): <(.*)>.* at [.0-9]+ irq/'; |
} |
if (preg_match($this->pci_regexp1, $buf, $ar_buf)) { |
$results[$s++] = $ar_buf[1] . ": " . $ar_buf[2]; |
} elseif (preg_match($this->pci_regexp2, $buf, $ar_buf)) { |
$results[$s++] = $ar_buf[1] . ": " . $ar_buf[2]; |
} |
} |
asort($results); |
} |
return $results; |
} |
// get the ide device information out of dmesg |
function ide () { |
$results = array(); |
$s = 0; |
for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) { |
$buf = $this->dmesg[$i]; |
if (preg_match('/^(ad[0-9]+): (.*)MB <(.*)> (.*) (.*)/', $buf, $ar_buf)) { |
$s = $ar_buf[1]; |
$results[$s]['model'] = $ar_buf[3]; |
$results[$s]['media'] = 'Hard Disk'; |
$results[$s]['capacity'] = $ar_buf[2] * 2048 * 1.049; |
} elseif (preg_match('/^(acd[0-9]+): (.*) <(.*)> (.*)/', $buf, $ar_buf)) { |
$s = $ar_buf[1]; |
$results[$s]['model'] = $ar_buf[3]; |
$results[$s]['media'] = 'CD-ROM'; |
} |
} |
// return array_values(array_unique($results)); |
// 1. more useful to have device names |
// 2. php 4.1.1 array_unique() deletes non-unique values. |
asort($results); |
return $results; |
} |
// place holder function until we add acual usb detection |
function usb () { |
return array(); |
} |
function sbus () { |
$results = array(); |
$_results[0] = ""; |
// TODO. Nothing here yet. Move along. |
$results = $_results; |
return $results; |
} |
function memory () { |
$s = $this->grab_key('hw.physmem'); |
if (PHP_OS == 'FreeBSD' || PHP_OS == 'OpenBSD') { |
// vmstat on fbsd 4.4 or greater outputs kbytes not hw.pagesize |
// I should probably add some version checking here, but for now |
// we only support fbsd 4.4 |
$pagesize = 1024; |
} else { |
$pagesize = $this->grab_key('hw.pagesize'); |
} |
$results['ram'] = array(); |
$pstat = execute_program('vmstat'); |
$lines = explode("\n", $pstat); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i], 19); |
if ($i == 2) { |
if(PHP_OS == 'NetBSD') { |
$results['ram']['free'] = $ar_buf[5]; |
} else { |
$results['ram']['free'] = $ar_buf[5] * $pagesize / 1024; |
} |
} |
} |
$results['ram']['total'] = $s / 1024; |
$results['ram']['shared'] = 0; |
$results['ram']['buffers'] = 0; |
$results['ram']['used'] = $results['ram']['total'] - $results['ram']['free']; |
$results['ram']['cached'] = 0; |
$results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); |
if (PHP_OS == 'OpenBSD' || PHP_OS == 'NetBSD') { |
$pstat = execute_program('swapctl', '-l -k'); |
} else { |
$pstat = execute_program('swapinfo', '-k'); |
} |
$lines = explode("\n", $pstat); |
$results['swap']['total'] = 0; |
$results['swap']['used'] = 0; |
$results['swap']['free'] = 0; |
for ($i = 1, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i], 6); |
if ($ar_buf[0] != 'Total') { |
$results['swap']['total'] = $results['swap']['total'] + $ar_buf[1]; |
$results['swap']['used'] = $results['swap']['used'] + $ar_buf[2]; |
$results['swap']['free'] = $results['swap']['free'] + $ar_buf[3]; |
$results['devswap'][$i - 1] = array(); |
$results['devswap'][$i - 1]['dev'] = $ar_buf[0]; |
$results['devswap'][$i - 1]['total'] = $ar_buf[1]; |
$results['devswap'][$i - 1]['used'] = $ar_buf[2]; |
$results['devswap'][$i - 1]['free'] = ($results['devswap'][$i - 1]['total'] - $results['devswap'][$i - 1]['used']); |
$results['devswap'][$i - 1]['percent'] = $ar_buf[2] > 0 ? round(($ar_buf[2] * 100) / $ar_buf[1]) : 0; |
} |
} |
$results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']); |
if( is_callable( array( 'sysinfo', 'memory_additional' ) ) ) { |
$results = $this->memory_additional( $results ); |
} |
return $results; |
} |
function filesystems () { |
return $this->parser->parse_filesystems(); |
} |
function distro () { |
$distro = execute_program('uname', '-s'); |
$result = $distro; |
return($result); |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.Linux.inc.php |
---|
0,0 → 1,552 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.Linux.inc.php,v 1.88 2007/02/25 20:50:52 bigmichi1 Exp $ |
if (!defined('IN_PHPSYSINFO')) { |
die("No Hacking"); |
} |
require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php'); |
class sysinfo { |
var $inifile = "distros.ini"; |
var $icon = "unknown.png"; |
var $distro = "unknown"; |
var $parser; |
// get the distro name and icon when create the sysinfo object |
function sysinfo() { |
$this->parser = new Parser(); |
$this->parser->df_param = 'P'; |
$list = @parse_ini_file(APP_ROOT . "/" . $this->inifile, true); |
if (!$list) { |
return; |
} |
$distro_info = execute_program('lsb_release','-a 2> /dev/null', false); // We have the '2> /dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown |
if ( $distro_info != 'ERROR') { |
$distro_tmp = explode("\n",$distro_info); |
foreach( $distro_tmp as $info ) { |
$info_tmp = explode(':', $info, 2); |
$distro[ $info_tmp[0] ] = trim($info_tmp[1]); |
} |
if( !isset( $list[$distro['Distributor ID']] ) ){ |
return; |
} |
$this->icon = isset($list[$distro['Distributor ID']]["Image"]) ? $list[$distro['Distributor ID']]["Image"] : $this->icon; |
$this->distro = $distro['Description']; |
} else { // Fall back in case 'lsb_release' does not exist ;) |
foreach ($list as $section => $distribution) { |
if (!isset($distribution["Files"])) { |
continue; |
} else { |
foreach (explode(";", $distribution["Files"]) as $filename) { |
if (file_exists($filename)) { |
$buf = rfts( $filename ); |
$this->icon = isset($distribution["Image"]) ? $distribution["Image"] : $this->icon; |
$this->distro = isset($distribution["Name"]) ? $distribution["Name"] . " " . trim($buf) : trim($buf); |
break 2; |
} |
} |
} |
} |
} |
} |
// get our apache SERVER_NAME or vhost |
function vhostname () { |
if (! ($result = getenv('SERVER_NAME'))) { |
$result = 'N.A.'; |
} |
return $result; |
} |
// get the IP address of our vhost name |
function vip_addr () { |
return gethostbyname($this->vhostname()); |
} |
// get our canonical hostname |
function chostname () { |
$result = rfts( '/proc/sys/kernel/hostname', 1 ); |
if ( $result == "ERROR" ) { |
$result = "N.A."; |
} else { |
$result = gethostbyaddr( gethostbyname( trim( $result ) ) ); |
} |
return $result; |
} |
// get the IP address of our canonical hostname |
function ip_addr () { |
if (!($result = getenv('SERVER_ADDR'))) { |
$result = gethostbyname($this->chostname()); |
} |
return $result; |
} |
function kernel () { |
$buf = rfts( '/proc/version', 1 ); |
if ( $buf == "ERROR" ) { |
$result = "N.A."; |
} else { |
if (preg_match('/version (.*?) /', $buf, $ar_buf)) { |
$result = $ar_buf[1]; |
if (preg_match('/SMP/', $buf)) { |
$result .= ' (SMP)'; |
} |
} |
} |
return $result; |
} |
function uptime () { |
$buf = rfts( '/proc/uptime', 1 ); |
$ar_buf = explode( ' ', $buf ); |
$result = trim( $ar_buf[0] ); |
return $result; |
} |
function users () { |
$strResult = 0; |
$strBuf = execute_program('who', '-q'); |
if( $strBuf != "ERROR" ) { |
$arrWho = explode( '=', $strBuf ); |
$strResult = $arrWho[1]; |
} |
return $strResult; |
} |
function loadavg ($bar = false) { |
$buf = rfts( '/proc/loadavg' ); |
if( $buf == "ERROR" ) { |
$results['avg'] = array('N.A.', 'N.A.', 'N.A.'); |
} else { |
$results['avg'] = preg_split("/\s/", $buf, 4); |
unset($results['avg'][3]); // don't need the extra values, only first three |
} |
if ($bar) { |
$buf = rfts( '/proc/stat', 1 ); |
if( $buf != "ERROR" ) { |
sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae); |
// Find out the CPU load |
// user + sys = load |
// total = total |
$load = $ab + $ac + $ad; // cpu.user + cpu.sys |
$total = $ab + $ac + $ad + $ae; // cpu.total |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour) |
sleep(1); |
$buf = rfts( '/proc/stat', 1 ); |
sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae); |
$load2 = $ab + $ac + $ad; |
$total2 = $ab + $ac + $ad + $ae; |
$results['cpupercent'] = (100*($load2 - $load)) / ($total2 - $total); |
} |
} |
return $results; |
} |
function cpu_info () { |
$bufr = rfts( '/proc/cpuinfo' ); |
$results = array("cpus" => 0); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
$results = array('cpus' => 0, 'bogomips' => 0); |
$ar_buf = array(); |
foreach( $bufe as $buf ) { |
$arrBuff = preg_split('/\s+:\s+/', trim($buf)); |
if( count( $arrBuff ) == 2 ) { |
$key = $arrBuff[0]; |
$value = $arrBuff[1]; |
// All of the tags here are highly architecture dependant. |
// the only way I could reconstruct them for machines I don't |
// have is to browse the kernel source. So if your arch isn't |
// supported, tell me you want it written in. |
switch ($key) { |
case 'model name': |
$results['model'] = $value; |
break; |
case 'cpu MHz': |
$results['cpuspeed'] = sprintf('%.2f', $value); |
break; |
case 'cycle frequency [Hz]': // For Alpha arch - 2.2.x |
$results['cpuspeed'] = sprintf('%.2f', $value / 1000000); |
break; |
case 'clock': // For PPC arch (damn borked POS) |
$results['cpuspeed'] = sprintf('%.2f', $value); |
break; |
case 'cpu': // For PPC arch (damn borked POS) |
$results['model'] = $value; |
break; |
case 'L2 cache': // More for PPC |
$results['cache'] = $value; |
break; |
case 'revision': // For PPC arch (damn borked POS) |
$results['model'] .= ' ( rev: ' . $value . ')'; |
break; |
case 'cpu model': // For Alpha arch - 2.2.x |
$results['model'] .= ' (' . $value . ')'; |
break; |
case 'cache size': |
$results['cache'] = $value; |
break; |
case 'bogomips': |
$results['bogomips'] += $value; |
break; |
case 'BogoMIPS': // For alpha arch - 2.2.x |
$results['bogomips'] += $value; |
break; |
case 'BogoMips': // For sparc arch |
$results['bogomips'] += $value; |
break; |
case 'cpus detected': // For Alpha arch - 2.2.x |
$results['cpus'] += $value; |
break; |
case 'system type': // Alpha arch - 2.2.x |
$results['model'] .= ', ' . $value . ' '; |
break; |
case 'platform string': // Alpha arch - 2.2.x |
$results['model'] .= ' (' . $value . ')'; |
break; |
case 'processor': |
$results['cpus'] += 1; |
break; |
case 'Cpu0ClkTck': // Linux sparc64 |
$results['cpuspeed'] = sprintf('%.2f', hexdec($value) / 1000000); |
break; |
case 'Cpu0Bogo': // Linux sparc64 & sparc32 |
$results['bogomips'] = $value; |
break; |
case 'ncpus probed': // Linux sparc64 & sparc32 |
$results['cpus'] = $value; |
break; |
} |
} |
} |
// sparc64 specific code follows |
// This adds the ability to display the cache that a CPU has |
// Originally made by Sven Blumenstein <bazik@gentoo.org> in 2004 |
// Modified by Tom Weustink <freshy98@gmx.net> in 2004 |
$sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0'); |
foreach ($sparclist as $name) { |
$buf = rfts( '/proc/openprom/' . $name . '/ecache-size',1 , 32, false ); |
if( $buf != "ERROR" ) { |
$results['cache'] = base_convert($buf, 16, 10)/1024 . ' KB'; |
} |
} |
// sparc64 specific code ends |
// XScale detection code |
if ( $results['cpus'] == 0 ) { |
foreach( $bufe as $buf ) { |
$fields = preg_split('/\s*:\s*/', trim($buf), 2); |
if (sizeof($fields) == 2) { |
list($key, $value) = $fields; |
switch($key) { |
case 'Processor': |
$results['cpus'] += 1; |
$results['model'] = $value; |
break; |
case 'BogoMIPS': //BogoMIPS are not BogoMIPS on this CPU, it's the speed, no BogoMIPS available |
$results['cpuspeed'] = $value; |
break; |
case 'I size': |
$results['cache'] = $value; |
break; |
case 'D size': |
$results['cache'] += $value; |
break; |
} |
} |
} |
$results['cache'] = $results['cache'] / 1024 . " KB"; |
} |
} |
$keys = array_keys($results); |
$keys2be = array('model', 'cpuspeed', 'cache', 'bogomips', 'cpus'); |
while ($ar_buf = each($keys2be)) { |
if (! in_array($ar_buf[1], $keys)) { |
$results[$ar_buf[1]] = 'N.A.'; |
} |
} |
$buf = rfts( '/proc/acpi/thermal_zone/THRM/temperature', 1, 4096, false ); |
if ( $buf != "ERROR" ) { |
$results['temp'] = substr( $buf, 25, 2 ); |
} |
return $results; |
} |
function pci () { |
$arrResults = array(); |
$booDevice = false; |
if( ! $arrResults = $this->parser->parse_lspci() ) { |
$strBuf = rfts( '/proc/pci', 0, 4096, false ); |
if( $strBuf != "ERROR" ) { |
$arrBuf = explode( "\n", $strBuf ); |
foreach( $arrBuf as $strLine ) { |
if( preg_match( '/Bus/', $strLine ) ) { |
$booDevice = true; |
continue; |
} |
if( $booDevice ) { |
list( $strKey, $strValue ) = explode( ': ', $strLine, 2 ); |
if( ! preg_match( '/bridge/i', $strKey ) && ! preg_match( '/USB/i ', $strKey ) ) { |
$arrResults[] = preg_replace( '/\([^\)]+\)\.$/', '', trim( $strValue ) ); |
} |
$booDevice = false; |
} |
} |
asort( $arrResults ); |
} |
} |
return $arrResults; |
} |
function ide () { |
$results = array(); |
$bufd = gdc( '/proc/ide', false ); |
foreach( $bufd as $file ) { |
if (preg_match('/^hd/', $file)) { |
$results[$file] = array(); |
$buf = rfts("/proc/ide/" . $file . "/media", 1 ); |
if ( $buf != "ERROR" ) { |
$results[$file]['media'] = trim($buf); |
if ($results[$file]['media'] == 'disk') { |
$results[$file]['media'] = 'Hard Disk'; |
$buf = rfts( "/proc/ide/" . $file . "/capacity", 1, 4096, false); |
if( $buf == "ERROR" ) { |
$buf = rfts( "/sys/block/" . $file . "/size", 1, 4096, false); |
} |
if ( $buf != "ERROR" ) { |
$results[$file]['capacity'] = trim( $buf ); |
} |
} elseif ($results[$file]['media'] == 'cdrom') { |
$results[$file]['media'] = 'CD-ROM'; |
unset($results[$file]['capacity']); |
} |
} else { |
unset($results[$file]); |
} |
$buf = rfts( "/proc/ide/" . $file . "/model", 1 ); |
if ( $buf != "ERROR" ) { |
$results[$file]['model'] = trim( $buf ); |
if (preg_match('/WDC/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'Western Digital'; |
} elseif (preg_match('/IBM/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'IBM'; |
} elseif (preg_match('/FUJITSU/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'Fujitsu'; |
} else { |
$results[$file]['manufacture'] = 'Unknown'; |
} |
} |
} |
} |
asort($results); |
return $results; |
} |
function scsi () { |
$results = array(); |
$dev_vendor = ''; |
$dev_model = ''; |
$dev_rev = ''; |
$dev_type = ''; |
$s = 1; |
$get_type = 0; |
$bufr = execute_program('lsscsi', '-c', false); |
if( $bufr == "ERROR" ) { |
$bufr = rfts( '/proc/scsi/scsi', 0, 4096, false); |
} |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/Vendor/', $buf)) { |
preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $dev); |
list($key, $value) = explode(': ', $buf, 2); |
$dev_str = $value; |
$get_type = true; |
continue; |
} |
if ($get_type) { |
preg_match('/Type:\s+(\S+)/i', $buf, $dev_type); |
$results[$s]['model'] = "$dev[1] $dev[2] ($dev_type[1])"; |
$results[$s]['media'] = "Hard Disk"; |
$s++; |
$get_type = false; |
} |
} |
} |
asort($results); |
return $results; |
} |
function usb () { |
$results = array(); |
$devnum = -1; |
$bufr = execute_program('lsusb', '', false); |
if( $bufr == "ERROR" ) { |
$bufr = rfts( '/proc/bus/usb/devices', 0, 4096, false ); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/^T/', $buf)) { |
$devnum += 1; |
$results[$devnum] = ""; |
} elseif (preg_match('/^S:/', $buf)) { |
list($key, $value) = explode(': ', $buf, 2); |
list($key, $value2) = explode('=', $value, 2); |
if (trim($key) != "SerialNumber") { |
$results[$devnum] .= " " . trim($value2); |
$devstring = 0; |
} |
} |
} |
} |
} else { |
$bufe = explode( "\n", $bufr ); |
foreach( $bufe as $buf ) { |
$device = preg_split("/ /", $buf, 7); |
if( isset( $device[6] ) && trim( $device[6] ) != "" ) { |
$results[$devnum++] = trim( $device[6] ); |
} |
} |
} |
return $results; |
} |
function sbus () { |
$results = array(); |
$_results[0] = ""; |
// TODO. Nothing here yet. Move along. |
$results = $_results; |
return $results; |
} |
function network () { |
$results = array(); |
$bufr = rfts( '/proc/net/dev' ); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/:/', $buf)) { |
list($dev_name, $stats_list) = preg_split('/:/', $buf, 2); |
$stats = preg_split('/\s+/', trim($stats_list)); |
$results[$dev_name] = array(); |
$results[$dev_name]['rx_bytes'] = $stats[0]; |
$results[$dev_name]['rx_packets'] = $stats[1]; |
$results[$dev_name]['rx_errs'] = $stats[2]; |
$results[$dev_name]['rx_drop'] = $stats[3]; |
$results[$dev_name]['tx_bytes'] = $stats[8]; |
$results[$dev_name]['tx_packets'] = $stats[9]; |
$results[$dev_name]['tx_errs'] = $stats[10]; |
$results[$dev_name]['tx_drop'] = $stats[11]; |
$results[$dev_name]['errs'] = $stats[2] + $stats[10]; |
$results[$dev_name]['drop'] = $stats[3] + $stats[11]; |
} |
} |
} |
return $results; |
} |
function memory () { |
$results['ram'] = array('total' => 0, 'free' => 0, 'used' => 0, 'percent' => 0); |
$results['swap'] = array('total' => 0, 'free' => 0, 'used' => 0, 'percent' => 0); |
$results['devswap'] = array(); |
$bufr = rfts( '/proc/meminfo' ); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/^MemTotal:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['total'] = $ar_buf[1]; |
} else if (preg_match('/^MemFree:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['free'] = $ar_buf[1]; |
} else if (preg_match('/^Cached:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['cached'] = $ar_buf[1]; |
} else if (preg_match('/^Buffers:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['buffers'] = $ar_buf[1]; |
} |
} |
$results['ram']['used'] = $results['ram']['total'] - $results['ram']['free']; |
$results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); |
// values for splitting memory usage |
if (isset($results['ram']['cached']) && isset($results['ram']['buffers'])) { |
$results['ram']['app'] = $results['ram']['used'] - $results['ram']['cached'] - $results['ram']['buffers']; |
$results['ram']['app_percent'] = round(($results['ram']['app'] * 100) / $results['ram']['total']); |
$results['ram']['buffers_percent'] = round(($results['ram']['buffers'] * 100) / $results['ram']['total']); |
$results['ram']['cached_percent'] = round(($results['ram']['cached'] * 100) / $results['ram']['total']); |
} |
$bufr = rfts( '/proc/swaps' ); |
if ( $bufr != "ERROR" ) { |
$swaps = explode("\n", $bufr); |
for ($i = 1; $i < (sizeof($swaps)); $i++) { |
if( trim( $swaps[$i] ) != "" ) { |
$ar_buf = preg_split('/\s+/', $swaps[$i], 6); |
$results['devswap'][$i - 1] = array(); |
$results['devswap'][$i - 1]['dev'] = $ar_buf[0]; |
$results['devswap'][$i - 1]['total'] = $ar_buf[2]; |
$results['devswap'][$i - 1]['used'] = $ar_buf[3]; |
$results['devswap'][$i - 1]['free'] = ($results['devswap'][$i - 1]['total'] - $results['devswap'][$i - 1]['used']); |
$results['devswap'][$i - 1]['percent'] = round(($ar_buf[3] * 100) / $ar_buf[2]); |
$results['swap']['total'] += $ar_buf[2]; |
$results['swap']['used'] += $ar_buf[3]; |
$results['swap']['free'] = $results['swap']['total'] - $results['swap']['used']; |
$results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']); |
} |
} |
} |
} |
return $results; |
} |
function filesystems () { |
return $this->parser->parse_filesystems(); |
} |
function distro () { |
return $this->distro; |
} |
function distroicon () { |
return $this->icon; |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.HP-UX.inc.php |
---|
0,0 → 1,423 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.HP-UX.inc.php,v 1.20 2007/02/18 18:59:54 bigmichi1 Exp $ |
class sysinfo { |
// get our apache SERVER_NAME or vhost |
function vhostname () { |
if (! ($result = getenv('SERVER_NAME'))) { |
$result = 'N.A.'; |
} |
return $result; |
} |
// get the IP address of our vhost name |
function vip_addr () { |
return gethostbyname($this->vhostname()); |
} |
// get our canonical hostname |
function chostname () { |
return execute_program('hostname'); |
} |
// get the IP address of our canonical hostname |
function ip_addr () { |
if (!($result = getenv('SERVER_ADDR'))) { |
$result = gethostbyname($this->chostname()); |
} |
return $result; |
} |
function kernel () { |
return execute_program('uname', '-srvm'); |
} |
function uptime () { |
$result = 0; |
$ar_buf = array(); |
$buf = execute_program('uptime'); |
if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $buf, $ar_buf)) { |
$min = $ar_buf[3]; |
$hours = $ar_buf[2]; |
$days = $ar_buf[1]; |
$result = $days * 86400 + $hours * 3600 + $min * 60; |
} |
return $result; |
} |
function users () { |
$who = explode('=', execute_program('who', '-q')); |
$result = $who[1]; |
return $result; |
} |
function loadavg ($bar = false) { |
$ar_buf = array(); |
$buf = execute_program('uptime'); |
if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) { |
$results['avg'] = array($ar_buf[1], $ar_buf[2], $ar_buf[3]); |
} else { |
$results['avg'] = array('N.A.', 'N.A.', 'N.A.'); |
} |
return $results; |
} |
function cpu_info () { |
$results = array(); |
$ar_buf = array(); |
$bufr = rfts( '/proc/cpuinfo' ); |
if( $bufr != "ERROR" ) { |
$bufe = explode( "\n", $bufr ); |
foreach( $bufe as $buf ) { |
list($key, $value) = preg_split('/\s+:\s+/', trim($buf), 2); |
// All of the tags here are highly architecture dependant. |
// the only way I could reconstruct them for machines I don't |
// have is to browse the kernel source. So if your arch isn't |
// supported, tell me you want it written in. |
switch ($key) { |
case 'model name': |
$results['model'] = $value; |
break; |
case 'cpu MHz': |
$results['cpuspeed'] = sprintf('%.2f', $value); |
break; |
case 'cycle frequency [Hz]': // For Alpha arch - 2.2.x |
$results['cpuspeed'] = sprintf('%.2f', $value / 1000000); |
break; |
case 'clock': // For PPC arch (damn borked POS) |
$results['cpuspeed'] = sprintf('%.2f', $value); |
break; |
case 'cpu': // For PPC arch (damn borked POS) |
$results['model'] = $value; |
break; |
case 'revision': // For PPC arch (damn borked POS) |
$results['model'] .= ' ( rev: ' . $value . ')'; |
break; |
case 'cpu model': // For Alpha arch - 2.2.x |
$results['model'] .= ' (' . $value . ')'; |
break; |
case 'cache size': |
$results['cache'] = $value; |
break; |
case 'bogomips': |
$results['bogomips'] += $value; |
break; |
case 'BogoMIPS': // For alpha arch - 2.2.x |
$results['bogomips'] += $value; |
break; |
case 'BogoMips': // For sparc arch |
$results['bogomips'] += $value; |
break; |
case 'cpus detected': // For Alpha arch - 2.2.x |
$results['cpus'] += $value; |
break; |
case 'system type': // Alpha arch - 2.2.x |
$results['model'] .= ', ' . $value . ' '; |
break; |
case 'platform string': // Alpha arch - 2.2.x |
$results['model'] .= ' (' . $value . ')'; |
break; |
case 'processor': |
$results['cpus'] += 1; |
break; |
} |
} |
fclose($fd); |
} |
$keys = array_keys($results); |
$keys2be = array('model', 'cpuspeed', 'cache', 'bogomips', 'cpus'); |
while ($ar_buf = each($keys2be)) { |
if (! in_array($ar_buf[1], $keys)) { |
$results[$ar_buf[1]] = 'N.A.'; |
} |
} |
return $results; |
} |
function pci () { |
$results = array(); |
$bufr = rfts( '/proc/pci' ); |
if( $bufr != "ERROR" ) { |
$bufe = explode( "\n", $bufr ); |
foreach( $bufe as $buf ) { |
if (preg_match('/Bus/', $buf)) { |
$device = true; |
continue; |
} |
if ($device) { |
list($key, $value) = explode(': ', $buf, 2); |
if (!preg_match('/bridge/i', $key) && !preg_match('/USB/i', $key)) { |
$results[] = preg_replace('/\([^\)]+\)\.$/', '', trim($value)); |
} |
$device = false; |
} |
} |
} |
asort($results); |
return $results; |
} |
function ide () { |
$results = array(); |
$bufd = gdc( '/proc/ide' ); |
foreach( $bufd as $file ) { |
if (preg_match('/^hd/', $file)) { |
$results[$file] = array(); |
// Check if device is CD-ROM (CD-ROM capacity shows as 1024 GB) |
$buf = rfts( "/proc/ide/" . $file . "/media", 1 ); |
if( $buf != "ERROR" ) { |
$results[$file]['media'] = trim( $buf ); |
if ($results[$file]['media'] == 'disk') { |
$results[$file]['media'] = 'Hard Disk'; |
} |
if ($results[$file]['media'] == 'cdrom') { |
$results[$file]['media'] = 'CD-ROM'; |
} |
} |
$buf = rfts( "/proc/ide/" . $file . "/model", 1 ); |
if( $buf != "ERROR" ) { |
$results[$file]['model'] = trim( $buf ); |
if (preg_match('/WDC/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'Western Digital'; |
} elseif (preg_match('/IBM/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'IBM'; |
} elseif (preg_match('/FUJITSU/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'Fujitsu'; |
} else { |
$results[$file]['manufacture'] = 'Unknown'; |
} |
} |
$buf = rfts( "/proc/ide/" . $file . "/capacity", 1 ); |
if( $buf != "ERROR" ) { |
$results[$file]['capacity'] = trim( $buf ); |
if ($results[$file]['media'] == 'CD-ROM') { |
unset($results[$file]['capacity']); |
} |
} |
} |
} |
asort($results); |
return $results; |
} |
function scsi () { |
$results = array(); |
$dev_vendor = ''; |
$dev_model = ''; |
$dev_rev = ''; |
$dev_type = ''; |
$s = 1; |
$bufr = rfts( '/proc/scsi/scsi' ); |
if( $bufr != "ERROR" ) { |
$bufe = explode( "\n", $bufr ); |
foreach( $bufe as $buf ) { |
if (preg_match('/Vendor/', $buf)) { |
preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $dev); |
list($key, $value) = explode(': ', $buf, 2); |
$dev_str = $value; |
$get_type = 1; |
continue; |
} |
if ($get_type) { |
preg_match('/Type:\s+(\S+)/i', $buf, $dev_type); |
$results[$s]['model'] = "$dev[1] $dev[2] ($dev_type[1])"; |
$results[$s]['media'] = "Hard Disk"; |
$s++; |
$get_type = 0; |
} |
} |
} |
asort($results); |
return $results; |
} |
function usb () { |
$results = array(); |
$devstring = 0; |
$devnum = -1; |
$bufr = rfts( '/proc/bus/usb/devices' ); |
if( $bufr != "ERROR" ) { |
$bufe = explode( "\n", $bufr ); |
foreach( $bufe as $buf ) { |
if (preg_match('/^T/', $buf)) { |
$devnum += 1; |
} |
if (preg_match('/^S/', $buf)) { |
$devstring = 1; |
} |
if ($devstring) { |
list($key, $value) = explode(': ', $buf, 2); |
list($key, $value2) = explode('=', $value, 2); |
$results[$devnum] .= " " . trim($value2); |
$devstring = 0; |
} |
} |
} |
return $results; |
} |
function sbus () { |
$results = array(); |
$_results[0] = ""; |
// TODO. Nothing here yet. Move along. |
$results = $_results; |
return $results; |
} |
function network () { |
$netstat = execute_program('netstat', '-ni | tail -n +2'); |
$lines = explode("\n", $netstat); |
$results = array(); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i]); |
if (!empty($ar_buf[0]) && !empty($ar_buf[3])) { |
$results[$ar_buf[0]] = array(); |
$results[$ar_buf[0]]['rx_bytes'] = $ar_buf[4]; |
$results[$ar_buf[0]]['rx_packets'] = $ar_buf[4]; |
$results[$ar_buf[0]]['rx_errs'] = $ar_buf[5]; |
$results[$ar_buf[0]]['rx_drop'] = $ar_buf[8]; |
$results[$ar_buf[0]]['tx_bytes'] = $ar_buf[6]; |
$results[$ar_buf[0]]['tx_packets'] = $ar_buf[6]; |
$results[$ar_buf[0]]['tx_errs'] = $ar_buf[7]; |
$results[$ar_buf[0]]['tx_drop'] = $ar_buf[8]; |
$results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[7]; |
$results[$ar_buf[0]]['drop'] = $ar_buf[8]; |
} |
} |
return $results; |
} |
function memory () { |
$results['ram'] = array(); |
$results['swap'] = array(); |
$results['devswap'] = array(); |
$bufr = rfts( '/proc/meminfo' ); |
if( $bufr != "ERROR" ) { |
$bufe = explode( "\n", $bufr ); |
foreach( $bufe as $buf ) { |
if (preg_match('/Mem:\s+(.*)$/', $buf, $ar_buf)) { |
$ar_buf = preg_split('/\s+/', $ar_buf[1], 6); |
$results['ram']['total'] = $ar_buf[0] / 1024; |
$results['ram']['used'] = $ar_buf[1] / 1024; |
$results['ram']['free'] = $ar_buf[2] / 1024; |
$results['ram']['shared'] = $ar_buf[3] / 1024; |
$results['ram']['buffers'] = $ar_buf[4] / 1024; |
$results['ram']['cached'] = $ar_buf[5] / 1024; |
// I don't like this since buffers and cache really aren't |
// 'used' per say, but I get too many emails about it. |
$results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); |
} |
if (preg_match('/Swap:\s+(.*)$/', $buf, $ar_buf)) { |
$ar_buf = preg_split('/\s+/', $ar_buf[1], 3); |
$results['swap']['total'] = $ar_buf[0] / 1024; |
$results['swap']['used'] = $ar_buf[1] / 1024; |
$results['swap']['free'] = $ar_buf[2] / 1024; |
$results['swap']['percent'] = round(($ar_buf[1] * 100) / $ar_buf[0]); |
// Get info on individual swap files |
$swaps = rfts( '/proc/swaps' ); |
if( $swaps != "ERROR" ) { |
$swapdevs = explode("\n", $swaps); |
for ($i = 1, $max = (sizeof($swapdevs) - 1); $i < $max; $i++) { |
$ar_buf = preg_split('/\s+/', $swapdevs[$i], 6); |
$results['devswap'][$i - 1] = array(); |
$results['devswap'][$i - 1]['dev'] = $ar_buf[0]; |
$results['devswap'][$i - 1]['total'] = $ar_buf[2]; |
$results['devswap'][$i - 1]['used'] = $ar_buf[3]; |
$results['devswap'][$i - 1]['free'] = ($results['devswap'][$i - 1]['total'] - $results['devswap'][$i - 1]['used']); |
$results['devswap'][$i - 1]['percent'] = round(($ar_buf[3] * 100) / $ar_buf[2]); |
} |
break; |
} |
} |
} |
} |
return $results; |
} |
function filesystems () { |
$df = execute_program('df', '-kP'); |
$mounts = explode("\n", $df); |
$fstype = array(); |
$s = execute_program('mount', '-v'); |
$lines = explode("\n", $s); |
$i = 0; |
while (list(, $line) = each($lines)) { |
$a = explode(' ', $line); |
$fsdev[$a[0]] = $a[4]; |
} |
for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $mounts[$i], 6); |
if (hide_mount($ar_buf[5])) { |
continue; |
} |
$results[$j] = array(); |
$results[$j]['disk'] = $ar_buf[0]; |
$results[$j]['size'] = $ar_buf[1]; |
$results[$j]['used'] = $ar_buf[2]; |
$results[$j]['free'] = $ar_buf[3]; |
$results[$j]['percent'] = $ar_buf[4]; |
$results[$j]['mount'] = $ar_buf[5]; |
($fstype[$ar_buf[5]]) ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : $results[$j]['fstype'] = $fsdev[$ar_buf[0]]; |
$j++; |
} |
return $results; |
} |
function distro () { |
$result = 'HP-UX'; |
return($result); |
} |
function distroicon () { |
$result = 'unknown.png'; |
return($result); |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.Linux.inc.php.default |
---|
0,0 → 1,552 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.Linux.inc.php,v 1.88 2007/02/25 20:50:52 bigmichi1 Exp $ |
if (!defined('IN_PHPSYSINFO')) { |
die("No Hacking"); |
} |
require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php'); |
class sysinfo { |
var $inifile = "distros.ini"; |
var $icon = "unknown.png"; |
var $distro = "unknown"; |
var $parser; |
// get the distro name and icon when create the sysinfo object |
function sysinfo() { |
$this->parser = new Parser(); |
$this->parser->df_param = 'P'; |
$list = @parse_ini_file(APP_ROOT . "/" . $this->inifile, true); |
if (!$list) { |
return; |
} |
$distro_info = execute_program('lsb_release','-a 2> /dev/null', false); // We have the '2> /dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown |
if ( $distro_info != 'ERROR') { |
$distro_tmp = explode("\n",$distro_info); |
foreach( $distro_tmp as $info ) { |
$info_tmp = explode(':', $info, 2); |
$distro[ $info_tmp[0] ] = trim($info_tmp[1]); |
} |
if( !isset( $list[$distro['Distributor ID']] ) ){ |
return; |
} |
$this->icon = isset($list[$distro['Distributor ID']]["Image"]) ? $list[$distro['Distributor ID']]["Image"] : $this->icon; |
$this->distro = $distro['Description']; |
} else { // Fall back in case 'lsb_release' does not exist ;) |
foreach ($list as $section => $distribution) { |
if (!isset($distribution["Files"])) { |
continue; |
} else { |
foreach (explode(";", $distribution["Files"]) as $filename) { |
if (file_exists($filename)) { |
$buf = rfts( $filename ); |
$this->icon = isset($distribution["Image"]) ? $distribution["Image"] : $this->icon; |
$this->distro = isset($distribution["Name"]) ? $distribution["Name"] . " " . trim($buf) : trim($buf); |
break 2; |
} |
} |
} |
} |
} |
} |
// get our apache SERVER_NAME or vhost |
function vhostname () { |
if (! ($result = getenv('SERVER_NAME'))) { |
$result = 'N.A.'; |
} |
return $result; |
} |
// get the IP address of our vhost name |
function vip_addr () { |
return gethostbyname($this->vhostname()); |
} |
// get our canonical hostname |
function chostname () { |
$result = rfts( '/proc/sys/kernel/hostname', 1 ); |
if ( $result == "ERROR" ) { |
$result = "N.A."; |
} else { |
$result = gethostbyaddr( gethostbyname( trim( $result ) ) ); |
} |
return $result; |
} |
// get the IP address of our canonical hostname |
function ip_addr () { |
if (!($result = getenv('SERVER_ADDR'))) { |
$result = gethostbyname($this->chostname()); |
} |
return $result; |
} |
function kernel () { |
$buf = rfts( '/proc/version', 1 ); |
if ( $buf == "ERROR" ) { |
$result = "N.A."; |
} else { |
if (preg_match('/version (.*?) /', $buf, $ar_buf)) { |
$result = $ar_buf[1]; |
if (preg_match('/SMP/', $buf)) { |
$result .= ' (SMP)'; |
} |
} |
} |
return $result; |
} |
function uptime () { |
$buf = rfts( '/proc/uptime', 1 ); |
$ar_buf = explode( ' ', $buf ); |
$result = trim( $ar_buf[0] ); |
return $result; |
} |
function users () { |
$strResult = 0; |
$strBuf = execute_program('who', '-q'); |
if( $strBuf != "ERROR" ) { |
$arrWho = explode( '=', $strBuf ); |
$strResult = $arrWho[1]; |
} |
return $strResult; |
} |
function loadavg ($bar = false) { |
$buf = rfts( '/proc/loadavg' ); |
if( $buf == "ERROR" ) { |
$results['avg'] = array('N.A.', 'N.A.', 'N.A.'); |
} else { |
$results['avg'] = preg_split("/\s/", $buf, 4); |
unset($results['avg'][3]); // don't need the extra values, only first three |
} |
if ($bar) { |
$buf = rfts( '/proc/stat', 1 ); |
if( $buf != "ERROR" ) { |
sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae); |
// Find out the CPU load |
// user + sys = load |
// total = total |
$load = $ab + $ac + $ad; // cpu.user + cpu.sys |
$total = $ab + $ac + $ad + $ae; // cpu.total |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour) |
sleep(1); |
$buf = rfts( '/proc/stat', 1 ); |
sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae); |
$load2 = $ab + $ac + $ad; |
$total2 = $ab + $ac + $ad + $ae; |
$results['cpupercent'] = (100*($load2 - $load)) / ($total2 - $total); |
} |
} |
return $results; |
} |
function cpu_info () { |
$bufr = rfts( '/proc/cpuinfo' ); |
$results = array("cpus" => 0); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
$results = array('cpus' => 0, 'bogomips' => 0); |
$ar_buf = array(); |
foreach( $bufe as $buf ) { |
$arrBuff = preg_split('/\s+:\s+/', trim($buf)); |
if( count( $arrBuff ) == 2 ) { |
$key = $arrBuff[0]; |
$value = $arrBuff[1]; |
// All of the tags here are highly architecture dependant. |
// the only way I could reconstruct them for machines I don't |
// have is to browse the kernel source. So if your arch isn't |
// supported, tell me you want it written in. |
switch ($key) { |
case 'model name': |
$results['model'] = $value; |
break; |
case 'cpu MHz': |
$results['cpuspeed'] = sprintf('%.2f', $value); |
break; |
case 'cycle frequency [Hz]': // For Alpha arch - 2.2.x |
$results['cpuspeed'] = sprintf('%.2f', $value / 1000000); |
break; |
case 'clock': // For PPC arch (damn borked POS) |
$results['cpuspeed'] = sprintf('%.2f', $value); |
break; |
case 'cpu': // For PPC arch (damn borked POS) |
$results['model'] = $value; |
break; |
case 'L2 cache': // More for PPC |
$results['cache'] = $value; |
break; |
case 'revision': // For PPC arch (damn borked POS) |
$results['model'] .= ' ( rev: ' . $value . ')'; |
break; |
case 'cpu model': // For Alpha arch - 2.2.x |
$results['model'] .= ' (' . $value . ')'; |
break; |
case 'cache size': |
$results['cache'] = $value; |
break; |
case 'bogomips': |
$results['bogomips'] += $value; |
break; |
case 'BogoMIPS': // For alpha arch - 2.2.x |
$results['bogomips'] += $value; |
break; |
case 'BogoMips': // For sparc arch |
$results['bogomips'] += $value; |
break; |
case 'cpus detected': // For Alpha arch - 2.2.x |
$results['cpus'] += $value; |
break; |
case 'system type': // Alpha arch - 2.2.x |
$results['model'] .= ', ' . $value . ' '; |
break; |
case 'platform string': // Alpha arch - 2.2.x |
$results['model'] .= ' (' . $value . ')'; |
break; |
case 'processor': |
$results['cpus'] += 1; |
break; |
case 'Cpu0ClkTck': // Linux sparc64 |
$results['cpuspeed'] = sprintf('%.2f', hexdec($value) / 1000000); |
break; |
case 'Cpu0Bogo': // Linux sparc64 & sparc32 |
$results['bogomips'] = $value; |
break; |
case 'ncpus probed': // Linux sparc64 & sparc32 |
$results['cpus'] = $value; |
break; |
} |
} |
} |
// sparc64 specific code follows |
// This adds the ability to display the cache that a CPU has |
// Originally made by Sven Blumenstein <bazik@gentoo.org> in 2004 |
// Modified by Tom Weustink <freshy98@gmx.net> in 2004 |
$sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0'); |
foreach ($sparclist as $name) { |
$buf = rfts( '/proc/openprom/' . $name . '/ecache-size',1 , 32, false ); |
if( $buf != "ERROR" ) { |
$results['cache'] = base_convert($buf, 16, 10)/1024 . ' KB'; |
} |
} |
// sparc64 specific code ends |
// XScale detection code |
if ( $results['cpus'] == 0 ) { |
foreach( $bufe as $buf ) { |
$fields = preg_split('/\s*:\s*/', trim($buf), 2); |
if (sizeof($fields) == 2) { |
list($key, $value) = $fields; |
switch($key) { |
case 'Processor': |
$results['cpus'] += 1; |
$results['model'] = $value; |
break; |
case 'BogoMIPS': //BogoMIPS are not BogoMIPS on this CPU, it's the speed, no BogoMIPS available |
$results['cpuspeed'] = $value; |
break; |
case 'I size': |
$results['cache'] = $value; |
break; |
case 'D size': |
$results['cache'] += $value; |
break; |
} |
} |
} |
$results['cache'] = $results['cache'] / 1024 . " KB"; |
} |
} |
$keys = array_keys($results); |
$keys2be = array('model', 'cpuspeed', 'cache', 'bogomips', 'cpus'); |
while ($ar_buf = each($keys2be)) { |
if (! in_array($ar_buf[1], $keys)) { |
$results[$ar_buf[1]] = 'N.A.'; |
} |
} |
$buf = rfts( '/proc/acpi/thermal_zone/THRM/temperature', 1, 4096, false ); |
if ( $buf != "ERROR" ) { |
$results['temp'] = substr( $buf, 25, 2 ); |
} |
return $results; |
} |
function pci () { |
$arrResults = array(); |
$booDevice = false; |
if( ! $arrResults = $this->parser->parse_lspci() ) { |
$strBuf = rfts( '/proc/pci', 0, 4096, false ); |
if( $strBuf != "ERROR" ) { |
$arrBuf = explode( "\n", $strBuf ); |
foreach( $arrBuf as $strLine ) { |
if( preg_match( '/Bus/', $strLine ) ) { |
$booDevice = true; |
continue; |
} |
if( $booDevice ) { |
list( $strKey, $strValue ) = explode( ': ', $strLine, 2 ); |
if( ! preg_match( '/bridge/i', $strKey ) && ! preg_match( '/USB/i ', $strKey ) ) { |
$arrResults[] = preg_replace( '/\([^\)]+\)\.$/', '', trim( $strValue ) ); |
} |
$booDevice = false; |
} |
} |
asort( $arrResults ); |
} |
} |
return $arrResults; |
} |
function ide () { |
$results = array(); |
$bufd = gdc( '/proc/ide', false ); |
foreach( $bufd as $file ) { |
if (preg_match('/^hd/', $file)) { |
$results[$file] = array(); |
$buf = rfts("/proc/ide/" . $file . "/media", 1 ); |
if ( $buf != "ERROR" ) { |
$results[$file]['media'] = trim($buf); |
if ($results[$file]['media'] == 'disk') { |
$results[$file]['media'] = 'Hard Disk'; |
$buf = rfts( "/proc/ide/" . $file . "/capacity", 1, 4096, false); |
if( $buf == "ERROR" ) { |
$buf = rfts( "/sys/block/" . $file . "/size", 1, 4096, false); |
} |
if ( $buf != "ERROR" ) { |
$results[$file]['capacity'] = trim( $buf ); |
} |
} elseif ($results[$file]['media'] == 'cdrom') { |
$results[$file]['media'] = 'CD-ROM'; |
unset($results[$file]['capacity']); |
} |
} else { |
unset($results[$file]); |
} |
$buf = rfts( "/proc/ide/" . $file . "/model", 1 ); |
if ( $buf != "ERROR" ) { |
$results[$file]['model'] = trim( $buf ); |
if (preg_match('/WDC/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'Western Digital'; |
} elseif (preg_match('/IBM/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'IBM'; |
} elseif (preg_match('/FUJITSU/', $results[$file]['model'])) { |
$results[$file]['manufacture'] = 'Fujitsu'; |
} else { |
$results[$file]['manufacture'] = 'Unknown'; |
} |
} |
} |
} |
asort($results); |
return $results; |
} |
function scsi () { |
$results = array(); |
$dev_vendor = ''; |
$dev_model = ''; |
$dev_rev = ''; |
$dev_type = ''; |
$s = 1; |
$get_type = 0; |
$bufr = execute_program('lsscsi', '-c', false); |
if( $bufr == "ERROR" ) { |
$bufr = rfts( '/proc/scsi/scsi', 0, 4096, false); |
} |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/Vendor/', $buf)) { |
preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $dev); |
list($key, $value) = explode(': ', $buf, 2); |
$dev_str = $value; |
$get_type = true; |
continue; |
} |
if ($get_type) { |
preg_match('/Type:\s+(\S+)/i', $buf, $dev_type); |
$results[$s]['model'] = "$dev[1] $dev[2] ($dev_type[1])"; |
$results[$s]['media'] = "Hard Disk"; |
$s++; |
$get_type = false; |
} |
} |
} |
asort($results); |
return $results; |
} |
function usb () { |
$results = array(); |
$devnum = -1; |
$bufr = execute_program('lsusb', '', false); |
if( $bufr == "ERROR" ) { |
$bufr = rfts( '/proc/bus/usb/devices', 0, 4096, false ); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/^T/', $buf)) { |
$devnum += 1; |
$results[$devnum] = ""; |
} elseif (preg_match('/^S:/', $buf)) { |
list($key, $value) = explode(': ', $buf, 2); |
list($key, $value2) = explode('=', $value, 2); |
if (trim($key) != "SerialNumber") { |
$results[$devnum] .= " " . trim($value2); |
$devstring = 0; |
} |
} |
} |
} |
} else { |
$bufe = explode( "\n", $bufr ); |
foreach( $bufe as $buf ) { |
$device = preg_split("/ /", $buf, 7); |
if( isset( $device[6] ) && trim( $device[6] ) != "" ) { |
$results[$devnum++] = trim( $device[6] ); |
} |
} |
} |
return $results; |
} |
function sbus () { |
$results = array(); |
$_results[0] = ""; |
// TODO. Nothing here yet. Move along. |
$results = $_results; |
return $results; |
} |
function network () { |
$results = array(); |
$bufr = rfts( '/proc/net/dev' ); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/:/', $buf)) { |
list($dev_name, $stats_list) = preg_split('/:/', $buf, 2); |
$stats = preg_split('/\s+/', trim($stats_list)); |
$results[$dev_name] = array(); |
$results[$dev_name]['rx_bytes'] = $stats[0]; |
$results[$dev_name]['rx_packets'] = $stats[1]; |
$results[$dev_name]['rx_errs'] = $stats[2]; |
$results[$dev_name]['rx_drop'] = $stats[3]; |
$results[$dev_name]['tx_bytes'] = $stats[8]; |
$results[$dev_name]['tx_packets'] = $stats[9]; |
$results[$dev_name]['tx_errs'] = $stats[10]; |
$results[$dev_name]['tx_drop'] = $stats[11]; |
$results[$dev_name]['errs'] = $stats[2] + $stats[10]; |
$results[$dev_name]['drop'] = $stats[3] + $stats[11]; |
} |
} |
} |
return $results; |
} |
function memory () { |
$results['ram'] = array('total' => 0, 'free' => 0, 'used' => 0, 'percent' => 0); |
$results['swap'] = array('total' => 0, 'free' => 0, 'used' => 0, 'percent' => 0); |
$results['devswap'] = array(); |
$bufr = rfts( '/proc/meminfo' ); |
if ( $bufr != "ERROR" ) { |
$bufe = explode("\n", $bufr); |
foreach( $bufe as $buf ) { |
if (preg_match('/^MemTotal:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['total'] = $ar_buf[1]; |
} else if (preg_match('/^MemFree:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['free'] = $ar_buf[1]; |
} else if (preg_match('/^Cached:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['cached'] = $ar_buf[1]; |
} else if (preg_match('/^Buffers:\s+(.*)\s*kB/i', $buf, $ar_buf)) { |
$results['ram']['buffers'] = $ar_buf[1]; |
} |
} |
$results['ram']['used'] = $results['ram']['total'] - $results['ram']['free']; |
$results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); |
// values for splitting memory usage |
if (isset($results['ram']['cached']) && isset($results['ram']['buffers'])) { |
$results['ram']['app'] = $results['ram']['used'] - $results['ram']['cached'] - $results['ram']['buffers']; |
$results['ram']['app_percent'] = round(($results['ram']['app'] * 100) / $results['ram']['total']); |
$results['ram']['buffers_percent'] = round(($results['ram']['buffers'] * 100) / $results['ram']['total']); |
$results['ram']['cached_percent'] = round(($results['ram']['cached'] * 100) / $results['ram']['total']); |
} |
$bufr = rfts( '/proc/swaps' ); |
if ( $bufr != "ERROR" ) { |
$swaps = explode("\n", $bufr); |
for ($i = 1; $i < (sizeof($swaps)); $i++) { |
if( trim( $swaps[$i] ) != "" ) { |
$ar_buf = preg_split('/\s+/', $swaps[$i], 6); |
$results['devswap'][$i - 1] = array(); |
$results['devswap'][$i - 1]['dev'] = $ar_buf[0]; |
$results['devswap'][$i - 1]['total'] = $ar_buf[2]; |
$results['devswap'][$i - 1]['used'] = $ar_buf[3]; |
$results['devswap'][$i - 1]['free'] = ($results['devswap'][$i - 1]['total'] - $results['devswap'][$i - 1]['used']); |
$results['devswap'][$i - 1]['percent'] = round(($ar_buf[3] * 100) / $ar_buf[2]); |
$results['swap']['total'] += $ar_buf[2]; |
$results['swap']['used'] += $ar_buf[3]; |
$results['swap']['free'] = $results['swap']['total'] - $results['swap']['used']; |
$results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']); |
} |
} |
} |
} |
return $results; |
} |
function filesystems () { |
return $this->parser->parse_filesystems(); |
} |
function distro () { |
return $this->distro; |
} |
function distroicon () { |
return $this->icon; |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.Darwin.inc.php |
---|
0,0 → 1,198 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.Darwin.inc.php,v 1.33 2006/06/14 16:36:34 bigmichi1 Exp $ |
if (!defined('IN_PHPSYSINFO')) { |
die("No Hacking"); |
} |
require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php'); |
$error->addWarning("The Darwin version of phpSysInfo is work in progress, some things currently don't work"); |
class sysinfo extends bsd_common { |
var $cpu_regexp; |
var $scsi_regexp; |
var $parser; |
// Our contstructor |
// this function is run on the initialization of this class |
function sysinfo () { |
// $this->cpu_regexp = "CPU: (.*) \((.*)-MHz (.*)\)"; |
// $this->scsi_regexp1 = "^(.*): <(.*)> .*SCSI.*device"; |
$this->cpu_regexp2 = "/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/"; |
$this->parser = new Parser(); |
} |
function grab_key ($key) { |
$s = execute_program('sysctl', $key); |
$s = ereg_replace($key . ': ', '', $s); |
$s = ereg_replace($key . ' = ', '', $s); // fix Apple set keys |
return $s; |
} |
function grab_ioreg ($key) { |
$s = execute_program('ioreg', '-cls "' . $key . '" | grep "' . $key . '"'); //ioreg -cls "$key" | grep "$key" |
$s = ereg_replace('\|', '', $s); |
$s = ereg_replace('\+\-\o', '', $s); |
$s = ereg_replace('[ ]+', '', $s); |
$s = ereg_replace('<[^>]+>', '', $s); // remove possible XML conflicts |
return $s; |
} |
function get_sys_ticks () { |
$a = execute_program('sysctl', '-n kern.boottime'); // get boottime (value in seconds) |
$sys_ticks = time() - $a; |
return $sys_ticks; |
} |
function cpu_info () { |
$results = array(); |
// $results['model'] = $this->grab_key('hw.model'); // need to expand this somehow... |
// $results['model'] = $this->grab_key('hw.machine'); |
$results['model'] = ereg_replace('Processor type: ', '', execute_program('hostinfo', '| grep "Processor type"')); // get processor type |
$results['cpus'] = $this->grab_key('hw.ncpu'); |
$results['cpuspeed'] = round($this->grab_key('hw.cpufrequency') / 1000000); // return cpu speed - Mhz |
$results['busspeed'] = round($this->grab_key('hw.busfrequency') / 1000000); // return bus speed - Mhz |
$results['cache'] = round($this->grab_key('hw.l2cachesize') / 1024); // return l2 cache |
if (($this->grab_key('hw.model') == "PowerMac3,6") && ($results['cpus'] == "2")) { $results['model'] = 'Dual G4 - (PowerPC 7450)';} // is Dual G4 |
if (($this->grab_key('hw.model') == "PowerMac7,2") && ($results['cpus'] == "2")) { $results['model'] = 'Dual G5 - (PowerPC 970)';} // is Dual G5 |
if (($this->grab_key('hw.model') == "PowerMac1,1") && ($results['cpus'] == "1")) { $results['model'] = 'B&W G3 - (PowerPC 750)';} // is B&W G3 |
return $results; |
} |
// get the pci device information out of ioreg |
function pci () { |
$results = array(); |
$s = $this->grab_ioreg('IOPCIDevice'); |
$lines = explode("\n", $s); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i], 19); |
$results[$i] = $ar_buf[0]; |
} |
asort($results); |
return array_values(array_unique($results)); |
} |
// get the ide device information out of ioreg |
function ide () { |
$results = array(); |
// ioreg | grep "Media <class IOMedia>" |
$s = $this->grab_ioreg('IOATABlockStorageDevice'); |
$lines = explode("\n", $s); |
$j = 0; |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\/\//", $lines[$i], 19); |
if ( isset( $ar_buf[1] ) && $ar_buf[1] == 'class IOMedia' && preg_match('/Media/', $ar_buf[0])) { |
$results[$j++]['model'] = $ar_buf[0]; |
} |
} |
asort($results); |
return array_values(array_unique($results)); |
} |
function memory () { |
$s = $this->grab_key('hw.memsize'); |
$results['ram'] = array(); |
$results['swap'] = array(); |
$results['devswap'] = array(); |
$pstat = execute_program('vm_stat'); // use darwin's vm_stat |
$lines = explode("\n", $pstat); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i], 19); |
if ($i == 1) { |
$results['ram']['free'] = $ar_buf[2] * 4; // calculate free memory from page sizes (each page = 4MB) |
} |
} |
$results['ram']['total'] = $s / 1024; |
$results['ram']['shared'] = 0; |
$results['ram']['buffers'] = 0; |
$results['ram']['used'] = $results['ram']['total'] - $results['ram']['free']; |
$results['ram']['cached'] = 0; |
$results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); |
// need to fix the swap info... |
// meanwhile silence and / or disable the swap information |
$pstat = execute_program('swapinfo', '-k', false); |
if( $pstat != "ERROR" ) { |
$lines = explode("\n", $pstat); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i], 6); |
if ($i == 0) { |
$results['swap']['total'] = 0; |
$results['swap']['used'] = 0; |
$results['swap']['free'] = 0; |
} else { |
$results['swap']['total'] = $results['swap']['total'] + $ar_buf[1]; |
$results['swap']['used'] = $results['swap']['used'] + $ar_buf[2]; |
$results['swap']['free'] = $results['swap']['free'] + $ar_buf[3]; |
} |
} |
$results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']); |
} |
return $results; |
} |
function network () { |
$netstat = execute_program('netstat', '-nbdi | cut -c1-24,42- | grep Link'); |
$lines = explode("\n", $netstat); |
$results = array(); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i], 10); |
if (!empty($ar_buf[0])) { |
$results[$ar_buf[0]] = array(); |
$results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5]; |
$results[$ar_buf[0]]['rx_packets'] = $ar_buf[3]; |
$results[$ar_buf[0]]['rx_errs'] = $ar_buf[4]; |
$results[$ar_buf[0]]['rx_drop'] = isset( $ar_buf[10] ) ? $ar_buf[10] : 0; |
$results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8]; |
$results[$ar_buf[0]]['tx_packets'] = $ar_buf[6]; |
$results[$ar_buf[0]]['tx_errs'] = $ar_buf[7]; |
$results[$ar_buf[0]]['tx_drop'] = isset( $ar_buf[10] ) ? $ar_buf[10] : 0; |
$results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7]; |
$results[$ar_buf[0]]['drop'] = isset( $ar_buf[10] ) ? $ar_buf[10] : 0; |
} |
} |
return $results; |
} |
function distroicon () { |
$result = 'Darwin.png'; |
return($result); |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.parseProgs.inc.php |
---|
0,0 → 1,159 |
<?php |
/*************************************************************************** |
* Copyright (C) 2006 by phpSysInfo - A PHP System Information Script * |
* http://phpsysinfo.sourceforge.net/ * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License, or * |
* (at your option) any later version. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
// $Id: class.parseProgs.inc.php,v 1.12 2007/02/01 17:37:06 bigmichi1 Exp $ |
class Parser { |
var $debug = false; |
var $df_param = ""; |
function parse_lspci() { |
$arrResults = array(); |
if ( ( $strBuff = execute_program( "lspci", "", $this->debug ) ) != "ERROR" ) { |
$arrLines = explode( "\n", $strBuff ); |
foreach( $arrLines as $strLine ) { |
list( $strAddr, $strName) = explode( ' ', trim( $strLine ), 2 ); |
$strName = preg_replace( '/\(.*\)/', '', $strName); |
$arrResults[] = $strName; |
} |
} |
if( empty( $arrResults ) ) { |
return false; |
} else { |
asort( $arrResults ); |
return $arrResults; |
} |
} |
function parse_pciconf() { |
$arrResults = array(); |
$intS = 0; |
if( ( $strBuff = execute_program( "pciconf", "-lv", $this->debug ) ) != "ERROR" ) { |
$arrLines = explode( "\n", $strBuff ); |
foreach( $arrLines as $strLine ) { |
if( preg_match( "/(.*) = '(.*)'/", $strLine, $arrParts ) ) { |
if( trim( $arrParts[1] ) == "vendor" ) { |
$arrResults[$intS] = trim( $arrParts[2] ); |
} elseif( trim( $arrParts[1]) == "device" ) { |
$arrResults[$intS] .= " - " . trim( $arrParts[2] ); |
$intS++; |
} |
} |
} |
} |
if( empty( $arrResults ) ) { |
return false; |
} else { |
asort( $arrResults ); |
return $arrResults; |
} |
} |
function parse_filesystems() { |
global $show_bind, $show_inodes; |
$results = array(); |
$j = 0; |
$df = execute_program('df', '-k' . $this->df_param ); |
$df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY); |
sort($df); |
if( $show_inodes ) { |
$df2 = execute_program('df', '-i' . $this->df_param ); |
$df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY); |
sort( $df2 ); |
} |
$mount = execute_program('mount'); |
$mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY); |
sort($mount); |
foreach( $df as $df_line) { |
$df_buf1 = preg_split("/(\%\s)/", $df_line, 2); |
if( count($df_buf1) != 2) { |
continue; |
} |
preg_match("/(.*)(\s+)(([0-9]+)(\s+)([0-9]+)(\s+)([0-9]+)(\s+)([0-9]+)$)/", $df_buf1[0], $df_buf2); |
$df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]); |
if( $show_inodes ) { |
preg_match_all("/([0-9]+)%/", $df2[$j + 1], $inode_buf, PREG_SET_ORDER); |
} |
if( count($df_buf) == 6 ) { |
$df_buf[5] = trim( $df_buf[5] ); |
if( hide_mount( $df_buf[5] ) ) { |
continue; |
} |
$df_buf[0] = trim( str_replace("\$", "\\$", $df_buf[0] ) ); |
$current = 0; |
foreach( $mount as $mount_line ) { |
if ( preg_match("#" . $df_buf[0] . " on " . $df_buf[5] . " type (.*) \((.*)\)#", $mount_line, $mount_buf) ) { |
$mount_buf[1] .= "," . $mount_buf[2]; |
} elseif ( !preg_match("#" . $df_buf[0] . "(.*) on " . $df_buf[5] . " \((.*)\)#", $mount_line, $mount_buf) ) { |
continue; |
} |
$strFstype = substr( $mount_buf[1], 0, strpos( $mount_buf[1], "," ) ); |
if( hide_fstype( $strFstype ) ) { |
continue; |
} |
$current++; |
if( $show_bind || !stristr($mount_buf[2], "bind")) { |
$results[$j] = array(); |
$results[$j]['disk'] = str_replace( "\\$", "\$", $df_buf[0] ); |
$results[$j]['size'] = $df_buf[1]; |
$results[$j]['used'] = $df_buf[2]; |
$results[$j]['free'] = $df_buf[3]; |
// --> Bug 1527673 |
if( $results[$j]['used'] < 0 ) { |
$results[$j]['size'] = $results[$j]['free']; |
$results[$j]['free'] = 0; |
$results[$j]['used'] = $results[$j]['size']; |
} |
// <-- Bug 1527673 |
// --> Bug 1649430 |
if( $results[$j]['size'] == 0 ) { |
break; |
} else { |
$results[$j]['percent'] = round(($results[$j]['used'] * 100) / $results[$j]['size']); |
} |
// <-- Bug 1649430 |
$results[$j]['mount'] = $df_buf[5]; |
$results[$j]['fstype'] = $strFstype; |
$results[$j]['options'] = substr( $mount_buf[1], strpos( $mount_buf[1], "," ) + 1, strlen( $mount_buf[1] ) ); |
if( $show_inodes && isset($inode_buf[ count( $inode_buf ) - 1][1]) ) { |
$results[$j]['inodes'] = $inode_buf[ count( $inode_buf ) - 1][1]; |
} |
$j++; |
unset( $mount[$current - 1] ); |
sort( $mount ); |
break; |
} |
} |
} |
} |
return $results; |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/class.SunOS.inc.php |
---|
0,0 → 1,240 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.SunOS.inc.php,v 1.24 2007/02/18 18:59:54 bigmichi1 Exp $ |
$error->addError("WARN", "The SunOS version of phpSysInfo is work in progress, some things currently don't work"); |
class sysinfo { |
// Extract kernel values via kstat() interface |
function kstat ($key) { |
$m = execute_program('kstat', "-p d $key"); |
list($key, $value) = explode("\t", trim($m), 2); |
return $value; |
} |
function vhostname () { |
if (! ($result = getenv('SERVER_NAME'))) { |
$result = 'N.A.'; |
} |
return $result; |
} |
// get the IP address of our vhost name |
function vip_addr () { |
return gethostbyname($this->vhostname()); |
} |
// get our canonical hostname |
function chostname () { |
if ($result = execute_program('uname', '-n')) { |
$result = gethostbyaddr(gethostbyname($result)); |
} else { |
$result = 'N.A.'; |
} |
return $result; |
} |
// get the IP address of our canonical hostname |
function ip_addr () { |
if (!($result = getenv('SERVER_ADDR'))) { |
$result = gethostbyname($this->chostname()); |
} |
return $result; |
} |
function kernel () { |
$os = execute_program('uname', '-s'); |
$version = execute_program('uname', '-r'); |
return $os . ' ' . $version; |
} |
function uptime () { |
$result = time() - $this->kstat('unix:0:system_misc:boot_time'); |
return $result; |
} |
function users () { |
$who = explode('=', execute_program('who', '-q')); |
$result = $who[1]; |
return $result; |
} |
function loadavg ($bar = false) { |
$load1 = $this->kstat('unix:0:system_misc:avenrun_1min'); |
$load5 = $this->kstat('unix:0:system_misc:avenrun_5min'); |
$load15 = $this->kstat('unix:0:system_misc:avenrun_15min'); |
$results['avg'] = array( round($load1/256, 2), round($load5/256, 2), round($load15/256, 2) ); |
return $results; |
} |
function cpu_info () { |
$results = array(); |
$ar_buf = array(); |
$results['model'] = execute_program('uname', '-i'); |
$results['cpuspeed'] = $this->kstat('cpu_info:0:cpu_info0:clock_MHz'); |
$results['cache'] = $this->kstat('cpu_info:0:cpu_info0:cpu_type'); |
$results['cpus'] = $this->kstat('unix:0:system_misc:ncpus'); |
return $results; |
} |
function pci () { |
// FIXME |
$results = array(); |
return $results; |
} |
function ide () { |
// FIXME |
$results = array(); |
return $results; |
} |
function scsi () { |
// FIXME |
$results = array(); |
return $results; |
} |
function usb () { |
// FIXME |
$results = array(); |
return $results; |
} |
function sbus () { |
$results = array(); |
$_results[0] = ""; |
// TODO. Nothing here yet. Move along. |
$results = $_results; |
return $results; |
} |
function network () { |
$results = array(); |
$netstat = execute_program('netstat', '-ni | awk \'(NF ==10){print;}\''); |
$lines = explode("\n", $netstat); |
$results = array(); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i]); |
if ((!empty($ar_buf[0])) && ($ar_buf[0] != 'Name')) { |
$results[$ar_buf[0]] = array(); |
$results[$ar_buf[0]]['rx_bytes'] = 0; |
$results[$ar_buf[0]]['rx_packets'] = $ar_buf[4]; |
$results[$ar_buf[0]]['rx_errs'] = $ar_buf[5]; |
$results[$ar_buf[0]]['rx_drop'] = 0; |
$results[$ar_buf[0]]['tx_bytes'] = 0; |
$results[$ar_buf[0]]['tx_packets'] = $ar_buf[6]; |
$results[$ar_buf[0]]['tx_errs'] = $ar_buf[7]; |
$results[$ar_buf[0]]['tx_drop'] = 0; |
$results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[ |
7]; |
$results[$ar_buf[0]]['drop'] = 0; |
preg_match('/^(\D+)(\d+)$/', $ar_buf[0], $intf); |
$prefix = $intf[1] . ':' . $intf[2] . ':' . $intf[1] . $intf[2] . ':'; |
$cnt = $this->kstat($prefix . 'drop'); |
if ($cnt > 0) { |
$results[$ar_buf[0]]['rx_drop'] = $cnt; |
} |
$cnt = $this->kstat($prefix . 'obytes64'); |
if ($cnt > 0) { |
$results[$ar_buf[0]]['tx_bytes'] = $cnt; |
} |
$cnt = $this->kstat($prefix . 'rbytes64'); |
if ($cnt > 0) { |
$results[$ar_buf[0]]['rx_bytes'] = $cnt; |
} |
} |
} |
return $results; |
} |
function memory () { |
$results['devswap'] = array(); |
$results['ram'] = array(); |
$pagesize = $this->kstat('unix:0:seg_cache:slab_size'); |
$results['ram']['total'] = $this->kstat('unix:0:system_pages:pagestotal') * $pagesize / 1024; |
$results['ram']['used'] = $this->kstat('unix:0:system_pages:pageslocked') * $pagesize / 1024; |
$results['ram']['free'] = $this->kstat('unix:0:system_pages:pagesfree') * $pagesize / 1024; |
$results['ram']['shared'] = 0; |
$results['ram']['buffers'] = 0; |
$results['ram']['cached'] = 0; |
$results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); |
$results['swap'] = array(); |
$results['swap']['total'] = $this->kstat('unix:0:vminfo:swap_avail') / 1024 / 1024; |
$results['swap']['used'] = $this->kstat('unix:0:vminfo:swap_alloc') / 1024 / 1024; |
$results['swap']['free'] = $this->kstat('unix:0:vminfo:swap_free') / 1024 / 1024; |
$results['swap']['percent'] = round(($ar_buf[1] * 100) / $ar_buf[0]); |
$results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']); |
return $results; |
} |
function filesystems () { |
$df = execute_program('df', '-k'); |
$mounts = explode("\n", $df); |
$dftypes = execute_program('df', '-n'); |
$mounttypes = explode("\n", $dftypes); |
for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { |
$ar_buf = preg_split('/\s+/', $mounts[$i], 6); |
$ty_buf = explode(':', $mounttypes[$i-1], 2); |
if (hide_mount($ar_buf[5])) { |
continue; |
} |
$results[$j] = array(); |
$results[$j]['disk'] = $ar_buf[0]; |
$results[$j]['size'] = $ar_buf[1]; |
$results[$j]['used'] = $ar_buf[2]; |
$results[$j]['free'] = $ar_buf[3]; |
$results[$j]['percent'] = round(($results[$j]['used'] * 100) / $results[$j]['size']); |
$results[$j]['mount'] = $ar_buf[5]; |
$results[$j]['fstype'] = $ty_buf[1]; |
$j++; |
} |
return $results; |
} |
function distro () { |
$result = 'SunOS'; |
return($result); |
} |
function distroicon () { |
$result = 'SunOS.png'; |
return($result); |
} |
} |
?> |
/web/acc/phpsysinfo/includes/os/index.html |
---|
--- class.OpenBSD.inc.php (nonexistent) |
+++ class.OpenBSD.inc.php (revision 325) |
@@ -0,0 +1,110 @@ |
+<?php |
+ |
+// phpSysInfo - A PHP System Information Script |
+// http://phpsysinfo.sourceforge.net/ |
+ |
+// This program is free software; you can redistribute it and/or |
+// modify it under the terms of the GNU General Public License |
+// as published by the Free Software Foundation; either version 2 |
+// of the License, or (at your option) any later version. |
+ |
+// This program is distributed in the hope that it will be useful, |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+// GNU General Public License for more details. |
+ |
+// You should have received a copy of the GNU General Public License |
+// along with this program; if not, write to the Free Software |
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+ |
+// $Id: class.OpenBSD.inc.php,v 1.21 2006/04/18 17:46:15 bigmichi1 Exp $ |
+if (!defined('IN_PHPSYSINFO')) { |
+ die("No Hacking"); |
+} |
+ |
+require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php'); |
+ |
+class sysinfo extends bsd_common { |
+ var $cpu_regexp = ""; |
+ var $scsi_regexp1 = ""; |
+ var $scsi_regexp2 = ""; |
+ var $cpu_regexp2 = ""; |
+ |
+ // Our contstructor |
+ // this function is run on the initialization of this class |
+ function sysinfo () { |
+ $this->bsd_common(); |
+ $this->cpu_regexp = "^cpu(.*) (.*) MHz"; |
+ $this->scsi_regexp1 = "^(.*) at scsibus.*: <(.*)> .*"; |
+ $this->scsi_regexp2 = "^(da[0-9]): (.*)MB "; |
+ $this->cpu_regexp2 = "/(.*),(.*),(.*),(.*),(.*)/"; |
+ $this->pci_regexp1 = '/(.*) at pci[0-9] .* "(.*)"/'; |
+ $this->pci_regexp2 = '/"(.*)" (.*).* at [.0-9]+ irq/'; |
+ } |
+ |
+ function get_sys_ticks () { |
+ $a = $this->grab_key('kern.boottime'); |
+ $sys_ticks = time() - $a; |
+ return $sys_ticks; |
+ } |
+ |
+ function network () { |
+ $netstat_b = execute_program('netstat', '-nbdi | cut -c1-25,44- | grep Link | grep -v \'* \''); |
+ $netstat_n = execute_program('netstat', '-ndi | cut -c1-25,44- | grep Link | grep -v \'* \''); |
+ $lines_b = explode("\n", $netstat_b); |
+ $lines_n = explode("\n", $netstat_n); |
+ $results = array(); |
+ for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) { |
+ $ar_buf_b = preg_split("/\s+/", $lines_b[$i]); |
+ $ar_buf_n = preg_split("/\s+/", $lines_n[$i]); |
+ if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) { |
+ $results[$ar_buf_b[0]] = array(); |
+ |
+ $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3]; |
+ $results[$ar_buf_b[0]]['rx_packets'] = $ar_buf_n[3]; |
+ $results[$ar_buf_b[0]]['rx_errs'] = $ar_buf_n[4]; |
+ $results[$ar_buf_b[0]]['rx_drop'] = $ar_buf_n[8]; |
+ |
+ $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4]; |
+ $results[$ar_buf_b[0]]['tx_packets'] = $ar_buf_n[5]; |
+ $results[$ar_buf_b[0]]['tx_errs'] = $ar_buf_n[6]; |
+ $results[$ar_buf_b[0]]['tx_drop'] = $ar_buf_n[8]; |
+ |
+ $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6]; |
+ $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8]; |
+ } |
+ } |
+ return $results; |
+ } |
+ // get the ide device information out of dmesg |
+ function ide () { |
+ $results = array(); |
+ |
+ $s = 0; |
+ for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) { |
+ $buf = $this->dmesg[$i]; |
+ if (preg_match('/^(.*) at pciide[0-9] (.*): <(.*)>/', $buf, $ar_buf)) { |
+ $s = $ar_buf[1]; |
+ $results[$s]['model'] = $ar_buf[3]; |
+ $results[$s]['media'] = 'Hard Disk'; |
+ // now loop again and find the capacity |
+ for ($j = 0, $max1 = count($this->read_dmesg()); $j < $max1; $j++) { |
+ $buf_n = $this->dmesg[$j]; |
+ if (preg_match("/^($s): (.*), (.*), (.*)MB, .*$/", $buf_n, $ar_buf_n)) { |
+ $results[$s]['capacity'] = $ar_buf_n[4] * 2048 * 1.049;; |
+ } |
+ } |
+ } |
+ } |
+ asort($results); |
+ return $results; |
+ } |
+ |
+ function distroicon () { |
+ $result = 'OpenBSD.png'; |
+ return($result); |
+ } |
+ |
+} |
+ |
+?> |
/web/acc/phpsysinfo/includes/os/class.FreeBSD.inc.php |
---|
0,0 → 1,108 |
<?php |
// phpSysInfo - A PHP System Information Script |
// http://phpsysinfo.sourceforge.net/ |
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU General Public License |
// as published by the Free Software Foundation; either version 2 |
// of the License, or (at your option) any later version. |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
// You should have received a copy of the GNU General Public License |
// along with this program; if not, write to the Free Software |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// $Id: class.FreeBSD.inc.php,v 1.17 2006/04/18 16:22:26 bigmichi1 Exp $ |
if (!defined('IN_PHPSYSINFO')) { |
die("No Hacking"); |
} |
require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php'); |
class sysinfo extends bsd_common { |
var $cpu_regexp = ""; |
var $scsi_regexp1 = ""; |
var $scsi_regexp2 = ""; |
var $cpu_regexp2 = ""; |
// Our contstructor |
// this function is run on the initialization of this class |
function sysinfo () { |
$this->bsd_common(); |
$this->cpu_regexp = "CPU: (.*) \((.*)-MHz (.*)\)"; |
$this->scsi_regexp1 = "^(.*): <(.*)> .*SCSI.*device"; |
$this->scsi_regexp2 = "^(da[0-9]): (.*)MB "; |
$this->cpu_regexp2 = "/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/"; |
} |
function get_sys_ticks () { |
$s = explode(' ', $this->grab_key('kern.boottime')); |
$a = ereg_replace('{ ', '', $s[3]); |
$sys_ticks = time() - $a; |
return $sys_ticks; |
} |
function network () { |
$netstat = execute_program('netstat', '-nibd | grep Link'); |
$lines = explode("\n", $netstat); |
$results = array(); |
for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { |
$ar_buf = preg_split("/\s+/", $lines[$i]); |
if (!empty($ar_buf[0])) { |
$results[$ar_buf[0]] = array(); |
if (strlen($ar_buf[3]) < 15) { |
$results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5]; |
$results[$ar_buf[0]]['rx_packets'] = $ar_buf[3]; |
$results[$ar_buf[0]]['rx_errs'] = $ar_buf[4]; |
$results[$ar_buf[0]]['rx_drop'] = $ar_buf[10]; |
$results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8]; |
$results[$ar_buf[0]]['tx_packets'] = $ar_buf[6]; |
$results[$ar_buf[0]]['tx_errs'] = $ar_buf[7]; |
$results[$ar_buf[0]]['tx_drop'] = $ar_buf[10]; |
$results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7]; |
$results[$ar_buf[0]]['drop'] = $ar_buf[10]; |
} else { |
$results[$ar_buf[0]]['rx_bytes'] = $ar_buf[6]; |
$results[$ar_buf[0]]['rx_packets'] = $ar_buf[4]; |
$results[$ar_buf[0]]['rx_errs'] = $ar_buf[5]; |
$results[$ar_buf[0]]['rx_drop'] = $ar_buf[11]; |
$results[$ar_buf[0]]['tx_bytes'] = $ar_buf[9]; |
$results[$ar_buf[0]]['tx_packets'] = $ar_buf[7]; |
$results[$ar_buf[0]]['tx_errs'] = $ar_buf[8]; |
$results[$ar_buf[0]]['tx_drop'] = $ar_buf[11]; |
$results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[8]; |
$results[$ar_buf[0]]['drop'] = $ar_buf[11]; |
} |
} |
} |
return $results; |
} |
function distroicon () { |
$result = 'FreeBSD.png'; |
return($result); |
} |
function memory_additional($results) { |
$pagesize = $this->grab_key("hw.pagesize"); |
$results['ram']['cached'] = $this->grab_key("vm.stats.vm.v_cache_count") * $pagesize / 1024; |
$results['ram']['cached_percent'] = round( $results['ram']['cached'] * 100 / $results['ram']['total']); |
$results['ram']['app'] = $this->grab_key("vm.stats.vm.v_active_count") * $pagesize / 1024; |
$results['ram']['app_percent'] = round( $results['ram']['app'] * 100 / $results['ram']['total']); |
$results['ram']['buffers'] = $results['ram']['used'] - $results['ram']['app'] - $results['ram']['cached']; |
$results['ram']['buffers_percent'] = round( $results['ram']['buffers'] * 100 / $results['ram']['total']); |
return $results; |
} |
} |
?> |