initial commit of file from CVS for smeserver-phpsysinfo on Sat Sep 7 20:53:46 AEST 2024
This commit is contained in:
62
root/opt/phpsysinfo/includes/mb/class.coretemp.inc.php
Normal file
62
root/opt/phpsysinfo/includes/mb/class.coretemp.inc.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
177
root/opt/phpsysinfo/includes/mb/class.freeipmi.inc.php
Normal file
177
root/opt/phpsysinfo/includes/mb/class.freeipmi.inc.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* freeipmi 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class FreeIPMI extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
case 'command':
|
||||
CommonFunctions::executeProgram('ipmi-sensors', '--output-sensor-thresholds', $lines);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case 'file':
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/freeipmi.txt', $lines)) {
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Temperature" && $buffer[11] != "N/A" && $buffer[4] == "C") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[1]);
|
||||
$dev->setValue($buffer[3]);
|
||||
if ($buffer[9] != "N/A") $dev->setMax($buffer[9]);
|
||||
if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'"));
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Voltage" && $buffer[11] != "N/A" && $buffer[4] == "V") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[1]);
|
||||
$dev->setValue($buffer[3]);
|
||||
if ($buffer[6] != "N/A") $dev->setMin($buffer[6]);
|
||||
if ($buffer[9] != "N/A") $dev->setMax($buffer[9]);
|
||||
if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'"));
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Fan" && $buffer[11] != "N/A" && $buffer[4] == "RPM") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[1]);
|
||||
$dev->setValue($buffer[3]);
|
||||
if ($buffer[6] != "N/A") {
|
||||
$dev->setMin($buffer[6]);
|
||||
} elseif (($buffer[9] != "N/A") && ($buffer[9]<$buffer[3])) { //max instead min issue
|
||||
$dev->setMin($buffer[9]);
|
||||
}
|
||||
if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'"));
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _power()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Current" && $buffer[11] != "N/A" && $buffer[4] == "W") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[1]);
|
||||
$dev->setValue($buffer[3]);
|
||||
if ($buffer[9] != "N/A") $dev->setMax($buffer[9]);
|
||||
if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'"));
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _current()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if ($buffer[2] == "Current" && $buffer[11] != "N/A" && $buffer[4] == "A") {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[1]);
|
||||
$dev->setValue($buffer[3]);
|
||||
if ($buffer[9] != "N/A") $dev->setMax($buffer[9]);
|
||||
if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'"));
|
||||
$this->mbinfo->setMbCurrent($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
}
|
||||
}
|
135
root/opt/phpsysinfo/includes/mb/class.hddtemp.inc.php
Normal file
135
root/opt/phpsysinfo/includes/mb/class.hddtemp.inc.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* hddtemp 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class HDDTemp extends Sensors
|
||||
{
|
||||
/**
|
||||
* get the temperature information from hddtemp
|
||||
* access is available through tcp or command
|
||||
*
|
||||
* @return array temperatures in array
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
$ar_buf = array();
|
||||
switch (strtolower(PSI_HDD_TEMP)) {
|
||||
case "tcp":
|
||||
$lines = '';
|
||||
// Timo van Roermund: connect to the hddtemp daemon, use a 5 second timeout.
|
||||
$fp = @fsockopen('localhost', 7634, $errno, $errstr, 5);
|
||||
// if connected, read the output of the hddtemp daemon
|
||||
if ($fp) {
|
||||
while (!feof($fp)) {
|
||||
$lines .= fread($fp, 1024);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
$this->error->addError("HDDTemp error", $errno.", ".$errstr);
|
||||
}
|
||||
$lines = str_replace("||", "|\n|", $lines);
|
||||
$ar_buf = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case "command":
|
||||
$strDrives = "";
|
||||
$strContent = "";
|
||||
$hddtemp_value = "";
|
||||
if (CommonFunctions::rfts("/proc/diskstats", $strContent, 0, 4096, false)) {
|
||||
$arrContent = preg_split("/\n/", $strContent, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($arrContent as $strLine) {
|
||||
preg_match("/^\s(.*)\s([a-z]*)\s(.*)/", $strLine, $arrSplit);
|
||||
if (! empty($arrSplit[2])) {
|
||||
$strDrive = '/dev/'.$arrSplit[2];
|
||||
if (file_exists($strDrive)) {
|
||||
$strDrives = $strDrives.$strDrive.' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (CommonFunctions::rfts("/proc/partitions", $strContent, 0, 4096, false)) {
|
||||
$arrContent = preg_split("/\n/", $strContent, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($arrContent as $strLine) {
|
||||
if (!preg_match("/^\s(.*)\s([\/a-z0-9]*(\/disc))\s(.*)/", $strLine, $arrSplit)) {
|
||||
preg_match("/^\s(.*)\s([a-z]*)\s(.*)/", $strLine, $arrSplit);
|
||||
}
|
||||
if (! empty($arrSplit[2])) {
|
||||
$strDrive = '/dev/'.$arrSplit[2];
|
||||
if (file_exists($strDrive)) {
|
||||
$strDrives = $strDrives.$strDrive.' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trim($strDrives) == "") {
|
||||
break;
|
||||
}
|
||||
if (CommonFunctions::executeProgram("hddtemp", $strDrives, $hddtemp_value, PSI_DEBUG)) {
|
||||
$hddtemp_value = preg_split("/\n/", $hddtemp_value, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($hddtemp_value as $line) {
|
||||
$temp = preg_split("/:\s/", $line, 3);
|
||||
if (count($temp) == 3 && preg_match("/^[0-9]/", $temp[2])) {
|
||||
preg_match("/^([0-9]*)(.*)/", $temp[2], $ar_temp);
|
||||
$temp[2] = trim($ar_temp[1]);
|
||||
$temp[3] = trim($ar_temp[2]);
|
||||
array_push($ar_buf, "|".implode("|", $temp)."|");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError("temperature()", "PSI_HDD_TEMP");
|
||||
break;
|
||||
}
|
||||
// Timo van Roermund: parse the info from the hddtemp daemon.
|
||||
foreach ($ar_buf as $line) {
|
||||
$data = array();
|
||||
if (preg_match("/\|(.*)\|(.*)\|(.*)\|(.*)\|/", $line, $data)) {
|
||||
if (trim($data[3]) != "ERR") {
|
||||
// get the info we need
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1] . ' (' . (strpos($data[2], " ")?substr($data[2], 0, strpos($data[2], " ")):$data[2]) . ')');
|
||||
if (is_numeric($data[3])) {
|
||||
$dev->setValue($data[3]);
|
||||
}
|
||||
$dev->setMax(60);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
}
|
||||
}
|
159
root/opt/phpsysinfo/includes/mb/class.healthd.inc.php
Normal file
159
root/opt/phpsysinfo/includes/mb/class.healthd.inc.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* healthd 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class Healthd 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':
|
||||
$lines = "";
|
||||
CommonFunctions::executeProgram('healthdc', '-t', $lines);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case 'file':
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/healthd.txt', $lines)) {
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return array voltage in array with lable
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_fans();
|
||||
$this->_voltage();
|
||||
}
|
||||
}
|
156
root/opt/phpsysinfo/includes/mb/class.hwsensors.inc.php
Normal file
156
root/opt/phpsysinfo/includes/mb/class.hwsensors.inc.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* hwsensors 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class HWSensors 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();
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+temp,\s+([0-9\.]+)\s+degC.*$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+([0-9\.]+)\s+degC$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+degC\s+\((.*)\)$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[3]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+degC$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+fanrpm,\s+([0-9\.]+)\s+RPM.*$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+([0-9\.]+)\s+RPM$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+RPM\s+\((.*)\)$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[3]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+RPM$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+volts_dc,\s+([0-9\.]+)\s+V.*$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[0-9]+=[^\s,]+,\s+([^,]+),\s+([0-9\.]+)\s+V\sDC$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+VDC\s+\((.*)\)$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[3]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
} elseif (preg_match('/^hw\.sensors\.[^\.]+\.(.*)=([0-9\.]+)\s+VDC$/', $line, $ar_buf)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($ar_buf[1]);
|
||||
$dev->setValue($ar_buf[2]);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
}
|
||||
}
|
197
root/opt/phpsysinfo/includes/mb/class.ipmi.inc.php
Normal file
197
root/opt/phpsysinfo/includes/mb/class.ipmi.inc.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
220
root/opt/phpsysinfo/includes/mb/class.ipmiutil.inc.php
Normal file
220
root/opt/phpsysinfo/includes/mb/class.ipmiutil.inc.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/**
|
||||
* ipmiutil 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class IPMIutil extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private content var through tcp or file access
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
case 'command':
|
||||
CommonFunctions::executeProgram('ipmiutil', 'sensor -stw', $lines);
|
||||
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case 'file':
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/ipmiutil.txt', $lines)) {
|
||||
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (isset($buffer[2]) && $buffer[2] == "Temperature" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sC$/", $buffer[6], $value)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
if (isset($buffer[7]) && $buffer[7] == "Thresholds") {
|
||||
if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[8], $limits))
|
||||
||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[9], $limits))
|
||||
||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[10], $limits))
|
||||
||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
|
||||
$dev->setMax($limits[1]);
|
||||
}
|
||||
}
|
||||
if ($buffer[5] != "OK") $dev->setEvent($buffer[5]);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (isset($buffer[2]) && $buffer[2] == "Voltage" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sV$/", $buffer[6], $value)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
if (isset($buffer[7]) && $buffer[7] == "Thresholds") {
|
||||
if ((isset($buffer[8]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[8], $limits))
|
||||
||(isset($buffer[9]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[9], $limits))
|
||||
||(isset($buffer[10]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[10], $limits))
|
||||
||(isset($buffer[11]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
|
||||
$dev->setMin($limits[1]);
|
||||
}
|
||||
if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[8], $limits))
|
||||
||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[9], $limits))
|
||||
||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[10], $limits))
|
||||
||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
|
||||
$dev->setMax($limits[1]);
|
||||
}
|
||||
}
|
||||
if ($buffer[5] != "OK") $dev->setEvent($buffer[5]);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (isset($buffer[2]) && $buffer[2] == "Fan" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sRPM$/", $buffer[6], $value)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
if (isset($buffer[7]) && $buffer[7] == "Thresholds") {
|
||||
if ((isset($buffer[8]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[8], $limits))
|
||||
||(isset($buffer[9]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[9], $limits))
|
||||
||(isset($buffer[10]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[10], $limits))
|
||||
||(isset($buffer[11]) && preg_match("/^lo-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
|
||||
$dev->setMin($limits[1]);
|
||||
} elseif ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[8], $limits))
|
||||
||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[9], $limits))
|
||||
||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[10], $limits))
|
||||
||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
|
||||
if ($limits[1]<$value[1]) {//max instead min issue
|
||||
$dev->setMin($limits[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($buffer[5] != "OK") $dev->setEvent($buffer[5]);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _power()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (isset($buffer[2]) && $buffer[2] == "Current" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sW$/", $buffer[6], $value)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
if (isset($buffer[7]) && $buffer[7] == "Thresholds") {
|
||||
if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[8], $limits))
|
||||
||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[9], $limits))
|
||||
||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[10], $limits))
|
||||
||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
|
||||
$dev->setMax($limits[1]);
|
||||
}
|
||||
}
|
||||
if ($buffer[5] != "OK") $dev->setEvent($buffer[5]);
|
||||
$this->mbinfo->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _current()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
$buffer = preg_split("/\s*\|\s*/", $line);
|
||||
if (isset($buffer[2]) && $buffer[2] == "Current" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\S+)\sA$/", $buffer[6], $value)) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($buffer[4]);
|
||||
$dev->setValue($value[1]);
|
||||
if (isset($buffer[7]) && $buffer[7] == "Thresholds") {
|
||||
if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[8], $limits))
|
||||
||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[9], $limits))
|
||||
||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[10], $limits))
|
||||
||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
|
||||
$dev->setMax($limits[1]);
|
||||
}
|
||||
}
|
||||
if ($buffer[5] != "OK") $dev->setEvent($buffer[5]);
|
||||
$this->mbinfo->setMbCurrent($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
}
|
||||
}
|
91
root/opt/phpsysinfo/includes/mb/class.k8temp.inc.php
Normal file
91
root/opt/phpsysinfo/includes/mb/class.k8temp.inc.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* K8Temp 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class K8Temp extends Sensors
|
||||
{
|
||||
/**
|
||||
* content to parse
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_lines = array();
|
||||
|
||||
/**
|
||||
* fill the private array
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
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)) {
|
||||
$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) {
|
||||
if (preg_match('/(.*):\s*(\d*)/', $line, $data)) {
|
||||
if ($data[2] > 0) {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setMax('70.0');
|
||||
if ($data[2] < 250) {
|
||||
$dev->setValue($data[2]);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
}
|
||||
}
|
411
root/opt/phpsysinfo/includes/mb/class.lmsensors.inc.php
Normal file
411
root/opt/phpsysinfo/includes/mb/class.lmsensors.inc.php
Normal file
@@ -0,0 +1,411 @@
|
||||
<?php
|
||||
/**
|
||||
* lmsensor 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class LMSensors 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':
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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";
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 ($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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 ($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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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]);
|
||||
|
||||
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->setMbPower($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 ($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);
|
||||
}
|
||||
}
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
$this->_current();
|
||||
}
|
||||
}
|
138
root/opt/phpsysinfo/includes/mb/class.mbm5.inc.php
Normal file
138
root/opt/phpsysinfo/includes/mb/class.mbm5.inc.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* MBM5 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class MBM5 extends Sensors
|
||||
{
|
||||
/**
|
||||
* array with the names of the labels
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_buf_label = array();
|
||||
|
||||
/**
|
||||
* array withe the values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_buf_value = array();
|
||||
|
||||
/**
|
||||
* read the MBM5.csv file and fill the private arrays
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
switch (strtolower(PSI_SENSOR_ACCESS)) {
|
||||
case 'file':
|
||||
$delim = "/;/";
|
||||
CommonFunctions::rfts(APP_ROOT."/data/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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
for ($intPosi = 3; $intPosi < 6; $intPosi++) {
|
||||
if ($this->_buf_value[$intPosi] == 0) {
|
||||
continue;
|
||||
}
|
||||
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($this->_buf_label[$intPosi]);
|
||||
$dev->setValue($hits[0]);
|
||||
$dev->setMax(70);
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
for ($intPosi = 13; $intPosi < 16; $intPosi++) {
|
||||
if (!isset($this->_buf_value[$intPosi])) {
|
||||
continue;
|
||||
}
|
||||
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($this->_buf_label[$intPosi]);
|
||||
$dev->setValue($hits[0]);
|
||||
$dev->setMin(3000);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
for ($intPosi = 6; $intPosi < 13; $intPosi++) {
|
||||
if ($this->_buf_value[$intPosi] == 0) {
|
||||
continue;
|
||||
}
|
||||
preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($this->_buf_label[$intPosi]);
|
||||
$dev->setValue($hits[0]);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_fans();
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
}
|
||||
}
|
143
root/opt/phpsysinfo/includes/mb/class.mbmon.inc.php
Normal file
143
root/opt/phpsysinfo/includes/mb/class.mbmon.inc.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* mbmon 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class MBMon 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 'tcp':
|
||||
$fp = fsockopen("localhost", 411, $errno, $errstr, 5);
|
||||
if ($fp) {
|
||||
$lines = "";
|
||||
while (!feof($fp)) {
|
||||
$lines .= fread($fp, 1024);
|
||||
}
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
} else {
|
||||
$this->error->addError("fsockopen()", $errno." ".$errstr);
|
||||
}
|
||||
break;
|
||||
case 'command':
|
||||
CommonFunctions::executeProgram('mbmon', '-c 1 -r', $lines, PSI_DEBUG);
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
break;
|
||||
case 'file':
|
||||
if (CommonFunctions::rfts(APP_ROOT.'/data/mbmon.txt', $lines)) {
|
||||
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^(TEMP\d*)\s*:\s*(.*)$/D', $line, $data)) {
|
||||
if ($data[2] <> '0') {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setMax(70);
|
||||
if ($data[2] < 250) {
|
||||
$dev->setValue($data[2]);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _fans()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^(FAN\d*)\s*:\s*(.*)$/D', $line, $data)) {
|
||||
if ($data[2] <> '0') {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
$dev->setMax(3000);
|
||||
$this->mbinfo->setMbFan($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _voltage()
|
||||
{
|
||||
foreach ($this->_lines as $line) {
|
||||
if (preg_match('/^(V.*)\s*:\s*(.*)$/D', $line, $data)) {
|
||||
if ($data[2] <> '+0.00') {
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName($data[1]);
|
||||
$dev->setValue($data[2]);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
}
|
||||
}
|
145
root/opt/phpsysinfo/includes/mb/class.ohm.inc.php
Normal file
145
root/opt/phpsysinfo/includes/mb/class.ohm.inc.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Open Hardware Monitor 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class OHM extends Sensors
|
||||
{
|
||||
/**
|
||||
* holds the COM object that we pull all the WMI data from
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
private $_buf = array();
|
||||
|
||||
/**
|
||||
* fill the private content var
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$_wmi = null;
|
||||
// don't set this params for local connection, it will not work
|
||||
$strHostname = '';
|
||||
$strUser = '';
|
||||
$strPassword = '';
|
||||
try {
|
||||
// initialize the wmi object
|
||||
$objLocator = new COM('WbemScripting.SWbemLocator');
|
||||
if ($strHostname == "") {
|
||||
$_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor');
|
||||
|
||||
} else {
|
||||
$_wmi = $objLocator->ConnectServer($strHostname, 'root\OpenHardwareMonitor', $strHostname.'\\'.$strUser, $strPassword);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data.");
|
||||
}
|
||||
if ($_wmi) {
|
||||
$this->_buf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get voltage information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get fan information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get power information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_fans();
|
||||
$this->_power();
|
||||
}
|
||||
}
|
62
root/opt/phpsysinfo/includes/mb/class.pitemp.inc.php
Normal file
62
root/opt/phpsysinfo/includes/mb/class.pitemp.inc.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* pitemp sensor class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PSI_Sensor
|
||||
* @author Marc Hillesheim <hawkeyexp@gmail.com>
|
||||
* @copyright 2012 Marc Hillesheim
|
||||
* @link http://pi.no-ip.biz
|
||||
*/
|
||||
class PiTemp extends Sensors
|
||||
{
|
||||
private function _temperature()
|
||||
{
|
||||
$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 (!is_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)) {
|
||||
$dev->setMax($temp_max / 1000);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("Voltage 1");
|
||||
$dev->setValue($volt / 1000000);
|
||||
$this->mbinfo->setMbVolt($dev);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
$dev = new SensorDevice();
|
||||
$dev->setName("Current 1");
|
||||
$dev->setValue($current / 1000000);
|
||||
$this->mbinfo->setMbCurrent($dev);
|
||||
}
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
$this->_voltage();
|
||||
$this->_current();
|
||||
}
|
||||
}
|
64
root/opt/phpsysinfo/includes/mb/class.sensors.inc.php
Normal file
64
root/opt/phpsysinfo/includes/mb/class.sensors.inc.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Basic OS Class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @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
|
||||
* @version SVN: $Id: class.sensors.inc.php 661 2012-08-27 11:26:39Z namiltd $
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
/**
|
||||
* Basic OS functions for all OS classes
|
||||
*
|
||||
* @category PHP
|
||||
* @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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
abstract class Sensors implements PSI_Interface_Sensor
|
||||
{
|
||||
/**
|
||||
* object for error handling
|
||||
*
|
||||
* @var Error
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
/**
|
||||
* object for the information
|
||||
*
|
||||
* @var MBInfo
|
||||
*/
|
||||
protected $mbinfo;
|
||||
|
||||
/**
|
||||
* build the global Error object
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->error = Error::singleton();
|
||||
$this->mbinfo = new MBInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the filled or unfilled (with default values) MBInfo object
|
||||
*
|
||||
* @see PSI_Interface_Sensor::getMBInfo()
|
||||
*
|
||||
* @return MBInfo
|
||||
*/
|
||||
final public function getMBInfo()
|
||||
{
|
||||
$this->build();
|
||||
|
||||
return $this->mbinfo;
|
||||
}
|
||||
}
|
132
root/opt/phpsysinfo/includes/mb/class.thermalzone.inc.php
Normal file
132
root/opt/phpsysinfo/includes/mb/class.thermalzone.inc.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Thermal Zone 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.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
|
||||
* @version Release: 3.0
|
||||
* @link http://phpsysinfo.sourceforge.net
|
||||
*/
|
||||
class ThermalZone extends Sensors
|
||||
{
|
||||
/**
|
||||
* holds the COM object that we pull all the WMI data from
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
private $_buf = array();
|
||||
|
||||
/**
|
||||
* fill the private content var
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
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');
|
||||
|
||||
} else {
|
||||
$_wmi = $objLocator->ConnectServer($strHostname, 'root\WMI', $strHostname.'\\'.$strUser, $strPassword);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for ThermalZone data.");
|
||||
}
|
||||
if ($_wmi) {
|
||||
$this->_buf = CommonFunctions::getWMI($_wmi, 'MSAcpi_ThermalZoneTemperature', array('InstanceName', 'CriticalTripPoint', 'CurrentTemperature'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get temperature information
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _temperature()
|
||||
{
|
||||
if (PSI_OS == 'WINNT') {
|
||||
if ($this->_buf) foreach ($this->_buf as $buffer) {
|
||||
if (isset($buffer['CurrentTemperature']) && (($value = ($buffer['CurrentTemperature'] - 2732)/10) > -100)) {
|
||||
$dev = new SensorDevice();
|
||||
if (isset($buffer['InstanceName']) && preg_match("/([^\\\\ ]+)$/", $buffer['InstanceName'], $outbuf)) {
|
||||
$dev->setName('ThermalZone '.$outbuf[1]);
|
||||
} else {
|
||||
$dev->setName('ThermalZone THM0_0');
|
||||
}
|
||||
$dev->setValue($value);
|
||||
if (isset($buffer['CriticalTripPoint']) && (($maxvalue = ($buffer['CriticalTripPoint'] - 2732)/10) > 0)) {
|
||||
$dev->setMax($maxvalue);
|
||||
}
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (glob('/sys/class/thermal/thermal_zone*/') as $thermalzone) {
|
||||
$thermalzonetemp = $thermalzone.'temp';
|
||||
$temp = null;
|
||||
if (CommonFunctions::rfts($thermalzonetemp, $temp, 0, 4096, false) && !is_null($temp) && (trim($temp) != "")) {
|
||||
if ($temp >= 1000) {
|
||||
$temp = $temp / 1000;
|
||||
}
|
||||
|
||||
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) != "")) {
|
||||
$dev->setName($temp_type);
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
$dev->setMax($temp_max);
|
||||
}
|
||||
|
||||
$this->mbinfo->setMbTemp($dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the information
|
||||
*
|
||||
* @see PSI_Interface_Sensor::build()
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->_temperature();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user