diff --git a/etc/apps/phpsysinfo/CHANGELOG.md b/etc/apps/phpsysinfo/CHANGELOG.md index 20ec493a0..79892873d 100644 --- a/etc/apps/phpsysinfo/CHANGELOG.md +++ b/etc/apps/phpsysinfo/CHANGELOG.md @@ -3,6 +3,51 @@ Changelog of phpSysInfo http://phpsysinfo.sourceforge.net/ +phpSysInfo 3.1.17 +---------------- + + - [UPD] BAT plugin - capacity unit, cycle count, FreeBSD support + - [UPD] Brazilian Portuguese Translation pt-br.xml + + - [ADD] Show the number of processes on Haiku + - [ADD] ThermalZone sensor support for WinNT + - [ADD] Tanglu to detected distros + - [ADD] Android and OS X version name + + - [FIX] Fixed display of treetables + +phpSysInfo 3.1.16 +---------------- + + - [ADD] Show the number of processes + - [ADD] Lunar and 4MLinux to detected distros + +phpSysInfo 3.1.15 +---------------- + + - [ADD] CoreOS and Pisi Linux to detected distros + - [ADD] pmset - UPS support on Darwin (thanks to pelletierr) + - [ADD] lspci support on Darwin + - [ADD] SHOW_CPULIST_EXPANDED option + - [ADD] lxc/docker detection on Linux + - [ADD] ability to hide all disks and all network interfaces + + - [FIX] Small CSS fix + + - [UPD] Memory informations on Darwin systems + - [UPD] BAT plugin - Darwin support + +phpSysInfo 3.1.14 +---------------- + + - [ADD] FreeIPMI sensor program support + - [ADD] IPMIutil sensor program support + - [ADD] PowerSoftPlus (EVER) UPS program support + - [ADD] Line frequency for the UPS info + - [ADD] SENSOR_EVENTS option - show events of sensors + - [ADD] HIDE_RAID_DEVICES option for plugins MDStatus and DMRaid - list of RAID devices to hide + - [ADD] idash template + phpSysInfo 3.1.13 ---------------- diff --git a/etc/apps/phpsysinfo/config.php b/etc/apps/phpsysinfo/config.php index ead2add7f..81e72ad90 100644 --- a/etc/apps/phpsysinfo/config.php +++ b/etc/apps/phpsysinfo/config.php @@ -3,7 +3,7 @@ /** * phpSysInfo version */ - define('PSI_VERSION','3.1.13'); + define('PSI_VERSION', '3.1.17'); /** * phpSysInfo configuration */ diff --git a/etc/apps/phpsysinfo/data/distros.ini b/etc/apps/phpsysinfo/data/distros.ini index 13c1784d7..c2aab2b10 100644 --- a/etc/apps/phpsysinfo/data/distros.ini +++ b/etc/apps/phpsysinfo/data/distros.ini @@ -38,6 +38,16 @@ Files = "/etc/antix-version" Image = "IPFire.png" ;detected in "/etc/system-release" +[4MLinux] +Image = "4MLinux.png" +Name = "4MLinux" +Files = "/etc/4MLinux-version" + +[Lunar Linux] +Image = "Lunar.png" +;detected in "/etc/lsb-release" +;detected in "/etc/os-release" + [CRUX] Image = "Crux.png" Mode = "Execute" @@ -105,6 +115,16 @@ Image = "Tails.png" ;detected in "/etc/os-release" ;wrong in "/etc/debian_version" Debian +[Tanglu] +Image = "Tanglu.png" +;detected in "lsb_release -a" +;detected in "/etc/lsb-release" +;wrong in "/etc/debian_version" Debian + +[Tanglu GNU/Linux] +Image = "Tanglu.png" +;detected in "/etc/os-release" + [KaOS] Image = "KaOS.png" Files = "/etc/KaOS-release" @@ -112,6 +132,11 @@ Files = "/etc/KaOS-release" ;detected in "/etc/lsb-release" ;detected in "/etc/os-release" +[CoreOS] +Image = "CoreOS.png" +;detected in "/etc/lsb-release" +;detected in "/etc/os-release" + [BOSS] Image = "BOSS.png" Name = "BOSS GNU/Linux" @@ -370,6 +395,16 @@ Image = "StartOS.png" Files = "/etc/startos-release" ;detected in "lsb_release -a" +[PisiLinux] +Image = "Pisi.png" +Files = "/etc/pisilinux-release" +;detected in "lsb_release -a" +;detected in "/etc/lsb-release" + +[Pisi_Linux] +Image = "Pisi.png" +;detected in "/etc/system-release" + [SME] Image = "SMEServer.png" Files = "/etc/e-smith-release" diff --git a/etc/apps/phpsysinfo/data/osnames.ini b/etc/apps/phpsysinfo/data/osnames.ini new file mode 100644 index 000000000..ea1c083ed --- /dev/null +++ b/etc/apps/phpsysinfo/data/osnames.ini @@ -0,0 +1,31 @@ +[Android] +1.0="Apple Pie" +1.1="Banana Bread" +1.5="Cupcake" +1.6="Donut" +2.0="Eclair" +2.1="Eclair" +2.2="Froyo" +2.3="Gingerbread" +3.0="Honeycomb" +3.1="Honeycomb" +3.2="Honeycomb" +4.0="Ice Cream Sandwich" +4.1="Jelly Bean" +4.2="Jelly Bean" +4.3="Jelly Bean" +4.4="KitKat" +5.0="Lollipop" + +[OS X] +10.0="Cheetah" +10.1="Puma" +10.2="Jaguar" +10.3="Panther" +10.4="Tiger" +10.5="Leopard" +10.6="Snow Leopard" +10.7="Lion" +10.8="Mountain Lion" +10.9="Mavericks" +10.10="Yosemite" diff --git a/etc/apps/phpsysinfo/gfx/images/4MLinux.png b/etc/apps/phpsysinfo/gfx/images/4MLinux.png new file mode 100644 index 000000000..e504fc7f7 Binary files /dev/null and b/etc/apps/phpsysinfo/gfx/images/4MLinux.png differ diff --git a/etc/apps/phpsysinfo/gfx/images/CoreOS.png b/etc/apps/phpsysinfo/gfx/images/CoreOS.png new file mode 100644 index 000000000..c955f7715 Binary files /dev/null and b/etc/apps/phpsysinfo/gfx/images/CoreOS.png differ diff --git a/etc/apps/phpsysinfo/gfx/images/Lunar.png b/etc/apps/phpsysinfo/gfx/images/Lunar.png new file mode 100644 index 000000000..4d2517695 Binary files /dev/null and b/etc/apps/phpsysinfo/gfx/images/Lunar.png differ diff --git a/etc/apps/phpsysinfo/gfx/images/Pisi.png b/etc/apps/phpsysinfo/gfx/images/Pisi.png new file mode 100644 index 000000000..3d44955c3 Binary files /dev/null and b/etc/apps/phpsysinfo/gfx/images/Pisi.png differ diff --git a/etc/apps/phpsysinfo/gfx/images/Tanglu.png b/etc/apps/phpsysinfo/gfx/images/Tanglu.png new file mode 100644 index 000000000..f2158451e Binary files /dev/null and b/etc/apps/phpsysinfo/gfx/images/Tanglu.png differ diff --git a/etc/apps/phpsysinfo/gfx/treeTable/tv-collapsable-last.gif b/etc/apps/phpsysinfo/gfx/treeTable/tv-collapsable-last.gif index 0c3f1a420..7b4f2bc80 100644 Binary files a/etc/apps/phpsysinfo/gfx/treeTable/tv-collapsable-last.gif and b/etc/apps/phpsysinfo/gfx/treeTable/tv-collapsable-last.gif differ diff --git a/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable-last.gif b/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable-last.gif index 77bd37ccb..f1eb592ff 100644 Binary files a/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable-last.gif and b/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable-last.gif differ diff --git a/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable.gif b/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable.gif index 989a9b7bb..a57904b95 100644 Binary files a/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable.gif and b/etc/apps/phpsysinfo/gfx/treeTable/tv-expandable.gif differ diff --git a/etc/apps/phpsysinfo/includes/class.CommonFunctions.inc.php b/etc/apps/phpsysinfo/includes/class.CommonFunctions.inc.php index d575fc0db..999efec12 100644 --- a/etc/apps/phpsysinfo/includes/class.CommonFunctions.inc.php +++ b/etc/apps/phpsysinfo/includes/class.CommonFunctions.inc.php @@ -205,15 +205,19 @@ public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $b if ($arrArgs[$i] == '|') { $strCmd = $arrArgs[$i + 1]; $strNewcmd = self::_findProgram($strCmd); - $strArgs = preg_replace("/\| ".$strCmd.'/', "| ".$strNewcmd, $strArgs); + $strArgs = preg_replace("/\| ".$strCmd.'/', '| "'.$strNewcmd.'"', $strArgs); } } } $descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w")); if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) { - $process = $pipes[1] = popen($strProgram." ".$strArgs." 2>/dev/null", "r"); + if (PSI_OS == 'WINNT') { + $process = $pipes[1] = popen('"'.$strProgram.'" '.$strArgs." 2>nul", "r"); + } else { + $process = $pipes[1] = popen('"'.$strProgram.'" '.$strArgs." 2>/dev/null", "r"); + } } else { - $process = proc_open($strProgram." ".$strArgs, $descriptorspec, $pipes); + $process = proc_open('"'.$strProgram.'" '.$strArgs, $descriptorspec, $pipes); } if (is_resource($process)) { self::_timeoutfgets($pipes, $strBuffer, $strError); @@ -444,7 +448,7 @@ private static function _timeoutfgets($pipes, &$out, &$err, $timeout = 30) } else { $pipe2 = true; } - while (!(feof($pipes[1]) || ($pipe2 && feof($pipes[2])))) { + while (!(feof($pipes[1]) && (!$pipe2 || feof($pipes[2])))) { if ($pipe2) { $read = array($pipes[1], $pipes[2]); } else { diff --git a/etc/apps/phpsysinfo/includes/class.Parser.inc.php b/etc/apps/phpsysinfo/includes/class.Parser.inc.php index f864c0435..95174897b 100644 --- a/etc/apps/phpsysinfo/includes/class.Parser.inc.php +++ b/etc/apps/phpsysinfo/includes/class.Parser.inc.php @@ -30,10 +30,10 @@ class Parser * * @return Array */ - public static function lspci() + public static function lspci($debug = PSI_DEBUG) { $arrResults = array(); - if (CommonFunctions::executeProgram("lspci", "", $strBuf, PSI_DEBUG)) { + if (CommonFunctions::executeProgram("lspci", "", $strBuf, $debug)) { $arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY); foreach ($arrLines as $strLine) { $arrParams = preg_split('/ /', trim($strLine), 2); diff --git a/etc/apps/phpsysinfo/includes/mb/class.freeipmi.inc.php b/etc/apps/phpsysinfo/includes/mb/class.freeipmi.inc.php new file mode 100644 index 000000000..5bb5c882a --- /dev/null +++ b/etc/apps/phpsysinfo/includes/mb/class.freeipmi.inc.php @@ -0,0 +1,177 @@ + + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id: class.freeipmi.inc.php 661 2012-08-27 11:26:39Z namiltd $ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * getting information from ipmi-sensors + * + * @category PHP + * @package PSI_Sensor + * @author Michael Cramer + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class FreeIPMI extends Sensors +{ + /** + * content to parse + * + * @var array + */ + private $_lines = array(); + + /** + * fill the private content var through tcp or file access + */ + public function __construct() + { + parent::__construct(); + switch (strtolower(PSI_SENSOR_ACCESS)) { + case 'command': + CommonFunctions::executeProgram('ipmi-sensors', '--output-sensor-thresholds', $lines); + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + break; + case 'file': + if (CommonFunctions::rfts(APP_ROOT.'/data/freeipmi.txt', $lines)) { + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + } + break; + default: + $this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS'); + break; + } + } + + /** + * get temperature information + * + * @return void + */ + private function _temperature() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if ($buffer[2] == "Temperature" && $buffer[11] != "N/A" && $buffer[4] == "C") { + $dev = new SensorDevice(); + $dev->setName($buffer[1]); + $dev->setValue($buffer[3]); + if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); + if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11],"'")); + $this->mbinfo->setMbTemp($dev); + } + } + } + + /** + * get voltage information + * + * @return void + */ + private function _voltage() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if ($buffer[2] == "Voltage" && $buffer[11] != "N/A" && $buffer[4] == "V") { + $dev = new SensorDevice(); + $dev->setName($buffer[1]); + $dev->setValue($buffer[3]); + if ($buffer[6] != "N/A") $dev->setMin($buffer[6]); + if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); + if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11],"'")); + $this->mbinfo->setMbVolt($dev); + } + } + } + + /** + * get fan information + * + * @return void + */ + private function _fans() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if ($buffer[2] == "Fan" && $buffer[11] != "N/A" && $buffer[4] == "RPM") { + $dev = new SensorDevice(); + $dev->setName($buffer[1]); + $dev->setValue($buffer[3]); + if ($buffer[6] != "N/A") { + $dev->setMin($buffer[6]); + } elseif (($buffer[9] != "N/A") && ($buffer[9]<$buffer[3])) { //max instead min issue + $dev->setMin($buffer[9]); + } + if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11],"'")); + $this->mbinfo->setMbFan($dev); + } + } + } + + /** + * get power information + * + * @return void + */ + private function _power() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if ($buffer[2] == "Current" && $buffer[11] != "N/A" && $buffer[4] == "W") { + $dev = new SensorDevice(); + $dev->setName($buffer[1]); + $dev->setValue($buffer[3]); + if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); + if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11],"'")); + $this->mbinfo->setMbPower($dev); + } + } + } + + /** + * get current information + * + * @return void + */ + private function _current() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if ($buffer[2] == "Current" && $buffer[11] != "N/A" && $buffer[4] == "A") { + $dev = new SensorDevice(); + $dev->setName($buffer[1]); + $dev->setValue($buffer[3]); + if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); + if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11],"'")); + $this->mbinfo->setMbCurrent($dev); + } + } + } + + /** + * get the information + * + * @see PSI_Interface_Sensor::build() + * + * @return Void + */ + public function build() + { + $this->_temperature(); + $this->_voltage(); + $this->_fans(); + $this->_power(); + $this->_current(); + } +} diff --git a/etc/apps/phpsysinfo/includes/mb/class.healthd.inc.php b/etc/apps/phpsysinfo/includes/mb/class.healthd.inc.php index 465d45421..dce675942 100644 --- a/etc/apps/phpsysinfo/includes/mb/class.healthd.inc.php +++ b/etc/apps/phpsysinfo/includes/mb/class.healthd.inc.php @@ -44,6 +44,11 @@ public function __construct() CommonFunctions::executeProgram('healthdc', '-t', $lines); $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); break; + case 'file': + if (CommonFunctions::rfts(APP_ROOT.'/data/healthd.txt', $lines)) { + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + } + break; default: $this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS'); break; diff --git a/etc/apps/phpsysinfo/includes/mb/class.hwsensors.inc.php b/etc/apps/phpsysinfo/includes/mb/class.hwsensors.inc.php index 2f7140c52..948fba649 100644 --- a/etc/apps/phpsysinfo/includes/mb/class.hwsensors.inc.php +++ b/etc/apps/phpsysinfo/includes/mb/class.hwsensors.inc.php @@ -38,17 +38,10 @@ class HWSensors extends Sensors public function __construct() { parent::__construct(); - switch (strtolower(PSI_SENSOR_ACCESS)) { - case 'command': - $lines = ""; -// CommonFunctions::executeProgram('sysctl', '-w hw.sensors', $lines); - CommonFunctions::executeProgram('sysctl', 'hw.sensors', $lines); - $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); - break; - default: - $this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS'); - break; - } + $lines = ""; +// CommonFunctions::executeProgram('sysctl', '-w hw.sensors', $lines); + CommonFunctions::executeProgram('sysctl', 'hw.sensors', $lines); + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); } /** diff --git a/etc/apps/phpsysinfo/includes/mb/class.ipmi.inc.php b/etc/apps/phpsysinfo/includes/mb/class.ipmi.inc.php index 6cb279db7..1d16bde68 100644 --- a/etc/apps/phpsysinfo/includes/mb/class.ipmi.inc.php +++ b/etc/apps/phpsysinfo/includes/mb/class.ipmi.inc.php @@ -68,6 +68,11 @@ private function _temperature() $dev->setName($buffer[0]); $dev->setValue($buffer[1]); if ($buffer[8] != "na") $dev->setMax($buffer[8]); + switch ($buffer[3]) { + case "nr": $dev->setEvent("Non-Recoverable"); break; + case "cr": $dev->setEvent("Critical"); break; + case "nc": $dev->setEvent("Non-Critical"); break; + } $this->mbinfo->setMbTemp($dev); } } @@ -88,6 +93,11 @@ private function _voltage() $dev->setValue($buffer[1]); if ($buffer[5] != "na") $dev->setMin($buffer[5]); if ($buffer[8] != "na") $dev->setMax($buffer[8]); + switch ($buffer[3]) { + case "nr": $dev->setEvent("Non-Recoverable"); break; + case "cr": $dev->setEvent("Critical"); break; + case "nc": $dev->setEvent("Non-Critical"); break; + } $this->mbinfo->setMbVolt($dev); } } @@ -106,7 +116,16 @@ private function _fans() $dev = new SensorDevice(); $dev->setName($buffer[0]); $dev->setValue($buffer[1]); - if ($buffer[8] != "na") $dev->setMin($buffer[8]); + if ($buffer[8] != "na") { + $dev->setMin($buffer[8]); + } elseif (($buffer[5] != "na") && ($buffer[5]<$buffer[1])) { //max instead min issue + $dev->setMin($buffer[5]); + } + switch ($buffer[3]) { + case "nr": $dev->setEvent("Non-Recoverable"); break; + case "cr": $dev->setEvent("Critical"); break; + case "nc": $dev->setEvent("Non-Critical"); break; + } $this->mbinfo->setMbFan($dev); } } @@ -126,6 +145,11 @@ private function _power() $dev->setName($buffer[0]); $dev->setValue($buffer[1]); if ($buffer[8] != "na") $dev->setMax($buffer[8]); + switch ($buffer[3]) { + case "nr": $dev->setEvent("Non-Recoverable"); break; + case "cr": $dev->setEvent("Critical"); break; + case "nc": $dev->setEvent("Non-Critical"); break; + } $this->mbinfo->setMbPower($dev); } } @@ -145,6 +169,11 @@ private function _current() $dev->setName($buffer[0]); $dev->setValue($buffer[1]); if ($buffer[8] != "na") $dev->setMax($buffer[8]); + switch ($buffer[3]) { + case "nr": $dev->setEvent("Non-Recoverable"); break; + case "cr": $dev->setEvent("Critical"); break; + case "nc": $dev->setEvent("Non-Critical"); break; + } $this->mbinfo->setMbCurrent($dev); } } diff --git a/etc/apps/phpsysinfo/includes/mb/class.ipmiutil.inc.php b/etc/apps/phpsysinfo/includes/mb/class.ipmiutil.inc.php new file mode 100644 index 000000000..158e2dc6b --- /dev/null +++ b/etc/apps/phpsysinfo/includes/mb/class.ipmiutil.inc.php @@ -0,0 +1,220 @@ + + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id: class.ipmiutil.inc.php 661 2012-08-27 11:26:39Z namiltd $ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * getting information from ipmi-sensors + * + * @category PHP + * @package PSI_Sensor + * @author Michael Cramer + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class IPMIutil extends Sensors +{ + /** + * content to parse + * + * @var array + */ + private $_lines = array(); + + /** + * fill the private content var through tcp or file access + */ + public function __construct() + { + parent::__construct(); + switch (strtolower(PSI_SENSOR_ACCESS)) { + case 'command': + CommonFunctions::executeProgram('ipmiutil', 'sensor -stw', $lines); + $this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + break; + case 'file': + if (CommonFunctions::rfts(APP_ROOT.'/data/ipmiutil.txt', $lines)) { + $this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + } + break; + default: + $this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS'); + break; + } + } + + /** + * get temperature information + * + * @return void + */ + private function _temperature() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if (isset($buffer[2]) && $buffer[2] == "Temperature" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sC$/",$buffer[6], $value)) { + $dev = new SensorDevice(); + $dev->setName($buffer[4]); + $dev->setValue($value[1]); + if (isset($buffer[7]) && $buffer[7] == "Thresholds") { + if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[8], $limits)) + ||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[9], $limits)) + ||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[10], $limits)) + ||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[11], $limits))) { + $dev->setMax($limits[1]); + } + } + if ($buffer[5] != "OK") $dev->setEvent($buffer[5]); + $this->mbinfo->setMbTemp($dev); + } + } + } + + /** + * get voltage information + * + * @return void + */ + private function _voltage() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if (isset($buffer[2]) && $buffer[2] == "Voltage" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sV$/",$buffer[6], $value)) { + $dev = new SensorDevice(); + $dev->setName($buffer[4]); + $dev->setValue($value[1]); + if (isset($buffer[7]) && $buffer[7] == "Thresholds") { + if ((isset($buffer[8]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[8], $limits)) + ||(isset($buffer[9]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[9], $limits)) + ||(isset($buffer[10]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[10], $limits)) + ||(isset($buffer[11]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[11], $limits))) { + $dev->setMin($limits[1]); + } + if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[8], $limits)) + ||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[9], $limits)) + ||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[10], $limits)) + ||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[11], $limits))) { + $dev->setMax($limits[1]); + } + } + if ($buffer[5] != "OK") $dev->setEvent($buffer[5]); + $this->mbinfo->setMbVolt($dev); + } + } + } + + /** + * get fan information + * + * @return void + */ + private function _fans() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if (isset($buffer[2]) && $buffer[2] == "Fan" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sRPM$/",$buffer[6], $value)) { + $dev = new SensorDevice(); + $dev->setName($buffer[4]); + $dev->setValue($value[1]); + if (isset($buffer[7]) && $buffer[7] == "Thresholds") { + if ((isset($buffer[8]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[8], $limits)) + ||(isset($buffer[9]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[9], $limits)) + ||(isset($buffer[10]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[10], $limits)) + ||(isset($buffer[11]) && preg_match("/^lo-crit\s(\S+)\s*$/",$buffer[11], $limits))) { + $dev->setMin($limits[1]); + } elseif ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[8], $limits)) + ||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[9], $limits)) + ||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[10], $limits)) + ||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[11], $limits))) { + if ($limits[1]<$value[1]) {//max instead min issue + $dev->setMin($limits[1]); + } + } + } + if ($buffer[5] != "OK") $dev->setEvent($buffer[5]); + $this->mbinfo->setMbFan($dev); + } + } + } + + /** + * get power information + * + * @return void + */ + private function _power() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if (isset($buffer[2]) && $buffer[2] == "Current" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sW$/",$buffer[6], $value)) { + $dev = new SensorDevice(); + $dev->setName($buffer[4]); + $dev->setValue($value[1]); + if (isset($buffer[7]) && $buffer[7] == "Thresholds") { + if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[8], $limits)) + ||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[9], $limits)) + ||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[10], $limits)) + ||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[11], $limits))) { + $dev->setMax($limits[1]); + } + } + if ($buffer[5] != "OK") $dev->setEvent($buffer[5]); + $this->mbinfo->setMbPower($dev); + } + } + } + + /** + * get current information + * + * @return void + */ + private function _current() + { + foreach ($this->_lines as $line) { + $buffer = preg_split("/\s*\|\s*/", $line); + if (isset($buffer[2]) && $buffer[2] == "Current" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sA$/",$buffer[6], $value)) { + $dev = new SensorDevice(); + $dev->setName($buffer[4]); + $dev->setValue($value[1]); + if (isset($buffer[7]) && $buffer[7] == "Thresholds") { + if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[8], $limits)) + ||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[9], $limits)) + ||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[10], $limits)) + ||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/",$buffer[11], $limits))) { + $dev->setMax($limits[1]); + } + } + if ($buffer[5] != "OK") $dev->setEvent($buffer[5]); + $this->mbinfo->setMbCurrent($dev); + } + } + } + + /** + * get the information + * + * @see PSI_Interface_Sensor::build() + * + * @return Void + */ + public function build() + { + $this->_temperature(); + $this->_voltage(); + $this->_fans(); + $this->_power(); + $this->_current(); + } +} diff --git a/etc/apps/phpsysinfo/includes/mb/class.k8temp.inc.php b/etc/apps/phpsysinfo/includes/mb/class.k8temp.inc.php index f9ce1ca7e..93833530d 100644 --- a/etc/apps/phpsysinfo/includes/mb/class.k8temp.inc.php +++ b/etc/apps/phpsysinfo/includes/mb/class.k8temp.inc.php @@ -44,6 +44,11 @@ public function __construct() CommonFunctions::executeProgram('k8temp', '', $lines); $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); break; + case 'file': + if (CommonFunctions::rfts(APP_ROOT.'/data/k8temp.txt', $lines)) { + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + } + break; default: $this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS'); break; diff --git a/etc/apps/phpsysinfo/includes/mb/class.lmsensors.inc.php b/etc/apps/phpsysinfo/includes/mb/class.lmsensors.inc.php index 917aa3672..53a0bb684 100644 --- a/etc/apps/phpsysinfo/includes/mb/class.lmsensors.inc.php +++ b/etc/apps/phpsysinfo/includes/mb/class.lmsensors.inc.php @@ -76,13 +76,13 @@ private function _temperature() } elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) { ; } else { - (preg_match("/(.*):(.*)/", $line, $data)); + preg_match("/(.*):(.*)/", $line, $data); } if (count($data) > 1) { $temp = substr(trim($data[2]), -1); switch ($temp) { case "C": - case "F": +// case "F": array_push($ar_buf, $line); } } @@ -135,9 +135,7 @@ private function _temperature() } elseif ($data[1][3] == "D") { $data[1] = $data[1] . " Die"; } - } - } $dev->setName($data[1]); @@ -148,6 +146,9 @@ private function _temperature() } elseif (isset($data[4]) && $data[2] <= $data[4]) { $dev->setMax($data[4]); } + if (preg_match("/\sALARM(\s*)$/", $line)) { + $dev->setEvent("Alarm"); + } $this->mbinfo->setMbTemp($dev); } } @@ -170,15 +171,10 @@ private function _fans() preg_match("/(.*):(.*)/", $line, $data); } if (count($data) > 1) { - $temp = preg_split("/ /", trim($data[2])); - if (count($temp) == 1) { - $temp = preg_split("/\xb0/", trim($data[2])); - } - if (isset($temp[1])) { - switch ($temp[1]) { - case "RPM": - array_push($ar_buf, $line); - } + $temp = substr(trim($data[2]), -4); + switch ($temp) { + case " RPM": + array_push($ar_buf, $line); } } } @@ -201,6 +197,9 @@ private function _fans() if (isset($data[4])) { $dev->setMin(trim($data[4])); } + if (preg_match("/\sALARM(\s*)$/", $line)) { + $dev->setEvent("Alarm"); + } $this->mbinfo->setMbFan($dev); } } @@ -217,25 +216,22 @@ private function _voltage() $data = array(); if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) { ; + } elseif (preg_match("/(.*):(.*)\(/", $line, $data)) { + ; } else { preg_match("/(.*):(.*)/", $line, $data); } if (count($data) > 1) { - $temp = preg_split("/ /", trim($data[2])); - if (count($temp) == 1) { - $temp = preg_split("/\xb0/", trim($data[2])); - } - if (isset($temp[1])) { - switch ($temp[1]) { - case "V": - array_push($ar_buf, $line); - } + $temp = substr(trim($data[2]), -2); + switch ($temp) { + case " V": + array_push($ar_buf, $line); } } } foreach ($ar_buf as $line) { $data = array(); - if (preg_match("/(.*)\:(.*) V[ ]*\((.*)=(.*) V,(.*)=(.*) V\)(.*)\)/", $line, $data)) { + if (preg_match("/(.*):(.*) V[ ]*\((.*)=(.*) V,(.*)=(.*) V\)(.*)\)/", $line, $data)) { ; } elseif (preg_match("/(.*):(.*) V[ ]*\((.*)=(.*) V,(.*)=(.*) V\)(.*)/", $line, $data)) { ; @@ -261,6 +257,9 @@ private function _voltage() if (isset($data[6])) { $dev->setMax($data[6]); } + if (preg_match("/\sALARM(\s*)$/", $line)) { + $dev->setEvent("Alarm"); + } $this->mbinfo->setMbVolt($dev); } } @@ -276,18 +275,17 @@ private function _power() $ar_buf = array(); foreach ($this->_lines as $line) { $data = array(); - //echo $line."
"; if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) { ; } elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) { ; } else { - (preg_match("/(.*):(.*)/", $line, $data)); + preg_match("/(.*):(.*)/", $line, $data); } if (count($data) > 1) { - $temp = substr(trim($data[2]), -1); + $temp = substr(trim($data[2]), -2); switch ($temp) { - case "W": + case " W": array_push($ar_buf, $line); } } @@ -295,18 +293,18 @@ private function _power() foreach ($ar_buf as $line) { $data = array(); /* not tested yet - if (preg_match("/(.*):(.*).W[ ]*\((.*)=(.*).W,(.*)=(.*).W\)(.*)\)/", $line, $data)) { + if (preg_match("/(.*):(.*) W[ ]*\((.*)=(.*) W,(.*)=(.*) W\)(.*)\)/", $line, $data)) { ; - } elseif (preg_match("/(.*):(.*).W[ ]*\((.*)=(.*).W,(.*)=(.*).W\)(.*)/", $line, $data)) { + } elseif (preg_match("/(.*):(.*) W[ ]*\((.*)=(.*) W,(.*)=(.*) W\)(.*)/", $line, $data)) { ; } else */ - if (preg_match("/(.*):(.*).W[ ]*\((.*)=(.*).W\)(.*)/", $line, $data)) { + if (preg_match("/(.*):(.*) W[ ]*\((.*)=(.*) W\)(.*)/", $line, $data)) { ; - } elseif (preg_match("/(.*):(.*).W[ \t]+/", $line, $data)) { + } elseif (preg_match("/(.*):(.*) W[ \t]+/", $line, $data)) { ; } else { - preg_match("/(.*):(.*).W$/", $line, $data); + preg_match("/(.*):(.*) W$/", $line, $data); } foreach ($data as $key=>$value) { if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) { @@ -324,6 +322,9 @@ private function _power() } elseif (isset($data[4]) && $data[2] <= $data[4]) { $dev->setMax($data[4]); } + if (preg_match("/\sALARM(\s*)$/", $line)) { + $dev->setEvent("Alarm"); + } $this->mbinfo->setMbPower($dev); } } @@ -338,18 +339,17 @@ private function _current() $ar_buf = array(); foreach ($this->_lines as $line) { $data = array(); - //echo $line."
"; if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) { ; } elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) { ; } else { - (preg_match("/(.*):(.*)/", $line, $data)); + preg_match("/(.*):(.*)/", $line, $data); } if (count($data) > 1) { - $temp = substr(trim($data[2]), -1); + $temp = substr(trim($data[2]), -2); switch ($temp) { - case "A": + case " A": array_push($ar_buf, $line); } } @@ -357,18 +357,18 @@ private function _current() foreach ($ar_buf as $line) { $data = array(); /* not tested yet - if (preg_match("/(.*):(.*).A[ ]*\((.*)=(.*).W,(.*)=(.*).A\)(.*)\)/", $line, $data)) { + if (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A,(.*)=(.*) A\)(.*)\)/", $line, $data)) { ; - } elseif (preg_match("/(.*):(.*).A[ ]*\((.*)=(.*).W,(.*)=(.*).A\)(.*)/", $line, $data)) { + } elseif (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A,(.*)=(.*) A\)(.*)/", $line, $data)) { ; } else */ - if (preg_match("/(.*):(.*).A[ ]*\((.*)=(.*).A\)(.*)/", $line, $data)) { + if (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A\)(.*)/", $line, $data)) { ; - } elseif (preg_match("/(.*):(.*).A[ \t]+/", $line, $data)) { + } elseif (preg_match("/(.*):(.*) A[ \t]+/", $line, $data)) { ; } else { - preg_match("/(.*):(.*).A$/", $line, $data); + preg_match("/(.*):(.*) A$/", $line, $data); } foreach ($data as $key=>$value) { if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) { @@ -386,6 +386,9 @@ private function _current() } elseif (isset($data[4]) && $data[2] <= $data[4]) { $dev->setMax($data[4]); } + if (preg_match("/\sALARM(\s*)$/", $line)) { + $dev->setEvent("Alarm"); + } $this->mbinfo->setMbCurrent($dev); } } diff --git a/etc/apps/phpsysinfo/includes/mb/class.mbmon.inc.php b/etc/apps/phpsysinfo/includes/mb/class.mbmon.inc.php index 78be31f86..351b0a83f 100644 --- a/etc/apps/phpsysinfo/includes/mb/class.mbmon.inc.php +++ b/etc/apps/phpsysinfo/includes/mb/class.mbmon.inc.php @@ -55,6 +55,11 @@ public function __construct() CommonFunctions::executeProgram('mbmon', '-c 1 -r', $lines, PSI_DEBUG); $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); break; + case 'file': + if (CommonFunctions::rfts(APP_ROOT.'/data/mbmon.txt', $lines)) { + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + } + break; default: $this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS'); break; diff --git a/etc/apps/phpsysinfo/includes/mb/class.ohm.inc.php b/etc/apps/phpsysinfo/includes/mb/class.ohm.inc.php index 35b3d46ce..7e86b50f9 100644 --- a/etc/apps/phpsysinfo/includes/mb/class.ohm.inc.php +++ b/etc/apps/phpsysinfo/includes/mb/class.ohm.inc.php @@ -30,14 +30,7 @@ class OHM extends Sensors * * @var Object */ - private $_buf = array(); - - /** - * holds the COM object that we pull all the WMI data from - * - * @var Object - */ - private $_wmi = null; + private $_buf = array(); /** * fill the private content var @@ -45,6 +38,7 @@ class OHM extends Sensors public function __construct() { parent::__construct(); + $_wmi = null; // don't set this params for local connection, it will not work $strHostname = ''; $strUser = ''; @@ -53,15 +47,17 @@ public function __construct() // initialize the wmi object $objLocator = new COM('WbemScripting.SWbemLocator'); if ($strHostname == "") { - $this->_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor'); + $_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor'); } else { - $this->_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor', $strHostname.'\\'.$strUser, $strPassword); + $_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor', $strHostname.'\\'.$strUser, $strPassword); } } catch (Exception $e) { - $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed."); + $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data."); } - $this->_buf = CommonFunctions::getWMI($this->_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value')); + if ($_wmi) { + $this->_buf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value')); + } } /** @@ -71,14 +67,12 @@ public function __construct() */ private function _temperature() { - if ($this->_wmi != null) { - foreach ($this->_buf as $buffer) { + if ($this->_buf) foreach ($this->_buf as $buffer) { if ($buffer['SensorType'] == "Temperature") { - $dev = new SensorDevice(); - $dev->setName($buffer['Parent'].' '.$buffer['Name']); - $dev->setValue($buffer['Value']); - $this->mbinfo->setMbTemp($dev); - } + $dev = new SensorDevice(); + $dev->setName($buffer['Parent'].' '.$buffer['Name']); + $dev->setValue($buffer['Value']); + $this->mbinfo->setMbTemp($dev); } } } @@ -90,14 +84,12 @@ private function _temperature() */ private function _voltage() { - if ($this->_wmi != null) { - foreach ($this->_buf as $buffer) { + if ($this->_buf) foreach ($this->_buf as $buffer) { if ($buffer['SensorType'] == "Voltage") { - $dev = new SensorDevice(); - $dev->setName($buffer['Parent'].' '.$buffer['Name']); - $dev->setValue($buffer['Value']); - $this->mbinfo->setMbVolt($dev); - } + $dev = new SensorDevice(); + $dev->setName($buffer['Parent'].' '.$buffer['Name']); + $dev->setValue($buffer['Value']); + $this->mbinfo->setMbVolt($dev); } } } @@ -109,14 +101,12 @@ private function _voltage() */ private function _fans() { - if ($this->_wmi != null) { - foreach ($this->_buf as $buffer) { + if ($this->_buf) foreach ($this->_buf as $buffer) { if ($buffer['SensorType'] == "Fan") { - $dev = new SensorDevice(); - $dev->setName($buffer['Parent'].' '.$buffer['Name']); - $dev->setValue($buffer['Value']); - $this->mbinfo->setMbFan($dev); - } + $dev = new SensorDevice(); + $dev->setName($buffer['Parent'].' '.$buffer['Name']); + $dev->setValue($buffer['Value']); + $this->mbinfo->setMbFan($dev); } } } @@ -128,14 +118,12 @@ private function _fans() */ private function _power() { - if ($this->_wmi != null) { - foreach ($this->_buf as $buffer) { + if ($this->_buf) foreach ($this->_buf as $buffer) { if ($buffer['SensorType'] == "Power") { - $dev = new SensorDevice(); - $dev->setName($buffer['Parent'].' '.$buffer['Name']); - $dev->setValue($buffer['Value']); - $this->mbinfo->setMbPower($dev); - } + $dev = new SensorDevice(); + $dev->setName($buffer['Parent'].' '.$buffer['Name']); + $dev->setValue($buffer['Value']); + $this->mbinfo->setMbPower($dev); } } } diff --git a/etc/apps/phpsysinfo/includes/mb/class.thermalzone.inc.php b/etc/apps/phpsysinfo/includes/mb/class.thermalzone.inc.php new file mode 100644 index 000000000..689c5b930 --- /dev/null +++ b/etc/apps/phpsysinfo/includes/mb/class.thermalzone.inc.php @@ -0,0 +1,99 @@ + + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id: class.ohm.inc.php 661 2012-08-27 11:26:39Z namiltd $ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * getting information from Thermal Zone WMI class + * + * @category PHP + * @package PSI_Sensor + * @author Michael Cramer + * @copyright 2009 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class ThermalZone extends Sensors +{ +/** + * holds the COM object that we pull all the WMI data from + * + * @var Object + */ + private $_buf = array(); + + /** + * fill the private content var + */ + public function __construct() + { + parent::__construct(); + $_wmi = null; + // don't set this params for local connection, it will not work + $strHostname = ''; + $strUser = ''; + $strPassword = ''; + try { + // initialize the wmi object + $objLocator = new COM('WbemScripting.SWbemLocator'); + if ($strHostname == "") { + $_wmi = $objLocator->ConnectServer($strHostname, 'root\WMI'); + + } else { + $_wmi = $objLocator->ConnectServer($strHostname, 'root\WMI', $strHostname.'\\'.$strUser, $strPassword); + } + } catch (Exception $e) { + $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for ThermalZone data."); + } + if ($_wmi) { + $this->_buf = CommonFunctions::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature')); + } + } + + /** + * get temperature information + * + * @return void + */ + private function _temperature() + { + if ($this->_buf) foreach ($this->_buf as $buffer) { + if (isset($buffer['CurrentTemperature']) && (( $value = ($buffer['CurrentTemperature'] - 2732)/10 ) > -100)) { + $dev = new SensorDevice(); + if (isset($buffer['InstanceName']) && preg_match("/([^\\\\ ]+)$/", $buffer['InstanceName'], $outbuf)) { + $dev->setName('ThermalZone '.$outbuf[1]); + } else { + $dev->setName('ThermalZone THM0_0'); + } + $dev->setValue($value); + if (isset($buffer['CriticalTripPoint']) && (( $maxvalue = ($buffer['CriticalTripPoint'] - 2732)/10 ) > 0)) { + $dev->setMax($maxvalue); + } + $this->mbinfo->setMbTemp($dev); + } + } + } + + + /** + * get the information + * + * @see PSI_Interface_Sensor::build() + * + * @return Void + */ + public function build() + { + $this->_temperature(); + } +} diff --git a/etc/apps/phpsysinfo/includes/os/class.Android.inc.php b/etc/apps/phpsysinfo/includes/os/class.Android.inc.php index 0804caac8..2e52ba1a5 100644 --- a/etc/apps/phpsysinfo/includes/os/class.Android.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.Android.inc.php @@ -146,12 +146,17 @@ private function _distro() $buf = ""; if (CommonFunctions::rfts('/system/build.prop', $lines, 0, 4096, false) && preg_match('/^ro\.build\.version\.release=([^\n]+)/m', $lines, $ar_buf)) { - $buf = $ar_buf[1]; + $buf = trim($ar_buf[1]); } - if ( is_null($buf) || (trim($buf) == "")) { + if ( is_null($buf) || ($buf == "")) { $this->sys->setDistribution('Android'); - } else { - $this->sys->setDistribution('Android '.trim($buf)); + } else { + if (preg_match('/^(\d+\.\d+)/', $buf, $ver) + && ($list = @parse_ini_file(APP_ROOT."/data/osnames.ini", true)) + && isset($list['Android'][$ver[1]])) { + $buf.=' '.$list['Android'][$ver[1]]; + } + $this->sys->setDistribution('Android '.$buf); } $this->sys->setDistributionIcon('Android.png'); } @@ -180,6 +185,46 @@ private function _machine() } } + /** + * PCI devices + * + * @return array + */ + private function _pci() + { + if (CommonFunctions::executeProgram('lspci', '', $bufr, false)) { + $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + foreach ($bufe as $buf) { + $device = preg_split("/ /", $buf, 4); + if (isset($device[3]) && trim($device[3]) != "") { + $dev = new HWDevice(); + $dev->setName(trim($device[3])); + $this->sys->setPciDevices($dev); + } + } + } + } + + /** + * USB devices + * + * @return array + */ + private function _usb() + { + if (CommonFunctions::executeProgram('lsusb', '', $bufr, false)) { + $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + foreach ($bufe as $buf) { + $device = preg_split("/ /", $buf, 6); + if (isset($device[5]) && trim($device[5]) != "") { + $dev = new HWDevice(); + $dev->setName(trim($device[5])); + $this->sys->setUsbDevices($dev); + } + } + } + } + /** * get the information * @@ -198,9 +243,12 @@ public function build() $this->_uptime(); $this->_users(); $this->_cpuinfo(); + $this->_pci(); + $this->_usb(); $this->_network(); $this->_memory(); $this->_filesystems(); $this->_loadavg(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.BSDCommon.inc.php b/etc/apps/phpsysinfo/includes/os/class.BSDCommon.inc.php index 4054f97d9..6ba117cf6 100644 --- a/etc/apps/phpsysinfo/includes/os/class.BSDCommon.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.BSDCommon.inc.php @@ -366,7 +366,7 @@ protected function scsi() */ protected function pci() { - if (!is_array($results = Parser::lspci()) || !is_array($results = Parser::pciconf())) { + if (!is_array($results = Parser::lspci(false)) || !is_array($results = Parser::pciconf())) { foreach ($this->readdmesg() as $line) { if (preg_match("/".$this->_PCIRegExp1."/", $line, $ar_buf)) { $dev = new HWDevice(); diff --git a/etc/apps/phpsysinfo/includes/os/class.Darwin.inc.php b/etc/apps/phpsysinfo/includes/os/class.Darwin.inc.php index 79b039a56..5aab3102a 100644 --- a/etc/apps/phpsysinfo/includes/os/class.Darwin.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.Darwin.inc.php @@ -119,15 +119,17 @@ protected function cpuinfo() if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) { $dev->setModel(preg_replace('/Processor type: /', '', $buf)); $buf=$this->grabkey('hw.model'); - $this->sys->setMachine(trim($buf)); - if (CommonFunctions::rfts(APP_ROOT.'/data/ModelTranslation.txt', $buffer)) { - $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY); - foreach ($buffer as $line) { - $ar_buf = preg_split("/:/", $line, 3); - if (trim($buf) === trim($ar_buf[0])) { - $dev->setModel(trim($ar_buf[2])); - $this->sys->getMachine($this->sys->setMachine().' - '.trim($ar_buf[1])); - break; + if ( !is_null($buf) && (trim($buf) != "")) { + $this->sys->setMachine(trim($buf)); + if (CommonFunctions::rfts(APP_ROOT.'/data/ModelTranslation.txt', $buffer)) { + $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY); + foreach ($buffer as $line) { + $ar_buf = preg_split("/:/", $line, 3); + if (trim($buf) === trim($ar_buf[0])) { + $dev->setModel(trim($ar_buf[2])); + $this->sys->setMachine($this->sys->getMachine().' - '.trim($ar_buf[1])); + break; + } } } } @@ -172,14 +174,20 @@ protected function cpuinfo() */ protected function pci() { - $s = $this->_grabioreg('IOPCIDevice'); - $lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY); - foreach ($lines as $line) { - $dev = new HWDevice(); - if (!preg_match('/"IOName" = "([^"]*)"/', $line, $ar_buf )) - $ar_buf = preg_split("/[\s@]+/", $line, 19); - $dev->setName(trim($ar_buf[1])); - $this->sys->setPciDevices($dev); + if (!$arrResults = Parser::lspci(false)) { //no lspci port + $s = $this->_grabioreg('IOPCIDevice'); + $lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY); + foreach ($lines as $line) { + $dev = new HWDevice(); + if (!preg_match('/"IOName" = "([^"]*)"/', $line, $ar_buf )) + $ar_buf = preg_split("/[\s@]+/", $line, 19); + $dev->setName(trim($ar_buf[1])); + $this->sys->setPciDevices($dev); + } + } else { + foreach ($arrResults as $dev) { + $this->sys->setPciDevices($dev); + } } } @@ -222,7 +230,7 @@ protected function usb() $lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY); foreach ($lines as $line) { $dev = new HWDevice(); - if (!preg_match('/"USB Product Name"="([^"]*)"/', $line, $ar_buf )) + if (!preg_match('/"USB Product Name" = "([^"]*)"/', $line, $ar_buf )) $ar_buf = preg_split("/[\s]+/", $line, 19); $dev->setName(trim($ar_buf[1])); $this->sys->setUsbDevices($dev); @@ -256,26 +264,37 @@ protected function memory() { $s = $this->grabkey('hw.memsize'); if (CommonFunctions::executeProgram('vm_stat', '', $pstat, PSI_DEBUG)) { - // calculate free memory from page sizes (each page = 4MB) - if ( (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf )) - && (preg_match('/^Pages speculative:\s+(\S+)/m', $pstat, $spec_buf )) ) { - - $this->sys->setMemFree(($free_buf[1]+$spec_buf[1]) * 4 * 1024); - - $appMemory = 0; - if (preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)) { - $appMemory += $wire_buf[1] * 4 * 1024; - } - if (preg_match('/^Pages active:\s+(\S+)/m', $pstat, $active_buf)) { - $appMemory += $active_buf[1] * 4 * 1024; - } - $this->sys->setMemApplication($appMemory); + // calculate free memory from page sizes (each page = 4096) + if (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf )) { + if (preg_match('/^Anonymous pages:\s+(\S+)/m', $pstat, $anon_buf) + && preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf) + && preg_match('/^File-backed pages:\s+(\S+)/m', $pstat, $fileb_buf)) { + // OS X 10.9 or never + $this->sys->setMemFree($free_buf[1] * 4 * 1024); + $this->sys->setMemApplication(($anon_buf[1]+$wire_buf[1]) * 4 * 1024); + $this->sys->setMemCache($fileb_buf[1] * 4 * 1024); + if (preg_match('/^Pages occupied by compressor:\s+(\S+)/m', $pstat, $compr_buf)) { + $this->sys->setMemBuffer($compr_buf[1] * 4 * 1024); + } + } else { + if (preg_match('/^Pages speculative:\s+(\S+)/m', $pstat, $spec_buf)) { + $this->sys->setMemFree(($free_buf[1]+$spec_buf[1]) * 4 * 1024); + } else { + $this->sys->setMemFree($free_buf[1] * 4 * 1024); + } + $appMemory = 0; + if (preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)) { + $appMemory += $wire_buf[1] * 4 * 1024; + } + if (preg_match('/^Pages active:\s+(\S+)/m', $pstat, $active_buf)) { + $appMemory += $active_buf[1] * 4 * 1024; + } + $this->sys->setMemApplication($appMemory); - if (preg_match('/^Pages inactive:\s+(\S+)/m', $pstat, $inactive_buf)) { - $this->sys->setMemCache($inactive_buf[1] * 4 * 1024); + if (preg_match('/^Pages inactive:\s+(\S+)/m', $pstat, $inactive_buf)) { + $this->sys->setMemCache($inactive_buf[1] * 4 * 1024); + } } - - $this->sys->setMemBuffer(0); } else { $lines = preg_split("/\n/", $pstat, -1, PREG_SPLIT_NO_EMPTY); $ar_buf = preg_split("/\s+/", $lines[1], 19); @@ -359,6 +378,11 @@ protected function distro() if (preg_match('/(^Mac OS)|(^OS X)/', $distro)) { $this->sys->setDistributionIcon('Apple.png'); + if (preg_match('/((^Mac OS X)|(^OS X)) (\d+\.\d+)/', $distro, $ver) + && ($list = @parse_ini_file(APP_ROOT."/data/osnames.ini", true)) + && isset($list['OS X'][$ver[4]])) { + $distro.=' '.$list['OS X'][$ver[4]]; + } } $this->sys->setDistribution($distro); @@ -369,6 +393,36 @@ protected function distro() } } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) { + $processes['*']++; + $state = $ar_buf[1]; + if ($state == 'U') $state = 'D'; //linux format + elseif ($state == 'I') $state = 'S'; + elseif ($state == 'D') $state = 'd'; //invalid + if (isset($processes[$state])) { + $processes[$state]++; + } else { + $processes[$state] = 1; + } + } + } + if ($processes['*'] > 0) { + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -381,5 +435,6 @@ public function build() parent::build(); $this->_uptime(); $this->_network(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.DragonFly.inc.php b/etc/apps/phpsysinfo/includes/os/class.DragonFly.inc.php index 36af2844e..9e9f946c1 100644 --- a/etc/apps/phpsysinfo/includes/os/class.DragonFly.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.DragonFly.inc.php @@ -107,6 +107,34 @@ private function _distroicon() $this->sys->setDistributionIcon('DragonFly.png'); } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) { + $processes['*']++; + $state = $ar_buf[1]; + if ($state == 'I') $state = 'S'; //linux format + if (isset($processes[$state])) { + $processes[$state]++; + } else { + $processes[$state] = 1; + } + } + } + if ($processes['*'] > 0) { + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -120,5 +148,6 @@ public function build() $this->_distroicon(); $this->_network(); $this->_uptime(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.FreeBSD.inc.php b/etc/apps/phpsysinfo/includes/os/class.FreeBSD.inc.php index 83c6b1611..4d49512e2 100644 --- a/etc/apps/phpsysinfo/includes/os/class.FreeBSD.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.FreeBSD.inc.php @@ -137,6 +137,35 @@ private function _memoryadditional() $this->sys->setMemBuffer($this->sys->getMemUsed() - $this->sys->getMemApplication() - $this->sys->getMemCache()); } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) { + $processes['*']++; + $state = $ar_buf[1]; + if ($state == 'L') $state = 'D'; //linux format + elseif ($state == 'I') $state = 'S'; + if (isset($processes[$state])) { + $processes[$state]++; + } else { + $processes[$state] = 1; + } + } + } + if ($processes['*'] > 0) { + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -151,5 +180,6 @@ public function build() $this->_distroicon(); $this->_network(); $this->_uptime(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.Haiku.inc.php b/etc/apps/phpsysinfo/includes/os/class.Haiku.inc.php index 0f89c3b84..9b6915398 100644 --- a/etc/apps/phpsysinfo/includes/os/class.Haiku.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.Haiku.inc.php @@ -355,6 +355,28 @@ private function _network() } } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', '', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^(kernel_team|\/)/", $line, $ar_buf)) { + $processes['*']++; + } + } + if ($processes['*'] > 0) { + $processes[' '] = $processes['*']; + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -376,5 +398,6 @@ public function build() $this->_memory(); $this->_filesystems(); $this->_network(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.Linux.inc.php b/etc/apps/phpsysinfo/includes/os/class.Linux.inc.php index 96e136fc0..672babc43 100644 --- a/etc/apps/phpsysinfo/includes/os/class.Linux.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.Linux.inc.php @@ -46,11 +46,44 @@ public function __construct() */ private function _machine() { - if ( (CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false) - && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf)) + if ( (CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false) + && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf)) ||(CommonFunctions::executeProgram('dmesg', '', $result, false) && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf)) ) { $this->sys->setMachine(trim($ar_buf[1])); + } else { //data from /sys/devices/virtual/dmi/id/ + $machine = ""; + $product = ""; + $board = ""; + $bios = ""; + if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) { + $machine = trim($buf); + } + if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) { + $product = trim($buf); + } + if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_name', $buf, 1, 4096, false) && (trim($buf)!="")) { + $board = trim($buf); + } + if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_version', $buf, 1, 4096, false) && (trim($buf)!="")) { + $bios = trim($buf); + } + if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_date', $buf, 1, 4096, false) && (trim($buf)!="")) { + $bios = trim($bios." ".trim($buf)); + } + if ($product != "") { + $machine .= " ".$product; + } + if ($board != "") { + $machine .= "/".$board; + } + if ($bios != "") { + $machine .= ", BIOS ".$bios; + } + + if ($machine != "") { + $this->sys->setMachine(trim($machine)); + } } } @@ -110,17 +143,27 @@ private function _kernel() if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) { $result .= ' '.trim($strBuf); } + if (CommonFunctions::rfts('/proc/self/cgroup', $strBuf2, 0, 4096, false)) { + if (preg_match('/:\/lxc\//m', $strBuf2)) { + $result .= ' [lxc]'; + } elseif (preg_match('/:\/docker\//m', $strBuf2)) { + $result .= ' [docker]'; + } + } $this->sys->setKernel($result); - } else { - if (CommonFunctions::rfts('/proc/version', $strBuf, 1)) { - if (preg_match('/version (.*?) /', $strBuf, $ar_buf)) { - $result = $ar_buf[1]; - if (preg_match('/SMP/', $strBuf)) { - $result .= ' (SMP)'; - } - $this->sys->setKernel($result); + } elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) && preg_match('/version (.*?) /', $strBuf, $ar_buf)) { + $result = $ar_buf[1]; + if (preg_match('/SMP/', $strBuf)) { + $result .= ' (SMP)'; + } + if (CommonFunctions::rfts('/proc/self/cgroup', $strBuf2, 0, 4096, false)) { + if (preg_match('/:\/lxc\//m', $strBuf2)) { + $result .= ' [lxc]'; + } elseif (preg_match('/:\/docker\//m', $strBuf2)) { + $result .= ' [docker]'; } } + $this->sys->setKernel($result); } } @@ -232,6 +275,7 @@ protected function _parseProcStat($cpuline) if (isset($this->_cpu_loads[$cpuline])) { return $this->_cpu_loads[$cpuline]; } + return 0; } @@ -268,6 +312,7 @@ protected function _cpuinfo() break; case 'model name': case 'cpu model': + case 'cpu type': case 'cpu': $dev->setModel($arrBuff[1]); break; @@ -492,6 +537,10 @@ private function _usb() $dev = new HWDevice(); $dev->setName(trim($device[6])); $this->sys->setUsbDevices($dev); + } elseif (isset($device[5]) && trim($device[5]) != "") { + $dev = new HWDevice(); + $dev->setName("unknown"); + $this->sys->setUsbDevices($dev); } } } @@ -949,6 +998,37 @@ private function _distro() } } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + $process = glob('/proc/*/status', GLOB_NOSORT); + if (($total = count($process)) > 0) { + + $processes['*'] = 0; + $buf = ""; + for ($i = 0; $i < $total; $i++) { + if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) { + $processes['*']++; //current total + if (preg_match('/^State:\s+(\w)/m', $buf, $state)) { + if (isset($processes[$state[1]])) { + $processes[$state[1]]++; + } else { + $processes[$state[1]] = 1; + } + } + } + } + if (!($processes['*'] > 0)) { + $processes['*'] = $processes[' '] = $total; //all unknown + } + $this->sys->setProcesses($processes); + } + } + /** * get the information * @@ -974,5 +1054,6 @@ public function build() $this->_memory(); $this->_filesystems(); $this->_loadavg(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.Minix.inc.php b/etc/apps/phpsysinfo/includes/os/class.Minix.inc.php index 36abc626f..8a52c4e6f 100644 --- a/etc/apps/phpsysinfo/includes/os/class.Minix.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.Minix.inc.php @@ -328,6 +328,35 @@ private function _network() } } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', 'alx', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^\s(\w)\s/", $line, $ar_buf)) { + $processes['*']++; + $state = $ar_buf[1]; + if ($state == 'W') $state = 'D'; //linux format + elseif ($state == 'D') $state = 'd'; //invalid + if (isset($processes[$state])) { + $processes[$state]++; + } else { + $processes[$state] = 1; + } + } + } + if ($processes['*'] > 0) { + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -348,5 +377,6 @@ public function build() $this->_memory(); $this->_filesystems(); $this->_network(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.NetBSD.inc.php b/etc/apps/phpsysinfo/includes/os/class.NetBSD.inc.php index 4d44efc32..d43e79cce 100644 --- a/etc/apps/phpsysinfo/includes/os/class.NetBSD.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.NetBSD.inc.php @@ -112,6 +112,35 @@ private function _distroicon() $this->sys->setDistributionIcon('NetBSD.png'); } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) { + $processes['*']++; + $state = $ar_buf[1]; + if ($state == 'O') $state = 'R'; //linux format + elseif ($state == 'I') $state = 'S'; + if (isset($processes[$state])) { + $processes[$state]++; + } else { + $processes[$state] = 1; + } + } + } + if ($processes['*'] > 0) { + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -125,5 +154,6 @@ public function build() $this->_distroicon(); $this->_network(); $this->_uptime(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.OpenBSD.inc.php b/etc/apps/phpsysinfo/includes/os/class.OpenBSD.inc.php index 999200667..e2a425bb8 100644 --- a/etc/apps/phpsysinfo/includes/os/class.OpenBSD.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.OpenBSD.inc.php @@ -128,6 +128,34 @@ private function _distroicon() $this->sys->setDistributionIcon('OpenBSD.png'); } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) { + $processes['*']++; + $state = $ar_buf[1]; + if ($state == 'I') $state = 'S'; //linux format + if (isset($processes[$state])) { + $processes[$state]++; + } else { + $processes[$state] = 1; + } + } + } + if ($processes['*'] > 0) { + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -141,5 +169,6 @@ public function build() $this->_distroicon(); $this->_network(); $this->_uptime(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.SunOS.inc.php b/etc/apps/phpsysinfo/includes/os/class.SunOS.inc.php index 071ca5adc..4a31a0c73 100644 --- a/etc/apps/phpsysinfo/includes/os/class.SunOS.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.SunOS.inc.php @@ -293,6 +293,36 @@ private function _distro() $this->sys->setDistributionIcon('SunOS.png'); } + /** + * Processes + * + * @return void + */ + protected function _processes() + { + if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) { + $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); + $processes['*'] = 0; + foreach ($lines as $line) { + if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) { + $processes['*']++; + $state = $ar_buf[1]; + if ($state == 'O') $state = 'R'; //linux format + elseif ($state == 'W') $state = 'D'; + elseif ($state == 'D') $state = 'd'; //invalid + if (isset($processes[$state])) { + $processes[$state]++; + } else { + $processes[$state] = 1; + } + } + } + if ($processes['*'] > 0) { + $this->sys->setProcesses($processes); + } + } + } + /** * get the information * @@ -314,5 +344,6 @@ public function build() $this->_network(); $this->_memory(); $this->_filesystems(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/os/class.WINNT.inc.php b/etc/apps/phpsysinfo/includes/os/class.WINNT.inc.php index 7ae937758..ed39cb4dc 100644 --- a/etc/apps/phpsysinfo/includes/os/class.WINNT.inc.php +++ b/etc/apps/phpsysinfo/includes/os/class.WINNT.inc.php @@ -72,7 +72,7 @@ public function __construct() $this->_wmi = $objLocator->ConnectServer(); } else { - $this->_wmi = $objLocator->ConnectServer($strHostname, 'rootcimv2', $strHostname.'\\'.$strUser, $strPassword); + $this->_wmi = $objLocator->ConnectServer($strHostname, 'root\CIMv2', $strHostname.'\\'.$strUser, $strPassword); } } catch (Exception $e) { $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed."); @@ -238,13 +238,13 @@ private function _distro() $icon = 'Win2000.png'; elseif ((substr($kernel,0,4) == "6.0.") || (substr($kernel,0,4) == "6.1.")) $icon = 'WinVista.png'; - elseif ((substr($kernel,0,4) == "6.2.") || (substr($kernel,0,4) == "6.3.")) + elseif ((substr($kernel,0,4) == "6.2.") || (substr($kernel,0,4) == "6.3.") || (substr($kernel,0,4) == "6.4.")) $icon = 'Win8.png'; else $icon = 'WinXP.png'; $this->sys->setDistributionIcon($icon); } elseif (CommonFunctions::executeProgram("cmd", "/c ver 2>nul", $ver_value, false)) { - if (preg_match("/ReactOS\nVersion\s+(.+)/", $ver_value, $ar_temp)) { + if (preg_match("/ReactOS\r?\nVersion\s+(.+)/", $ver_value, $ar_temp)) { $this->sys->setDistribution("ReactOS"); $this->sys->setKernel($ar_temp[1]); $this->sys->setDistributionIcon('ReactOS.png'); @@ -273,14 +273,16 @@ private function _loadavg() $loadavg = ""; $sum = 0; $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('LoadPercentage')); - foreach ($buffer as $load) { - $value = $load['LoadPercentage']; - $loadavg .= $value.' '; - $sum += $value; - } - $this->sys->setLoad(trim($loadavg)); - if (PSI_LOAD_BAR) { - $this->sys->setLoadPercent($sum / count($buffer)); + if ($buffer) { + foreach ($buffer as $load) { + $value = $load['LoadPercentage']; + $loadavg .= $value.' '; + $sum += $value; + } + $this->sys->setLoad(trim($loadavg)); + if (PSI_LOAD_BAR) { + $this->sys->setLoadPercent($sum / count($buffer)); + } } } @@ -397,7 +399,7 @@ private function _network() if (preg_match('/\s-\s([^-]*)$/', $name, $ar_name)) $name=substr($name,0,strlen($name)-strlen($ar_name[0])); $dev->setName($name); - + if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS) foreach ($allNetworkAdapterConfigurations as $NetworkAdapterConfiguration) { if ( preg_replace('/[^A-Za-z0-9]/', '_', $NetworkAdapterConfiguration['Description']) == $cname ) { if (!is_null($dev->getInfo())) { @@ -542,6 +544,19 @@ public function getLanguage() return $this->_syslang; } + public function _processes() + { + $processes['*'] = 0; + $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Process', array('Caption')); + + foreach ($buffer as $process) { + $processes['*']++; + } + $processes[' '] = $processes['*']; + $this->sys->setProcesses($processes); + } + + /** * get the information * @@ -566,5 +581,6 @@ public function build() $this->_filesystems(); $this->_memory(); $this->_loadavg(); + $this->_processes(); } } diff --git a/etc/apps/phpsysinfo/includes/to/class.System.inc.php b/etc/apps/phpsysinfo/includes/to/class.System.inc.php index 12b9a315e..e6fc2d10d 100644 --- a/etc/apps/phpsysinfo/includes/to/class.System.inc.php +++ b/etc/apps/phpsysinfo/includes/to/class.System.inc.php @@ -209,6 +209,13 @@ class System */ private $_swapDevices = array(); + /** + * array of types of processes + * + * @var Array + */ + private $_processes = array(); + /** * remove duplicate Entries and Count * @@ -1040,4 +1047,35 @@ public function setSwapDevices($swapDevices) { array_push($this->_swapDevices, $swapDevices); } + + /** + * Returns $_processes. + * + * @see System::$_processes + * + * @return Array + */ + public function getProcesses() + { + return $this->_processes; + } + + /** + * Sets $_proceses. + * + * @param $processes array of types of processes + * + * @see System::$_processes + * + * @return Void + */ + public function setProcesses($processes) + { + $this->_processes = $processes; +/* + foreach ($processes as $proc_type=>$proc_count) { + $this->_processes[$proc_type] = $proc_count; + } +*/ + } } diff --git a/etc/apps/phpsysinfo/includes/to/device/class.SensorDevice.inc.php b/etc/apps/phpsysinfo/includes/to/device/class.SensorDevice.inc.php index ef3eef687..65c2f6c33 100644 --- a/etc/apps/phpsysinfo/includes/to/device/class.SensorDevice.inc.php +++ b/etc/apps/phpsysinfo/includes/to/device/class.SensorDevice.inc.php @@ -53,6 +53,13 @@ class SensorDevice */ private $_min = null; + /** + * event of the sensor + * + * @var String + */ + private $_event = ""; + /** * Returns $_max. * @@ -156,4 +163,30 @@ public function setValue($value) { $this->_value = $value; } + + /** + * Returns $_event. + * + * @see Sensor::$_event + * + * @return String + */ + public function getEvent() + { + return $this->_event; + } + + /** + * Sets $_event. + * + * @param String $event sensor event + * + * @see Sensor::$_event + * + * @return Void + */ + public function setEvent($event) + { + $this->_event = $event; + } } diff --git a/etc/apps/phpsysinfo/includes/to/device/class.UPSDevice.inc.php b/etc/apps/phpsysinfo/includes/to/device/class.UPSDevice.inc.php index c731030e9..f72e30aa9 100644 --- a/etc/apps/phpsysinfo/includes/to/device/class.UPSDevice.inc.php +++ b/etc/apps/phpsysinfo/includes/to/device/class.UPSDevice.inc.php @@ -95,6 +95,13 @@ class UPSDevice */ private $_lineVoltage = null; + /** + * line freq + * + * @var Integer + */ + private $_lineFrequency = null; + /** * current load of the ups in percent * @@ -286,6 +293,32 @@ public function setLineVoltage($lineVoltage) $this->_lineVoltage = $lineVoltage; } + /** + * Returns $_lineFrequency. + * + * @see UPSDevice::$_lineFrequency + * + * @return Integer + */ + public function getLineFrequency() + { + return $this->_lineFrequency; + } + + /** + * Sets $_lineFrequency. + * + * @param Integer $lineFrequency line frequency + * + * @see UPSDevice::$_lineFrequency + * + * @return Void + */ + public function setLineFrequency($lineFrequency) + { + $this->_lineFrequency = $lineFrequency; + } + /** * Returns $_load. * diff --git a/etc/apps/phpsysinfo/includes/ups/class.apcupsd.inc.php b/etc/apps/phpsysinfo/includes/ups/class.apcupsd.inc.php index c1c65cfa2..15b6e7019 100644 --- a/etc/apps/phpsysinfo/includes/ups/class.apcupsd.inc.php +++ b/etc/apps/phpsysinfo/includes/ups/class.apcupsd.inc.php @@ -56,7 +56,7 @@ public function __construct() if (! empty($temp)) { $this->_output[] = $temp; } - } + } } /** @@ -108,6 +108,9 @@ private function _info() if (preg_match('/^LINEV\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { $dev->setLineVoltage(trim($data[1])); } + if (preg_match('/^LINEFREQ\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { + $dev->setLineFrequency(trim($data[1])); + } if (preg_match('/^LOADPCT\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) { $dev->setLoad(trim($data[1])); } diff --git a/etc/apps/phpsysinfo/includes/ups/class.nut.inc.php b/etc/apps/phpsysinfo/includes/ups/class.nut.inc.php index 740904e4b..8766204b1 100644 --- a/etc/apps/phpsysinfo/includes/ups/class.nut.inc.php +++ b/etc/apps/phpsysinfo/includes/ups/class.nut.inc.php @@ -68,19 +68,6 @@ public function __construct() } } - /** - * check if a specific value is set in an array - * - * @param object $hash array in which a specific value should be found - * @param object $key key that is looked for in the array - * - * @return array - */ - private function _checkIsSet($hash, $key) - { - return isset($hash[$key]) ? $hash[$key] : ''; - } - /** * parse the input and store data in resultset for xml generation * @@ -99,19 +86,36 @@ private function _info() $dev = new UPSDevice(); //General $dev->setName($name); - $dev->setModel($this->_checkIsSet($ups_data, 'ups.model')); - $dev->setMode($this->_checkIsSet($ups_data, 'driver.name')); - $dev->setStatus($this->_checkIsSet($ups_data, 'ups.status')); + if (isset($ups_data['ups.model'])) { + $dev->setModel($ups_data['ups.model']); + } + if (isset($ups_data['driver.name'])) { + $dev->setMode($ups_data['driver.name']); + } + if (isset($ups_data['ups.status'])) { + $dev->setStatus($ups_data['ups.status']); + } //Line - $dev->setLineVoltage($this->_checkIsSet($ups_data, 'input.voltage')); - $dev->setLoad($this->_checkIsSet($ups_data, 'ups.load')); + if (isset($ups_data['input.voltage'])) { + $dev->setLineVoltage($ups_data['input.voltage']); + } + if (isset($ups_data['input.frequency'])) { + $dev->setLineFrequency($ups_data['input.frequency']); + } + if (isset($ups_data['ups.load'])) { + $dev->setLoad($ups_data['ups.load']); + } //Battery - $dev->setBatteryVoltage($this->_checkIsSet($ups_data, 'battery.voltage')); - $dev->setBatterCharge($this->_checkIsSet($ups_data, 'battery.charge')); + if (isset($ups_data['battery.voltage'])) { + $dev->setBatteryVoltage($ups_data['battery.voltage']); + } + if (isset($ups_data['battery.charge'])) { + $dev->setBatterCharge($ups_data['battery.charge']); + } if (isset($ups_data['battery.runtime'])) { - $dev->setTimeLeft($ups_data['battery.runtime']/60); + $dev->setTimeLeft(round($ups_data['battery.runtime']/60, 2)); } //Temperature diff --git a/etc/apps/phpsysinfo/includes/ups/class.pmset.inc.php b/etc/apps/phpsysinfo/includes/ups/class.pmset.inc.php new file mode 100644 index 000000000..fc8fb62f6 --- /dev/null +++ b/etc/apps/phpsysinfo/includes/ups/class.pmset.inc.php @@ -0,0 +1,90 @@ + + * @copyright 2014 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id: class.nut.inc.php 661 2012-08-27 11:26:39Z namiltd $ + * @link http://phpsysinfo.sourceforge.net + */ + /** + * getting ups information from pmset program + * + * @category PHP + * @package PSI_UPS + * @author Robert Pelletier + * @copyright 2014 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net + */ +class Pmset extends UPS +{ + /** + * internal storage for all gathered data + * + * @var array + */ + private $_output = array(); + + /** + * get all information from all configured ups and store output in internal array + */ + public function __construct() + { + parent::__construct(); + CommonFunctions::executeProgram('pmset', '-g batt', $temp); + if (! empty($temp)) { + $this->_output[] = $temp; + } + } + + /** + * parse the input and store data in resultset for xml generation + * + * @return array + */ + private function _info() + { + $model = array(); + $percCharge = array(); + $lines = explode(PHP_EOL, implode($this->_output)); + $dev = new UPSDevice(); + $model = explode('FW:', $lines[1]); + if (strpos($model[0], 'InternalBattery') === FALSE) { + $percCharge = explode(';', $lines[1]); + $dev->setName('UPS'); + if ($model !== FALSE) { + $dev->setModel(substr(trim($model[0]), 1)); + } + if ($percCharge !== FALSE) { + $dev->setBatterCharge(trim(substr($percCharge[0], -4, 3))); + $dev->setStatus(trim($percCharge[1])); + if (isset($percCharge[2])) { + $time = explode(':', $percCharge[2]); + $hours = $time[0]; + $minutes = $hours*60+substr($time[1], 0, 2); + $dev->setTimeLeft($minutes); + } + } + $this->upsinfo->setUpsDevices($dev); + } + } + + /** + * get the information + * + * @see PSI_Interface_UPS::build() + * + * @return Void + */ + public function build() + { + $this->_info(); + } +} diff --git a/etc/apps/phpsysinfo/includes/ups/class.powersoftplus.inc.php b/etc/apps/phpsysinfo/includes/ups/class.powersoftplus.inc.php new file mode 100644 index 000000000..8f575b00f --- /dev/null +++ b/etc/apps/phpsysinfo/includes/ups/class.powersoftplus.inc.php @@ -0,0 +1,115 @@ + + * @copyright 2014 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version SVN: $Id: class.powersoftplus.inc.php 661 2014-06-13 11:26:39Z namiltd $ + * @link http://phpsysinfo.sourceforge.net +*/ +/** + * getting ups information from powersoftplus program + * + * @category PHP + * @package PSI_UPS + * @author Mieczyslaw Nalewaj + * @copyright 2014 phpSysInfo + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @version Release: 3.0 + * @link http://phpsysinfo.sourceforge.net +*/ +class PowerSoftPlus extends UPS +{ + /** + * internal storage for all gathered data + * + * @var Array + */ + private $_output = array(); + + /** + * get all information from all configured ups in config.php and store output in internal array + */ + public function __construct() + { + parent::__construct(); + CommonFunctions::executeProgram('powersoftplus', '-p', $temp); + if (! empty($temp)) { + $this->_output[] = $temp; + } + } + + /** + * parse the input and store data in resultset for xml generation + * + * @return Void + */ + private function _info() + { + foreach ($this->_output as $ups) { + + $dev = new UPSDevice(); + + // General info + $dev->setName("EVER"); + $dev->setMode("PowerSoftPlus"); + $maxpwr = 0; + $load = null; + if (preg_match('/^Identifier: UPS Model\s*:\s*(.*)$/m', $ups, $data)) { + $dev->setModel(trim($data[1])); + if (preg_match('/\s(\d*)[^\d]*$/', trim($data[1]), $number)) { + $maxpwr=$number[1]*0.65; + } + } + if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) { + $dev->setStatus(trim($data[1])); + } + if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]$/m', $ups, $data)) { + $load = trim($data[1]); + } + //wrong Output load issue + if (($load == 0) && ( $maxpwr != 0 ) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]$/m', $ups, $data)) { + $load = 100.0*trim($data[1])/$maxpwr; + } + if ($load != null) { + $dev->setLoad($load); + } + // Battery + if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) { + $dev->setBatteryVoltage(trim($data[1])); + } + if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) { + if (preg_match('/^At full capacity$/', trim($data[1]))) { + $dev->setBatterCharge(100); + } elseif (preg_match('/^(Discharged)|(Depleted)$/', trim($data[1]))) { + $dev->setBatterCharge(0); + } + } + // Line + if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) { + $dev->setLineVoltage(trim($data[1])); + } + if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]$/m', $ups, $data)) { + $dev->setLineFrequency(trim($data[1])); + } + $this->upsinfo->setUpsDevices($dev); + } + } + + /** + * get the information + * + * @see PSI_Interface_UPS::build() + * + * @return Void + */ + public function build() + { + $this->_info(); + } +} diff --git a/etc/apps/phpsysinfo/includes/xml/class.XML.inc.php b/etc/apps/phpsysinfo/includes/xml/class.XML.inc.php index 2df83ca6d..92c981980 100644 --- a/etc/apps/phpsysinfo/includes/xml/class.XML.inc.php +++ b/etc/apps/phpsysinfo/includes/xml/class.XML.inc.php @@ -136,6 +136,39 @@ private function _buildVitals() if ($this->_sysinfo->getEncoding() !== null) { $vitals->addAttribute('CodePage', $this->_sysinfo->getEncoding()); } + + //processes + if (($procss = $this->_sys->getProcesses()) !== null) { + if (isset($procss['*']) && (($procall = $procss['*']) > 0)) { + $vitals->addAttribute('Processes', $procall); + if (!isset($procss[' ']) || !($procss[' '] > 0)) { // not unknown + $procsum = 0; + if (isset($procss['R']) && (($proctmp = $procss['R']) > 0)) { + $vitals->addAttribute('ProcessesRunning', $proctmp); + $procsum += $proctmp; + } + if (isset($procss['S']) && (($proctmp = $procss['S']) > 0)) { + $vitals->addAttribute('ProcessesSleeping', $proctmp); + $procsum += $proctmp; + } + if (isset($procss['T']) && (($proctmp = $procss['T']) > 0)) { + $vitals->addAttribute('ProcessesStopped', $proctmp); + $procsum += $proctmp; + } + if (isset($procss['Z']) && (($proctmp = $procss['Z']) > 0)) { + $vitals->addAttribute('ProcessesZombie', $proctmp); + $procsum += $proctmp; + } + if (isset($procss['D']) && (($proctmp = $procss['D']) > 0)) { + $vitals->addAttribute('ProcessesWaiting', $proctmp); + $procsum += $proctmp; + } + if (($proctmp = $procall - $procsum) > 0) { + $vitals->addAttribute('ProcessesOther', $proctmp); + } + } + } + } $vitals->addAttribute('OS', PSI_OS); } @@ -146,15 +179,18 @@ private function _buildVitals() */ private function _buildNetwork() { + $hideDevices = array(); $network = $this->_xml->addChild('Network'); - if ( defined('PSI_HIDE_NETWORK_INTERFACE') && is_string(PSI_HIDE_NETWORK_INTERFACE) ) { - if (preg_match(ARRAY_EXP, PSI_HIDE_NETWORK_INTERFACE)) { - $hideDevices = eval(PSI_HIDE_NETWORK_INTERFACE); - } else { - $hideDevices = array(PSI_HIDE_NETWORK_INTERFACE); + if (defined('PSI_HIDE_NETWORK_INTERFACE')) { + if (is_string(PSI_HIDE_NETWORK_INTERFACE)) { + if (preg_match(ARRAY_EXP, PSI_HIDE_NETWORK_INTERFACE)) { + $hideDevices = eval(PSI_HIDE_NETWORK_INTERFACE); + } else { + $hideDevices = array(PSI_HIDE_NETWORK_INTERFACE); + } + } elseif (PSI_HIDE_NETWORK_INTERFACE === true) { + return; } - } else { - $hideDevices = array(); } foreach ($this->_sys->getNetDevices() as $dev) { if (!in_array(trim($dev->getName()), $hideDevices)) { @@ -340,11 +376,15 @@ private function _buildFilesystems() $hideFstypes = array(PSI_HIDE_FS_TYPES); } } - if ( defined('PSI_HIDE_DISKS') && is_string(PSI_HIDE_DISKS) ) { - if (preg_match(ARRAY_EXP, PSI_HIDE_DISKS)) { - $hideDisks = eval(PSI_HIDE_DISKS); - } else { - $hideDisks = array(PSI_HIDE_DISKS); + if (defined('PSI_HIDE_DISKS')) { + if (is_string(PSI_HIDE_DISKS)) { + if (preg_match(ARRAY_EXP, PSI_HIDE_DISKS)) { + $hideDisks = eval(PSI_HIDE_DISKS); + } else { + $hideDisks = array(PSI_HIDE_DISKS); + } + } elseif (PSI_HIDE_DISKS === true) { + return; } } $fs = $this->_xml->addChild('FileSystem'); @@ -364,75 +404,101 @@ private function _buildFilesystems() private function _buildMbinfo() { $mbinfo = $this->_xml->addChild('MBInfo'); - if ((sizeof(unserialize(PSI_MBINFO))>0) || PSI_HDDTEMP) { - $temp = $mbinfo->addChild('Temperature'); - if (sizeof(unserialize(PSI_MBINFO))>0) { - foreach (unserialize(PSI_MBINFO) as $mbinfoclass) { - $mbinfo_data = new $mbinfoclass(); - $mbinfo_detail = $mbinfo_data->getMBInfo(); - foreach ($mbinfo_detail->getMbTemp() as $dev) { - $item = $temp->addChild('Item'); - $item->addAttribute('Label', $dev->getName()); - $item->addAttribute('Value', $dev->getValue()); - if ($dev->getMax() !== null) { - $item->addAttribute('Max', $dev->getMax()); - } + $temp = $fan = $volt = $power = $current = null; + + if (sizeof(unserialize(PSI_MBINFO))>0) { + foreach (unserialize(PSI_MBINFO) as $mbinfoclass) { + $mbinfo_data = new $mbinfoclass(); + $mbinfo_detail = $mbinfo_data->getMBInfo(); + + foreach ($mbinfo_detail->getMbTemp() as $dev) { + if ($temp == null) { + $temp = $mbinfo->addChild('Temperature'); } - } - } - if (PSI_HDDTEMP) { - $hddtemp = new HDDTemp(); - $hddtemp_data = $hddtemp->getMBInfo(); - foreach ($hddtemp_data->getMbTemp() as $dev) { $item = $temp->addChild('Item'); $item->addAttribute('Label', $dev->getName()); $item->addAttribute('Value', $dev->getValue()); if ($dev->getMax() !== null) { $item->addAttribute('Max', $dev->getMax()); } + if ( defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "" ) { + $item->addAttribute('Event', $dev->getEvent()); + } } - } - } - if (sizeof(unserialize(PSI_MBINFO))>0) { - $fan = $mbinfo->addChild('Fans'); - foreach ($mbinfo_detail->getMbFan() as $dev) { - $item = $fan->addChild('Item'); - $item->addAttribute('Label', $dev->getName()); - $item->addAttribute('Value', $dev->getValue()); - if ($dev->getMin() !== null) { - $item->addAttribute('Min', $dev->getMin()); + + foreach ($mbinfo_detail->getMbFan() as $dev) { + if ($fan == null) { + $fan = $mbinfo->addChild('Fans'); + } + $item = $fan->addChild('Item'); + $item->addAttribute('Label', $dev->getName()); + $item->addAttribute('Value', $dev->getValue()); + if ($dev->getMin() !== null) { + $item->addAttribute('Min', $dev->getMin()); + } + if ( defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "" ) { + $item->addAttribute('Event', $dev->getEvent()); + } } - } - } - if (sizeof(unserialize(PSI_MBINFO))>0) { - $volt = $mbinfo->addChild('Voltage'); - foreach ($mbinfo_detail->getMbVolt() as $dev) { - $item = $volt->addChild('Item'); - $item->addAttribute('Label', $dev->getName()); - $item->addAttribute('Value', $dev->getValue()); - if ($dev->getMin() !== null) { - $item->addAttribute('Min', $dev->getMin()); + + foreach ($mbinfo_detail->getMbVolt() as $dev) { + if ($volt == null) { + $volt = $mbinfo->addChild('Voltage'); + } + $item = $volt->addChild('Item'); + $item->addAttribute('Label', $dev->getName()); + $item->addAttribute('Value', $dev->getValue()); + if ($dev->getMin() !== null) { + $item->addAttribute('Min', $dev->getMin()); + } + if ($dev->getMax() !== null) { + $item->addAttribute('Max', $dev->getMax()); + } + if ( defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { + $item->addAttribute('Event', $dev->getEvent()); + } } - if ($dev->getMax() !== null) { - $item->addAttribute('Max', $dev->getMax()); + + foreach ($mbinfo_detail->getMbPower() as $dev) { + if ($power == null) { + $power = $mbinfo->addChild('Power'); + } + $item = $power->addChild('Item'); + $item->addAttribute('Label', $dev->getName()); + $item->addAttribute('Value', $dev->getValue()); + if ($dev->getMax() !== null) { + $item->addAttribute('Max', $dev->getMax()); + } + if ( defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { + $item->addAttribute('Event', $dev->getEvent()); + } } - } - } - if (sizeof(unserialize(PSI_MBINFO))>0) { - $volt = $mbinfo->addChild('Power'); - foreach ($mbinfo_detail->getMbPower() as $dev) { - $item = $volt->addChild('Item'); - $item->addAttribute('Label', $dev->getName()); - $item->addAttribute('Value', $dev->getValue()); - if ($dev->getMax() !== null) { - $item->addAttribute('Max', $dev->getMax()); + + foreach ($mbinfo_detail->getMbCurrent() as $dev) { + if ($current == null) { + $current = $mbinfo->addChild('Current'); + } + $item = $current->addChild('Item'); + $item->addAttribute('Label', $dev->getName()); + $item->addAttribute('Value', $dev->getValue()); + if ($dev->getMax() !== null) { + $item->addAttribute('Max', $dev->getMax()); + } + if ( defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { + $item->addAttribute('Event', $dev->getEvent()); + } } } } - if (sizeof(unserialize(PSI_MBINFO))>0) { - $volt = $mbinfo->addChild('Current'); - foreach ($mbinfo_detail->getMbCurrent() as $dev) { - $item = $volt->addChild('Item'); + + if (PSI_HDDTEMP) { + $hddtemp = new HDDTemp(); + $hddtemp_data = $hddtemp->getMBInfo(); + foreach ($hddtemp_data->getMbTemp() as $dev) { + if ($temp == null) { + $temp = $mbinfo->addChild('Temperature'); + } + $item = $temp->addChild('Item'); $item->addAttribute('Label', $dev->getName()); $item->addAttribute('Value', $dev->getValue()); if ($dev->getMax() !== null) { @@ -460,7 +526,9 @@ private function _buildUpsinfo() foreach ($upsinfo_detail->getUpsDevices() as $ups) { $item = $upsinfo->addChild('UPS'); $item->addAttribute('Name', $ups->getName()); - $item->addAttribute('Model', $ups->getModel()); + if ($ups->getModel() !== "") { + $item->addAttribute('Model', $ups->getModel()); + } $item->addAttribute('Mode', $ups->getMode()); if ($ups->getStartTime() !== "") { $item->addAttribute('StartTime', $ups->getStartTime()); @@ -481,6 +549,9 @@ private function _buildUpsinfo() if ($ups->getLineVoltage() !== null) { $item->addAttribute('LineVoltage', $ups->getLineVoltage()); } + if ($ups->getLineFrequency() !== null) { + $item->addAttribute('LineFrequency', $ups->getLineFrequency()); + } if ($ups->getLoad() !== null) { $item->addAttribute('LoadPercent', $ups->getLoad()); } @@ -625,6 +696,7 @@ private function _xmlbody() } $options->addAttribute('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE') ? (PSI_SHOW_PICKLIST_TEMPLATE ? 'true' : 'false') : 'false'); $options->addAttribute('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG') ? (PSI_SHOW_PICKLIST_LANG ? 'true' : 'false') : 'false'); + $options->addAttribute('showCPUListExpanded', defined('PSI_SHOW_CPULIST_EXPANDED') ? (PSI_SHOW_CPULIST_EXPANDED ? 'true' : 'false') : 'true'); $options->addAttribute('showCPUInfoExpanded', defined('PSI_SHOW_CPUINFO_EXPANDED') ? (PSI_SHOW_CPUINFO_EXPANDED ? 'true' : 'false') : 'false'); $plug = $this->_xml->addChild('UsedPlugins'); if ($this->_complete_request && count($this->_plugins) > 0) { diff --git a/etc/apps/phpsysinfo/js/jQuery/README b/etc/apps/phpsysinfo/js/jQuery/README index 2b12a578d..6a3b6e1ad 100644 --- a/etc/apps/phpsysinfo/js/jQuery/README +++ b/etc/apps/phpsysinfo/js/jQuery/README @@ -50,7 +50,7 @@ USED : show alert and error message jquery.treeTable.js ------------------- -VERSION : 2009-06-22 +VERSION : 2009-06-22+statefix URL : http://plugins.jquery.com/project/jQTreeTable; http://www.hanpau.com/index.php?page=jqtreetable DESC : Take a plain html table, wrap the rows you want collapsing/expanding in a tbody tag with an id of treetable, map each row to it's parent row, set some options, and let jQTreeTable take it from there. USED : Hardware, Memory, UPS blocks diff --git a/etc/apps/phpsysinfo/js/jQuery/jquery.treeTable.js b/etc/apps/phpsysinfo/js/jQuery/jquery.treeTable.js index 6c21be72f..9c918f4f6 100644 --- a/etc/apps/phpsysinfo/js/jQuery/jquery.treeTable.js +++ b/etc/apps/phpsysinfo/js/jQuery/jquery.treeTable.js @@ -84,16 +84,20 @@ with it, as long as you keep this copyright notice on the page jq("tbody tr", this).each(function(i){//Inject the images into the column to make it work jq(this).children("td").eq(opts.column).prepend(mapb[i]); }); - collarr = cget(tid); - if(opts.collapse.constructor == Array) { - collarr=collarr.concat(opts.collapse); - } - if (collarr.length){ - cset(tid,collarr); - for (var y=0,yl=collarr.length;y" + model + "\n"; cpucoreposition = tree.push(rootposition); if (showCPUInfoExpanded !== 'true') { @@ -825,19 +914,19 @@ function refreshNetwork(xml) { tx = parseInt($(this).attr("TxBytes"), 10); er = parseInt($(this).attr("Err"), 10); dr = parseInt($(this).attr("Drops"), 10); - html +="" + name + "" + formatBytes(rx, xml) + "" + formatBytes(tx, xml) + "" + er.toString() + "/" + dr.toString() + ""; + html +="" + name + "" + formatBytes(rx, xml) + "" + formatBytes(tx, xml) + "" + er.toString() + "/​" + dr.toString() + ""; networkindex = tree.push(0); info = $(this).attr("Info"); if ( (info !== undefined) && (info != "") ) { - var i =0, infos = info.split(";"); - isinfo = true; - for(i = 0; i < infos.length; i++){ - html +="" + infos[i] + ""; - tree.push(networkindex); - closed.push(networkindex); + var i =0, infos = info.split(";"); + isinfo = true; + for(i = 0; i < infos.length; i++){ + html +="" + infos[i] + ""; + tree.push(networkindex); } + closed.push(networkindex); } }); html += "\n"; @@ -1039,12 +1128,15 @@ function refreshTemp(xml) { var values = false; $("#tempTable tbody").empty(); $("MBInfo Temperature Item", xml).each(function getTemperatures(id) { - var label = "", value = "", limit = 0, _limit = ""; + var label = "", value = "", limit = 0, _limit = "", event = ""; label = $(this).attr("Label"); value = $(this).attr("Value").replace(/\+/g, ""); limit = ($(this).attr("Max") !== undefined) ? parseFloat($(this).attr("Max").replace(/\+/g, "")) : 'NaN'; if (isFinite(limit)) _limit = formatTemp(limit, xml); + event = $(this).attr("Event"); + if (event !== undefined) + label += " \"!\""; $("#tempTable tbody").append("" + label + "" + formatTemp(value, xml) + "" + _limit + ""); values = true; }); @@ -1066,7 +1158,7 @@ function refreshVoltage(xml) { var values = false; $("#voltageTable tbody").empty(); $("MBInfo Voltage Item", xml).each(function getVoltages(id) { - var label = "", value = 0, max = 0, min = 0, _min = "", _max = ""; + var label = "", value = 0, max = 0, min = 0, _min = "", _max = "", event = ""; label = $(this).attr("Label"); value = parseFloat($(this).attr("Value")); max = parseFloat($(this).attr("Max")); @@ -1075,6 +1167,9 @@ function refreshVoltage(xml) { min = parseFloat($(this).attr("Min")); if (isFinite(min)) _min = round(min, 2) + " " + genlang(62, true); + event = $(this).attr("Event"); + if (event !== undefined) + label += " \"!\""; $("#voltageTable tbody").append("" + label + "" + round(value, 2) + " " + genlang(62, true) + "" + _min + "" + _max + ""); values = true; }); @@ -1096,12 +1191,15 @@ function refreshFan(xml) { var values = false; $("#fanTable tbody").empty(); $("MBInfo Fans Item", xml).each(function getFans(id) { - var label = "", value = 0, min = 0, _min = ""; + var label = "", value = 0, min = 0, _min = "", event = ""; label = $(this).attr("Label"); value = parseFloat($(this).attr("Value")); min = parseFloat($(this).attr("Min")); if (isFinite(min)) _min = round(min,0) + " " + genlang(63, true); + event = $(this).attr("Event"); + if (event !== undefined) + label += " \"!\""; $("#fanTable tbody").append("" + label + "" + round(value,0) + " " + genlang(63, true) + "" + _min + ""); values = true; }); @@ -1123,12 +1221,15 @@ function refreshPower(xml) { var values = false; $("#powerTable tbody").empty(); $("MBInfo Power Item", xml).each(function getPowers(id) { - var label = "", value = "", limit = 0, _limit = ""; + var label = "", value = "", limit = 0, _limit = "", event = ""; label = $(this).attr("Label"); value = $(this).attr("Value").replace(/\+/g, ""); limit = ($(this).attr("Max") !== undefined) ? parseFloat($(this).attr("Max").replace(/\+/g, "")) : 'NaN'; if (isFinite(limit)) _limit = round(limit, 2) + " " + genlang(103, true); + event = $(this).attr("Event"); + if (event !== undefined) + label += " \"!\""; $("#powerTable tbody").append("" + label + "" + round(value, 2) + " " + genlang(103, true) + "" + _limit + ""); values = true; }); @@ -1150,12 +1251,15 @@ function refreshCurrent(xml) { var values = false; $("#currentTable tbody").empty(); $("MBInfo Current Item", xml).each(function getCurrents(id) { - var label = "", value = "", limit = 0, _limit = ""; + var label = "", value = "", limit = 0, _limit = "", event = ""; label = $(this).attr("Label"); value = $(this).attr("Value").replace(/\+/g, ""); limit = ($(this).attr("Max") !== undefined) ? parseFloat($(this).attr("Max").replace(/\+/g, "")) : 'NaN'; if (isFinite(limit)) _limit = round(limit, 2) + " " + genlang(106, true); + event = $(this).attr("Event"); + if (event !== undefined) + label += " \"!\""; $("#currentTable tbody").append("" + label + "" + round(value, 2) + " " + genlang(106, true) + "" + _limit + ""); values = true; }); @@ -1182,7 +1286,7 @@ function refreshUps(xml) { $("#ups").empty(); $("UPSInfo UPS", xml).each(function getUps(id) { - var name = "", model = "", mode = "", start_time = "", upsstatus = "", temperature = "", outages_count = "", last_outage = "", last_outage_finish = "", line_voltage = "", load_percent = "", battery_date = "", battery_voltage = "", battery_charge_percent = "", time_left_minutes = ""; + var name = "", model = "", mode = "", start_time = "", upsstatus = "", temperature = "", outages_count = "", last_outage = "", last_outage_finish = "", line_voltage = "", line_frequency = "", load_percent = "", battery_date = "", battery_voltage = "", battery_charge_percent = "", time_left_minutes = ""; name = $(this).attr("Name"); model = $(this).attr("Model"); mode = $(this).attr("Mode"); @@ -1194,6 +1298,7 @@ function refreshUps(xml) { last_outage = $(this).attr("LastOutage"); last_outage_finish = $(this).attr("LastOutageFinish"); line_voltage = $(this).attr("LineVoltage"); + line_frequency = $(this).attr("LineFrequency"); load_percent = parseInt($(this).attr("LoadPercent"), 10); battery_date = $(this).attr("BatteryDate"); battery_voltage = $(this).attr("BatteryVoltage"); @@ -1202,8 +1307,10 @@ function refreshUps(xml) { html += "" + name + " (" + mode + ")\n"; index = tree.push(0); - html += "" + genlang(70, false) + "" + model + "\n"; - tree.push(index); + if (model !== undefined) { + html += "" + genlang(70, false) + "" + model + "\n"; + tree.push(index); + } if (start_time !== undefined) { html += "" + genlang(72, false) + "" + start_time + "\n"; tree.push(index); @@ -1230,6 +1337,10 @@ function refreshUps(xml) { html += "" + genlang(77, false) + "" + line_voltage + " " + genlang(82, true) + "\n"; tree.push(index); } + if (line_frequency !== undefined) { + html += "" + genlang(108, false) + "" + line_frequency + " " + genlang(109, true) + "\n"; + tree.push(index); + } if (!isNaN(load_percent)) { html += "" + genlang(78, false) + "" + createBar(load_percent) + "\n"; tree.push(index); diff --git a/etc/apps/phpsysinfo/language/ast.xml b/etc/apps/phpsysinfo/language/ast.xml index 17ce860a4..5a68b7e5d 100644 --- a/etc/apps/phpsysinfo/language/ast.xml +++ b/etc/apps/phpsysinfo/language/ast.xml @@ -1,4 +1,4 @@ - + @@ -326,4 +327,31 @@ phpSysInfo language file Language: Hebrew translated by: Eliezer Croitoru Machine + + Line frequency + + + Hz + + + Processes + + + running + + + sleeping + + + stopped + + + zombie + + + waiting + + + other + diff --git a/etc/apps/phpsysinfo/language/hu.xml b/etc/apps/phpsysinfo/language/hu.xml index ebb819573..64bf77266 100644 --- a/etc/apps/phpsysinfo/language/hu.xml +++ b/etc/apps/phpsysinfo/language/hu.xml @@ -1,4 +1,4 @@ - + - - Informacao do Sistema + Informação do Sistema Sistema Vital - Nome do Host Canonico + Nome do Host Canônico Ouvindo o IP - Versao do Kernel + Versão do Kernel - Distribuicao + Distribução Ativo - Usuarios Ativos + Usuários Ativos - Carga Media + Carga Média - Informacao do Hardware + Informação do Hardware Processadores @@ -56,16 +55,16 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com Bogomips do Sistema - Perifericos PCI + Periféricos PCI - Perifericos IDE + Periféricos IDE - Perifericos SCSI + Periféricos SCSI - Perifericos USB + Periféricos USB Uso da Rede @@ -80,16 +79,16 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com Enviado - Erro/Perdido + Erro/​Perdido - Conexoes de Rede Estabilizadas + Conexões de Rede Estabilizadas - Uso da Memoria + Uso da Memória - Memoria Fisica + Memória Física Swap do Disco @@ -101,7 +100,7 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com Ponto Montado - Particao + Partição Percentual @@ -182,7 +181,7 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com Limite - Rotulos + Rótulos C @@ -197,7 +196,7 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com RPM - Kernel + aplicacoes + Kernel + aplicações Buffers @@ -209,7 +208,7 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com Ir para - Informacao do UPS + Informação do UPS Nome @@ -224,16 +223,16 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com Iniciado - Estatus + Status Queda - Causa da Ultima Queda + Causa da Última Queda - Ultimo registro de Queda + Último registro de Queda Voltagem de linha @@ -287,22 +286,22 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com GHz - Virtualization + Virtualização - Last boot + Último boot B - System Language + Idioma do Sistema - Code Page + Página de código - Details + Detalhes CPU Speed Max @@ -317,15 +316,42 @@ Giancarlo Gil Ottaviani Raduan graduan at gmail.com W - Battery date + Data da bateria - Current + Corrente A - Machine + Máquina + + + Frequência da linha + + + Hz + + + Processos + + + executando + + + dormindo + + + parado + + + zombie + + + esperando + + + outro diff --git a/etc/apps/phpsysinfo/language/pt-pt.xml b/etc/apps/phpsysinfo/language/pt-pt.xml index 09ae16361..f6e767275 100644 --- a/etc/apps/phpsysinfo/language/pt-pt.xml +++ b/etc/apps/phpsysinfo/language/pt-pt.xml @@ -1,4 +1,4 @@ - + Trimis - Erori + Erori/Drop Conexiuni Rețea Stabilite @@ -328,4 +327,31 @@ Update by: Iulian Alexe Machine + + Line frequency + + + Hz + + + Processes + + + running + + + sleeping + + + stopped + + + zombie + + + waiting + + + other + diff --git a/etc/apps/phpsysinfo/language/ru.xml b/etc/apps/phpsysinfo/language/ru.xml index be917acc3..cae44ee27 100644 --- a/etc/apps/phpsysinfo/language/ru.xml +++ b/etc/apps/phpsysinfo/language/ru.xml @@ -1,8 +1,7 @@ - + Machine + + Line frequency + + + Hz + + + Processes + + + running + + + sleeping + + + stopped + + + zombie + + + waiting + + + other + diff --git a/etc/apps/phpsysinfo/language/sk.xml b/etc/apps/phpsysinfo/language/sk.xml index c7bbf9760..33c3f6008 100644 --- a/etc/apps/phpsysinfo/language/sk.xml +++ b/etc/apps/phpsysinfo/language/sk.xml @@ -1,8 +1,7 @@ - + Odoslaných - Chyby/Zahodené + Chyby/​Zahodené Vytvorené Sieťove Spojenia @@ -328,4 +327,31 @@ Kolínek Machine + + Line frequency + + + Hz + + + Processes + + + running + + + sleeping + + + stopped + + + zombie + + + waiting + + + other + diff --git a/etc/apps/phpsysinfo/language/sl.xml b/etc/apps/phpsysinfo/language/sl.xml index 6feb971a1..290a22ffb 100644 --- a/etc/apps/phpsysinfo/language/sl.xml +++ b/etc/apps/phpsysinfo/language/sl.xml @@ -1,4 +1,4 @@ - + - + รายละเอียดเครื่อง @@ -325,4 +327,31 @@ phpSysInfo language file Language: Thai Created by: Audun Larsen Machine + + Line frequency + + + Hz + + + Processes + + + running + + + sleeping + + + stopped + + + zombie + + + waiting + + + other + diff --git a/etc/apps/phpsysinfo/language/tr.xml b/etc/apps/phpsysinfo/language/tr.xml index c7b0feed2..d73be35c7 100644 --- a/etc/apps/phpsysinfo/language/tr.xml +++ b/etc/apps/phpsysinfo/language/tr.xml @@ -1,4 +1,4 @@ - + Machine + + Line frequency + + + Hz + + + Processes + + + running + + + sleeping + + + stopped + + + zombie + + + waiting + + + other + diff --git a/etc/apps/phpsysinfo/language/uk.xml b/etc/apps/phpsysinfo/language/uk.xml index 3383dadac..aa7743e63 100644 --- a/etc/apps/phpsysinfo/language/uk.xml +++ b/etc/apps/phpsysinfo/language/uk.xml @@ -1,4 +1,4 @@ - + Machine + + Line frequency + + + Hz + + + Processes + + + running + + + sleeping + + + stopped + + + zombie + + + waiting + + + other + diff --git a/etc/apps/phpsysinfo/phpsysinfo.ini b/etc/apps/phpsysinfo/phpsysinfo.ini index 54c29e561..cc69a30ca 100644 --- a/etc/apps/phpsysinfo/phpsysinfo.ini +++ b/etc/apps/phpsysinfo/phpsysinfo.ini @@ -1,502 +1,78 @@ -; PSI Config File -; -; @category PHP -; @package PSI -; @author Michael Cramer -; @copyright 2009 phpSysInfo -; @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License -; @version SVN: $Id: phpsysinfo.ini.new 705 2012-11-11 00:33:29Z namiltd $ -; @link http://phpsysinfo.sourceforge.net - -[main] -; ******************************** -; MAIN PARAMETERS -; ******************************** - -; Turn on debugging of some functions and include errors and warnings in xml and provide a popup for displaying errors -; - false : no debug information are stored in xml or displayed -; - true : debug information stored in xml and displayed *be careful if set this to true, may include sensitive information from your pc* -; -DEBUG=false - -; Turn on logging/unlogging of functions executeProgram() and rfts() -; example : executeProgram () and rfts () record the results to the "/tmp/phpsysinfo.log" file -; LOG="/tmp/phpsysinfo.log" -; example : executeProgram () and rfts () read the results from the "/tmp/phpsysinfo.log" file -; LOG="-/tmp/phpsysinfo.log" -; -LOG=false - -; Turn on/off compression for JavaScript file -; - JS_COMPRESSION=false //no compression (recommended with slow processor) -; - JS_COMPRESSION="None" //code minimizing -; - JS_COMPRESSION="Normal" //code packing -; -JS_COMPRESSION="Normal" - -; Additional paths where to look for installed programs -; Example : ADD_PATHS="/opt/bin,/opt/sbin" -; -ADD_PATHS=false - -; Plugins that should be included in xml and output -; List of plugins should look like "plugin,plugin,plugin". See /plugins directory -; - PLUGINS="MDStatus,PS" //list of plugins -; - PLUGINS=false //no plugins -; included plugins: -; - MDStatus - show the raid status and whats currently going on -; - DMRaid - show the software raid status -; - PS - show a process tree of all running processes -; - PSStatus - show a graphical representation if a process is running or not -; - Quotas - show a table with all quotas that are active and there current state -; - SMART - show S.M.A.R.T. information from drives that support it -; - BAT - show battery state on a laptop -; - IPMIInfo - show IPMI status -; - UpdateNotifier - show update notifications (only for Ubuntu server) -; - SNMPPInfo - show printers info via SNMP -; - Uprecords - show uprecords info -; -PLUGINS=false - - -; ******************************** -; DISPLAY PARAMETERS -; ******************************** - - -; Define the default display mode -; auto: let user browser choose the mode -; dynamic: use javascript to refresh data -; static: static page (use metatag to reload page) -; -DEFAULT_DISPLAY_MODE="auto" - - -; Define the default language -; -DEFAULT_LANG="en" - - -; Define the default template -; -DEFAULT_TEMPLATE="phpsysinfo" - - -; Show or hide language picklist -; -SHOW_PICKLIST_LANG=true - - -; Show or hide template picklist -; -SHOW_PICKLIST_TEMPLATE=true - - -; Show CPU info expanded -; -SHOW_CPUINFO_EXPANDED=false - - -; Define the interval for refreshing data in ms -; - 0 : disabled -; - 1000 : 1 second -; Default is 60 seconds -; -REFRESH=60000 - - -; Show a graph for current cpuload -; - true : displayed, but it's a performance hit (because we have to wait to get a value, 1 second) -; - false : will not be displayed -; -LOAD_BAR=false - - -; Display the virtual host name and address -; - Default is canonical host name and address -; - Use USE_VHOST=true to display virtual host name. -; -USE_VHOST=false - - -; Controls the units & format for network, memory and filesystem -; - 1 KiB = 2^10 bytes = 1,024 bytes -; - 1 KB = 10^3 bytes = 1,000 bytes -; - "B" everything is in Byte -; - "PiB" everything is in PeBiByte -; - "TiB" everything is in TeBiByte -; - "GiB" everything is in GiBiByte -; - "MiB" everything is in MeBiByte -; - "KiB" everything is in KiBiByte -; - "auto_binary" everything is automatic done if value is to big for, e.g MiB then it will be in GiB -; - "PB" everything is in PetaByte -; - "TB" everything is in TeraByte -; - "GB" everything is in GigaByte -; - "MB" everything is in MegaByte -; - "KB" everything is in KiloByte -; - "auto_decimal" everything is automatic done if value is to big for, e.g MB then it will be in GB -; -BYTE_FORMAT="auto_binary" - - -; Format in which temperature is displayed -; - "c" shown in celsius -; - "f" shown in fahrenheit -; - "c-f" both shown first celsius and fahrenheit in braces -; - "f-c" both shown first fahrenheit and celsius in braces -; -TEMP_FORMAT="c" - - -; ******************************** -; SENSORS PARAMETERS -; ******************************** - - -; Define the motherboard monitoring program -; We support the following programs so far -; - LMSensors http://www.lm-sensors.org/ -; - Healthd http://healthd.thehousleys.net/ -; - HWSensors http://www.openbsd.org/ -; - MBMon http://www.nt.phys.kyushu-u.ac.jp/shimizu/download/download.html -; - MBM5 http://mbm.livewiredev.com/ -; - Coretemp -; - IPMI http://openipmi.sourceforge.net/ -; - K8Temp http://hur.st/k8temp/ -; - PiTemp No addon tool neded -; - OHM http://openhardwaremonitor.org/ -; -; Example: If you want to use lmsensors : SENSOR_PROGRAM="LMSensors" -; If you want to use lmsensors and IPMI: SENSOR_PROGRAM="LMSensors,IPMI" -; -SENSOR_PROGRAM=false - - -; Define how to access the monitor program -; Available methods for the above list are in the following list -; default method "command" should be fine for everybody -; if multiple SENSOR_PROGRAM defined must fit to all -; !!! tcp connections are only made local and on the default port !!! -; - LMSensors command, file -; - Healthd command -; - HWSensors command -; - MBMon command, tcp -; - MBM5 file -; - Coretemp command -; - IPMI command, file -; - K8Temp command -; - PiTemp command -; - OHM command -; -SENSOR_ACCESS="command" - - -; Hddtemp program -; If the hddtemp program is available we can read the temperature, if hdd is smart capable -; !!ATTENTION!! hddtemp might be a security issue -; - HDD_TEMP="tcp" //read data from hddtemp deamon (localhost:7634) -; - HDD_TEMP="command" //read data from hddtemp programm (must be set suid) -; -HDD_TEMP=false - - -; ******************************** -; FILESYSTEM PARAMETERS -; ******************************** - - -; Show mount point -; - true : show mount point -; - false : do not show mount point -; -SHOW_MOUNT_POINT=true - -; Show mount option -; - true : show mount option -; - false : do not show mount option -; -SHOW_MOUNT_OPTION=true - - -; Show mount credentials -; - true : show mount credentials -; - false : do not show mount credentials -; -SHOW_MOUNT_CREDENTIALS=false - - -; Show inode usage -; - true : display used inodes in percent -; - false : hide them -; -SHOW_INODES=true - - -; Hide mounts -; Example : HIDE_MOUNTS="/home,/usr" -; -HIDE_MOUNTS="" - - -; Hide filesystem types -; Example : HIDE_FS_TYPES="tmpfs,devtmpfs,usbfs,bstfolder" -; -HIDE_FS_TYPES="" - - -; Hide partitions -; Example : HIDE_DISKS="rootfs" -; -HIDE_DISKS="" - -; Filesystem usage warning threshold in percent -; - 0 : disabled -; - 90 : 90% -; Default is 90% -; -FS_USAGE_THRESHOLD=90 - - -; ******************************** -; NETWORK PARAMETERS -; ******************************** - - -; Hide network interfaces -; Example : HIDE_NETWORK_INTERFACE="eth0,sit0" -; -HIDE_NETWORK_INTERFACE="" - - -; Show network interfaces infos for Linux, FreeBSD, Haiku, Darwin, Minix and WinNT -; Example : SHOW_NETWORK_INFOS=true -; -SHOW_NETWORK_INFOS=false - - -; ******************************** -; UPS PARAMETERS -; ******************************** - - -; Define the ups monitoring program -; We support the following programs so far -; - 1. Apcupsd http://www.apcupsd.com/ -; - 2. Nut http://www.networkupstools.org/ -; Example: If you want to use Apcupsd : UPS_PROGRAM="Apcupsd" -; If you want to use Apcupsd and Nut : UPS_PROGRAM="Apcupsd,Nut" -; -UPS_PROGRAM=false - - -; Apcupsd supports multiple UPSes -; You can specify comma delimited list in the form : or :. The defaults are: 127.0.0.1:3551 -; See the following parameters in apcupsd.conf: NETSERVER, NISIP, NISPORT -; It uses the defaults if not specified. -; -UPS_APCUPSD_LIST=false - - -; Apcupsd has a CGI monitoring utility called apcupsd-cgi -; You can set the parameter below to true if you have it installed - this will add apcupsd-cgi links to the UPS tree -; -UPS_APCUPSD_CGI_ENABLE=false - - -; Nut supports multiple UPSes -; You can specify comma delimited list in the form : or :. The defaults are: 127.0.0.1:3493 -; See the following parameters in upsd.conf: LISTEN -; It uses the defaults if not specified. -; -UPS_NUT_LIST=false - - -; ******************************** -; PLUGINS PARAMETERS -; ******************************** - - [bat] -; BAT Plugin configuration - -; define how to access the battery statistic data -; - "command" read /proc/acpi/battery/BAT0/info and /proc/acpi/battery/BAT0/state -; on newer kernel or on Android read file from /sys/class/power_supply/ -; - "data" (a file must be available in the data directory of the phpsysinfo installation -; with the filename "bat_info.txt" and "bat_state.txt"; content is the output -; from "cat /proc/acpi/battery/BAT0/info" and "cat /proc/acpi/battery/BAT0/state") -; -ACCESS="command" - -; define the battery device (no matter for Android) -; -DEVICE="BAT0" +ACCESS = "command" +DEVICE = "BAT0" +[dmraid] +ACCESS = "command" +HIDE_RAID_DEVICES = "" [ipmiinfo] -; ipmiinfo Plugin configuration - -; define how to access the IPMI statistic data -; - "command" ipmitool command is run everytime the block gets refreshed or build -; if access error execute first: chmod 666 /dev/ipmi0 -; - "data" (a file must be available in the data directory of the phpsysinfo installation -; with the filename "ipmiinfo.txt"; content is the output from "ipmitool sensor") -; -ACCESS="command" +ACCESS = "command" +[main] +ADD_PATHS = false +BYTE_FORMAT = "auto_binary" +DEBUG = false +DEFAULT_DISPLAY_MODE = "auto" +DEFAULT_LANG = "en" +DEFAULT_TEMPLATE = "phpsysinfo" +FS_USAGE_THRESHOLD = 90 +HDD_TEMP = false +HIDE_DISKS = "" +HIDE_FS_TYPES = "" +HIDE_MOUNTS = "" +HIDE_NETWORK_INTERFACE = "" +JS_COMPRESSION = "Normal" +LOAD_BAR = false +LOG = false +PLUGINS = false +REFRESH = 60000 +SENSOR_ACCESS = "command" +SENSOR_EVENTS = true +SENSOR_PROGRAM = false +SHOW_CPUINFO_EXPANDED = false +SHOW_CPULIST_EXPANDED = true +SHOW_INODES = true +SHOW_MOUNT_CREDENTIALS = false +SHOW_MOUNT_OPTION = true +SHOW_MOUNT_POINT = true +SHOW_NETWORK_INFOS = false +SHOW_PICKLIST_LANG = true +SHOW_PICKLIST_TEMPLATE = true +TEMP_FORMAT = "c" +UPS_APCUPSD_CGI_ENABLE = false +UPS_APCUPSD_LIST = false +UPS_NUT_LIST = false +UPS_PROGRAM = false +USE_VHOST = false [mdstatus] -; MDStatus Plugin configuration - -; define how to access the mdstat statistic data -; - "file" /proc/mdstat is read -; - "data" (a file must be available in the data directory of the phpsysinfo installation -; with the filename "mdstat.txt"; content is the output from "cat /proc/mdstat") -; -ACCESS="file" - - -[dmraid] -; DMRaid Plugin configuration - -; define how to access the dmraid statistic data -; - "command" dmraid command is run everytime the block gets refreshed or build -; if access error try execute first: chmod 4755 /sbin/dmraid -; This method is not recommended for safety reasons! -; - "data" (a file must be available in the data directory of the phpsysinfo installation -; with the filename "dmraid.txt"; content is generated by command "dmraid -s -vv >dmraid.txt 2>&1") -; -ACCESS="command" - +ACCESS = "file" +HIDE_RAID_DEVICES = "" [ps] -; PS Plugin configuration - -; define how to access the ps statistic data -; - "command" ps command is run everytime the block gets refreshed or build / on WINNT -; information is retrieved everytime through WMI -; - "data" (a file must be available in the data directory of the phpsysinfo installation -; with the filename "ps.txt"; content is the output from "ps -axo pid,ppid,pmem,args") -; -ACCESS="command" - +ACCESS = "command" [psstatus] -; PSStatus Plugin configuration - -; define how to access the psstatus statistic data -; - "command" pidof command is run everytime the block gets refreshed or build / on WINNT -; information is retrieved everytime through WMI -; - "data" a file must be available in the data directory of the phpsysinfo installation -; with the filename "psstatus.txt"; content is the output from -; ps=("apache2" "mysqld" "sshd"); for((i=0;i<${#ps};i++)); do echo ${ps[$i]} "|" `pidof -s ${ps[$i]}` ;done -; -; @var string -; -ACCESS="command" - -; Regular expression search in the process name (e.g. "ddclient.*") -; - true : Regular expression search (used pgrep command) -; - false : Normal search (used pidof command) -; -USE_REGEX=false - -; controls which processes are checked if they are running -; -; @var string contains a list of process names that are checked, names are seperated by a comma (on WINNT names must end with '.exe') -; -PROCESSES="mysqld, sshd, explorer.exe" - +ACCESS = "command" +PROCESSES = "mysqld, sshd, explorer.exe" +USE_REGEX = false [quotas] -; Quotas Plugin configuration -; -; define how to access the repquota statistic data -; - "command" repquota command is run everytime the block gets refreshed or build -; - "data" (a file must be available in the data directory of the phpsysinfo installation with the filename "quotas.txt"; content is the output from "repquota -au") -; -ACCESS="command" - +ACCESS = "command" [smart] -; SMART Plugin configuration - -; Smartctl program -; If the smartctl program is available we can read S.M.A.R.T informations -; - "command" smartctl command is run everytime the block gets refreshed or build -; if error: Smartctl open device: /dev/sda failed: Permission denied -; Not recommended method: -; execute: chmod 4755 /usr/sbin/smartctl -; - "data" (a file must be available in the data directory of the -; phpsysinfo installation with the filename "smart{disk_number}.txt"; -; content is the output from "smartctl --all device") -; -ACCESS="command" - -; Smartctl devices to monitor -; If the smartctl support is enabled, those disks information will be displayed -; - DEVICES="/dev/hda,/dev/hdb" //Will display those two disks informations -; You also can specify --device option value for smartctl command surrounded by parentheses eg: -; - DEVICES="(marvell)/dev/sda" -; or -; - DEVICES="(megaraid.0)/dev/sda" //comma in --device option value is replaced by a dot -; -DEVICES="/dev/sda, /dev/sdb" - -; Smartctl ID# and column name from "Vendor Specific SMART Attributes with Thresholds" table -; If the smartctl support is enabled, enter the ID#-COLUMN_NAME from "Vendor Specific SMART Attributes with Thresholds" table from smartctl output. -; or for no SCSI devices: ID#-COLUMN_NAME-REPLACEMENT_ID# where REPLACEMENT_ID# is an alternative ID number. -; COLUMN_NAME of this ID# will be displayed in the phpsysinfo S.M.A.R.T table. If you want RAW_VALUE to be displayed for the temperature (ID# 194) enter 194-RAW_VALUE -; - IDS="194-VALUE,4-VALUE,009-RAW_VALUE" //ID#-COLUMN_NAME, ID#-COLUMN_NAME, etc... -; -IDS="005-RAW_VALUE,194-RAW_VALUE,4-RAW_VALUE,009-RAW_VALUE,012-RAW_VALUE,193-RAW_VALUE-225,001-RAW_VALUE,007-RAW_VALUE,200-RAW_VALUE,197-RAW_VALUE,198-RAW_VALUE" - +ACCESS = "command" +DEVICES = "/dev/sda, /dev/sdb" +IDS = "005-RAW_VALUE,194-RAW_VALUE,4-RAW_VALUE,009-RAW_VALUE,012-RAW_VALUE,193-RAW_VALUE-225,001-RAW_VALUE,007-RAW_VALUE,200-RAW_VALUE,197-RAW_VALUE,198-RAW_VALUE" [snmppinfo] -; SNMPPInfo Plugin configuration - -; define how to access the SNMP Printer Info statistic data -; - "php-snmp" execute php snmprealwalk function (php-snmp module must be installed) -; - "command" execute snmpwalk command -; - "data" a file must be available in the data directory of the -; phpsysinfo installation with the filename "snmppinfo{printer_number}.txt"; -; content is the output from: -; snmpwalk -On -c public -v 1 {printer_address} .1.3.6.1.2.1.1.5 > snmppinfo{printer_number}.txt -; snmpwalk -On -c public -v 1 {printer_address} .1.3.6.1.2.1.43.11.1.1 >> snmppinfo{printer_number}.txt -; snmpwalk -On -c public -v 1 {printer_address} .1.3.6.1.2.1.43.18.1.1 >> snmppinfo{printer_number}.txt -; -ACCESS="php-snmp" - -;define the Printer devices -; -; @var string contains a list of printer addresses that are checked -; -DEVICES="192.168.0.5, 192.168.0.9" - +ACCESS = "php-snmp" +DEVICES = "192.168.0.5, 192.168.0.9" [updatenotifier] -; Update Notifier Plugin configuration - -; define the update info file format -; - true: Ubuntu Landscape format (file: /var/lib/update-notifier/updates-available) -; - false: universal format (format: A;B) -; A: total packages to update -; B: security packages to update -; -UBUNTU_LANDSCAPE_FORMAT=true - -; define the update info file -; -FILE="/var/lib/update-notifier/updates-available" +FILE = "/var/lib/update-notifier/updates-available" +UBUNTU_LANDSCAPE_FORMAT = true [uprecords] -; Uprecords Plugin configuration - -; define how to access the uprecords statistic data -; - "command" uprecords command is run everytime the block gets refreshed or build -; if access error try execute first: chmod 4755 /usr/bin/uprecords -; This method is not recommended for safety reasons! -; - "data" (a file must be available in the data directory of the phpsysinfo installation -; with the filename "uprecords.txt"; content is the output from "uprecords -a -w") -; -ACCESS="command" +ACCESS = "command" diff --git a/etc/apps/phpsysinfo/plugins/bat/class.bat.inc.php b/etc/apps/phpsysinfo/plugins/bat/class.bat.inc.php index 373fbce9a..f6cc7565a 100644 --- a/etc/apps/phpsysinfo/plugins/bat/class.bat.inc.php +++ b/etc/apps/phpsysinfo/plugins/bat/class.bat.inc.php @@ -24,13 +24,6 @@ class BAT extends PSI_Plugin */ private $_result = array(); - /** - * holds the COM object that we pull all the WMI data from - * - * @var Object - */ - private $_wmi = null; - /** * read the data into an internal array and also call the parent constructor * @@ -41,150 +34,185 @@ public function __construct($enc) parent::__construct(__CLASS__, $enc); switch (strtolower(PSI_PLUGIN_BAT_ACCESS)) { case 'command': - if (PSI_OS == 'Android') { - CommonFunctions::rfts('/sys/class/power_supply/battery/uevent', $buffer_info, 0, 4096, PSI_DEBUG); - $buffer_state = ''; - if (CommonFunctions::rfts('/sys/class/power_supply/battery/capacity', $buffer1, 1, 4096, false)) { - $buffer_state .= 'POWER_SUPPLY_CAPACITY='.$buffer1; - } - if (CommonFunctions::rfts('/sys/class/power_supply/battery/batt_temp', $buffer1, 1, 4096, false)) { - $buffer_state .= 'POWER_SUPPLY_TEMP='.$buffer1; - } - if (CommonFunctions::rfts('/sys/class/power_supply/battery/batt_vol', $buffer1, 1, 4096, false)) { - if ($buffer1<100000) { // uV or mV detection - $buffer1 = $buffer1*1000; - } - $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW='.$buffer1."\n"; - } - if (CommonFunctions::rfts('/sys/class/power_supply/battery/voltage_max_design', $buffer1, 1, 4096, false)) { - if ($buffer1<100000) { // uV or mV detection - $buffer1 = $buffer1*1000; - } - $buffer_state .= 'POWER_SUPPLY_VOLTAGE_MAX_DESIGN='.$buffer1."\n"; - } - if (CommonFunctions::rfts('/sys/class/power_supply/battery/technology', $buffer1, 1, 4096, false)) { - $buffer_state .= 'POWER_SUPPLY_TECHNOLOGY='.$buffer1; - } - if (CommonFunctions::rfts('/sys/class/power_supply/battery/status', $buffer1, 1, 4096, false)) { - $buffer_state .= 'POWER_SUPPLY_STATUS='.$buffer1; - } - if (CommonFunctions::rfts('/sys/class/power_supply/battery/health', $buffer1, 1, 4096, false)) { - $buffer_state .= 'POWER_SUPPLY_HEALTH='.$buffer1; - } - } elseif (PSI_OS == 'WINNT') { + if (PSI_OS == 'WINNT') { + $_cim = null; //root\CIMv2 + $_wmi = null; //root\WMI // don't set this params for local connection, it will not work $strHostname = ''; $strUser = ''; $strPassword = ''; try { // initialize the wmi object - $objLocator = new COM('WbemScripting.SWbemLocator'); + $objLocatorCIM = new COM('WbemScripting.SWbemLocator'); + if ($strHostname == "") { + $_cim = $objLocatorCIM->ConnectServer(); + + } else { + $_cim = $objLocatorCIM->ConnectServer($strHostname, 'root\CIMv2', $strHostname.'\\'.$strUser, $strPassword); + } + + // initialize the wmi object + $objLocatorWMI = new COM('WbemScripting.SWbemLocator'); if ($strHostname == "") { - $this->_wmi = $objLocator->ConnectServer(); + $_wmi = $objLocatorWMI->ConnectServer($strHostname, 'root\WMI'); } else { - $this->_wmi = $objLocator->ConnectServer($strHostname, 'rootcimv2', $strHostname.'\\'.$strUser, $strPassword); + $_wmi = $objLocatorWMI->ConnectServer($strHostname, 'root\WMI', $strHostname.'\\'.$strUser, $strPassword); } + } catch (Exception $e) { $this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed."); } $buffer_info = ''; $buffer_state = ''; - $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_Battery', array('EstimatedChargeRemaining', 'DesignVoltage', 'BatteryStatus', 'Chemistry')); - $capacity = ''; - if (isset($buffer[0]['EstimatedChargeRemaining'])) { - $capacity = $buffer[0]['EstimatedChargeRemaining']; - } - if (isset($buffer[0]['DesignVoltage'])) { - $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW='.(1000*$buffer[0]['DesignVoltage'])."\n"; - } - if (isset($buffer[0]['BatteryStatus'])) { - switch ($buffer[0]['BatteryStatus']) { - case 1: $batstat = 'Discharging'; break; - case 2: $batstat = 'AC connected'; break; - case 3: $batstat = 'Fully Charged'; break; - case 4: $batstat = 'Low'; break; - case 5: $batstat = 'Critical'; break; - case 6: $batstat = 'Charging'; break; - case 7: $batstat = 'Charging and High'; break; - case 8: $batstat = 'Charging and Low'; break; - case 9: $batstat = 'Charging and Critical'; break; - case 10: $batstat = 'Undefined'; break; - case 11: $batstat = 'Partially Charged'; break; - default: $batstat = ''; + $bufferWB = CommonFunctions::getWMI($_cim, 'Win32_Battery', array('EstimatedChargeRemaining', 'DesignVoltage', 'BatteryStatus', 'Chemistry')); + if (sizeof($bufferWB)>0) { + $capacity = ''; + if (isset($bufferWB[0]['EstimatedChargeRemaining'])) { + $capacity = $bufferWB[0]['EstimatedChargeRemaining']; } - if ($batstat != '') $buffer_state .= 'POWER_SUPPLY_STATUS='.$batstat."\n"; - } - $techn = ''; - if (isset($buffer[0]['Chemistry'])) { - switch ($buffer[0]['Chemistry']) { - case 1: $techn = 'Other'; break; - case 2: $techn = 'Unknown'; break; - case 3: $techn = 'PbAc'; break; - case 4: $techn = 'NiCd'; break; - case 5: $techn = 'NiMH'; break; - case 6: $techn = 'Li-ion'; break; - case 7: $techn = 'Zinc-air'; break; - case 8: $techn = 'Li-poly'; break; + if (isset($bufferWB[0]['BatteryStatus'])) { + switch ($bufferWB[0]['BatteryStatus']) { + case 1: $batstat = 'Discharging'; break; + case 2: $batstat = 'AC connected'; break; + case 3: $batstat = 'Fully Charged'; break; + case 4: $batstat = 'Low'; break; + case 5: $batstat = 'Critical'; break; + case 6: $batstat = 'Charging'; break; + case 7: $batstat = 'Charging and High'; break; + case 8: $batstat = 'Charging and Low'; break; + case 9: $batstat = 'Charging and Critical'; break; + case 10: $batstat = 'Undefined'; break; + case 11: $batstat = 'Partially Charged'; break; + default: $batstat = ''; + } + if ($batstat != '') $buffer_state .= 'POWER_SUPPLY_STATUS='.$batstat."\n"; } - } - $buffer = CommonFunctions::getWMI($this->_wmi, 'Win32_PortableBattery', array('DesignVoltage', 'Chemistry', 'DesignCapacity')); - if (isset($buffer[0]['DesignVoltage'])) { - $buffer_info .= 'POWER_SUPPLY_VOLTAGE_MAX_DESIGN='.(1000*$buffer[0]['DesignVoltage'])."\n"; - } - // sometimes Chemistry from Win32_Battery returns 2 but Win32_PortableBattery returns e.g. 6 - if ((($techn == '') || ($techn == 'Unknown')) && isset($buffer[0]['Chemistry'])) { - switch ($buffer[0]['Chemistry']) { - case 1: $techn = 'Other'; break; - case 2: $techn = 'Unknown'; break; - case 3: $techn = 'PbAc'; break; - case 4: $techn = 'NiCd'; break; - case 5: $techn = 'NiMH'; break; - case 6: $techn = 'Li-ion'; break; - case 7: $techn = 'Zinc-air'; break; - case 8: $techn = 'Li-poly'; break; + $techn = ''; + if (isset($bufferWB[0]['Chemistry'])) { + switch ($bufferWB[0]['Chemistry']) { + case 1: $techn = 'Other'; break; + case 2: $techn = 'Unknown'; break; + case 3: $techn = 'PbAc'; break; + case 4: $techn = 'NiCd'; break; + case 5: $techn = 'NiMH'; break; + case 6: $techn = 'Li-ion'; break; + case 7: $techn = 'Zinc-air'; break; + case 8: $techn = 'Li-poly'; break; + } + } + $bufferWPB = CommonFunctions::getWMI($_cim, 'Win32_PortableBattery', array('DesignVoltage', 'Chemistry', 'DesignCapacity', 'FullChargeCapacity')); + if (isset($bufferWPB[0]['DesignVoltage'])) { + $buffer_info .= 'POWER_SUPPLY_VOLTAGE_MIN_DESIGN='.($bufferWPB[0]['DesignVoltage']*1000)."\n"; + } + // sometimes Chemistry from Win32_Battery returns 2 but Win32_PortableBattery returns e.g. 6 + if ((($techn == '') || ($techn == 'Unknown')) && isset($bufferWPB[0]['Chemistry'])) { + switch ($bufferWPB[0]['Chemistry']) { + case 1: $techn = 'Other'; break; + case 2: $techn = 'Unknown'; break; + case 3: $techn = 'PbAc'; break; + case 4: $techn = 'NiCd'; break; + case 5: $techn = 'NiMH'; break; + case 6: $techn = 'Li-ion'; break; + case 7: $techn = 'Zinc-air'; break; + case 8: $techn = 'Li-poly'; break; + } + } + if ($techn != '') $buffer_info .= 'POWER_SUPPLY_TECHNOLOGY='.$techn."\n"; + + $bufferBS = CommonFunctions::getWMI($_wmi, 'BatteryStatus', array('RemainingCapacity', 'Voltage')); + if (sizeof($bufferBS)>0) { + if (isset($bufferBS[0]['RemainingCapacity']) && ($bufferBS[0]['RemainingCapacity']>0)) { + $buffer_state .= 'POWER_SUPPLY_ENERGY_NOW='.($bufferBS[0]['RemainingCapacity']*1000)."\n"; + $capacity = ''; + } + if (isset($bufferBS[0]['Voltage']) && ($bufferBS[0]['Voltage']>0)) { + $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW='.($bufferBS[0]['Voltage']*1000)."\n"; + } elseif (isset($bufferWB[0]['DesignVoltage'])) { + $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW='.($bufferWB[0]['DesignVoltage']*1000)."\n"; + } + } + + if (!isset($bufferWPB[0]['FullChargeCapacity'])) { + $bufferBFCC = CommonFunctions::getWMI($_wmi, 'BatteryFullChargedCapacity', array('FullChargedCapacity')); + if ((sizeof($bufferBFCC)>0) && isset($bufferBFCC[0]['FullChargedCapacity'])) { + $bufferWPB[0]['FullChargeCapacity'] = $bufferBFCC[0]['FullChargedCapacity']; + } + } + if (isset($bufferWPB[0]['FullChargeCapacity'])) { + $buffer_info .= 'POWER_SUPPLY_ENERGY_FULL='.($bufferWPB[0]['FullChargeCapacity']*1000)."\n"; + if ($capacity != '') $buffer_state .= 'POWER_SUPPLY_ENERGY_NOW='.(round($capacity*$bufferWPB[0]['FullChargeCapacity']*10)."\n"); + if (isset($bufferWPB[0]['DesignCapacity']) && ($bufferWPB[0]['DesignCapacity']!=0)) + $buffer_info .= 'POWER_SUPPLY_ENERGY_FULL_DESIGN='.($bufferWPB[0]['DesignCapacity']*1000)."\n"; + } elseif (isset($bufferWPB[0]['DesignCapacity'])) { + $buffer_info .= 'POWER_SUPPLY_ENERGY_FULL_DESIGN='.($bufferWPB[0]['DesignCapacity']*1000)."\n"; + if ($capacity != '') $buffer_state .= 'POWER_SUPPLY_ENERGY_NOW='.(round($capacity*$bufferWPB[0]['DesignCapacity']*10)."\n"); + } else { + if ($capacity != '') $buffer_state .= 'POWER_SUPPLY_CAPACITY='.$capacity."\n"; + } + + $bufferBCC = CommonFunctions::getWMI($_wmi, 'BatteryCycleCount', array('CycleCount')); + if ((sizeof($bufferBCC)>0) && isset($bufferBCC[0]['CycleCount']) && ($bufferBCC[0]['CycleCount']>0)) { + $buffer_info .= 'POWER_SUPPLY_CYCLE_COUNT='.$bufferBCC[0]['CycleCount']."\n"; } } - if ($techn != '') $buffer_info .= 'POWER_SUPPLY_TECHNOLOGY='.$techn."\n"; - if (isset($buffer[0]['DesignCapacity'])) { - $buffer_info .= 'design capacity:'.$buffer[0]['DesignCapacity'].' mWh'; - if ($capacity != '') $buffer_state .= 'remaining capacity:'.(round($capacity*$buffer[0]['DesignCapacity']/100).' mWh'); - } else { - if ($capacity != '') $buffer_state .= 'POWER_SUPPLY_CAPACITY='.$capacity."\n"; - } + } elseif (PSI_OS == 'Darwin') { + $buffer_info = ''; + $buffer_state = ''; + CommonFunctions::executeProgram('ioreg', '-w0 -l -n AppleSmartBattery -r', $buffer_info, false); + } elseif (PSI_OS == 'FreeBSD') { + $buffer_info = ''; + $buffer_state = ''; + CommonFunctions::executeProgram('acpiconf', '-i batt', $buffer_info, false); } else { - $rfts_bi = CommonFunctions::rfts('/proc/acpi/battery/'.PSI_PLUGIN_BAT_DEVICE.'/info', $buffer_info, 0, 4096, false); - $rfts_bs = CommonFunctions::rfts('/proc/acpi/battery/'.PSI_PLUGIN_BAT_DEVICE.'/state', $buffer_state, 0, 4096, false); + $bat_name = PSI_PLUGIN_BAT_DEVICE; + $rfts_bi = CommonFunctions::rfts('/proc/acpi/battery/'.$bat_name.'/info', $buffer_info, 0, 4096, false); + $rfts_bs = CommonFunctions::rfts('/proc/acpi/battery/'.$bat_name.'/state', $buffer_state, 0, 4096, false); if (!$rfts_bi && !$rfts_bs) { - CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/uevent', $buffer_info, 0, 4096, PSI_DEBUG); + if ((PSI_OS == 'Android') && !CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/uevent', $buffer_info, 0, 4096, false)) { + $bat_name = 'battery'; + } + CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/uevent', $buffer_info, 0, 4096, PSI_DEBUG); $buffer_state = ''; - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/voltage_min_design', $buffer1, 1, 4096, false)) { + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/voltage_min_design', $buffer1, 1, 4096, false)) { $buffer_state .= 'POWER_SUPPLY_VOLTAGE_MIN_DESIGN='.$buffer1."\n"; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/voltage_now', $buffer1, 1, 4096, false)) { + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/voltage_max_design', $buffer1, 1, 4096, false)) { + $buffer_state .= 'POWER_SUPPLY_VOLTAGE_MAX_DESIGN='.$buffer1."\n"; + } + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/voltage_now', $buffer1, 1, 4096, false)) { $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW='.$buffer1."\n"; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/energy_full', $buffer1, 1, 4096, false)) { + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/energy_full', $buffer1, 1, 4096, false)) { $buffer_state .= 'POWER_SUPPLY_ENERGY_FULL='.$buffer1."\n"; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/energy_now', $buffer1, 1, 4096, false)) { + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/energy_now', $buffer1, 1, 4096, false)) { $buffer_state .= 'POWER_SUPPLY_ENERGY_NOW='.$buffer1."\n"; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/charge_full', $buffer1, 1, 4096, false)) { - $buffer_state .= 'POWER_SUPPLY_ENERGY_FULL='.$buffer1."\n"; + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/charge_full', $buffer1, 1, 4096, false)) { + $buffer_state .= 'POWER_SUPPLY_CHARGE_FULL='.$buffer1."\n"; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/charge_now', $buffer1, 1, 4096, false)) { - $buffer_state .= 'POWER_SUPPLY_ENERGY_NOW='.$buffer1."\n"; + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/charge_now', $buffer1, 1, 4096, false)) { + $buffer_state .= 'POWER_SUPPLY_CHARGE_NOW='.$buffer1."\n"; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/capacity', $buffer1, 1, 4096, false)) { + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/capacity', $buffer1, 1, 4096, false)) { $buffer_state .= 'POWER_SUPPLY_CAPACITY='.$buffer1; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/technology', $buffer1, 1, 4096, false)) { + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/technology', $buffer1, 1, 4096, false)) { $buffer_state .= 'POWER_SUPPLY_TECHNOLOGY='.$buffer1; } - if (CommonFunctions::rfts('/sys/class/power_supply/'.PSI_PLUGIN_BAT_DEVICE.'/status', $buffer1, 1, 4096, false)) { + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/status', $buffer1, 1, 4096, false)) { $buffer_state .= 'POWER_SUPPLY_STATUS='.$buffer1; } + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/batt_temp', $buffer1, 1, 4096, false)) { + $buffer_state .= 'POWER_SUPPLY_TEMP='.$buffer1; + } + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/batt_vol', $buffer1, 1, 4096, false)) { + $buffer_state .= 'POWER_SUPPLY_VOLTAGE_NOW='.$buffer1; + } + if (CommonFunctions::rfts('/sys/class/power_supply/'.$bat_name.'/health', $buffer1, 1, 4096, false)) { + $buffer_state .= 'POWER_SUPPLY_HEALTH='.$buffer1; + } } } break; @@ -212,66 +240,219 @@ public function execute() return; } foreach ($this->_filecontent['info'] as $roworig) { - if (preg_match('/^design capacity\s*:\s*(.*) (.*)$/', trim($roworig), $data)) { + if (preg_match('/^[dD]esign capacity:\s*(.*) (.*)$/', trim($roworig), $data)) { + $bat['design_capacity_max'] = $data[1]; + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = trim($data[2]); + } elseif ($bat['capacity_unit'] != trim($data[2])) { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^[lL]ast full capacity:\s*(.*) (.*)$/', trim($roworig), $data)) { $bat['design_capacity'] = $data[1]; - } elseif (preg_match('/^design voltage\s*:\s*(.*) (.*)$/', trim($roworig), $data)) { - $bat['design_voltage'] = $data[1]; - } elseif (preg_match('/^battery type\s*:\s*(.*)$/', trim($roworig), $data)) { + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = trim($data[2]); + } elseif ($bat['capacity_unit'] != trim($data[2])) { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^cycle count:\s*(.*)$/', trim($roworig), $data) && ($data[1]>0)) { + $bat['cycle_count'] = $data[1]; + } elseif (preg_match('/^[dD]esign voltage:\s*(.*) (.*)$/', trim($roworig), $data)) { + if ($data[2]=="mV") { // uV or mV detection + $bat['design_voltage'] = $data[1]; + } else { + $bat['design_voltage'] = round($data[1]/1000); + } + } elseif (preg_match('/^battery type:\s*(.*)$/', trim($roworig), $data)) { $bat['battery_type'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MIN_DESIGN\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['design_voltage'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_CYCLE_COUNT=(.*)$/', trim($roworig), $data) && ($data[1]>0)) { + $bat['cycle_count'] = $data[1]; + } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MIN_DESIGN=(.*)$/', trim($roworig), $data)) { + if ($data[1]<100000) { // uV or mV detection + $bat['design_voltage'] = $data[1]; + } else { + $bat['design_voltage'] = round($data[1]/1000); + } + } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MAX_DESIGN=(.*)$/', trim($roworig), $data)) { + if ($data[1]<100000) { // uV or mV detection + $bat['design_voltage_max'] = $data[1]; + } else { + $bat['design_voltage_max'] = round($data[1]/1000); + } + } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL=(.*)$/', trim($roworig), $data)) { + $bat['design_capacity'] = ($data[1]/1000); + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = "mWh"; + } elseif ($bat['capacity_unit'] != "mWh") { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^POWER_SUPPLY_CHARGE_FULL=(.*)$/', trim($roworig), $data)) { $bat['design_capacity'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_ENERGY_NOW\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['remaining_capacity'] = ($data[1]/1000); + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = "mAh"; + } elseif ($bat['capacity_unit'] != "mAh") { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^POWER_SUPPLY_ENERGY_NOW=(.*)$/', trim($roworig), $data)) { + if (!isset($bat['capacity_unit']) || ($bat['capacity_unit'] == "mWh")) { + $bat['capacity_unit'] = "mWh"; + $bat['remaining_capacity'] = ($data[1]/1000); + $bat['capacity'] = -1; + } + } elseif (preg_match('/^POWER_SUPPLY_CHARGE_NOW=(.*)$/', trim($roworig), $data)) { + if (!isset($bat['capacity_unit']) || ($bat['capacity_unit'] == "mAh")) { + $bat['capacity_unit'] = "mAh"; + $bat['remaining_capacity'] = ($data[1]/1000); + $bat['capacity'] = -1; + } - /* Android */ - } elseif (preg_match('/^POWER_SUPPLY_CAPACITY\s*=\s*(.*)$/', trim($roworig), $data) && !isset($bat['remaining_capacity'])) { + /* auxiary */ + } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL_DESIGN=(.*)$/', trim($roworig), $data)) { + $bat['design_capacity_max'] = ($data[1]/1000); + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = "mWh"; + } elseif ($bat['capacity_unit'] != "mWh") { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^POWER_SUPPLY_CHARGE_FULL_DESIGN=(.*)$/', trim($roworig), $data)) { + $bat['design_capacity_max'] = ($data[1]/1000); + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = "mAh"; + } elseif ($bat['capacity_unit'] != "mAh") { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_NOW=(.*)$/', trim($roworig), $data)) { + if ($data[1]<100000) { // uV or mV detection + $bat['present_voltage'] = $data[1]; + } else { + $bat['present_voltage'] = round($data[1]/1000); + } + + } elseif (preg_match('/^POWER_SUPPLY_CAPACITY=(.*)$/', trim($roworig), $data) && !isset($bat['remaining_capacity'])) { $bat['capacity'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_TEMP\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_TEMP=(.*)$/', trim($roworig), $data)) { $bat['battery_temperature'] = $data[1]/10; - } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_NOW\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['present_voltage'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MAX_DESIGN\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['design_voltage'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_TECHNOLOGY\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_TECHNOLOGY=(.*)$/', trim($roworig), $data)) { $bat['battery_type'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_STATUS\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_STATUS=(.*)$/', trim($roworig), $data)) { $bat['charging_state'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_HEALTH\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_HEALTH=(.*)$/', trim($roworig), $data)) { $bat['battery_condition'] = $data[1]; + + /* Darwin */ + } elseif (preg_match('/^"MaxCapacity"\s*=\s*(.*)$/', trim($roworig), $data)) { + $bat['design_capacity'] = $data[1]; + } elseif (preg_match('/^"CurrentCapacity"\s*=\s*(.*)$/', trim($roworig), $data)) { + $bat['remaining_capacity'] = $data[1]; + } elseif (preg_match('/^"Voltage"\s*=\s*(.*)$/', trim($roworig), $data)) { + $bat['present_voltage'] = $data[1]; + } elseif (preg_match('/^"BatteryType"\s*=\s*"(.*)"$/', trim($roworig), $data)) { + $bat['battery_type'] = $data[1]; + } elseif (preg_match('/^"Temperature"\s*=\s*(.*)$/', trim($roworig), $data)) { + if ($data[1]>0) $bat['battery_temperature'] = $data[1]/100; + } elseif (preg_match('/^"DesignCapacity"\s*=\s*(.*)$/', trim($roworig), $data)) { + $bat['design_capacity_max'] = $data[1]; + } elseif (preg_match('/^"CycleCount"\s*=\s*(.*)$/', trim($roworig), $data) && ($data[1]>0)) { + $bat['cycle_count'] = $data[1]; + /* auxiary */ + } elseif (preg_match('/^"FullyCharged"\s*=\s*Yes$/', trim($roworig), $data)) { + $bat['charging_state_f'] = true; + } elseif (preg_match('/^"IsCharging"\s*=\s*Yes$/', trim($roworig), $data)) { + $bat['charging_state_i'] = true; + } elseif (preg_match('/^"ExternalConnected"\s*=\s*Yes$/', trim($roworig), $data)) { + $bat['charging_state_e'] = true; + + /* FreeBSD */ + } elseif (preg_match('/^Type:\s*(.*)$/', trim($roworig), $data)) { + $bat['battery_type'] = $data[1]; + } elseif (preg_match('/^State:\s*(.*)$/', trim($roworig), $data)) { + $bat['charging_state'] = $data[1]; + } elseif (preg_match('/^Present voltage:\s*(.*) (.*)$/', trim($roworig), $data)) { + if ($data[2]=="mV") { // uV or mV detection + $bat['present_voltage'] = $data[1]; + } else { + $bat['present_voltage'] = round($data[1]/1000); + } + } elseif (preg_match('/^Voltage:\s*(.*) (.*)$/', trim($roworig), $data)) { + if ($data[2]=="mV") { // uV or mV detection + $bat['present_voltage'] = $data[1]; + } else { + $bat['present_voltage'] = round($data[1]/1000); + } + } elseif (preg_match('/^Remaining capacity:\s*(.*)%$/', trim($roworig), $data) && !isset($bat['remaining_capacity'])) { + $bat['capacity'] = $data[1]; } } foreach ($this->_filecontent['state'] as $roworig) { - if (preg_match('/^remaining capacity\s*:\s*(.*) (.*)$/', trim($roworig), $data)) { - $bat['remaining_capacity'] = $data[1]; - } elseif (preg_match('/^present voltage\s*:\s*(.*) (.*)$/', trim($roworig), $data)) { - $bat['present_voltage'] = $data[1]; - } elseif (preg_match('/^charging state\s*:\s*(.*)$/', trim($roworig), $data)) { + if (preg_match('/^remaining capacity:\s*(.*) (.*)$/', trim($roworig), $data)) { + if (!isset($bat['capacity_unit']) || ($bat['capacity_unit'] == trim($data[2]))) { + $bat['capacity_unit'] = trim($data[2]); + $bat['remaining_capacity'] = $data[1]; + $bat['capacity'] = -1; + } + } elseif (preg_match('/^present voltage:\s*(.*) (.*)$/', trim($roworig), $data)) { + if ($data[2]=="mV") { // uV or mV detection + $bat['present_voltage'] = $data[1]; + } else { + $bat['present_voltage'] = round($data[1]/1000); + } + } elseif (preg_match('/^charging state:\s*(.*)$/', trim($roworig), $data)) { $bat['charging_state'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MIN_DESIGN\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['design_voltage'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MIN_DESIGN=(.*)$/', trim($roworig), $data)) { + if ($data[1]<100000) { // uV or mV detection + $bat['design_voltage'] = $data[1]; + } else { + $bat['design_voltage'] = round($data[1]/1000); + } + } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MAX_DESIGN=(.*)$/', trim($roworig), $data)) { + if ($data[1]<100000) { // uV or mV detection + $bat['design_voltage_max'] = $data[1]; + } else { + $bat['design_voltage_max'] = round($data[1]/1000); + } + } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL=(.*)$/', trim($roworig), $data)) { $bat['design_capacity'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_ENERGY_NOW\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['remaining_capacity'] = ($data[1]/1000); + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = "mWh"; + } elseif ($bat['capacity_unit'] != "mWh") { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^POWER_SUPPLY_CHARGE_FULL=(.*)$/', trim($roworig), $data)) { + $bat['design_capacity'] = ($data[1]/1000); + if (!isset($bat['capacity_unit'])) { + $bat['capacity_unit'] = "mAh"; + } elseif ($bat['capacity_unit'] != "mAh") { + $bat['capacity_unit'] = "???"; + } + } elseif (preg_match('/^POWER_SUPPLY_ENERGY_NOW=(.*)$/', trim($roworig), $data)) { + if (!isset($bat['capacity_unit']) || ($bat['capacity_unit'] == "mWh")) { + $bat['capacity_unit'] = "mWh"; + $bat['remaining_capacity'] = ($data[1]/1000); + $bat['capacity'] = -1; + } + } elseif (preg_match('/^POWER_SUPPLY_CHARGE_NOW=(.*)$/', trim($roworig), $data)) { + if (!isset($bat['capacity_unit']) || ($bat['capacity_unit'] == "mAh")) { + $bat['capacity_unit'] = "mAh"; + $bat['remaining_capacity'] = ($data[1]/1000); + $bat['capacity'] = -1; + } + } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_NOW=(.*)$/', trim($roworig), $data)) { + if ($data[1]<100000) { // uV or mV detection + $bat['present_voltage'] = $data[1]; + } else { + $bat['present_voltage'] = round($data[1]/1000); + } - /* Android */ - } elseif (preg_match('/^POWER_SUPPLY_CAPACITY\s*=\s*(.*)$/', trim($roworig), $data) && !isset($bat['remaining_capacity'])) { + } elseif (preg_match('/^POWER_SUPPLY_CAPACITY=(.*)$/', trim($roworig), $data) && !isset($bat['remaining_capacity'])) { $bat['capacity'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_TEMP\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_TEMP=(.*)$/', trim($roworig), $data)) { $bat['battery_temperature'] = $data[1]/10; - } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_NOW\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['present_voltage'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_VOLTAGE_MAX_DESIGN\s*=\s*(.*)$/', trim($roworig), $data)) { - $bat['design_voltage'] = ($data[1]/1000); - } elseif (preg_match('/^POWER_SUPPLY_TECHNOLOGY\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_TECHNOLOGY=(.*)$/', trim($roworig), $data)) { $bat['battery_type'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_STATUS\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_STATUS=(.*)$/', trim($roworig), $data)) { $bat['charging_state'] = $data[1]; - } elseif (preg_match('/^POWER_SUPPLY_HEALTH\s*=\s*(.*)$/', trim($roworig), $data)) { + } elseif (preg_match('/^POWER_SUPPLY_HEALTH=(.*)$/', trim($roworig), $data)) { $bat['battery_condition'] = $data[1]; } } @@ -288,23 +469,39 @@ public function xml() { foreach ($this->_result as $bat_item) { $xmlbat = $this->xml->addChild("Bat"); - if (isset($bat_item['design_capacity'])) { - $xmlbat->addAttribute("DesignCapacity", $bat_item['design_capacity']); + if (isset($bat_item['capacity']) && ($bat_item['capacity']>=0)) { + $xmlbat->addAttribute("Capacity", $bat_item['capacity']); + } else { + if (isset($bat_item['design_capacity'])) { + $xmlbat->addAttribute("DesignCapacity", $bat_item['design_capacity']); + } elseif (isset($bat_item['design_capacity_max'])) { + $xmlbat->addAttribute("DesignCapacity", $bat_item['design_capacity_max']); + } + if (isset($bat_item['remaining_capacity'])) { + $xmlbat->addAttribute("RemainingCapacity", $bat_item['remaining_capacity']); + } } if (isset($bat_item['design_voltage'])) { $xmlbat->addAttribute("DesignVoltage", $bat_item['design_voltage']); } - if (isset($bat_item['remaining_capacity'])) { - $xmlbat->addAttribute("RemainingCapacity", $bat_item['remaining_capacity']); - } - if (isset($bat_item['capacity'])) { - $xmlbat->addAttribute("Capacity", $bat_item['capacity']); + if (isset($bat_item['design_voltage_max'])) { + $xmlbat->addAttribute("DesignVoltageMax", $bat_item['design_voltage_max']); } if (isset($bat_item['present_voltage'])) { $xmlbat->addAttribute("PresentVoltage", $bat_item['present_voltage']); } if (isset($bat_item['charging_state'])) { $xmlbat->addAttribute("ChargingState", $bat_item['charging_state']); + } else { + if (isset($bat_item['charging_state_i'])) { + $xmlbat->addAttribute("ChargingState", 'Charging'); + } elseif (!isset($bat_item['charging_state_e'])) { + $xmlbat->addAttribute("ChargingState", 'Discharging'); + } elseif (isset($bat_item['charging_state_f'])) { + $xmlbat->addAttribute("ChargingState", 'Fully Charged'); + } else { + $xmlbat->addAttribute("ChargingState", 'Unknown state'); + } } if (isset($bat_item['battery_type'])) { $xmlbat->addAttribute("BatteryType", $bat_item['battery_type']); @@ -314,6 +511,16 @@ public function xml() } if (isset($bat_item['battery_condition'])) { $xmlbat->addAttribute("BatteryCondition", $bat_item['battery_condition']); + } elseif (isset($bat_item['design_capacity']) + && isset($bat_item['design_capacity_max']) && ($bat_item['design_capacity_max'] != 0) + && (!isset($bat['capacity_unit']) || ($bat['capacity_unit'] != "???"))) { + $xmlbat->addAttribute("BatteryCondition", round(100*$bat_item['design_capacity']/$bat_item['design_capacity_max'])."%"); + } + if (isset($bat_item['capacity_unit'])) { + $xmlbat->addAttribute("CapacityUnit", $bat_item['capacity_unit']); + } + if (isset($bat_item['cycle_count'])) { + $xmlbat->addAttribute("CycleCount", $bat_item['cycle_count']); } } diff --git a/etc/apps/phpsysinfo/plugins/bat/js/bat.js b/etc/apps/phpsysinfo/plugins/bat/js/bat.js index 6f529ad17..f8e77ebd0 100644 --- a/etc/apps/phpsysinfo/plugins/bat/js/bat.js +++ b/etc/apps/phpsysinfo/plugins/bat/js/bat.js @@ -35,7 +35,7 @@ function bat_populate(xml) { bat_table.fnClearTable(); $("Plugins Plugin_BAT Bat", xml).each(function bat_getitem(idp) { - var DesignCapacity = "", DesignVoltage = "", BatteryType = "",RemainingCapacity = "", PresentVoltage = "", ChargingState = "", BatteryTemperature = "", BatteryCondition = "", Capacity = ""; + var DesignCapacity = "", DesignVoltage = "", BatteryType = "",RemainingCapacity = "", PresentVoltage = "", ChargingState = "", BatteryTemperature = "", BatteryCondition = "", Capacity = "", CapacityUnit = "", CycleCount = "", DesignVoltageMax = ""; DesignCapacity = $(this).attr("DesignCapacity"); DesignVoltage = $(this).attr("DesignVoltage"); BatteryType = $(this).attr("BatteryType"); @@ -45,20 +45,33 @@ function bat_populate(xml) { BatteryTemperature = $(this).attr("BatteryTemperature"); BatteryCondition = $(this).attr("BatteryCondition"); Capacity = $(this).attr("Capacity"); + CapacityUnit = $(this).attr("CapacityUnit"); + CycleCount = $(this).attr("CycleCount"); + DesignVoltageMax = $(this).attr("DesignVoltageMax"); + + if (CapacityUnit == undefined) { + CapacityUnit = "mWh"; + } if (Capacity != undefined) { bat_table.fnAddData([genlang(4, true, "BAT"), createBar(parseInt(Capacity, 10)), ' ']); } else if (DesignCapacity == undefined) { - if (RemainingCapacity != undefined) bat_table.fnAddData([genlang(4, true, "BAT"), RemainingCapacity+' mWh', ' ']); + if (RemainingCapacity != undefined) bat_table.fnAddData([genlang(4, true, "BAT"), RemainingCapacity+' '+CapacityUnit, ' ']); } else { - bat_table.fnAddData([genlang(3, true, "BAT"), DesignCapacity+' mWh', ' ']); - if (RemainingCapacity != undefined) bat_table.fnAddData([genlang(4, true, "BAT"), RemainingCapacity+' mWh', createBar(parseInt(parseInt(RemainingCapacity, 10) / parseInt(DesignCapacity, 10) * 100, 10))]); + bat_table.fnAddData([genlang(3, true, "BAT"), DesignCapacity+' '+CapacityUnit, ' ']); + if (RemainingCapacity != undefined) bat_table.fnAddData([genlang(4, true, "BAT"), RemainingCapacity+' '+CapacityUnit, createBar(round(parseInt(RemainingCapacity, 10) / parseInt(DesignCapacity, 10) * 100, 0))]); } if (ChargingState != undefined) { bat_table.fnAddData([genlang(9, true, "BAT"), ChargingState, ' ']); } if (DesignVoltage != undefined) { - bat_table.fnAddData([genlang(5, true, "BAT"), DesignVoltage+' mV', ' ']); + if (DesignVoltageMax != undefined) { + bat_table.fnAddData([genlang(5, true, "BAT"), DesignVoltage+' mV', DesignVoltageMax+' mV']); + } else { + bat_table.fnAddData([genlang(5, true, "BAT"), DesignVoltage+' mV', ' ']); + } + } else if (DesignVoltageMax != undefined) { + bat_table.fnAddData([genlang(5, true, "BAT"), DesignVoltageMax+' mV', ' ']); } if (PresentVoltage != undefined) { bat_table.fnAddData([genlang(6, true, "BAT"), PresentVoltage+' mV', ' ']); @@ -72,6 +85,9 @@ function bat_populate(xml) { if (BatteryCondition != undefined) { bat_table.fnAddData([genlang(12, true, "BAT"), BatteryCondition, ' ']); } + if (CycleCount != undefined) { + bat_table.fnAddData([genlang(13, true, "BAT"), CycleCount, ' ']); + } bat_show = true; }); diff --git a/etc/apps/phpsysinfo/plugins/bat/lang/cz.xml b/etc/apps/phpsysinfo/plugins/bat/lang/cz.xml index 1a15e5f1e..2101e4928 100644 --- a/etc/apps/phpsysinfo/plugins/bat/lang/cz.xml +++ b/etc/apps/phpsysinfo/plugins/bat/lang/cz.xml @@ -42,4 +42,7 @@ Battery Condition + + Cycle Count + diff --git a/etc/apps/phpsysinfo/plugins/bat/lang/de.xml b/etc/apps/phpsysinfo/plugins/bat/lang/de.xml index d136cf56b..664211975 100644 --- a/etc/apps/phpsysinfo/plugins/bat/lang/de.xml +++ b/etc/apps/phpsysinfo/plugins/bat/lang/de.xml @@ -42,4 +42,7 @@ Akku-Zustand + + Cycle Count + diff --git a/etc/apps/phpsysinfo/plugins/bat/lang/en.xml b/etc/apps/phpsysinfo/plugins/bat/lang/en.xml index cd0100da8..b11940e13 100644 --- a/etc/apps/phpsysinfo/plugins/bat/lang/en.xml +++ b/etc/apps/phpsysinfo/plugins/bat/lang/en.xml @@ -42,4 +42,7 @@ Battery Condition + + Cycle Count + diff --git a/etc/apps/phpsysinfo/plugins/bat/lang/fr.xml b/etc/apps/phpsysinfo/plugins/bat/lang/fr.xml index e410d1350..1e25bdc22 100644 --- a/etc/apps/phpsysinfo/plugins/bat/lang/fr.xml +++ b/etc/apps/phpsysinfo/plugins/bat/lang/fr.xml @@ -42,4 +42,7 @@ Battery Condition + + Cycle Count + diff --git a/etc/apps/phpsysinfo/plugins/bat/lang/pl.xml b/etc/apps/phpsysinfo/plugins/bat/lang/pl.xml index ff70fc11a..3d7a310f8 100644 --- a/etc/apps/phpsysinfo/plugins/bat/lang/pl.xml +++ b/etc/apps/phpsysinfo/plugins/bat/lang/pl.xml @@ -42,4 +42,7 @@ Kondycja ogniw + + Cykli ładowania + diff --git a/etc/apps/phpsysinfo/plugins/bat/lang/ro.xml b/etc/apps/phpsysinfo/plugins/bat/lang/ro.xml index 40b63902e..05bbd498a 100644 --- a/etc/apps/phpsysinfo/plugins/bat/lang/ro.xml +++ b/etc/apps/phpsysinfo/plugins/bat/lang/ro.xml @@ -42,4 +42,7 @@ Condiții Baterie + + Cycle Count + diff --git a/etc/apps/phpsysinfo/plugins/bat/lang/ru.xml b/etc/apps/phpsysinfo/plugins/bat/lang/ru.xml index cc9ba6497..ea96fe7e1 100644 --- a/etc/apps/phpsysinfo/plugins/bat/lang/ru.xml +++ b/etc/apps/phpsysinfo/plugins/bat/lang/ru.xml @@ -42,4 +42,7 @@ Состояние аккумулятора + + Cycle Count + diff --git a/etc/apps/phpsysinfo/plugins/dmraid/class.dmraid.inc.php b/etc/apps/phpsysinfo/plugins/dmraid/class.dmraid.inc.php index c42e74a41..2f3ab1b3f 100644 --- a/etc/apps/phpsysinfo/plugins/dmraid/class.dmraid.inc.php +++ b/etc/apps/phpsysinfo/plugins/dmraid/class.dmraid.inc.php @@ -13,12 +13,7 @@ * @link http://phpsysinfo.sourceforge.net */ /** - * mdstat Plugin, which displays a snapshot of the kernel's RAID/md state - * a simple view which shows supported types and RAID-Devices which are determined by - * parsing the "/proc/mdstat" file, another way is to provide - * a file with the output of the /proc/mdstat file, so there is no need to run a execute by the - * webserver, the format of the command is written down in the mdstat.config.php file, where also - * the method of getting the information is configured + * dmraid Plugin, which displays software RAID status * * @category PHP * @package PSI_Plugin_DMRaid @@ -143,25 +138,35 @@ public function xml() if ( empty($this->_result)) { return $this->xml->getSimpleXmlElement(); } + $hideRaids = array(); + if ( defined('PSI_PLUGIN_DMRAID_HIDE_RAID_DEVICES') && is_string(PSI_PLUGIN_DMRAID_HIDE_RAID_DEVICES) ) { + if (preg_match(ARRAY_EXP, PSI_PLUGIN_DMRAID_HIDE_RAID_DEVICES)) { + $hideRaids = eval(PSI_PLUGIN_DMRAID_HIDE_RAID_DEVICES); + } else { + $hideRaids = array(PSI_PLUGIN_DMRAID_HIDE_RAID_DEVICES); + } + } foreach ($this->_result['devices'] as $key=>$device) { - $dev = $this->xml->addChild("Raid"); - $dev->addAttribute("Device_Name", $key); - $dev->addAttribute("Type", $device["type"]); - $dev->addAttribute("Disk_Status", $device["status"]); - $dev->addAttribute("Name", $device["name"]); - $dev->addAttribute("Size", $device["size"]); - $dev->addAttribute("Stride", $device["stride"]); - $dev->addAttribute("Subsets", $device["subsets"]); - $dev->addAttribute("Devs", $device["devs"]); - $dev->addAttribute("Spares", $device["spares"]); - $disks = $dev->addChild("Disks"); - if (isset($device['partitions']) && sizeof($device['partitions']>0)) foreach ($device['partitions'] as $diskkey=>$disk) { - $disktemp = $disks->addChild("Disk"); - $disktemp->addAttribute("Name", $diskkey); - if ($device["status"]=='ok') { - $disktemp->addAttribute("Status", $disk['status']); - } else { - $disktemp->addAttribute("Status", 'W'); + if (!in_array($key, $hideRaids, true)) { + $dev = $this->xml->addChild("Raid"); + $dev->addAttribute("Device_Name", $key); + $dev->addAttribute("Type", $device["type"]); + $dev->addAttribute("Disk_Status", $device["status"]); + $dev->addAttribute("Name", $device["name"]); + $dev->addAttribute("Size", $device["size"]); + $dev->addAttribute("Stride", $device["stride"]); + $dev->addAttribute("Subsets", $device["subsets"]); + $dev->addAttribute("Devs", $device["devs"]); + $dev->addAttribute("Spares", $device["spares"]); + $disks = $dev->addChild("Disks"); + if (isset($device['partitions']) && sizeof($device['partitions']>0)) foreach ($device['partitions'] as $diskkey=>$disk) { + $disktemp = $disks->addChild("Disk"); + $disktemp->addAttribute("Name", $diskkey); + if ($device["status"]=='ok') { + $disktemp->addAttribute("Status", $disk['status']); + } else { + $disktemp->addAttribute("Status", 'W'); + } } } } diff --git a/etc/apps/phpsysinfo/plugins/mdstatus/class.mdstatus.inc.php b/etc/apps/phpsysinfo/plugins/mdstatus/class.mdstatus.inc.php index c7412e549..69ca0c2a6 100644 --- a/etc/apps/phpsysinfo/plugins/mdstatus/class.mdstatus.inc.php +++ b/etc/apps/phpsysinfo/plugins/mdstatus/class.mdstatus.inc.php @@ -13,7 +13,7 @@ * @link http://phpsysinfo.sourceforge.net */ /** - * mdstat Plugin, which displays a snapshot of the kernel's RAID/md state + * mdstatus Plugin, which displays a snapshot of the kernel's RAID/md state * a simple view which shows supported types and RAID-Devices which are determined by * parsing the "/proc/mdstat" file, another way is to provide * a file with the output of the /proc/mdstat file, so there is no need to run a execute by the @@ -106,6 +106,8 @@ public function execute() $details = preg_split('/ /', $parts[1]); if (!strstr($details[0], 'inactive')) { $this->_result['devices'][$dev]['level'] = $details[1]; + } else { + $this->_result['devices'][$dev]['level'] = "none"; } $this->_result['devices'][$dev]['status'] = $details[0]; for ($i = 2, $cnt_details = count($details); $i < $cnt_details; $i++) { @@ -186,32 +188,42 @@ public function xml() if ( empty($this->_result)) { return $this->xml->getSimpleXmlElement(); } + $hideRaids = array(); + if ( defined('PSI_PLUGIN_MDSTATUS_HIDE_RAID_DEVICES') && is_string(PSI_PLUGIN_MDSTATUS_HIDE_RAID_DEVICES) ) { + if (preg_match(ARRAY_EXP, PSI_PLUGIN_MDSTATUS_HIDE_RAID_DEVICES)) { + $hideRaids = eval(PSI_PLUGIN_MDSTATUS_HIDE_RAID_DEVICES); + } else { + $hideRaids = array(PSI_PLUGIN_MDSTATUS_HIDE_RAID_DEVICES); + } + } $sup = $this->xml->addChild("Supported_Types"); foreach ($this->_result['supported_types'] as $type) { $typ = $sup->addChild("Type"); $typ->addAttribute("Name", $type); } foreach ($this->_result['devices'] as $key=>$device) { - $dev = $this->xml->addChild("Raid"); - $dev->addAttribute("Device_Name", $key); - $dev->addAttribute("Level", $device["level"]); - $dev->addAttribute("Disk_Status", $device["status"]); - $dev->addAttribute("Chunk_Size", $device["chunk_size"]); - $dev->addAttribute("Persistend_Superblock", $device["pers_superblock"]); - $dev->addAttribute("Algorithm", $device["algorithm"]); - $dev->addAttribute("Disks_Registered", $device["registered"]); - $dev->addAttribute("Disks_Active", $device["active"]); - $action = $dev->addChild("Action"); - $action->addAttribute("Percent", $device['action']['percent']); - $action->addAttribute("Name", $device['action']['name']); - $action->addAttribute("Time_To_Finish", $device['action']['finish_time']); - $action->addAttribute("Time_Unit", $device['action']['finish_unit']); - $disks = $dev->addChild("Disks"); - foreach ($device['partitions'] as $diskkey=>$disk) { - $disktemp = $disks->addChild("Disk"); - $disktemp->addAttribute("Name", $diskkey); - $disktemp->addAttribute("Status", $disk['status']); - $disktemp->addAttribute("Index", $disk['raid_index']); + if (!in_array($key, $hideRaids, true)) { + $dev = $this->xml->addChild("Raid"); + $dev->addAttribute("Device_Name", $key); + $dev->addAttribute("Level", $device["level"]); + $dev->addAttribute("Disk_Status", $device["status"]); + $dev->addAttribute("Chunk_Size", $device["chunk_size"]); + $dev->addAttribute("Persistend_Superblock", $device["pers_superblock"]); + $dev->addAttribute("Algorithm", $device["algorithm"]); + $dev->addAttribute("Disks_Registered", $device["registered"]); + $dev->addAttribute("Disks_Active", $device["active"]); + $action = $dev->addChild("Action"); + $action->addAttribute("Percent", $device['action']['percent']); + $action->addAttribute("Name", $device['action']['name']); + $action->addAttribute("Time_To_Finish", $device['action']['finish_time']); + $action->addAttribute("Time_Unit", $device['action']['finish_unit']); + $disks = $dev->addChild("Disks"); + foreach ($device['partitions'] as $diskkey=>$disk) { + $disktemp = $disks->addChild("Disk"); + $disktemp->addAttribute("Name", $diskkey); + $disktemp->addAttribute("Status", $disk['status']); + $disktemp->addAttribute("Index", $disk['raid_index']); + } } } if ($this->_result['unused_devs'] !== - 1) { diff --git a/etc/apps/phpsysinfo/plugins/mdstatus/js/mdstatus.js b/etc/apps/phpsysinfo/plugins/mdstatus/js/mdstatus.js index 1ec1d9f5e..9f0d8c32e 100644 --- a/etc/apps/phpsysinfo/plugins/mdstatus/js/mdstatus.js +++ b/etc/apps/phpsysinfo/plugins/mdstatus/js/mdstatus.js @@ -138,7 +138,8 @@ function mdstatus_populate(xml) { $("#Plugin_MDStatusTable").empty(); $("Plugins Plugin_MDStatus Supported_Types Type", xml).each(function mdstatus_getsupportedtypes(id) { - htmltypes += "
  • " + $(this).attr("Name") + "
  • "; +// htmltypes += "
  • " + $(this).attr("Name") + "
  • "; + htmltypes += "" + $(this).attr("Name") + " "; }); if (htmltypes.length > 0) { htmltypes = "
      " + htmltypes + "
    "; diff --git a/etc/apps/phpsysinfo/plugins/snmppinfo/lang/de.xml b/etc/apps/phpsysinfo/plugins/snmppinfo/lang/de.xml index 193de1312..487d71efd 100644 --- a/etc/apps/phpsysinfo/plugins/snmppinfo/lang/de.xml +++ b/etc/apps/phpsysinfo/plugins/snmppinfo/lang/de.xml @@ -1,6 +1,6 @@ - _lines as $line) { if (($i > 1) and (strpos($line, '---') === false)) { $buffer = preg_split("/\s*[ |]\s+/", ltrim(ltrim($line, '->'), ' ')); @@ -71,22 +61,11 @@ private function uprecords() $result[$i]['hash'] = $buffer[0]; $result[$i]['Uptime'] = $buffer[1]; $result[$i]['System'] = $buffer[2]; - $result[$i]['Bootup'] = $buffer[3]; + //Date formating + $result[$i]['Bootup'] = preg_replace("/^(\S+)(\s+)/", "$1,$2", preg_replace("/^(\S+\s+\S+\s+)(\d)(\s+)/", "$1 0$2$3", $buffer[3]." GMT")); } $i++; } - if (preg_match('/(\+)|(-)/', $diff)) { //GMT conversion - foreach ($result as $resnr=>$resval) { - $result[$resnr]['Bootup']=gmdate('D, d M Y H:i:s \G\M\T', strTotime($result[$resnr]['Bootup'])); - } - } - - /* restore error level */ - error_reporting($old_err_rep); - /* restore error handler */ - if (function_exists('errorHandlerPsi')) { - set_error_handler('errorHandlerPsi'); - } return $result; } @@ -97,12 +76,15 @@ public function execute() switch (strtolower(PSI_PLUGIN_UPRECORDS_ACCESS)) { case 'command': $lines = ""; + $oldtz=getenv("TZ"); + putenv("TZ=GMT"); if (CommonFunctions::executeProgram('uprecords', '-a -w', $lines) && !empty($lines)) - $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + putenv("TZ=".$oldtz); break; case 'data': if (CommonFunctions::rfts(APP_ROOT."/data/uprecords.txt", $lines) && !empty($lines)) - $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); + $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); break; default: $this->error->addConfigError('__construct()', 'PSI_PLUGIN_UPRECORDS_ACCESS'); @@ -129,5 +111,4 @@ public function xml() return $this->xml->getSimpleXmlElement(); } - } diff --git a/etc/apps/phpsysinfo/templates/aqua.css b/etc/apps/phpsysinfo/templates/aqua.css index 38aa4d82f..d83f2e812 100644 --- a/etc/apps/phpsysinfo/templates/aqua.css +++ b/etc/apps/phpsysinfo/templates/aqua.css @@ -43,11 +43,8 @@ h1 { } #select { - position: absolute; - top: 30px; - right: 40px; - width: 370px; text-align: right; + padding: 10px; } #select select { diff --git a/etc/apps/phpsysinfo/templates/html/index_dynamic.html b/etc/apps/phpsysinfo/templates/html/index_dynamic.html index 8ec44b133..b5c7eea8b 100644 --- a/etc/apps/phpsysinfo/templates/html/index_dynamic.html +++ b/etc/apps/phpsysinfo/templates/html/index_dynamic.html @@ -134,6 +134,14 @@

    System vitals

    Code Page + + Processes + + + + Processes + +
    diff --git a/etc/apps/phpsysinfo/templates/idash.css b/etc/apps/phpsysinfo/templates/idash.css new file mode 100644 index 000000000..39606c14f --- /dev/null +++ b/etc/apps/phpsysinfo/templates/idash.css @@ -0,0 +1,151 @@ +/* NextGen Remixed by iDash.pl */ +a { + text-decoration: none; + color: #006; +} + +a:hover { + text-decoration: underline; + color: #5A7000; +} + +* { + margin: 0; + padding: 0; +} + +html { + height: 100%; + background: url("idash/bg.png") repeat-x scroll center top #111; +} + +body { + position: relative; + width: 940px; + _width: 945px; /* ie6 */ + min-height: 100%; + overflow: auto; + margin: 0 auto; + padding: 20px 20px 0 20px; + font: 0.75em tahoma, arial, sans-serif; + color: #CCC; +} + +div#container { + margin: -20px -10px 0 -10px; + padding: 95px 0 0 0; +} + +h1 { + position: absolute; + top: 35px; + left: 10px; + margin: 0; + padding: 0px 10px; + font-size: 2em; + font-weight: normal; + color: #FFF; +} + +#select { + position: absolute; + top: 75px; + color: #FFF; + right: 30px; + width: 370px; + text-align: right; +} + +#select select { + width: 100px; +} + +#vitals, #network, #memory, #filesystem, #hardware, #temp, #voltage, #fan, #power, #current, #ups { + float: left; + width: 451px; + margin: 10px 0 0 10px; + _margin: 10px 5px 0 5px; /* ie6 */ + padding: 1px; + border: 1px solid #354242; +} + +h2 { + padding: 5px 10px; + font-family: "trebuchet ms"; + font-size: 1.2em; + font-weight: bold; + letter-spacing: 0.0em; + text-transform: uppercase; + color: #FFF; /* #7D9100; */ + background: #354242; +} + +table { + width: 100%; +} + +.plugin { + float: left; + margin: 10px 0 0 10px; + _margin: 10px 5px 0 5px; /* ie6 */ + padding: 1px; + border: 1px solid #354242; +} + +.dataTables_wrapper{ + margin: 0 0 0 0 !important; + border: 0px !important; +} + + +th, td, h3 { + padding: 4px 10px 2px 10px; + text-align: left; + vertical-align: top; +} + +h3 { + font-size: 120%; +} + +.even { + background: #333; +} + +#footer { + color: #777777; + clear: both; + margin: 12px; + padding: 13px 25px; + line-height: 18px; + text-align: right; +} + +#memory, #filesystem { + width: 915px; +} + +.bar { + background: #34DA64 url("idash/html.gif"); +} + +.barwarn { + background: #e69575 url("idash/htmlwarn.gif"); +} + +p { + padding: 4px 10px 2px 10px; + line-height: 1.6; + text-align: left; + vertical-align: top; +} + +.right { + text-align: right; + padding-right: 20px; +} + +#pciTable, #ideTable, #scsiTable, #usbTable { + padding: 0px 30px; +} +#lang_047{color:444} diff --git a/etc/apps/phpsysinfo/templates/idash/bg.png b/etc/apps/phpsysinfo/templates/idash/bg.png new file mode 100644 index 000000000..60b8e4cc2 Binary files /dev/null and b/etc/apps/phpsysinfo/templates/idash/bg.png differ diff --git a/etc/apps/phpsysinfo/templates/idash/html.gif b/etc/apps/phpsysinfo/templates/idash/html.gif new file mode 100644 index 000000000..cc6e2051a Binary files /dev/null and b/etc/apps/phpsysinfo/templates/idash/html.gif differ diff --git a/etc/apps/phpsysinfo/templates/idash/htmlwarn.gif b/etc/apps/phpsysinfo/templates/idash/htmlwarn.gif new file mode 100644 index 000000000..7257e8bbb Binary files /dev/null and b/etc/apps/phpsysinfo/templates/idash/htmlwarn.gif differ diff --git a/etc/apps/phpsysinfo/templates/nextgen.css b/etc/apps/phpsysinfo/templates/nextgen.css index be8a33f02..117f82d9f 100644 --- a/etc/apps/phpsysinfo/templates/nextgen.css +++ b/etc/apps/phpsysinfo/templates/nextgen.css @@ -62,7 +62,7 @@ h1 { width: 100px; } -#vitals, #network, #memory, #filesystem, #hardware, #temp, #voltage, #fan, #power, #currect, #ups { +#vitals, #network, #memory, #filesystem, #hardware, #temp, #voltage, #fan, #power, #current, #ups { float: left; width: 451px; margin: 10px 0 0 10px; diff --git a/etc/apps/phpsysinfo/templates/phpsysinfo.css b/etc/apps/phpsysinfo/templates/phpsysinfo.css index db0196223..a07eb3b9e 100644 --- a/etc/apps/phpsysinfo/templates/phpsysinfo.css +++ b/etc/apps/phpsysinfo/templates/phpsysinfo.css @@ -45,11 +45,8 @@ h1 { } #select { - position: absolute; - top: 30px; - right: 40px; - width: 370px; text-align: right; + padding: 10px; } #select select {