* Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme
- Adding SM2 panel [SME: 13004] - Upgrade to phpsysinfo 3.4.4 - Add code to delete inline styles and add css to make it look better. - version saved / built uses the static version, which means no drops downs and choices.
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* coretemp sensor class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.coretemp.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting hardware temperature information through sysctl
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @author William Johansson <radar@radhuset.org>
|
||||
* @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 Coretemp extends Sensors
|
||||
{
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
$smp = 1;
|
||||
CommonFunctions::executeProgram('sysctl', '-n kern.smp.cpus', $smp);
|
||||
for ($i = 0; $i < $smp; $i++) {
|
||||
$temp = 0;
|
||||
if (CommonFunctions::executeProgram('sysctl', '-n dev.cpu.'.$i.'.temperature', $temp)) {
|
||||
$temp = preg_replace('/C/', '', $temp);
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("CPU ".($i + 1));
|
||||
$dev->setValue($temp);
|
||||
$dev->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
}
|
||||
}
|
96
root/opt/phpsysinfo/includes/mb/class.cpumem.inc.php
Normal file
96
root/opt/phpsysinfo/includes/mb/class.cpumem.inc.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* cpumem sensor class, getting hardware sensors information of CPU and memory
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @author William Johansson <radar@radhuset.org>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class CpuMem extends Hwmon
|
||||
{
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
|
||||
$hwpaths = CommonFunctions::findglob("/sys/devices/platform/coretemp.*/", GLOB_NOSORT);
|
||||
if (is_array($hwpaths) && (count($hwpaths) > 0)) {
|
||||
$hwpaths2 = CommonFunctions::findglob("/sys/devices/platform/coretemp.*/hwmon/hwmon*/", GLOB_NOSORT);
|
||||
if (is_array($hwpaths2) && (count($hwpaths2) > 0)) {
|
||||
$hwpaths = array_merge($hwpaths, $hwpaths2);
|
||||
}
|
||||
$totalh = count($hwpaths);
|
||||
for ($h = 0; $h < $totalh; $h++) {
|
||||
$this->_temperature($hwpaths[$h]);
|
||||
}
|
||||
}
|
||||
} elseif (PSI_OS == 'FreeBSD') {
|
||||
$smp = 1;
|
||||
CommonFunctions::executeProgram('sysctl', '-n kern.smp.cpus', $smp);
|
||||
for ($i = 0; $i < $smp; $i++) {
|
||||
$temp = 0;
|
||||
if (CommonFunctions::executeProgram('sysctl', '-n dev.cpu.'.$i.'.temperature', $temp)) {
|
||||
$temp = preg_replace('/,/', '.', preg_replace('/C/', '', $temp));
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("CPU ".($i + 1));
|
||||
$dev->setValue($temp);
|
||||
// $dev->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
} elseif ((PSI_OS == 'WINNT') || defined('PSI_EMU_HOSTNAME')) {
|
||||
$allCpus = WINNT::_get_Win32_Processor();
|
||||
foreach ($allCpus as $oneCpu) if (isset($oneCpu['CurrentVoltage']) && ($oneCpu['CurrentVoltage'] > 0)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($oneCpu['DeviceID']);
|
||||
$dev->setValue($oneCpu['CurrentVoltage']/10);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
$allMems = WINNT::_get_Win32_PhysicalMemory();
|
||||
$counter = 0;
|
||||
foreach ($allMems as $oneMem) if (isset($oneMem['ConfiguredVoltage']) && ($oneMem['ConfiguredVoltage'] > 0)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName('Mem'.($counter++));
|
||||
$dev->setValue($oneMem['ConfiguredVoltage']/1000);
|
||||
if (isset($oneMem['MaxVoltage']) && ($oneMem['MaxVoltage'] > 0)) {
|
||||
$dev->setMax($oneMem['MaxVoltage']/1000);
|
||||
}
|
||||
if (isset($oneMem['MinVoltage']) && ($oneMem['MinVoltage'] > 0)) {
|
||||
$dev->setMin($oneMem['MinVoltage']/1000);
|
||||
}
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) {
|
||||
$dmimd = CommonFunctions::readdmimemdata();
|
||||
$counter = 0;
|
||||
foreach ($dmimd as $mem) {
|
||||
if (isset($mem['Size']) && preg_match('/^(\d+)\s(M|G)B$/', $mem['Size'], $size) && ($size[1] > 0)
|
||||
&& isset($mem['Configured Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Configured Voltage'], $voltage) && ($voltage[1] > 0)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName('Mem'.($counter++));
|
||||
$dev->setValue($voltage[1]);
|
||||
if (isset($mem['Minimum Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Minimum Voltage'], $minv) && ($minv[1] > 0)) {
|
||||
$dev->setMin($minv[1]);
|
||||
}
|
||||
if (isset($mem['Maximum Voltage']) && preg_match('/^([\d\.]+)\sV$/', $mem['Maximum Voltage'], $maxv) && ($maxv[1] > 0)) {
|
||||
$dev->setMax($maxv[1]);
|
||||
}
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
122
root/opt/phpsysinfo/includes/mb/class.fortisensor.inc.php
Normal file
122
root/opt/phpsysinfo/includes/mb/class.fortisensor.inc.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* fortisensor sensor class, getting hardware sensors information from Fortinet devices
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2022 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class FortiSensor extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private array
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$lines = "";
|
||||
if (defined('PSI_EMU_PORT') && CommonFunctions::executeProgram('execute', 'sensor list', $resulte, false) && ($resulte !== "")
|
||||
&& preg_match('/^(.*[\$#]\s*)/', $resulte, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$resulti = substr($resulte, strlen($resulto[1][0]));
|
||||
if (preg_match('/(\n.*[\$#])$/', $resulti, $resulto, PREG_OFFSET_CAPTURE)) {
|
||||
$lines = substr($resulti, 0, $resulto[1][1]);
|
||||
}
|
||||
}
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^\s*\d+\s(.+)\sTemperature\s+([\d\.]+)\s\S*C\s*$/', $line, $data)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
} elseif (preg_match('/^\s*\d+\s(.+)\s+alarm=(\d)\s+value=(\d+)\s/', $line, $data)
|
||||
&& !preg_match('/fan| vin/i', $data[1])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($data[1]));
|
||||
$dev->setValue($data[3]);
|
||||
if ($data[2] != 0) {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^\s*\d+\s(.+)\s+alarm=(\d)\s+value=([\d\.]+)\s/', $line, $data)
|
||||
&& preg_match('/\./', $data[3])
|
||||
&& !preg_match('/fan|temp/i', $data[1])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($data[1]));
|
||||
$dev->setValue($data[3]);
|
||||
if ($data[2] != 0) {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^\s*\d+\s(.+)\s+alarm=(\d)\s+value=(\d+)\s/', $line, $data)
|
||||
&& preg_match('/fan/i', $data[1])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($data[1]));
|
||||
$dev->setValue($data[3]);
|
||||
if ($data[2] != 0) {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
}
|
||||
}
|
@@ -1,25 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* freeipmi sensor class
|
||||
* freeipmi sensor class, getting information from ipmi-sensors
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @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 <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2014 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -33,24 +22,23 @@ class FreeIPMI extends Sensors
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
* fill the private content var through command or data access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_FREEIPMI_ACCESS')?strtolower(PSI_SENSOR_FREEIPMI_ACCESS):'command') {
|
||||
case 'command':
|
||||
CommonFunctions::executeProgram('ipmi-sensors', '--output-sensor-thresholds', $lines);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$this->_lines = preg_split("/\r?\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);
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('freeipmi.tmp', $lines)) {
|
||||
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
$this->error->addConfigError('__construct()', '[sensor_freeipmi] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +140,7 @@ class FreeIPMI extends Sensors
|
||||
$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->setMbCurrent($dev);
|
||||
@@ -159,12 +148,31 @@ class FreeIPMI extends Sensors
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get other information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _other()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[4] == "N/A"
|
||||
&& $buffer[2] != "OEM Reserved" && $buffer[11] != "N/A") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[1].' ('.$buffer[2].')');
|
||||
$dev->setValue(trim($buffer[11], '\''));
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
@@ -173,5 +181,6 @@ class FreeIPMI extends Sensors
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
$this->_other();
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* hddtemp sensor class
|
||||
* hddtemp sensor class, getting information from hddtemp
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.hddtemp.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from hddtemp
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @author T.A. van Roermund <timo@van-roermund.nl>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -30,16 +19,16 @@ class HDDTemp extends Sensors
|
||||
* get the temperature information from hddtemp
|
||||
* access is available through tcp or command
|
||||
*
|
||||
* @return array temperatures in array
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
$ar_buf = array();
|
||||
switch (strtolower(PSI_HDD_TEMP)) {
|
||||
case "tcp":
|
||||
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_HDDTEMP_ACCESS')?strtolower(PSI_SENSOR_HDDTEMP_ACCESS):'command') {
|
||||
case 'tcp':
|
||||
$lines = '';
|
||||
// Timo van Roermund: connect to the hddtemp daemon, use a 5 second timeout.
|
||||
$fp = @fsockopen('localhost', 7634, $errno, $errstr, 5);
|
||||
$fp = @fsockopen(defined('PSI_EMU_HOSTNAME')?PSI_EMU_HOSTNAME:'localhost', 7634, $errno, $errstr, 5);
|
||||
// if connected, read the output of the hddtemp daemon
|
||||
if ($fp) {
|
||||
while (!feof($fp)) {
|
||||
@@ -52,7 +41,7 @@ class HDDTemp extends Sensors
|
||||
$lines = str_replace("||", "|\n|", $lines);
|
||||
$ar_buf = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case "command":
|
||||
case 'command':
|
||||
$strDrives = "";
|
||||
$strContent = "";
|
||||
$hddtemp_value = "";
|
||||
@@ -100,8 +89,7 @@ class HDDTemp extends Sensors
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError("temperature()", "PSI_HDD_TEMP");
|
||||
break;
|
||||
$this->error->addConfigError("temperature()", "[sensor_hddtemp] ACCESS");
|
||||
}
|
||||
// Timo van Roermund: parse the info from the hddtemp daemon.
|
||||
foreach ($ar_buf as $line) {
|
||||
@@ -114,7 +102,7 @@ class HDDTemp extends Sensors
|
||||
if (is_numeric($data[3])) {
|
||||
$dev->setValue($data[3]);
|
||||
}
|
||||
$dev->setMax(60);
|
||||
// $dev->setMax(60);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +114,7 @@ class HDDTemp extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* healthd sensor class
|
||||
* healthd sensor class, getting information from healthd
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@@ -8,18 +8,7 @@
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.healthd.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from healthd
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -30,28 +19,33 @@ class Healthd extends Sensors
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_lines = array();
|
||||
private $_values = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
* fill the private content var through command or data access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
if (PSI_OS == 'FreeBSD') switch (defined('PSI_SENSOR_HEALTHD_ACCESS')?strtolower(PSI_SENSOR_HEALTHD_ACCESS):'command') {
|
||||
case 'command':
|
||||
$lines = "";
|
||||
CommonFunctions::executeProgram('healthdc', '-t', $lines);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (CommonFunctions::executeProgram('healthdc', '-t', $lines)) {
|
||||
$lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
|
||||
if (count($lines0) == 1) {
|
||||
$this->_values = preg_split("/\t+/", $lines0[0]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'file':
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/healthd.txt', $lines)) {
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('healthd.tmp', $lines)) {
|
||||
$lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
|
||||
if (count($lines0) == 1) {
|
||||
$this->_values = preg_split("/\t+/", $lines0[0]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
$this->error->addConfigError('__construct()', '[sensor_healthd] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,22 +56,23 @@ class Healthd extends Sensors
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
$ar_buf = preg_split("/\t+/", $this->_lines);
|
||||
$dev1 = new SensorDevice();
|
||||
$dev1->setName('temp1');
|
||||
$dev1->setValue($ar_buf[1]);
|
||||
$dev1->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev1);
|
||||
$dev2 = new SensorDevice();
|
||||
$dev2->setName('temp1');
|
||||
$dev2->setValue($ar_buf[2]);
|
||||
$dev2->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev2);
|
||||
$dev3 = new SensorDevice();
|
||||
$dev3->setName('temp1');
|
||||
$dev3->setValue($ar_buf[3]);
|
||||
$dev3->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev3);
|
||||
if (count($this->_values) == 14) {
|
||||
$dev1 = new SensorDevice();
|
||||
$dev1->setName('temp1');
|
||||
$dev1->setValue($this->_values[1]);
|
||||
// $dev1->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev1);
|
||||
$dev2 = new SensorDevice();
|
||||
$dev2->setName('temp1');
|
||||
$dev2->setValue($this->_values[2]);
|
||||
// $dev2->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev2);
|
||||
$dev3 = new SensorDevice();
|
||||
$dev3->setName('temp1');
|
||||
$dev3->setValue($this->_values[3]);
|
||||
// $dev3->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,60 +82,62 @@ class Healthd extends Sensors
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
$ar_buf = preg_split("/\t+/", $this->_lines);
|
||||
$dev1 = new SensorDevice();
|
||||
$dev1->setName('fan1');
|
||||
$dev1->setValue($ar_buf[4]);
|
||||
$dev1->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev1);
|
||||
$dev2 = new SensorDevice();
|
||||
$dev2->setName('fan2');
|
||||
$dev2->setValue($ar_buf[5]);
|
||||
$dev2->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev2);
|
||||
$dev3 = new SensorDevice();
|
||||
$dev3->setName('fan3');
|
||||
$dev3->setValue($ar_buf[6]);
|
||||
$dev3->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev3);
|
||||
if (count($this->_values) == 14) {
|
||||
$dev1 = new SensorDevice();
|
||||
$dev1->setName('fan1');
|
||||
$dev1->setValue($this->_values[4]);
|
||||
// $dev1->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev1);
|
||||
$dev2 = new SensorDevice();
|
||||
$dev2->setName('fan2');
|
||||
$dev2->setValue($this->_values[5]);
|
||||
// $dev2->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev2);
|
||||
$dev3 = new SensorDevice();
|
||||
$dev3->setName('fan3');
|
||||
$dev3->setValue($this->_values[6]);
|
||||
// $dev3->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return array voltage in array with lable
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
$ar_buf = preg_split("/\t+/", $this->_lines);
|
||||
$dev1 = new SensorDevice();
|
||||
$dev1->setName('Vcore1');
|
||||
$dev1->setValue($ar_buf[7]);
|
||||
$this->mbinfo->setMbVolt($dev1);
|
||||
$dev2 = new SensorDevice();
|
||||
$dev2->setName('Vcore2');
|
||||
$dev2->setValue($ar_buf[8]);
|
||||
$this->mbinfo->setMbVolt($dev2);
|
||||
$dev3 = new SensorDevice();
|
||||
$dev3->setName('3volt');
|
||||
$dev3->setValue($ar_buf[9]);
|
||||
$this->mbinfo->setMbVolt($dev3);
|
||||
$dev4 = new SensorDevice();
|
||||
$dev4->setName('+5Volt');
|
||||
$dev4->setValue($ar_buf[10]);
|
||||
$this->mbinfo->setMbVolt($dev4);
|
||||
$dev5 = new SensorDevice();
|
||||
$dev5->setName('+12Volt');
|
||||
$dev5->setValue($ar_buf[11]);
|
||||
$this->mbinfo->setMbVolt($dev5);
|
||||
$dev6 = new SensorDevice();
|
||||
$dev6->setName('-12Volt');
|
||||
$dev6->setValue($ar_buf[12]);
|
||||
$this->mbinfo->setMbVolt($dev6);
|
||||
$dev7 = new SensorDevice();
|
||||
$dev7->setName('-5Volt');
|
||||
$dev7->setValue($ar_buf[13]);
|
||||
$this->mbinfo->setMbVolt($dev7);
|
||||
if (count($this->_values) == 14) {
|
||||
$dev1 = new SensorDevice();
|
||||
$dev1->setName('Vcore1');
|
||||
$dev1->setValue($this->_values[7]);
|
||||
$this->mbinfo->setMbVolt($dev1);
|
||||
$dev2 = new SensorDevice();
|
||||
$dev2->setName('Vcore2');
|
||||
$dev2->setValue($this->_values[8]);
|
||||
$this->mbinfo->setMbVolt($dev2);
|
||||
$dev3 = new SensorDevice();
|
||||
$dev3->setName('3volt');
|
||||
$dev3->setValue($this->_values[9]);
|
||||
$this->mbinfo->setMbVolt($dev3);
|
||||
$dev4 = new SensorDevice();
|
||||
$dev4->setName('+5Volt');
|
||||
$dev4->setValue($this->_values[10]);
|
||||
$this->mbinfo->setMbVolt($dev4);
|
||||
$dev5 = new SensorDevice();
|
||||
$dev5->setName('+12Volt');
|
||||
$dev5->setValue($this->_values[11]);
|
||||
$this->mbinfo->setMbVolt($dev5);
|
||||
$dev6 = new SensorDevice();
|
||||
$dev6->setName('-12Volt');
|
||||
$dev6->setValue($this->_values[12]);
|
||||
$this->mbinfo->setMbVolt($dev6);
|
||||
$dev7 = new SensorDevice();
|
||||
$dev7->setName('-5Volt');
|
||||
$dev7->setValue($this->_values[13]);
|
||||
$this->mbinfo->setMbVolt($dev7);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +145,7 @@ class Healthd extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
267
root/opt/phpsysinfo/includes/mb/class.hwmon.inc.php
Normal file
267
root/opt/phpsysinfo/includes/mb/class.hwmon.inc.php
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
/**
|
||||
* hwmon sensor class, getting hardware sensors information from /sys/class/hwmon/hwmon
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2016 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class Hwmon extends Sensors
|
||||
{
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @param string $hwpath
|
||||
* @return void
|
||||
*/
|
||||
protected function _temperature($hwpath)
|
||||
{
|
||||
$sensor = CommonFunctions::findglob($hwpath."temp*_input", GLOB_NOSORT);
|
||||
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
|
||||
$buf = "";
|
||||
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setValue($buf/1000);
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/\/[^\/]*_input$/", "/name"))!==null) {
|
||||
$name = " (".$buf.")";
|
||||
} else {
|
||||
$name = "";
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_label"))!==null) {
|
||||
$dev->setName($buf.$name);
|
||||
} else {
|
||||
$labelname = trim(preg_replace("/_input$/", "", pathinfo($sensor[$i], PATHINFO_BASENAME)));
|
||||
if (($name == " (drivetemp)") && (count($buf = CommonFunctions::gdc($hwpath . "device/block", false)))) {
|
||||
$labelname = "/dev/" . $buf[0];
|
||||
if (($buf = CommonFunctions::rolv($hwpath . "device/model"))!==null) {
|
||||
$labelname .= " (".$buf.")";
|
||||
$name = "";
|
||||
}
|
||||
}
|
||||
if ($labelname !== "") {
|
||||
$dev->setName($labelname.$name);
|
||||
} else {
|
||||
$dev->setName('unknown'.$name);
|
||||
}
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_crit"))!==null) {
|
||||
$dev->setMax($buf/1000);
|
||||
if (CommonFunctions::rolv($sensor[$i], "/_input$/", "_crit_alarm")==="1") {
|
||||
$dev->setEvent("Critical Alarm");
|
||||
}
|
||||
} elseif (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_max"))!==null) {
|
||||
$dev->setMax($buf/1000);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @param string $hwpath
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage($hwpath)
|
||||
{
|
||||
$sensor = CommonFunctions::findglob($hwpath."in*_input", GLOB_NOSORT);
|
||||
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
|
||||
$buf = "";
|
||||
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setValue($buf/1000);
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/\/[^\/]*_input$/", "/name"))!==null) {
|
||||
$name = " (".$buf.")";
|
||||
} else {
|
||||
$name = "";
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_label"))!==null) {
|
||||
$dev->setName($buf.$name);
|
||||
} else {
|
||||
$labelname = trim(preg_replace("/_input$/", "", pathinfo($sensor[$i], PATHINFO_BASENAME)));
|
||||
if ($labelname !== "") {
|
||||
$dev->setName($labelname.$name);
|
||||
} else {
|
||||
$dev->setName('unknown'.$name);
|
||||
}
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_max"))!==null) {
|
||||
$dev->setMax($buf/1000);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_min"))!==null) {
|
||||
$dev->setMin($buf/1000);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_alarm"))==="1") {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @param string $hwpath
|
||||
* @return void
|
||||
*/
|
||||
protected function _fans($hwpath)
|
||||
{
|
||||
$sensor = CommonFunctions::findglob($hwpath."fan*_input", GLOB_NOSORT);
|
||||
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
|
||||
$buf = "";
|
||||
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setValue($buf);
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/\/[^\/]*_input$/", "/name"))!==null) {
|
||||
$name = " (".$buf.")";
|
||||
} else {
|
||||
$name = "";
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_label"))!==null) {
|
||||
$dev->setName($buf.$name);
|
||||
} else {
|
||||
$labelname = trim(preg_replace("/_input$/", "", pathinfo($sensor[$i], PATHINFO_BASENAME)));
|
||||
if ($labelname !== "") {
|
||||
$dev->setName($labelname.$name);
|
||||
} else {
|
||||
$dev->setName('unknown'.$name);
|
||||
}
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_full_speed"))!==null) {
|
||||
$dev->setMax($buf);
|
||||
} elseif (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_max"))!==null) {
|
||||
$dev->setMax($buf);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_min"))!==null) {
|
||||
$dev->setMin($buf);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_alarm"))==="1") {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @param string $hwpath
|
||||
* @return void
|
||||
*/
|
||||
private function _power($hwpath)
|
||||
{
|
||||
$sensor = CommonFunctions::findglob($hwpath."power*_input", GLOB_NOSORT);
|
||||
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
|
||||
$buf = "";
|
||||
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setValue($buf/1000000);
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/\/[^\/]*_input$/", "/name"))!==null) {
|
||||
$name = " (".$buf.")";
|
||||
} else {
|
||||
$name = "";
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_label"))!==null) {
|
||||
$dev->setName($buf.$name);
|
||||
} else {
|
||||
$labelname = trim(preg_replace("/_input$/", "", pathinfo($sensor[$i], PATHINFO_BASENAME)));
|
||||
if ($labelname !== "") {
|
||||
$dev->setName($labelname.$name);
|
||||
} else {
|
||||
$dev->setName('unknown'.$name);
|
||||
}
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_max"))!==null) {
|
||||
$dev->setMax($buf/1000000);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_min"))!==null) {
|
||||
$dev->setMin($buf/1000000);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_alarm"))==="1") {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
* @param string $hwpath
|
||||
* @return void
|
||||
*/
|
||||
private function _current($hwpath)
|
||||
{
|
||||
$sensor = CommonFunctions::findglob($hwpath."curr*_input", GLOB_NOSORT);
|
||||
if (is_array($sensor) && (($total = count($sensor)) > 0)) {
|
||||
$buf = "";
|
||||
for ($i = 0; $i < $total; $i++) if (($buf = CommonFunctions::rolv($sensor[$i]))!==null) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setValue($buf/1000);
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/\/[^\/]*_input$/", "/name"))!==null) {
|
||||
$name = " (".$buf.")";
|
||||
} else {
|
||||
$name = "";
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_label"))!==null) {
|
||||
$dev->setName($buf.$name);
|
||||
} else {
|
||||
$labelname = trim(preg_replace("/_input$/", "", pathinfo($sensor[$i], PATHINFO_BASENAME)));
|
||||
if ($labelname !== "") {
|
||||
$dev->setName($labelname.$name);
|
||||
} else {
|
||||
$dev->setName('unknown'.$name);
|
||||
}
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_max"))!==null) {
|
||||
$dev->setMax($buf/1000);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_min"))!==null) {
|
||||
$dev->setMin($buf/1000);
|
||||
}
|
||||
if (($buf = CommonFunctions::rolv($sensor[$i], "/_input$/", "_alarm"))==="1") {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbCurrent($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) {
|
||||
$hwpaths = CommonFunctions::findglob("/sys/class/hwmon/hwmon*/", GLOB_NOSORT);
|
||||
if (is_array($hwpaths) && (count($hwpaths) > 0)) {
|
||||
$hwpaths2 = CommonFunctions::findglob("/sys/class/hwmon/hwmon*/device/", GLOB_NOSORT);
|
||||
if (is_array($hwpaths2) && (count($hwpaths2) > 0)) {
|
||||
$hwpaths = array_merge($hwpaths, $hwpaths2);
|
||||
}
|
||||
$totalh = count($hwpaths);
|
||||
for ($h = 0; $h < $totalh; $h++) {
|
||||
$this->_temperature($hwpaths[$h]);
|
||||
$this->_voltage($hwpaths[$h]);
|
||||
$this->_fans($hwpaths[$h]);
|
||||
$this->_power($hwpaths[$h]);
|
||||
$this->_current($hwpaths[$h]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* hwsensors sensor class
|
||||
* hwsensors sensor class, getting information from hwsensors
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@@ -8,18 +8,7 @@
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.hwsensors.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from hwsensors
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -33,15 +22,17 @@ class HWSensors extends Sensors
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
* fill the private content var through command
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$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);
|
||||
if (PSI_OS == 'OpenBSD') {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +136,7 @@ class HWSensors extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
@@ -1,197 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* ipmi sensor class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.ipmi.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from ipmitool
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @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 IPMI 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('ipmitool', 'sensor', $lines);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case 'file':
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/ipmi.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] == "degrees C" && $buffer[3] != "na") {
|
||||
$dev = new SensorDevice();
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Volts" && $buffer[3] != "na") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[0]);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "RPM" && $buffer[3] != "na") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[0]);
|
||||
$dev->setValue($buffer[1]);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _power()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Watts" && $buffer[3] != "na") {
|
||||
$dev = new SensorDevice();
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _current()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Amps" && $buffer[3] != "na") {
|
||||
$dev = new SensorDevice();
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
}
|
||||
}
|
321
root/opt/phpsysinfo/includes/mb/class.ipmicfg.inc.php
Normal file
321
root/opt/phpsysinfo/includes/mb/class.ipmicfg.inc.php
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
/**
|
||||
* ipmicfg sensor class, getting information from ipmicfg -sdr
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2021 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class IPMIcfg extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through command or data access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_IPMICFG_ACCESS')?strtolower(PSI_SENSOR_IPMICFG_ACCESS):'command') {
|
||||
case 'command':
|
||||
if ((!defined('PSI_SENSOR_IPMICFG_SDR') || (PSI_SENSOR_IPMICFG_SDR!==false)) ||
|
||||
(!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (PSI_SENSOR_IPMICFG_PSFRUINFO!==false)) ||
|
||||
(!defined('PSI_SENSOR_IPMICFG_PMINFO') || (PSI_SENSOR_IPMICFG_PMINFO!==false))) {
|
||||
$lines='';
|
||||
$first=true;
|
||||
if (!defined('PSI_SENSOR_IPMICFG_SDR') || (PSI_SENSOR_IPMICFG_SDR!==false)) {
|
||||
$linestmp='';
|
||||
if (CommonFunctions::executeProgram('ipmicfg', '-sdr', $linestmp)) {
|
||||
$lines=$linestmp;
|
||||
}
|
||||
$first=false;
|
||||
}
|
||||
if (!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (PSI_SENSOR_IPMICFG_PSFRUINFO!==false)) {
|
||||
$linestmp='';
|
||||
if (CommonFunctions::executeProgram('ipmicfg', '-psfruinfo', $linestmp, $first || PSI_DEBUG)) {
|
||||
$lines.=$linestmp;
|
||||
}
|
||||
$first=false;
|
||||
}
|
||||
if (!defined('PSI_SENSOR_IPMICFG_PMINFO') || (PSI_SENSOR_IPMICFG_PMINFO!==false)) {
|
||||
$linestmp='';
|
||||
if (CommonFunctions::executeProgram('ipmicfg', '-pminfo', $linestmp, $first || PSI_DEBUG)) {
|
||||
$lines.=$linestmp;
|
||||
}
|
||||
}
|
||||
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
} else {
|
||||
$this->error->addConfigError('__construct()', '[sensor_ipmicfg] Not defined: SDR or PSFRUINFO or PMINFO');
|
||||
}
|
||||
break;
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('ipmicfg.tmp', $lines)) {
|
||||
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', '[sensor_ipmicfg] ACCESS');
|
||||
}
|
||||
|
||||
if ($this->_lines===false) {
|
||||
$this->_lines = array();
|
||||
} else {
|
||||
$pmbus=false;
|
||||
for ($licz=count($this->_lines); $licz--; $licz>0) {
|
||||
$line=$this->_lines[$licz];
|
||||
if (preg_match("/^\s*PMBus Revision\s*\|/", $line)) {
|
||||
$pmbus=true;
|
||||
} else if (preg_match("/^(\s*\[SlaveAddress = [\da..fA..F]+h\] \[)(Module )(\d+\])/", $line, $tmpbuf)) {
|
||||
$this->_lines[$licz]=$tmpbuf[1].($pmbus?"PMBus ":"SMBus ").$tmpbuf[3];
|
||||
$pmbus=false;
|
||||
} else {
|
||||
$this->_lines[$licz]=preg_replace("/\|\s*$/", "", $line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
$mdid='';
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match("/^\s*\[SlaveAddress = [\da..fA..F]+h\] \[((PMBus \d+)|(SMBus \d+))\]/", $line, $mdidtmp)) {
|
||||
$mdid=$mdidtmp[1];
|
||||
continue;
|
||||
}
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (($mdid=='') && (count($buffer)==5) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[2], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($namebuff[1]);
|
||||
if ($valbuff[1]<-128) $valbuff[1]+=256; //+256 correction
|
||||
$dev->setValue($valbuff[1]);
|
||||
if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[3], $valbuffmin)) {
|
||||
if ($valbuffmin[1]<-128) $valbuffmin[1]+=256; //+256 correction
|
||||
}
|
||||
if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[4], $valbuffmax)) {
|
||||
if ($valbuffmax[1]<-128) $valbuffmax[1]+=256; //+256 correction
|
||||
$dev->setMax($valbuffmax[1]);
|
||||
}
|
||||
if ((isset($valbuffmin[1]) && ($valbuff[1]<=$valbuffmin[1])) || (isset($valbuffmax[1]) && ($valbuff[1]>=$valbuffmax[1]))) { //own range test due to errors with +256 correction
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
} elseif (($mdid!='') && (count($buffer)==2) && preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[1], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($buffer[0])." (".$mdid.")");
|
||||
$dev->setValue($valbuff[1]);
|
||||
$this->mbinfo->setMBTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
$mdid='';
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match("/^\s*\[SlaveAddress = [\da..fA..F]+h\] \[((PMBus \d+)|(SMBus \d+))\]/", $line, $mdidtmp)) {
|
||||
$mdid=$mdidtmp[1];
|
||||
continue;
|
||||
}
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (($mdid=='') && (count($buffer)==5) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sV\s*$/", $buffer[2], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($namebuff[1]);
|
||||
$dev->setValue($valbuff[1]);
|
||||
if (preg_match("/^\s*([\d\.].+)\sV\s*$/", $buffer[3], $valbuffmin)) {
|
||||
$dev->setMin($valbuffmin[1]);
|
||||
}
|
||||
if (preg_match("/^\s*([\d\.].+)\sV\s*$/", $buffer[4], $valbuffmax)) {
|
||||
$dev->setMax($valbuffmax[1]);
|
||||
}
|
||||
if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
} elseif (($mdid!='') && (count($buffer)==2) && preg_match("/^\s*([\d\.]+)\sV\s*$/", $buffer[1], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($buffer[0])." (".$mdid.")");
|
||||
$dev->setValue($valbuff[1]);
|
||||
$this->mbinfo->setMBVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
$mdid='';
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match("/^\s*\[SlaveAddress = [\da..fA..F]+h\] \[((PMBus \d+)|(SMBus \d+))\]/", $line, $mdidtmp)) {
|
||||
$mdid=$mdidtmp[1];
|
||||
continue;
|
||||
}
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (($mdid=='') && (count($buffer)==5) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sRPM\s*$/", $buffer[2], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($namebuff[1]);
|
||||
$dev->setValue($valbuff[1]);
|
||||
if (preg_match("/^\s*(\d+)\sRPM\s*$/", $buffer[3], $valbuffmin)) {
|
||||
$dev->setMin($valbuffmin[1]);
|
||||
}
|
||||
if ((trim($buffer[0]) != "OK") && isset($valbuffmin[1])) {
|
||||
$dev->setEvent(trim($buffer[0]));
|
||||
}
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
} elseif (($mdid!='') && (count($buffer)==2) && preg_match("/^\s*(\d+)\sRPM\s*$/", $buffer[1], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($buffer[0])." (".$mdid.")");
|
||||
$dev->setValue($valbuff[1]);
|
||||
$this->mbinfo->setMBFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _power()
|
||||
{
|
||||
$mdid='';
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match("/^\s*\[SlaveAddress = [\da..fA..F]+h\] \[((PMBus \d+)|(SMBus \d+))\]/", $line, $mdidtmp)) {
|
||||
$mdid=$mdidtmp[1];
|
||||
continue;
|
||||
}
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (($mdid=='') && (count($buffer)==5) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sWatts\s*$/", $buffer[2], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($namebuff[1]);
|
||||
$dev->setValue($valbuff[1]);
|
||||
if (preg_match("/^\s*(\d+)\sWatts\s*$/", $buffer[4], $valbuffmax)) {
|
||||
$dev->setMax($valbuffmax[1]);
|
||||
}
|
||||
if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
} elseif (($mdid!='') && (count($buffer)==2) && preg_match("/^\s*(\d+)\sW\s*$/", $buffer[1], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($buffer[0])." (".$mdid.")");
|
||||
$dev->setValue($valbuff[1]);
|
||||
$this->mbinfo->setMBPower($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _current()
|
||||
{
|
||||
$mdid='';
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match("/^\s*\[SlaveAddress = [\da..fA..F]+h\] \[((PMBus \d+)|(SMBus \d+))\]/", $line, $mdidtmp)) {
|
||||
$mdid=$mdidtmp[1];
|
||||
continue;
|
||||
}
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (($mdid=='') && (count($buffer)==5) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sAmps\s*$/", $buffer[2], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($namebuff[1]);
|
||||
$dev->setValue($valbuff[1]);
|
||||
if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/", $buffer[3], $valbuffmin)) {
|
||||
$dev->setMin($valbuffmin[1]);
|
||||
}
|
||||
if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/", $buffer[4], $valbuffmax)) {
|
||||
$dev->setMax($valbuffmax[1]);
|
||||
}
|
||||
if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
|
||||
$this->mbinfo->setMbCurrent($dev);
|
||||
} elseif (($mdid!='') && (count($buffer)==2) && preg_match("/^\s*([\d\.]+)\sA\s*$/", $buffer[1], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($buffer[0])." (".$mdid.")");
|
||||
$dev->setValue($valbuff[1]);
|
||||
$this->mbinfo->setMBCurrent($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get other information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _other()
|
||||
{
|
||||
$mdid='';
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match("/^\s*\[SlaveAddress = [\da..fA..F]+h\] \[((PMBus \d+)|(SMBus \d+))\]/", $line, $mdidtmp)) {
|
||||
$mdid=$mdidtmp[1];
|
||||
continue;
|
||||
}
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (($mdid=='') && (count($buffer)>=3) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff)) {
|
||||
$buffer[2]=trim($buffer[2]);
|
||||
if ((count($buffer)==3) &&
|
||||
($buffer[2]!=="Correctable ECC / other correctable memory error") &&
|
||||
($buffer[2]!=="Not Present") &&
|
||||
($buffer[2]!=="N/A") &&
|
||||
(trim($buffer[0]) != "")) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($namebuff[1]);
|
||||
$dev->setValue($buffer[2]);
|
||||
if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
} elseif ((count($buffer)==5)&& preg_match("/(^\s*[\d\.]+\s*$)|(^\s*[\da-fA-F]{2}\s+[\da-fA-F]{2}\s+[\da-fA-F]{2}\s+[\da-fA-F]{2}\s*$)/", $buffer[2], $valbuff)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($namebuff[1]);
|
||||
$dev->setValue($buffer[0]);
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
} elseif (($mdid!='') && (count($buffer)==2) && ((trim($buffer[0])=="Status") || (trim($buffer[0])=="Current Sharing Control"))) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($buffer[0])." (".$mdid.")");
|
||||
$dev->setValue($buffer[1]);
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
$this->_other();
|
||||
}
|
||||
}
|
320
root/opt/phpsysinfo/includes/mb/class.ipmitool.inc.php
Normal file
320
root/opt/phpsysinfo/includes/mb/class.ipmitool.inc.php
Normal file
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
/**
|
||||
* ipmitool sensor class, getting information from ipmitool
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class IPMItool extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_buf = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through command or data access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$lines = "";
|
||||
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_IPMITOOL_ACCESS')?strtolower(PSI_SENSOR_IPMITOOL_ACCESS):'command') {
|
||||
case 'command':
|
||||
CommonFunctions::executeProgram('ipmitool', 'sensor -v', $lines);
|
||||
break;
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT')) {
|
||||
CommonFunctions::rftsdata('ipmitool.tmp', $lines);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', '[sensor_ipmitool] ACCESS');
|
||||
}
|
||||
if (trim($lines) !== "") {
|
||||
if (preg_match("/^Sensor ID\s+/", $lines)) { //new data format ('ipmitool sensor -v')
|
||||
$lines = preg_replace("/\n?Unable to read sensor/", "\nUnable to read sensor", $lines);
|
||||
$sensors = preg_split("/Sensor ID\s+/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($sensors as $sensor) {
|
||||
if (preg_match("/^:\s*(.+)\s\((0x[a-f\d]+)\)\r?\n/", $sensor, $name) && (($name1 = trim($name[1])) !== "")) {
|
||||
$sensorvalues = preg_split("/\r?\n/", $sensor, -1, PREG_SPLIT_NO_EMPTY);
|
||||
unset($sensorvalues[0]); //skip first
|
||||
$sens = array();
|
||||
$was = false;
|
||||
foreach ($sensorvalues as $sensorvalue) {
|
||||
if (preg_match("/^\s+\[(.+)\]$/", $sensorvalue, $buffer) && (($buffer1 = trim($buffer[1])) !== "")) {
|
||||
if (isset($sens['State'])) {
|
||||
$sens['State'] .= ', '.$buffer1;
|
||||
} else {
|
||||
$sens['State'] = $buffer1;
|
||||
}
|
||||
$was = true;
|
||||
} elseif (preg_match("/^([^:]+):(.+)$/", $sensorvalue, $buffer)
|
||||
&& (($buffer1 = trim($buffer[1])) !== "")
|
||||
&& (($buffer2 = trim($buffer[2])) !== "")) {
|
||||
$sens[$buffer1] = $buffer2;
|
||||
$was = true;
|
||||
}
|
||||
}
|
||||
if ($was && !isset($sens['Unable to read sensor'])) {
|
||||
$sens['Sensor'] = $name1;
|
||||
if (isset($sens['Sensor Reading'])
|
||||
&& preg_match("/^([\d\.]+)\s+\([^\)]*\)\s+(.+)$/", $sens['Sensor Reading'], $buffer)
|
||||
&& (($buffer2 = trim($buffer[2])) !== "")) {
|
||||
$sens['Value'] = $buffer[1];
|
||||
$sens['Unit'] = $buffer2;
|
||||
}
|
||||
$this->_buf[intval($name[2], 0)] = $sens;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (count($lines)>0) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $lines[0]);
|
||||
if (count($buffer)>8) { //old data format ('ipmitool sensor')
|
||||
foreach ($lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (count($buffer)>8) {
|
||||
$sens = array();
|
||||
$sens['Sensor'] = $buffer[0];
|
||||
switch ($buffer[2]) {
|
||||
case 'degrees C':
|
||||
$sens['Value'] = $buffer[1];
|
||||
$sens['Unit'] = $buffer[2];
|
||||
$sens['Upper Critical'] = $buffer[8];
|
||||
$sens['Sensor Type (Threshold)'] = 'Temperature';
|
||||
break;
|
||||
case 'Volts':
|
||||
$sens['Value'] = $buffer[1];
|
||||
$sens['Unit'] = $buffer[2];
|
||||
$sens['Lower Critical'] = $buffer[5];
|
||||
$sens['Upper Critical'] = $buffer[8];
|
||||
$sens['Sensor Type (Threshold)'] = 'Voltage';
|
||||
break;
|
||||
case 'RPM':
|
||||
$sens['Value'] = $buffer[1];
|
||||
$sens['Unit'] = $buffer[2];
|
||||
$sens['Lower Critical'] = $buffer[5];
|
||||
$sens['Upper Critical'] = $buffer[8];
|
||||
$sens['Sensor Type (Threshold)'] = 'Fan';
|
||||
break;
|
||||
case 'Watts':
|
||||
$sens['Value'] = $buffer[1];
|
||||
$sens['Unit'] = $buffer[2];
|
||||
$sens['Upper Critical'] = $buffer[8];
|
||||
$sens['Sensor Type (Threshold)'] = 'Current';
|
||||
break;
|
||||
case 'Amps':
|
||||
$sens['Value'] = $buffer[1];
|
||||
$sens['Unit'] = $buffer[2];
|
||||
$sens['Lower Critical'] = $buffer[5];
|
||||
$sens['Upper Critical'] = $buffer[8];
|
||||
$sens['Sensor Type (Threshold)'] = 'Current';
|
||||
break;
|
||||
case 'discrete':
|
||||
if (($buffer[1]==='0x0') || ($buffer[1]==='0x1')) {
|
||||
$sens['State'] = $buffer[1];
|
||||
$sens['Sensor Type (Discrete)'] = '';
|
||||
$sens['State'] = $buffer[1];
|
||||
}
|
||||
}
|
||||
$this->_buf[] = $sens;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
foreach ($this->_buf as $sensor) {
|
||||
if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Temperature'))
|
||||
||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Temperature')))
|
||||
&& isset($sensor['Unit']) && ($sensor['Unit'] == 'degrees C')
|
||||
&& isset($sensor['Value'])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor['Sensor']);
|
||||
$dev->setValue($sensor['Value']);
|
||||
if (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")) {
|
||||
$dev->setMax($max);
|
||||
}
|
||||
if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
|
||||
$dev->setEvent($status);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
foreach ($this->_buf as $sensor) {
|
||||
if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Voltage'))
|
||||
||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Voltage')))
|
||||
&& isset($sensor['Unit']) && ($sensor['Unit'] == 'Volts')
|
||||
&& isset($sensor['Value'])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor['Sensor']);
|
||||
$dev->setValue($sensor['Value']);
|
||||
if (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")) {
|
||||
$dev->setMax($max);
|
||||
}
|
||||
if (isset($sensor['Lower Critical']) && (($min = $sensor['Lower Critical']) != "na")) {
|
||||
$dev->setMin($min);
|
||||
}
|
||||
if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
|
||||
$dev->setEvent($status);
|
||||
}
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
foreach ($this->_buf as $sensor) {
|
||||
if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Fan'))
|
||||
||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Fan')))
|
||||
&& isset($sensor['Unit']) && ($sensor['Unit'] == 'RPM')
|
||||
&& isset($sensor['Value'])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor['Sensor']);
|
||||
$dev->setValue($value = $sensor['Value']);
|
||||
if (isset($sensor['Lower Critical']) && (($min = $sensor['Lower Critical']) != "na")) {
|
||||
$dev->setMin($min);
|
||||
} elseif (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")
|
||||
&& ($max < $value)) { // max instead min issue
|
||||
$dev->setMin($max);
|
||||
}
|
||||
if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
|
||||
$dev->setEvent($status);
|
||||
}
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _power()
|
||||
{
|
||||
foreach ($this->_buf as $sensor) {
|
||||
if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Current'))
|
||||
||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Current')))
|
||||
&& isset($sensor['Unit']) && ($sensor['Unit'] == 'Watts')
|
||||
&& isset($sensor['Value'])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor['Sensor']);
|
||||
$dev->setValue($sensor['Value']);
|
||||
if (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")) {
|
||||
$dev->setMax($max);
|
||||
}
|
||||
if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
|
||||
$dev->setEvent($status);
|
||||
}
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _current()
|
||||
{
|
||||
foreach ($this->_buf as $sensor) {
|
||||
if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Current'))
|
||||
||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Current')))
|
||||
&& isset($sensor['Unit']) && ($sensor['Unit'] == 'Amps')
|
||||
&& isset($sensor['Value'])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor['Sensor']);
|
||||
$dev->setValue($sensor['Value']);
|
||||
if (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")) {
|
||||
$dev->setMax($max);
|
||||
}
|
||||
if (isset($sensor['Lower Critical']) && (($min = $sensor['Lower Critical']) != "na")) {
|
||||
$dev->setMin($min);
|
||||
}
|
||||
if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
|
||||
$dev->setEvent($status);
|
||||
}
|
||||
$this->mbinfo->setMbCurrent($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get other information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _other()
|
||||
{
|
||||
foreach ($this->_buf as $sensor) {
|
||||
if (isset($sensor['Sensor Type (Discrete)'])) {
|
||||
$dev = new SensorDevice();
|
||||
if ($sensor['Sensor Type (Discrete)']!=='') {
|
||||
$dev->setName($sensor['Sensor'].' ('.$sensor['Sensor Type (Discrete)'].')');
|
||||
} else {
|
||||
$dev->setName($sensor['Sensor']);
|
||||
}
|
||||
if (isset($sensor['State'])) {
|
||||
$dev->setValue($sensor['State']);
|
||||
} else {
|
||||
$dev->setValue('0x0');
|
||||
}
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
$this->_other();
|
||||
}
|
||||
}
|
@@ -1,25 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* ipmiutil sensor class
|
||||
* ipmiutil sensor class, getting information from ipmi-sensors
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @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 <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2014 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -33,24 +22,23 @@ class IPMIutil extends Sensors
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
* fill the private content var through command or data access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_IPMIUTIL_ACCESS')?strtolower(PSI_SENSOR_IPMIUTIL_ACCESS):'command') {
|
||||
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)) {
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('ipmiutil.tmp', $lines)) {
|
||||
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
$this->error->addConfigError('__construct()', '[sensor_ipmiutil] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +51,10 @@ class IPMIutil extends Sensors
|
||||
{
|
||||
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)) {
|
||||
if (isset($buffer[2]) && $buffer[2] == "Temperature"
|
||||
&& $buffer[1] == "Full"
|
||||
&& isset($buffer[6]) && preg_match("/^(\S+)\sC$/", $buffer[6], $value)
|
||||
&& $buffer[5] !== "Init") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
@@ -90,7 +81,10 @@ class IPMIutil extends Sensors
|
||||
{
|
||||
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)) {
|
||||
if (isset($buffer[2]) && $buffer[2] == "Voltage"
|
||||
&& $buffer[1] == "Full"
|
||||
&& isset($buffer[6]) && preg_match("/^(\S+)\sV$/", $buffer[6], $value)
|
||||
&& $buffer[5] !== "Init") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
@@ -123,7 +117,10 @@ class IPMIutil extends Sensors
|
||||
{
|
||||
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)) {
|
||||
if (isset($buffer[2]) && $buffer[2] == "Fan"
|
||||
&& $buffer[1] == "Full"
|
||||
&& isset($buffer[6]) && preg_match("/^(\S+)\sRPM$/", $buffer[6], $value)
|
||||
&& $buffer[5] !== "Init") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
@@ -157,7 +154,10 @@ class IPMIutil extends Sensors
|
||||
{
|
||||
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)) {
|
||||
if (isset($buffer[2]) && $buffer[2] == "Current"
|
||||
&& $buffer[1] == "Full"
|
||||
&& isset($buffer[6]) && preg_match("/^(\S+)\sW$/", $buffer[6], $value)
|
||||
&& $buffer[5] !== "Init") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
@@ -184,11 +184,20 @@ class IPMIutil extends Sensors
|
||||
{
|
||||
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)) {
|
||||
if (isset($buffer[2]) && $buffer[2] == "Current"
|
||||
&& $buffer[1] == "Full"
|
||||
&& isset($buffer[6]) && preg_match("/^(\S+)\sA$/", $buffer[6], $value)
|
||||
&& $buffer[5] !== "Init") {
|
||||
$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))
|
||||
@@ -202,12 +211,50 @@ class IPMIutil extends Sensors
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get other information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _other()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (isset($buffer[1]) && $buffer[1] == "Compact"
|
||||
&& $buffer[5] !== "Init"
|
||||
&& $buffer[5] !== "Unknown"
|
||||
&& $buffer[5] !== "NotAvailable") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4].' ('.$buffer[2].')');
|
||||
|
||||
$buffer5s = preg_split("/\s+/", $buffer5 = $buffer[5]);
|
||||
if (isset($buffer5s[1])) {
|
||||
if (preg_match('/^[0-9A-Fa-f]+$/', $buffer5s[0])) {
|
||||
$value = hexdec($buffer5s[0]) & 0xff;
|
||||
if ($buffer5s[1] === 'DiscreteEvt') {
|
||||
$dev->setValue('0x'.dechex($value));
|
||||
} elseif (($buffer5s[1] === 'DiscreteUnit') && ($value > 0)) {
|
||||
$dev->setValue('0x'.dechex($value - 1));
|
||||
} else {
|
||||
$dev->setValue($buffer5);
|
||||
}
|
||||
} else {
|
||||
$dev->setValue($buffer5);
|
||||
}
|
||||
} else {
|
||||
$dev->setValue($buffer5);
|
||||
}
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
@@ -216,5 +263,6 @@ class IPMIutil extends Sensors
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
$this->_other();
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* K8Temp sensor class
|
||||
* K8Temp sensor class, getting information from k8temp
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@@ -8,18 +8,7 @@
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.k8temp.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from k8temp
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -38,20 +27,19 @@ class K8Temp extends Sensors
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_K8TEMP_ACCESS')?strtolower(PSI_SENSOR_K8TEMP_ACCESS):'command') {
|
||||
case 'command':
|
||||
$lines = "";
|
||||
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)) {
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('k8temp.tmp', $lines)) {
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
$this->error->addConfigError('__construct()', '[sensor_k8temp] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +55,7 @@ class K8Temp extends Sensors
|
||||
if ($data[2] > 0) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setMax('70.0');
|
||||
// $dev->setMax('70.0');
|
||||
if ($data[2] < 250) {
|
||||
$dev->setValue($data[2]);
|
||||
}
|
||||
@@ -82,7 +70,7 @@ class K8Temp extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* lmsensor sensor class
|
||||
* lmsensor sensor class, getting information from lmsensor
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@@ -8,56 +8,122 @@
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.lmsensors.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from lmsensor
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class LMSensors extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
* array of values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_lines = array();
|
||||
private $_values = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
* fill the private content var through command or data access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
$lines = "";
|
||||
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_LMSENSORS_ACCESS')?strtolower(PSI_SENSOR_LMSENSORS_ACCESS):'command') {
|
||||
case 'command':
|
||||
if (CommonFunctions::executeProgram("sensors", "", $lines)) {
|
||||
// Martijn Stolk: Dirty fix for misinterpreted output of sensors,
|
||||
// where info could come on next line when the label is too long.
|
||||
$lines = str_replace(":\n", ":", $lines);
|
||||
$lines = str_replace("\n\n", "\n", $lines);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
CommonFunctions::executeProgram("sensors", "", $lines);
|
||||
break;
|
||||
case 'file':
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/lmsensors.txt', $lines)) {
|
||||
$lines = str_replace(":\n", ":", $lines);
|
||||
$lines = str_replace("\n\n", "\n", $lines);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT')) {
|
||||
CommonFunctions::rftsdata('lmsensors.tmp', $lines);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
$this->error->addConfigError('__construct()', '[sensor_lmsensors] ACCESS');
|
||||
}
|
||||
|
||||
if (trim($lines) !== "") {
|
||||
$lines = str_replace("\r\n", "\n", $lines);
|
||||
$lines = str_replace(":\n", ":", $lines);
|
||||
$lines = str_replace("\n\n", "\n", $lines);
|
||||
$lines = preg_replace("/\n\s+\(/m", " (", $lines);
|
||||
$_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$applearray1 = array(
|
||||
"A" => "Ambient",
|
||||
"B" => "Battery",
|
||||
"C" => "CPU",
|
||||
"G" => "GPU",
|
||||
"H" => "Harddisk Bay",
|
||||
"h" => "Heatpipe",
|
||||
"L" => "LCD",
|
||||
"M" => "Memory",
|
||||
"m" => "Memory Contr.",
|
||||
"N" => "Northbridge",
|
||||
"O" => "Optical Drive",
|
||||
"p" => "Power supply",
|
||||
"S" => "Slot",
|
||||
"s" => "Slot",
|
||||
"W" => "Airport"
|
||||
);
|
||||
$applearray3 = array(
|
||||
"H" => "Heatsink",
|
||||
"P" => "Proximity",
|
||||
"D" => "Die"
|
||||
);
|
||||
|
||||
$tmpvalue=array();
|
||||
$applesmc = false;
|
||||
$sname = '';
|
||||
foreach ($_lines as $line) {
|
||||
if ((trim($line) !== "") && (strpos($line, ':') === false)) {
|
||||
if (sizeof($tmpvalue)>0) {
|
||||
$this->_values[] = $tmpvalue;
|
||||
$tmpvalue = array();
|
||||
}
|
||||
$sname = trim($line);
|
||||
$applesmc = ($sname === "applesmc-isa-0300");
|
||||
if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
|
||||
$sname = $snamebuf[1];
|
||||
} else {
|
||||
$sname = '';
|
||||
}
|
||||
} else {
|
||||
if (preg_match("/^(.+):(.+)$/", trim($line), $data) && ($data[1]!=="Adapter")) {
|
||||
if ($applesmc && (strlen($data[1]) == 4) && ($data[1][0] == "T")) {
|
||||
if (isset($applearray1[$data[1][1]])) $data[1] .= " ".$applearray1[$data[1][1]];
|
||||
if (isset($applearray3[$data[1][3]])) $data[1] .= " ".$applearray3[$data[1][3]];
|
||||
}
|
||||
|
||||
$arrtemp=array();
|
||||
if ($sname !== "" ) {
|
||||
$arrtemp["name"] = $data[1]." (".$sname.")";
|
||||
} else {
|
||||
$arrtemp["name"] = $data[1];
|
||||
}
|
||||
if (preg_match("/^([^\(]+)\s+\(/", $data[2], $tmp) || preg_match("/^(.+)\s+ALARM$/", $data[2], $tmp)) {
|
||||
if (($tmp[1] = trim($tmp[1])) == "") {
|
||||
$arrtemp["value"] = "ALARM";
|
||||
} else {
|
||||
$arrtemp["value"] = $tmp[1];
|
||||
}
|
||||
if (preg_match("/\s(ALARM)\s*$/", $data[2]) || preg_match("/\s(ALARM)\s+\(/", $data[2]) || preg_match("/\s(ALARM)\s+sensor\s+=/", $data[2])) {
|
||||
$arrtemp["alarm"]="ALARM";
|
||||
}
|
||||
|
||||
if (preg_match_all("/\(([^\)]+\s+=\s+[^\)]+)\)/", $data[2], $tmp2)) foreach ($tmp2[1] as $tmp3) {
|
||||
$arrtmp3 = preg_split('/,/', $tmp3);
|
||||
foreach ($arrtmp3 as $tmp4) if (preg_match("/^(\S+)\s+=\s+(.*)$/", trim($tmp4), $tmp5)) {
|
||||
$arrtemp[$tmp5[1]]=trim($tmp5[2]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$arrtemp["value"] = trim($data[2]);
|
||||
}
|
||||
$tmpvalue[] = $arrtemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sizeof($tmpvalue)>0) $this->_values[] = $tmpvalue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,88 +134,35 @@ class LMSensors extends Sensors
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
$ar_buf = array();
|
||||
foreach ($this->_lines as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*)/", $line, $data);
|
||||
}
|
||||
if (count($data) > 1) {
|
||||
$temp = substr(trim($data[2]), -1);
|
||||
switch ($temp) {
|
||||
case "C":
|
||||
// case "F":
|
||||
array_push($ar_buf, $line);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($ar_buf as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*).C[ \t]+/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*).C$/", $line, $data);
|
||||
}
|
||||
foreach ($data as $key=>$value) {
|
||||
if (preg_match("/^\+?(-?[0-9\.]+).?$/", trim($value), $newvalue)) {
|
||||
$data[$key] = 0+trim($newvalue[1]);
|
||||
} else {
|
||||
$data[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
$dev = new SensorDevice();
|
||||
|
||||
if (strlen($data[1]) == 4) {
|
||||
if ($data[1][0] == "T") {
|
||||
|
||||
if ($data[1][1] == "A") {
|
||||
$data[1] = $data[1] . " Ambient";
|
||||
} elseif ($data[1][1] == "C") {
|
||||
$data[1] = $data[1] . " CPU";
|
||||
} elseif ($data[1][1] == "G") {
|
||||
$data[1] = $data[1] . " GPU";
|
||||
} elseif ($data[1][1] == "H") {
|
||||
$data[1] = $data[1] . " Harddisk";
|
||||
} elseif ($data[1][1] == "L") {
|
||||
$data[1] = $data[1] . " LCD";
|
||||
} elseif ($data[1][1] == "O") {
|
||||
$data[1] = $data[1] . " ODD";
|
||||
} elseif ($data[1][1] == "B") {
|
||||
$data[1] = $data[1] . " Battery";
|
||||
foreach ($this->_values as $sensors) foreach ($sensors as $sensor){
|
||||
if (isset($sensor["value"])) {
|
||||
$limit = "";
|
||||
if (preg_match("/^\+?(-?[\d\.]+)[^\w\r\n\t]+C$/", $sensor["value"], $tmpbuf) ||
|
||||
((isset($sensor[$limit="crit"]) || isset($sensor[$limit="high"]) || isset($sensor[$limit="hyst"])) && preg_match("/^\+?(-?[\d\.]+)[^\w\r\n\t]+C$/", $sensor[$limit]))) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor["name"]);
|
||||
if ($limit != "") {
|
||||
$dev->setValue($sensor["value"]);
|
||||
$dev->setEvent("FAULT");
|
||||
} else {
|
||||
if ($tmpbuf[1] == -110.8) {
|
||||
$dev->setValue("FAULT");
|
||||
$dev->setEvent("FAULT");
|
||||
} else {
|
||||
$dev->setValue(floatval($tmpbuf[1]));
|
||||
if (isset($sensor["alarm"])) $dev->setEvent("ALARM");
|
||||
}
|
||||
}
|
||||
|
||||
if ($data[1][3] == "H") {
|
||||
$data[1] = $data[1] . " Heatsink";
|
||||
} elseif ($data[1][3] == "P") {
|
||||
$data[1] = $data[1] . " Proximity";
|
||||
} elseif ($data[1][3] == "D") {
|
||||
$data[1] = $data[1] . " Die";
|
||||
if (isset($sensor[$limit="crit"]) && preg_match("/^\+?(-?[\d\.]+)[^\w\r\n\t]+C$/", $sensor[$limit], $tmpbuf) && (($tmpbuf[1]=floatval($tmpbuf[1])) > 0)) {
|
||||
$dev->setMax(floatval($tmpbuf[1]));
|
||||
} elseif (isset($sensor[$limit="high"]) && preg_match("/^\+?(-?[\d\.]+)[^\w\r\n\t]+C$/", $sensor[$limit], $tmpbuf) && (($tmpbuf[1]=floatval($tmpbuf[1])) > 0) && ($tmpbuf[1]<65261.8)) {
|
||||
$dev->setMax(floatval($tmpbuf[1]));
|
||||
}
|
||||
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
|
||||
if (isset($data[6]) && $data[2] <= $data[6]) {
|
||||
$dev->setMax(max($data[4], $data[6]));
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,50 +173,32 @@ class LMSensors extends Sensors
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
$ar_buf = array();
|
||||
foreach ($this->_lines as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*)/", $line, $data);
|
||||
}
|
||||
if (count($data) > 1) {
|
||||
$temp = substr(trim($data[2]), -4);
|
||||
switch ($temp) {
|
||||
case " RPM":
|
||||
array_push($ar_buf, $line);
|
||||
foreach ($this->_values as $sensors) foreach ($sensors as $sensor){
|
||||
if (isset($sensor["value"])) {
|
||||
$limit = "";
|
||||
if (preg_match("/^(\d+) RPM$/", $sensor["value"], $tmpbuf) ||
|
||||
((isset($sensor[$limit="min"]) || isset($sensor[$limit="max"])) && preg_match("/^(\d+) RPM$/", $sensor[$limit]))) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor["name"]);
|
||||
if ($limit != "") {
|
||||
$dev->setValue($sensor["value"]);
|
||||
$dev->setEvent("FAULT");
|
||||
} else {
|
||||
$dev->setValue($tmpbuf[1]);
|
||||
}
|
||||
if (isset($sensor["alarm"])) $dev->setEvent("ALARM");
|
||||
|
||||
if (isset($sensor[$limit="min"]) && preg_match("/^(\d+) RPM$/", $sensor[$limit], $tmpbuf) && ($tmpbuf[1] > 0)) {
|
||||
$dev->setMin($tmpbuf[1]);
|
||||
}
|
||||
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($ar_buf as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*) RPM[ ]*\((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) RPM[ ]*\((.*)=(.*) RPM,(.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) RPM[ ]*\((.*)=(.*) RPM\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) RPM[ \t]+/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*) RPM$/", $line, $data);
|
||||
}
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName(trim($data[1]));
|
||||
$dev->setValue(trim($data[2]));
|
||||
if (isset($data[4])) {
|
||||
$dev->setMin(trim($data[4]));
|
||||
}
|
||||
if (preg_match("/\sALARM(\s*)$/", $line)) {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
@@ -211,58 +206,37 @@ class LMSensors extends Sensors
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
$ar_buf = array();
|
||||
foreach ($this->_lines as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*)\(/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*)/", $line, $data);
|
||||
}
|
||||
if (count($data) > 1) {
|
||||
$temp = substr(trim($data[2]), -2);
|
||||
switch ($temp) {
|
||||
case " V":
|
||||
array_push($ar_buf, $line);
|
||||
foreach ($this->_values as $sensors) foreach ($sensors as $sensor){
|
||||
if (isset($sensor["value"])) {
|
||||
$limit = "";
|
||||
if (preg_match("/^\+?(-?[\d\.]+) (m?)V$/", $sensor["value"], $tmpbuf) ||
|
||||
((isset($sensor[$limit="min"]) || isset($sensor[$limit="max"])) && preg_match("/^\+?(-?[\d\.]+) (m?)V$/", $sensor[$limit]))) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor["name"]);
|
||||
if ($limit != "") {
|
||||
$dev->setValue($sensor["value"]);
|
||||
$dev->setEvent("FAULT");
|
||||
} else {
|
||||
if ($tmpbuf[2] == "m") {
|
||||
$dev->setValue(floatval($tmpbuf[1])/1000);
|
||||
} else {
|
||||
$dev->setValue(floatval($tmpbuf[1]));
|
||||
}
|
||||
}
|
||||
if (isset($sensor["alarm"])) $dev->setEvent("ALARM");
|
||||
|
||||
if (isset($sensor[$limit="min"]) && preg_match("/^\+?(-?[\d\.]+) (m?)V$/", $sensor[$limit], $tmpbuf)) {
|
||||
$dev->setMin(floatval($tmpbuf[1]));
|
||||
}
|
||||
|
||||
if (isset($sensor[$limit="max"]) && preg_match("/^\+?(-?[\d\.]+) (m?)V$/", $sensor[$limit], $tmpbuf)) {
|
||||
$dev->setMax(floatval($tmpbuf[1]));
|
||||
}
|
||||
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($ar_buf as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*) V[ ]*\((.*)=(.*) V,(.*)=(.*) V\)(.*)\)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) V[ ]*\((.*)=(.*) V,(.*)=(.*) V\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) V[ \t]+/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*) V$/", $line, $data);
|
||||
}
|
||||
foreach ($data as $key=>$value) {
|
||||
if (preg_match("/^\+?(-?[0-9\.]+)$/", trim($value), $newvalue)) {
|
||||
$data[$key] = 0+trim($newvalue[1]);
|
||||
} else {
|
||||
$data[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
if (isset($data[1])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
if (isset($data[4])) {
|
||||
$dev->setMin($data[4]);
|
||||
}
|
||||
if (isset($data[6])) {
|
||||
$dev->setMax($data[6]);
|
||||
}
|
||||
if (preg_match("/\sALARM(\s*)$/", $line)) {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,63 +246,32 @@ class LMSensors extends Sensors
|
||||
*/
|
||||
private function _power()
|
||||
{
|
||||
$ar_buf = array();
|
||||
foreach ($this->_lines as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*)/", $line, $data);
|
||||
}
|
||||
if (count($data) > 1) {
|
||||
$temp = substr(trim($data[2]), -2);
|
||||
switch ($temp) {
|
||||
case " W":
|
||||
array_push($ar_buf, $line);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($ar_buf as $line) {
|
||||
$data = array();
|
||||
/* not tested yet
|
||||
if (preg_match("/(.*):(.*) W[ ]*\((.*)=(.*) W,(.*)=(.*) W\)(.*)\)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) W[ ]*\((.*)=(.*) W,(.*)=(.*) W\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} else
|
||||
*/
|
||||
if (preg_match("/(.*):(.*) W[ ]*\((.*)=(.*) W\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) W[ \t]+/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*) W$/", $line, $data);
|
||||
}
|
||||
foreach ($data as $key=>$value) {
|
||||
if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) {
|
||||
$data[$key] = trim($newvalue[1]);
|
||||
} else {
|
||||
$data[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
foreach ($this->_values as $sensors) foreach ($sensors as $sensor){
|
||||
if (isset($sensor["value"])) {
|
||||
$limit = "";
|
||||
if (preg_match("/^\+?(-?[\d\.]+) W$/", $sensor["value"], $tmpbuf) ||
|
||||
(isset($sensor[$limit="crit"]) && preg_match("/^\+?(-?[\d\.]+) W$/", $sensor[$limit]))) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor["name"]);
|
||||
if ($limit != "") {
|
||||
$dev->setValue($sensor["value"]);
|
||||
$dev->setEvent("FAULT");
|
||||
} else {
|
||||
$dev->setValue(floatval($tmpbuf[1]));
|
||||
}
|
||||
if (isset($sensor["alarm"])) $dev->setEvent("ALARM");
|
||||
|
||||
if (isset($data[6]) && $data[2] <= $data[6]) {
|
||||
$dev->setMax(max($data[4], $data[6]));
|
||||
} elseif (isset($data[4]) && $data[2] <= $data[4]) {
|
||||
$dev->setMax($data[4]);
|
||||
if (isset($sensor[$limit="crit"]) && preg_match("/^\+?(-?[\d\.]+) W$/", $sensor[$limit], $tmpbuf)) {
|
||||
$dev->setMax(floatval($tmpbuf[1]));
|
||||
}
|
||||
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
if (preg_match("/\sALARM(\s*)$/", $line)) {
|
||||
$dev->setEvent("Alarm");
|
||||
}
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
@@ -336,60 +279,54 @@ class LMSensors extends Sensors
|
||||
*/
|
||||
private function _current()
|
||||
{
|
||||
$ar_buf = array();
|
||||
foreach ($this->_lines as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*)\((.*)=(.*)\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*)/", $line, $data);
|
||||
}
|
||||
if (count($data) > 1) {
|
||||
$temp = substr(trim($data[2]), -2);
|
||||
switch ($temp) {
|
||||
case " A":
|
||||
array_push($ar_buf, $line);
|
||||
foreach ($this->_values as $sensors) foreach ($sensors as $sensor){
|
||||
if (isset($sensor["value"])) {
|
||||
$limit = "";
|
||||
if (preg_match("/^\+?(-?[\d\.]+) A$/", $sensor["value"], $tmpbuf) ||
|
||||
(isset($sensor[$limit="crit"]) && preg_match("/^\+?(-?[\d\.]+) A$/", $sensor[$limit]))) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor["name"]);
|
||||
if ($limit != "") {
|
||||
$dev->setValue($sensor["value"]);
|
||||
$dev->setEvent("FAULT");
|
||||
} else {
|
||||
$dev->setValue(floatval($tmpbuf[1]));
|
||||
}
|
||||
if (isset($sensor["alarm"])) $dev->setEvent("ALARM");
|
||||
|
||||
if (isset($sensor[$limit="min"]) && preg_match("/^\+?(-?[\d\.]+) A$/", $sensor[$limit], $tmpbuf)) {
|
||||
$dev->setMin(floatval($tmpbuf[1]));
|
||||
}
|
||||
|
||||
if (isset($sensor[$limit="max"]) && preg_match("/^\+?(-?[\d\.]+) A$/", $sensor[$limit], $tmpbuf)) {
|
||||
$dev->setMax(floatval($tmpbuf[1]));
|
||||
}
|
||||
|
||||
$this->mbinfo->setMbCurrent($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($ar_buf as $line) {
|
||||
$data = array();
|
||||
/* not tested yet
|
||||
if (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A,(.*)=(.*) A\)(.*)\)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A,(.*)=(.*) A\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} else
|
||||
*/
|
||||
if (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A\)(.*)/", $line, $data)) {
|
||||
;
|
||||
} elseif (preg_match("/(.*):(.*) A[ \t]+/", $line, $data)) {
|
||||
;
|
||||
} else {
|
||||
preg_match("/(.*):(.*) A$/", $line, $data);
|
||||
}
|
||||
foreach ($data as $key=>$value) {
|
||||
if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) {
|
||||
$data[$key] = trim($newvalue[1]);
|
||||
} else {
|
||||
$data[$key] = trim($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* get other information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _other()
|
||||
{
|
||||
foreach ($this->_values as $sensors) foreach ($sensors as $sensor){
|
||||
if (isset($sensor["value"])) {
|
||||
if ((preg_match("/^[^\-\+\d]/", $sensor["value"]) || preg_match("/^\d+$/", $sensor["value"])) && ($sensor["value"] !== 'failed') &&
|
||||
!isset($sensor[$limit="min"]) && !isset($sensor[$limit="max"]) && !isset($sensor[$limit="crit"]) && !isset($sensor[$limit="high"]) && !isset($sensor[$limit="hyst"])) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($sensor["name"]);
|
||||
$dev->setValue($sensor["value"]);
|
||||
if (isset($sensor["alarm"])) $dev->setEvent("ALARM");
|
||||
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
}
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
|
||||
if (isset($data[6]) && $data[2] <= $data[6]) {
|
||||
$dev->setMax(max($data[4], $data[6]));
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,14 +335,15 @@ class LMSensors extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_voltage();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
$this->_other();
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* MBM5 sensor class
|
||||
* MBM5 sensor class, getting information from Motherboard Monitor 5 information retrival through csv file
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@@ -8,19 +8,7 @@
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.mbm5.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from Motherboard Monitor 5
|
||||
* information retrival through csv file
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -46,20 +34,15 @@ class MBM5 extends Sensors
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
case 'file':
|
||||
if ((PSI_OS == 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
|
||||
$delim = "/;/";
|
||||
CommonFunctions::rfts(APP_ROOT."/data/MBM5.csv", $buffer);
|
||||
CommonFunctions::rftsdata("MBM5.csv", $buffer);
|
||||
if (strpos($buffer, ";") === false) {
|
||||
$delim = "/,/";
|
||||
}
|
||||
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$this->_buf_label = preg_split($delim, substr($buffer[0], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
|
||||
$this->_buf_value = preg_split($delim, substr($buffer[1], 0, -2), -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +61,7 @@ class MBM5 extends Sensors
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($this->_buf_label[$intPosi]);
|
||||
$dev->setValue($hits[0]);
|
||||
$dev->setMax(70);
|
||||
// $dev->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
@@ -98,7 +81,7 @@ class MBM5 extends Sensors
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($this->_buf_label[$intPosi]);
|
||||
$dev->setValue($hits[0]);
|
||||
$dev->setMin(3000);
|
||||
// $dev->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +110,7 @@ class MBM5 extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* mbmon sensor class
|
||||
* mbmon sensor class, getting information from mbmon
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@@ -8,18 +8,7 @@
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @version SVN: $Id: class.mbmon.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* getting information from mbmon
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -33,14 +22,14 @@ class MBMon extends Sensors
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
* fill the private content var through tcp, command or data access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
if ((PSI_OS != 'WINNT') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) switch (defined('PSI_SENSOR_MBMON_ACCESS')?strtolower(PSI_SENSOR_MBMON_ACCESS):'command') {
|
||||
case 'tcp':
|
||||
$fp = fsockopen("localhost", 411, $errno, $errstr, 5);
|
||||
$fp = fsockopen(defined('PSI_EMU_HOSTNAME')?PSI_EMU_HOSTNAME:'localhost', 411, $errno, $errstr, 5);
|
||||
if ($fp) {
|
||||
$lines = "";
|
||||
while (!feof($fp)) {
|
||||
@@ -55,14 +44,13 @@ class MBMon extends Sensors
|
||||
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)) {
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('mbmon.tmp', $lines)) {
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
$this->error->addConfigError('__construct()', '[sensor_mbmon] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +66,7 @@ class MBMon extends Sensors
|
||||
if ($data[2] <> '0') {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setMax(70);
|
||||
// $dev->setMax(70);
|
||||
if ($data[2] < 250) {
|
||||
$dev->setValue($data[2]);
|
||||
}
|
||||
@@ -101,7 +89,7 @@ class MBMon extends Sensors
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
$dev->setMax(3000);
|
||||
// $dev->setMax(3000);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
|
136
root/opt/phpsysinfo/includes/mb/class.nvidiasmi.inc.php
Normal file
136
root/opt/phpsysinfo/includes/mb/class.nvidiasmi.inc.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* nvidiasmi sensor class, getting hardware temperature information and fan speed from nvidia-smi utility
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2020 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class NvidiaSMI extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_gpus = array();
|
||||
|
||||
/**
|
||||
* fill the private array
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT')) switch (defined('PSI_SENSOR_NVIDIASMI_ACCESS')?strtolower(PSI_SENSOR_NVIDIASMI_ACCESS):'command') {
|
||||
case 'command':
|
||||
if (PSI_OS == 'WINNT') {
|
||||
$winnt_exe = (defined('PSI_SENSOR_NVIDIASMI_EXE_PATH') && is_string(PSI_SENSOR_NVIDIASMI_EXE_PATH))?strtolower(PSI_SENSOR_NVIDIASMI_EXE_PATH):"c:\\Program Files\\NVIDIA Corporation\\NVSMI\\nvidia-smi.exe";
|
||||
if (($_exe=realpath(trim($winnt_exe))) && preg_match("/^([a-zA-Z]:\\\\[^\\\\]+)/", $_exe, $out)) {
|
||||
CommonFunctions::executeProgram('cmd', "/c set ProgramFiles=".$out[1]."^&\"".$_exe."\" -q", $lines);
|
||||
} else {
|
||||
$this->error->addConfigError('__construct()', '[sensor_nvidiasmi] EXE_PATH="'.$winnt_exe.'"');
|
||||
}
|
||||
} else {
|
||||
CommonFunctions::executeProgram('nvidia-smi', '-q', $lines);
|
||||
}
|
||||
|
||||
$this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('nvidiasmi.tmp', $lines)) {
|
||||
$this->_gpus = preg_split("/^(?=GPU )/m", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', '[sensor_nvidiasmi] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$gpuc=count($this->_gpus);
|
||||
switch ($gpuc) {
|
||||
case 0:
|
||||
$this->error->addError("nvidia-smi", "No values");
|
||||
break;
|
||||
case 1:
|
||||
$this->error->addError("nvidia-smi", "Error: ".$this->_gpus[0]);
|
||||
break;
|
||||
default:
|
||||
for ($c = 0; $c < $gpuc; $c++) {
|
||||
if (preg_match("/^\s+GPU Current Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
if (preg_match("/^\s+GPU Shutdown Temp\s+:\s*(\d+)\s*C\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev->setMax($out[1]);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
if (preg_match("/^\s+Power Draw\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
if (preg_match("/^\s+Power Limit\s+:\s*([\d\.]+)\s*W\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev->setMax($out[1]);
|
||||
}
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
if (preg_match("/^\s+Fan Speed\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
$dev->setUnit("%");
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
if (preg_match("/^\s+Performance State\s+:\s*(\S+)\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." Performance State (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
if (preg_match("/^\s+Gpu\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." Utilization (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
$dev->setUnit("%");
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
if (preg_match("/^\s+Memory\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." Memory Utilization (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
$dev->setUnit("%");
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
if (preg_match("/^\s+Encoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." Encoder Utilization (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
$dev->setUnit("%");
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
if (preg_match("/^\s+Decoder\s+:\s*(\d+)\s*%\s*$/m", $this->_gpus[$c], $out)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("GPU ".($c)." Decoder Utilization (nvidiasmi)");
|
||||
$dev->setValue($out[1]);
|
||||
$dev->setUnit("%");
|
||||
$this->mbinfo->setMbOther($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,25 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Open Hardware Monitor sensor class
|
||||
* Open Hardware Monitor sensor class, getting information from Open Hardware Monitor
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @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 Open Hardware Monitor
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2014 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -38,25 +27,16 @@ 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 = '';
|
||||
$strPassword = '';
|
||||
try {
|
||||
// initialize the wmi object
|
||||
$objLocator = new COM('WbemScripting.SWbemLocator');
|
||||
if ($strHostname == "") {
|
||||
$_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor');
|
||||
|
||||
} else {
|
||||
$_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor', $strHostname.'\\'.$strUser, $strPassword);
|
||||
if ((PSI_OS == 'WINNT') || (defined('PSI_EMU_HOSTNAME') && !defined('PSI_EMU_PORT'))) {
|
||||
$_wmi = WINNT::initWMI('root\OpenHardwareMonitor', true);
|
||||
if ($_wmi) {
|
||||
$tmpbuf = WINNT::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
|
||||
if ($tmpbuf) foreach ($tmpbuf as $buffer) {
|
||||
if (!isset($this->_buf[$buffer['SensorType']]) || !isset($this->_buf[$buffer['SensorType']][$buffer['Parent'].' '.$buffer['Name']])) { // avoid duplicates
|
||||
$this->_buf[$buffer['SensorType']][$buffer['Parent'].' '.$buffer['Name']] = $buffer['Value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data.");
|
||||
}
|
||||
if ($_wmi) {
|
||||
$this->_buf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +47,11 @@ class OHM extends Sensors
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($name);
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,13 +62,11 @@ class OHM extends Sensors
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($name);
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,13 +77,11 @@ class OHM extends Sensors
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($name);
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,13 +92,11 @@ class OHM extends Sensors
|
||||
*/
|
||||
private function _power()
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($name);
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +105,7 @@ class OHM extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
@@ -7,8 +7,10 @@
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Marc Hillesheim <hawkeyexp@gmail.com>
|
||||
* @copyright 2012 Marc Hillesheim
|
||||
* @link http://pi.no-ip.biz
|
||||
* @copyright 2012 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class PiTemp extends Sensors
|
||||
{
|
||||
@@ -16,15 +18,15 @@ class PiTemp extends Sensors
|
||||
{
|
||||
$temp = null;
|
||||
$temp_max = null;
|
||||
if (!CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input', $temp, 0, 4096, false)) { // Not Banana Pi
|
||||
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/temp', $temp);
|
||||
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/trip_point_0_temp', $temp_max, 0, 4096, PSI_DEBUG);
|
||||
if (!CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input', $temp, 1, 4096, false)) { // Not Banana Pi
|
||||
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/temp', $temp, 1);
|
||||
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/trip_point_0_temp', $temp_max, 1, 4096, PSI_DEBUG);
|
||||
}
|
||||
if (!is_null($temp) && (trim($temp) != "")) {
|
||||
if (($temp !== null) && (($temp = trim($temp)) != "")) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("CPU 1");
|
||||
$dev->setValue($temp / 1000);
|
||||
if (!is_null($temp_max) && (trim($temp_max) != "") && ($temp_max > 0)) {
|
||||
if (($temp_max !== null) && (($temp_max = trim($temp_max)) != "") && ($temp_max > 0)) {
|
||||
$dev->setMax($temp_max / 1000);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
@@ -34,7 +36,7 @@ class PiTemp extends Sensors
|
||||
private function _voltage()
|
||||
{
|
||||
$volt = null;
|
||||
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now', $volt, 0, 4096, false) && !is_null($volt) && (trim($volt) != "")) { // Banana Pi
|
||||
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now', $volt, 1, 4096, false) && ($volt !== null) && (($volt = trim($volt)) != "")) { // Banana Pi
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("Voltage 1");
|
||||
$dev->setValue($volt / 1000000);
|
||||
@@ -45,7 +47,7 @@ class PiTemp extends Sensors
|
||||
private function _current()
|
||||
{
|
||||
$current = null;
|
||||
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now', $current, 0, 4096, false) && !is_null($current) && (trim($current) != "")) { // Banana Pi
|
||||
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now', $current, 1, 4096, false) && ($current !== null) && (($current = trim($current)) != "")) { // Banana Pi
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("Current 1");
|
||||
$dev->setValue($current / 1000000);
|
||||
@@ -55,8 +57,10 @@ class PiTemp extends Sensors
|
||||
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_current();
|
||||
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_current();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
93
root/opt/phpsysinfo/includes/mb/class.qtssnmp.inc.php
Normal file
93
root/opt/phpsysinfo/includes/mb/class.qtssnmp.inc.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* qtstemp sensor class, getting hardware temperature information through snmpwalk
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2016 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class QTSsnmp extends Sensors
|
||||
{
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
if (!defined('PSI_EMU_PORT')) {
|
||||
$address = '127.0.0.1';
|
||||
} else {
|
||||
$address = PSI_EMU_HOSTNAME;
|
||||
}
|
||||
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.5.0", $buffer, PSI_DEBUG)
|
||||
&& preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("CPU");
|
||||
$dev->setValue($data[1]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
|
||||
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.6.0", $buffer, PSI_DEBUG)
|
||||
&& preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("System");
|
||||
$dev->setValue($data[1]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
|
||||
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.11.1.3", $buffer, PSI_DEBUG)) {
|
||||
$lines = preg_split('/\r?\n/', $buffer);
|
||||
foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sC/', $line, $data)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("HDD ".$data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
if (!defined('PSI_EMU_PORT')) {
|
||||
$address = '127.0.0.1';
|
||||
} else {
|
||||
$address = PSI_EMU_HOSTNAME;
|
||||
}
|
||||
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.15.1.3", $buffer, PSI_DEBUG)) {
|
||||
$lines = preg_split('/\r?\n/', $buffer);
|
||||
foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sRPM/', $line, $data)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("Fan ".$data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) {
|
||||
$this->_temperature();
|
||||
$this->_fans();
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@
|
||||
* @package PSI sensors class
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version SVN: $Id: class.sensors.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
* @package PSI sensors class
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
@@ -28,7 +28,7 @@ abstract class Sensors implements PSI_Interface_Sensor
|
||||
/**
|
||||
* object for error handling
|
||||
*
|
||||
* @var Error
|
||||
* @var PSI_Error
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
@@ -44,7 +44,7 @@ abstract class Sensors implements PSI_Interface_Sensor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->error = Error::singleton();
|
||||
$this->error = PSI_Error::singleton();
|
||||
$this->mbinfo = new MBInfo();
|
||||
}
|
||||
|
||||
|
125
root/opt/phpsysinfo/includes/mb/class.speedfan.inc.php
Normal file
125
root/opt/phpsysinfo/includes/mb/class.speedfan.inc.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* speedfan sensor class, getting hardware information through SpeedFanGet
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2016 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class SpeedFan extends Sensors
|
||||
{
|
||||
/*
|
||||
* variable, which holds the content of the command
|
||||
* @var array
|
||||
*/
|
||||
private $_filecontent = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if ((PSI_OS == 'WINNT') && !defined('PSI_EMU_HOSTNAME')) switch (defined('PSI_SENSOR_SPEEDFAN_ACCESS')?strtolower(PSI_SENSOR_SPEEDFAN_ACCESS):'command') {
|
||||
case 'command':
|
||||
if (CommonFunctions::executeProgram("SpeedFanGet.exe", "", $buffer, PSI_DEBUG) && (strlen($buffer) > 0)) {
|
||||
if (preg_match("/^Temperatures:\s+(.+)$/m", $buffer, $out)) {
|
||||
$this->_filecontent["temp"] = $out[1];
|
||||
}
|
||||
if (preg_match("/^Fans:\s+(.+)$/m", $buffer, $out)) {
|
||||
$this->_filecontent["fans"] = $out[1];
|
||||
}
|
||||
if (preg_match("/^Voltages:\s+(.+)$/m", $buffer, $out)) {
|
||||
$this->_filecontent["volt"] = $out[1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'data':
|
||||
if (CommonFunctions::rftsdata('speedfan.tmp', $buffer) && (strlen($buffer) > 0)) {
|
||||
if (preg_match("/^Temperatures:\s+(.+)$/m", $buffer, $out)) {
|
||||
$this->_filecontent["temp"] = $out[1];
|
||||
}
|
||||
if (preg_match("/^Fans:\s+(.+)$/m", $buffer, $out)) {
|
||||
$this->_filecontent["fans"] = $out[1];
|
||||
}
|
||||
if (preg_match("/^Voltages:\s+(.+)$/m", $buffer, $out)) {
|
||||
$this->_filecontent["volt"] = $out[1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', '[sensor_speedfan] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
if (isset($this->_filecontent["temp"]) && (trim($this->_filecontent["temp"]) !== "")) {
|
||||
$values = preg_split("/ /", trim($this->_filecontent["temp"]));
|
||||
foreach ($values as $id=>$value) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("temp".$id);
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
if (isset($this->_filecontent["fans"]) && (trim($this->_filecontent["fans"]) !== "")) {
|
||||
$values = preg_split("/ /", trim($this->_filecontent["fans"]));
|
||||
foreach ($values as $id=>$value) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("fan".$id);
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
if (isset($this->_filecontent["volt"]) && (trim($this->_filecontent["volt"]) !== "")) {
|
||||
$values = preg_split("/ /", trim($this->_filecontent["volt"]));
|
||||
foreach ($values as $id=>$value) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("in".$id);
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_fans();
|
||||
$this->_voltage();
|
||||
}
|
||||
}
|
@@ -1,31 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Thermal Zone sensor class
|
||||
* Thermal Zone sensor class, getting information from Thermal Zone WMI class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
||||
* @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 <BigMichi1@users.sourceforge.net>
|
||||
* @copyright 2009 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2014 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @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
|
||||
@@ -38,27 +27,39 @@ class ThermalZone extends Sensors
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (PSI_OS == 'WINNT') {
|
||||
$_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');
|
||||
|
||||
switch (defined('PSI_SENSOR_THERMALZONE_ACCESS')?strtolower(PSI_SENSOR_THERMALZONE_ACCESS):'command') {
|
||||
case 'command':
|
||||
if ((PSI_OS == 'WINNT') || (defined('PSI_EMU_HOSTNAME') && !defined('PSI_EMU_PORT'))) {
|
||||
if (defined('PSI_EMU_HOSTNAME') || WINNT::isAdmin()) {
|
||||
$_wmi = WINNT::initWMI('root\WMI', true);
|
||||
if ($_wmi) {
|
||||
$this->_buf = WINNT::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature'));
|
||||
}
|
||||
} else {
|
||||
$_wmi = $objLocator->ConnectServer($strHostname, 'root\WMI', $strHostname.'\\'.$strUser, $strPassword);
|
||||
$_wmi = WINNT::getcimv2wmi();
|
||||
if ($_wmi) {
|
||||
$this->_buf = WINNT::getWMI($_wmi, 'Win32_PerfFormattedData_Counters_ThermalZoneInformation', array('Name', 'HighPrecisionTemperature', 'Temperature'));
|
||||
}
|
||||
if (!$this->_buf || PSI_DEBUG) {
|
||||
$this->error->addError("Error reading data from thermalzone sensor", "Allowed only for systems with administrator privileges (run as administrator)");
|
||||
}
|
||||
}
|
||||
} 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'));
|
||||
break;
|
||||
case 'data':
|
||||
if (!defined('PSI_EMU_HOSTNAME') && CommonFunctions::rftsdata('thermalzone.tmp', $lines)) { //output of "wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CriticalTripPoint,CurrentTemperature,InstanceName"
|
||||
$lines = trim(preg_replace('/[\x00-\x09\x0b-\x1F]/', '', $lines));
|
||||
$lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if ((($clines=count($lines)) > 1) && preg_match("/CriticalTripPoint\s+CurrentTemperature\s+InstanceName/i", $lines[0])) for ($i = 1; $i < $clines; $i++) {
|
||||
$values = preg_split("/\s+/", trim($lines[$i]), -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (count($values)==3) {
|
||||
$this->_buf[] = array('CriticalTripPoint'=>trim($values[0]), 'CurrentTemperature'=>trim($values[1]), 'InstanceName'=>trim($values[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', '[sensor_thermalzone] ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +70,9 @@ class ThermalZone extends Sensors
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
if (PSI_OS == 'WINNT') {
|
||||
$mode = defined('PSI_SENSOR_THERMALZONE_ACCESS')?strtolower(PSI_SENSOR_THERMALZONE_ACCESS):'command';
|
||||
if ((($mode == 'command') && ((PSI_OS == 'WINNT') || defined('PSI_EMU_HOSTNAME')))
|
||||
|| (($mode == 'data') && !defined('PSI_EMU_HOSTNAME'))) {
|
||||
if ($this->_buf) foreach ($this->_buf as $buffer) {
|
||||
if (isset($buffer['CurrentTemperature']) && (($value = ($buffer['CurrentTemperature'] - 2732)/10) > -100)) {
|
||||
$dev = new SensorDevice();
|
||||
@@ -83,34 +86,73 @@ class ThermalZone extends Sensors
|
||||
$dev->setMax($maxvalue);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
} else {
|
||||
if ((isset($buffer['HighPrecisionTemperature']) && (($value = ($buffer['HighPrecisionTemperature'] - 2732)/10) > -100))
|
||||
|| (isset($buffer['Temperature']) && (($value = ($buffer['Temperature'] - 273)) > -100))) {
|
||||
$dev = new SensorDevice();
|
||||
if (isset($buffer['Name']) && preg_match("/([^\\\\\. ]+)$/", $buffer['Name'], $outbuf)) {
|
||||
$dev->setName('ThermalZone '.$outbuf[1]);
|
||||
} else {
|
||||
$dev->setName('ThermalZone THM0');
|
||||
}
|
||||
$dev->setValue($value);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (glob('/sys/class/thermal/thermal_zone*/') as $thermalzone) {
|
||||
} elseif (($mode == 'command') && (PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME')) {
|
||||
$notwas = true;
|
||||
$thermalzones = CommonFunctions::findglob('/sys/class/thermal/thermal_zone*/');
|
||||
if (is_array($thermalzones) && (count($thermalzones) > 0)) foreach ($thermalzones as $thermalzone) {
|
||||
$thermalzonetemp = $thermalzone.'temp';
|
||||
$temp = null;
|
||||
if (CommonFunctions::rfts($thermalzonetemp, $temp, 0, 4096, false) && !is_null($temp) && (trim($temp) != "")) {
|
||||
if (CommonFunctions::rfts($thermalzonetemp, $temp, 1, 4096, false) && ($temp !== null) && (($temp = trim($temp)) != "")) {
|
||||
if ($temp >= 1000) {
|
||||
$temp = $temp / 1000;
|
||||
$div = 1000;
|
||||
} elseif ($temp >= 200) {
|
||||
$div = 10;
|
||||
} else {
|
||||
$div = 1;
|
||||
}
|
||||
|
||||
$temp = $temp / $div;
|
||||
|
||||
if ($temp > -40) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setValue($temp);
|
||||
|
||||
$temp_type = null;
|
||||
if (CommonFunctions::rfts($thermalzone.'type', $temp_type, 0, 4096, false) && !is_null($temp_type) && (trim($temp_type) != "")) {
|
||||
if (CommonFunctions::rfts($thermalzone.'type', $temp_type, 1, 4096, false) && ($temp_type !== null) && (($temp_type = trim($temp_type)) != "")) {
|
||||
$dev->setName($temp_type);
|
||||
} else {
|
||||
$dev->setName("ThermalZone");
|
||||
}
|
||||
|
||||
$temp_max = null;
|
||||
if (CommonFunctions::rfts($thermalzone.'trip_point_0_temp', $temp_max, 0, 4096, false) && !is_null($temp_max) && (trim($temp_max) != "") && ($temp_max > 0)) {
|
||||
if ($temp_max >= 1000) {
|
||||
$temp_max = $temp_max / 1000;
|
||||
if (CommonFunctions::rfts($thermalzone.'trip_point_0_temp', $temp_max, 1, 4096, false) && ($temp_max !== null) && (($temp_max = trim($temp_max)) != "") && ($temp_max > -40)) {
|
||||
$temp_max = $temp_max / $div;
|
||||
if (($temp_max != 0) || ($temp != 0)) { // if non-zero values
|
||||
$dev->setMax($temp_max);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
$dev->setMax($temp_max);
|
||||
} else {
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
|
||||
$notwas = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($notwas) {
|
||||
$thermalzones = (PSI_ROOT_FILESYSTEM.'/proc/acpi/thermal_zone/TH*/temperature');
|
||||
if (is_array($thermalzones) && (count($thermalzones) > 0)) foreach ($thermalzones as $thermalzone) {
|
||||
$temp = null;
|
||||
if (CommonFunctions::rfts($thermalzone, $temp, 1, 4096, false) && ($temp !== null) && (($temp = trim($temp)) != "")) {
|
||||
$dev = new SensorDevice();
|
||||
if (preg_match("/^\/proc\/acpi\/thermal_zone\/(.+)\/temperature$/", $thermalzone, $name)) {
|
||||
$dev->setName("ThermalZone ".$name[1]);
|
||||
} else {
|
||||
$dev->setName("ThermalZone");
|
||||
}
|
||||
$dev->setValue(trim(substr($temp, 23, 4)));
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +165,7 @@ class ThermalZone extends Sensors
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
41
root/opt/phpsysinfo/includes/mb/class.thinkpad.inc.php
Normal file
41
root/opt/phpsysinfo/includes/mb/class.thinkpad.inc.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* thinkpad sensor class, getting hardware temperature information and fan speed from /sys/devices/platform/thinkpad_hwmon/
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
||||
* @copyright 2017 phpSysInfo
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class Thinkpad extends Hwmon
|
||||
{
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
|
||||
$hwpaths = CommonFunctions::findglob("/sys/devices/platform/thinkpad_hwmon/", GLOB_NOSORT);
|
||||
if (is_array($hwpaths) && (count($hwpaths) == 1)) {
|
||||
$hwpaths2 = CommonFunctions::findglob("/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon*/", GLOB_NOSORT);
|
||||
if (is_array($hwpaths2) && (count($hwpaths2) > 0)) {
|
||||
$hwpaths = array_merge($hwpaths, $hwpaths2);
|
||||
}
|
||||
$totalh = count($hwpaths);
|
||||
for ($h = 0; $h < $totalh; $h++) {
|
||||
$this->_temperature($hwpaths[$h]);
|
||||
$this->_fans($hwpaths[$h]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user