Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2769 → Rev 2770

/web/acc/phpsysinfo/includes/mb/class.coretemp.inc.php
0,0 → 1,54
<?php
/**
* coretemp sensor class, getting hardware temperature information through sysctl on FreeBSD
* or from /sys/devices/platform/coretemp. on Linux
*
* 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 Coretemp extends Hwmon
{
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
if (PSI_OS == 'Linux') {
$hwpaths = glob("/sys/devices/platform/coretemp.*/", GLOB_NOSORT);
if (is_array($hwpaths) && (count($hwpaths) > 0)) {
$hwpaths = array_merge($hwpaths, glob("/sys/devices/platform/coretemp.*/hwmon/hwmon*/", GLOB_NOSORT));
}
if (is_array($hwpaths) && (($totalh = count($hwpaths)) > 0)) {
for ($h = 0; $h < $totalh; $h++) {
$this->_temperature($hwpaths[$h]);
}
}
} else {
$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);
}
}
}
}
}
/web/acc/phpsysinfo/includes/mb/class.freeipmi.inc.php
0,0 → 1,187
<?php
/**
* freeipmi sensor class, getting information from ipmi-sensors
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @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 FreeIPMI 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();
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);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/freeipmi.txt', $lines)) {
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_freeipmi] 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[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);
}
}
}
 
/**
* 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
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
$this->_power();
$this->_current();
$this->_other();
}
}
/web/acc/phpsysinfo/includes/mb/class.hddtemp.inc.php
1,114 → 1,124
<?php
/**
* hddtemp sensor class, getting information from hddtemp
*
* PHP version 5
*
* @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 2, or (at your option) any later version
* @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 void
*/
private function _temperature()
{
$ar_buf = array();
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);
// 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()", "[sensor_hddtemp] ACCESS");
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);
}
}
}
}
 
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
// $Id: class.hddtemp.inc.php,v 1.7 2007/01/21 13:17:20 bigmichi1 Exp $
 
class hddtemp {
function temperature($hddtemp_avail) {
$ar_buf = array();
$results = array();
switch ($hddtemp_avail) {
case "tcp":
// 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) {
// read output of the daemon
$lines = '';
while (!feof($fp)) {
$lines .= fread($fp, 1024);
}
// close the connection
fclose($fp);
} else {
die("HDDTemp error: " . $errno . ", " . $errstr);
}
$lines = str_replace("||", "|\n|", $lines);
$ar_buf = explode("\n", $lines);
break;
case "suid":
$strDrives = "";
$strContent = rfts( "/proc/diskstats", 0, 4096, false );
if( $strContent != "ERROR" ) {
$arrContent = explode( "\n", $strContent );
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 {
$strContent = rfts( "/proc/partitions", 0, 4096, false );
if( $strContent != "ERROR" ) {
$arrContent = explode( "\n", $strContent );
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 ) == "" ) {
return array();
}
 
$hddtemp_value = execute_program("hddtemp", $strDrives);
$hddtemp_value = explode("\n", $hddtemp_value);
foreach($hddtemp_value as $line) {
$temp = preg_split("/:\s/", $line, 3);
if(count($temp) == 3 && preg_match("/^[0-9]/", $temp[2])) {
list($temp[2], $temp[3]) = (preg_split("/\s/", $temp[2]));
array_push( $ar_buf, "|" . implode("|", $temp) . "|");
}
}
break;
default:
die("Bad hddtemp configuration in config.php");
}
// Timo van Roermund: parse the info from the hddtemp daemon.
$i = 0;
foreach($ar_buf as $line) {
$data = array();
if (ereg("\|(.*)\|(.*)\|(.*)\|(.*)\|", $line, $data)) {
if( trim($data[3]) != "ERR" ) {
// get the info we need
$results[$i]['label'] = $data[1];
$results[$i]['value'] = $data[3];
$results[$i]['model'] = $data[2];
$i++;
}
}
}
return $results;
}
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
}
}
?>
/web/acc/phpsysinfo/includes/mb/class.healthd.inc.php
1,116 → 1,157
<?php
<?php
/**
* healthd sensor class, getting information from healthd
*
* 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 Healthd extends Sensors
{
/**
* content to parse
*
* @var array
*/
private $_values = array();
 
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
/**
* fill the private content var through command or data access
*/
public function __construct()
{
parent::__construct();
switch (defined('PSI_SENSOR_HEALTHD_ACCESS')?strtolower(PSI_SENSOR_HEALTHD_ACCESS):'command') {
case 'command':
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 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/healthd.txt', $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()', '[sensor_healthd] ACCESS');
break;
}
}
 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
/**
* get temperature information
*
* @return void
*/
private function _temperature()
{
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);
}
}
 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
// $Id: class.healthd.inc.php,v 1.6 2007/02/18 19:11:31 bigmichi1 Exp $
 
class mbinfo {
var $lines;
 
function temperature() {
$ar_buf = array();
$results = array();
 
if (!isset($this->lines)) {
$this->lines = execute_program('healthdc', '-t');
/**
* get fan information
*
* @return void
*/
private function _fans()
{
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);
}
}
 
$ar_buf = preg_split("/\t+/", $this->lines);
 
$results[0]['label'] = 'temp1';
$results[0]['value'] = $ar_buf[1];
$results[0]['limit'] = '70.0';
$results[0]['percent'] = $results[0]['value'] * 100 / $results[0]['limit'];
$results[1]['label'] = 'temp2';
$results[1]['value'] = $ar_buf[2];
$results[1]['limit'] = '70.0';
$results[1]['percent'] = $results[1]['value'] * 100 / $results[1]['limit'];
$results[2]['label'] = 'temp3';
$results[2]['value'] = $ar_buf[3];
$results[2]['limit'] = '70.0';
$results[2]['percent'] = $results[2]['value'] * 100 / $results[2]['limit'];
return $results;
}
 
function fans() {
$ar_buf = array();
$results = array();
 
if (!isset($this->lines)) {
$this->lines = execute_program('healthdc', '-t');
/**
* get voltage information
*
* @return void
*/
private function _voltage()
{
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);
}
}
 
$ar_buf = preg_split("/\t+/", $this->lines);
 
$results[0]['label'] = 'fan1';
$results[0]['value'] = $ar_buf[4];
$results[0]['min'] = '3000';
$results[1]['label'] = 'fan2';
$results[1]['value'] = $ar_buf[5];
$results[1]['min'] = '3000';
$results[2]['label'] = 'fan3';
$results[2]['value'] = $ar_buf[6];
$results[2]['min'] = '3000';
 
return $results;
}
 
function voltage() {
$ar_buf = array();
$results = array();
 
if (!isset($this->lines)) {
$this->lines = execute_program('healthdc', '-t');
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
$this->_fans();
$this->_voltage();
}
 
$ar_buf = preg_split("/\t+/", $this->lines);
 
$results[0]['label'] = 'Vcore1';
$results[0]['value'] = $ar_buf[7];
$results[0]['min'] = '0.00';
$results[0]['max'] = '0.00';
$results[1]['label'] = 'Vcore2';
$results[1]['value'] = $ar_buf[8];
$results[1]['min'] = '0.00';
$results[1]['max'] = '0.00';
$results[2]['label'] = '3volt';
$results[2]['value'] = $ar_buf[9];
$results[2]['min'] = '0.00';
$results[2]['max'] = '0.00';
$results[3]['label'] = '+5Volt';
$results[3]['value'] = $ar_buf[10];
$results[3]['min'] = '0.00';
$results[3]['max'] = '0.00';
$results[4]['label'] = '+12Volt';
$results[4]['value'] = $ar_buf[11];
$results[4]['min'] = '0.00';
$results[4]['max'] = '0.00';
$results[5]['label'] = '-12Volt';
$results[5]['value'] = $ar_buf[12];
$results[5]['min'] = '0.00';
$results[5]['max'] = '0.00';
$results[6]['label'] = '-5Volt';
$results[6]['value'] = $ar_buf[13];
$results[6]['min'] = '0.00';
$results[6]['max'] = '0.00';
 
return $results;
}
}
 
?>
}
/web/acc/phpsysinfo/includes/mb/class.hwmon.inc.php
0,0 → 1,256
<?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 = glob($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 ($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 = glob($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 = glob($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 = glob($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 = glob($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()
{
$hwpaths = glob("/sys/class/hwmon/hwmon*/", GLOB_NOSORT);
if (is_array($hwpaths) && (count($hwpaths) > 0)) {
$hwpaths = array_merge($hwpaths, glob("/sys/class/hwmon/hwmon*/device/", GLOB_NOSORT));
}
if (is_array($hwpaths) && (($totalh = count($hwpaths)) > 0)) {
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]);
}
}
}
}
/web/acc/phpsysinfo/includes/mb/class.hwsensors.inc.php
1,80 → 1,145
<?php
<?php
/**
* hwsensors sensor class, getting information from hwsensors
*
* 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 HWSensors extends Sensors
{
/**
* content to parse
*
* @var array
*/
private $_lines = array();
 
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
/**
* 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);
}
 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
// $Id: class.hwsensors.inc.php,v 1.4 2006/05/20 17:01:07 bigmichi1 Exp $
 
class mbinfo {
var $lines;
 
function mbinfo() {
$this->lines = execute_program('sysctl', '-w hw.sensors');
$this->lines = explode("\n", $this->lines);
/**
* 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);
}
}
}
 
function temperature() {
$ar_buf = array();
$results = array();
 
foreach( $this->lines as $line ) {
$ar_buf = preg_split("/[\s,]+/", $line);
if( isset( $ar_buf[3] ) && $ar_buf[2] == 'temp') {
$results[$j]['label'] = $ar_buf[1];
$results[$j]['value'] = $ar_buf[3];
$results[$j]['limit'] = '70.0';
$results[$j]['percent'] = $results[$j]['value'] * 100 / $results[$j]['limit'];
$j++;
}
}
return $results;
/**
* 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);
}
}
}
 
function fans() {
$ar_buf = array();
$results = array();
 
foreach( $this->lines as $line ) {
$ar_buf = preg_split("/[\s,]+/", $line );
if( isset( $ar_buf[3] ) && $ar_buf[2] == 'fanrpm') {
$results[$j]['label'] = $ar_buf[1];
$results[$j]['value'] = $ar_buf[3];
$j++;
}
}
return $results;
/**
* 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);
}
}
}
 
function voltage() {
$ar_buf = array();
$results = array();
 
foreach( $this->lines as $line ) {
$ar_buf = preg_split("/[\s,]+/", $line );
if ( isset( $ar_buf[3] ) && $ar_buf[2] == 'volts_dc') {
$results[$j]['label'] = $ar_buf[1];
$results[$j]['value'] = $ar_buf[3];
$results[$j]['min'] = '0.00';
$results[$j]['max'] = '0.00';
$j++;
}
}
return $results;
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
}
}
 
?>
/web/acc/phpsysinfo/includes/mb/class.ipmitool.inc.php
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 = "";
switch (defined('PSI_SENSOR_IPMITOOL_ACCESS')?strtolower(PSI_SENSOR_IPMITOOL_ACCESS):'command') {
case 'command':
CommonFunctions::executeProgram('ipmitool', 'sensor -v', $lines);
break;
case 'data':
CommonFunctions::rfts(PSI_APP_ROOT.'/data/ipmitool.txt', $lines);
break;
default:
$this->error->addConfigError('__construct()', '[sensor_ipmitool] ACCESS');
break;
}
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];
}
break;
}
$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();
}
}
/web/acc/phpsysinfo/includes/mb/class.ipmiutil.inc.php
0,0 → 1,265
<?php
/**
* ipmiutil sensor class, getting information from ipmi-sensors
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @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 IPMIutil 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();
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 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/ipmiutil.txt', $lines)) {
$this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_ipmiutil] 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)
&& $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("/^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)
&& $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))
||(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)
&& $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]);
} 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)
&& $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("/^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)
&& $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))
||(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 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])) {
$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);
}
$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();
}
}
/web/acc/phpsysinfo/includes/mb/class.k8temp.inc.php
0,0 → 1,80
<?php
/**
* K8Temp sensor class, getting information from k8temp
*
* 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 K8Temp extends Sensors
{
/**
* content to parse
*
* @var array
*/
private $_lines = array();
 
/**
* fill the private array
*/
public function __construct()
{
parent::__construct();
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 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/k8temp.txt', $lines)) {
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_k8temp] 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();
}
}
/web/acc/phpsysinfo/includes/mb/class.lmsensors.inc.php
1,175 → 1,419
<?php
<?php
/**
* lmsensor sensor class, getting information from lmsensor
*
* 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 LMSensors extends Sensors
{
/**
* content to parse
*
* @var array
*/
private $_lines = array();
 
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
/**
* fill the private content var through command or data access
*/
public function __construct()
{
parent::__construct();
$lines = "";
switch (defined('PSI_SENSOR_LMSENSORS_ACCESS')?strtolower(PSI_SENSOR_LMSENSORS_ACCESS):'command') {
case 'command':
CommonFunctions::executeProgram("sensors", "", $lines);
break;
case 'data':
CommonFunctions::rfts(PSI_APP_ROOT.'/data/lmsensors.txt', $lines);
break;
default:
$this->error->addConfigError('__construct()', '[sensor_lmsensors] ACCESS');
break;
}
 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
if (trim($lines) !== "") {
$lines = str_replace(":\n", ":", $lines);
$lines = str_replace("\n\n", "\n", $lines);
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
}
 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* get temperature information
*
* @return void
*/
private function _temperature()
{
$applesmc = false;
$sname = '';
foreach ($this->_lines as $line) {
if ((trim($line) !== "") && (strpos($line, ':') === false)) {
//$applesmc = preg_match("/^applesmc-/", $line);
$sname = trim($line);
$applesmc = ($sname === "applesmc-isa-0300");
if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
$sname = ' ('.$snamebuf[1].')';
} else {
$sname = '';
}
}
$data = array();
if (preg_match("/^(.+):(.+).C\s*\((.+)=(.+).C,(.+)=(.+).C\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+).C\s*\((.+)=(.+).C,(.+)=(.+).C\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+).C\s*\((.+)=(.+).C\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+).C\s*\(/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+).C$/", $line, $data);
}
if (count($data)>2) {
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 ($applesmc && (strlen($data[1]) == 4)) {
if ($data[1][0] == "T") {
if ($data[1][1] == "A") {
$data[1] = $data[1] . " Ambient";
} elseif ($data[1][1] == "B") {
$data[1] = $data[1] . " Battery";
} 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 Bay";
} elseif ($data[1][1] == "h") {
$data[1] = $data[1] . " Heatpipe";
} elseif ($data[1][1] == "L") {
$data[1] = $data[1] . " LCD";
} elseif ($data[1][1] == "M") {
$data[1] = $data[1] . " Memory";
} elseif ($data[1][1] == "m") {
$data[1] = $data[1] . " Memory Contr.";
} elseif ($data[1][1] == "N") {
$data[1] = $data[1] . " Northbridge";
} elseif ($data[1][1] == "O") {
$data[1] = $data[1] . " Optical Drive";
} elseif ($data[1][1] == "p") {
$data[1] = $data[1] . " Power supply";
} elseif ($data[1][1] == "S") {
$data[1] = $data[1] . " Slot";
} elseif ($data[1][1] == "s") {
$data[1] = $data[1] . " Slot";
} elseif ($data[1][1] == "W") {
$data[1] = $data[1] . " Airport";
}
 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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";
}
}
}
 
// $Id: class.lmsensors.inc.php,v 1.19 2007/02/18 19:11:31 bigmichi1 Exp $
if (!defined('IN_PHPSYSINFO')) {
die("No Hacking");
}
$dev = new SensorDevice();
$dev->setName($data[1].$sname);
$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) || preg_match("/\sALARM\s+sensor\s+=/", $line)) {
$dev->setEvent("Alarm");
}
$this->mbinfo->setMbTemp($dev);
}
}
}
 
require_once(APP_ROOT . "/includes/common_functions.php");
 
class mbinfo {
var $lines;
 
function mbinfo() {
$lines = execute_program("sensors", "");
// 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 = explode("\n", $lines);
}
function temperature() {
$ar_buf = array();
$results = array();
 
$sensors_value = $this->lines;
 
foreach($sensors_value as $line) {
$data = array();
if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)) ;
elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)) ;
else (ereg("(.*):(.*)", $line, $data));
if (count($data) > 1) {
$temp = substr(trim($data[2]), -1);
switch ($temp) {
case "C";
case "F":
array_push($ar_buf, $line);
break;
/**
* get fan information
*
* @return void
*/
private function _fans()
{
$sname = '';
foreach ($this->_lines as $line) {
if ((trim($line) !== "") && (strpos($line, ':') === false)) {
$sname = trim($line);
if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
$sname = ' ('.$snamebuf[1].')';
} else {
$sname = '';
}
}
$data = array();
if (preg_match("/^(.+):(.+) RPM\s*\((.+)=(.+) RPM,(.+)=(.+)\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) RPM\s*\((.+)=(.+) RPM,(.+)=(.+)\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) RPM\s*\((.+)=(.+) RPM\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) RPM\s*\(/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) RPM$/", $line, $data);
}
if (count($data)>2) {
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();
$dev->setName($data[1].$sname);
$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);
}
}
}
}
 
$i = 0;
foreach($ar_buf as $line) {
unset($data);
if (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)", $line, $data)) ;
elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)", $line, $data)) ;
elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)", $line, $data)) ;
else (ereg("(.*):(.*).C", $line, $data));
/**
* get voltage information
*
* @return void
*/
private function _voltage()
{
$sname = '';
foreach ($this->_lines as $line) {
if ((trim($line) !== "") && (strpos($line, ':') === false)) {
$sname = trim($line);
if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
$sname = ' ('.$snamebuf[1].')';
} else {
$sname = '';
}
}
$data = array();
if (preg_match("/^(.+):(.+) V\s*\((.+)=(.+) V,(.+)=(.+) V\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) V\s*\((.+)=(.+) V,(.+)=(.+) V\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) V\s*\(/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) V$/", $line, $data);
}
 
$results[$i]['label'] = $data[1];
$results[$i]['value'] = trim($data[2]);
if ( isset( $data[6] ) && trim( $data[2] ) > trim( $data[6] ) ) {
$results[$i]['limit'] = "+75";
$results[$i]['perce'] = "+75";
} else {
$results[$i]['limit'] = isset($data[4]) ? trim($data[4]) : "+75";
$results[$i]['perce'] = isset($data[6]) ? trim($data[6]) : "+75";
}
if ($results[$i]['limit'] < $results[$i]['perce']) {
$results[$i]['limit'] = $results[$i]['perce'];
}
$i++;
if (count($data)>2) {
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();
$dev->setName($data[1].$sname);
$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);
}
}
}
 
asort($results);
return array_values($results);
}
/**
* get power information
*
* @return void
*/
private function _power()
{
$sname = '';
foreach ($this->_lines as $line) {
if ((trim($line) !== "") && (strpos($line, ':') === false)) {
$sname = trim($line);
if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
$sname = ' ('.$snamebuf[1].')';
} else {
$sname = '';
}
}
$data = array();
/* not tested yet
if (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W,(.+)=(.+) W\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W,(.+)=(.+) W\)(.*)/", $line, $data)) {
;
} else
*/
if (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) W\s*\(/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) W$/", $line, $data);
}
if (count($data)>2) {
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();
$dev->setName($data[1].$sname);
$dev->setValue($data[2]);
 
function fans() {
$ar_buf = array();
$results = array();
 
$sensors_value = $this->lines;
 
foreach($sensors_value as $line) {
$data = array();
if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data));
elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data));
else ereg("(.*):(.*)", $line, $data);
 
if (count($data) > 1) {
$temp = explode(" ", trim($data[2]));
if (count($temp) == 1)
$temp = explode("\xb0", trim($data[2]));
if(isset($temp[1])) {
switch ($temp[1]) {
case "RPM":
array_push($ar_buf, $line);
break;
}
}
}
/* not tested yet
if (isset($data[6]) && $data[2] <= $data[6]) {
$dev->setMax(max($data[4], $data[6]));
} else
*/
if (isset($data[4]) && $data[2] <= $data[4]) {
$dev->setMax($data[4]);
}
if (preg_match("/\sALARM\s*$/", $line)) {
$dev->setEvent("Alarm");
}
$this->mbinfo->setMbPower($dev);
}
}
}
 
$i = 0;
foreach($ar_buf as $line) {
unset($data);
if (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)", $line, $data));
elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM,(.*)=(.*)\)(.*)", $line, $data));
elseif (ereg("(.*):(.*) RPM \((.*)=(.*) RPM\)(.*)", $line, $data));
else ereg("(.*):(.*) RPM", $line, $data);
 
$results[$i]['label'] = trim($data[1]);
$results[$i]['value'] = trim($data[2]);
$results[$i]['min'] = isset($data[4]) ? trim($data[4]) : 0;
$i++;
/**
* get current information
*
* @return void
*/
private function _current()
{
$sname = '';
foreach ($this->_lines as $line) {
if ((trim($line) !== "") && (strpos($line, ':') === false)) {
$sname = trim($line);
if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
$sname = ' ('.$snamebuf[1].')';
} else {
$sname = '';
}
}
$data = array();
if (preg_match("/^(.+):(.+) A\s*\((.+)=(.+) A,(.+)=(.+) A\)(.*)\)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) A\s*\((.+)=(.+) A,(.+)=(.+) A\)(.*)/", $line, $data)) {
;
} elseif (preg_match("/^(.+):(.+) A\s*\(/", $line, $data)) {
;
} else {
preg_match("/^(.+):(.+) A$/", $line, $data);
}
if (count($data)>2) {
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].$sname);
$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->setMbCurrent($dev);
}
}
}
 
asort($results);
return array_values($results);
}
 
function voltage() {
$ar_buf = array();
$results = array();
 
$sensors_value = $this->lines;
 
foreach($sensors_value as $line) {
$data = array();
if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data));
else ereg("(.*):(.*)", $line, $data);
if (count($data) > 1) {
$temp = explode(" ", trim($data[2]));
if (count($temp) == 1)
$temp = explode("\xb0", trim($data[2]));
if (isset($temp[1])) {
switch ($temp[1]) {
case "V":
array_push($ar_buf, $line);
break;
}
/**
* get other information
*
* @return void
*/
private function _other()
{
$sname = '';
foreach ($this->_lines as $line) {
if ((trim($line) !== "") && (strpos($line, ':') === false)) {
$sname = trim($line);
if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
$sname = ' ('.$snamebuf[1].')';
} else {
$sname = '';
}
}
$data = array();
preg_match("/^(.+):\s*([^\-\+\d\s].+)$/", $line, $data);
if ((count($data)>2) && ($data[1]!=="Adapter")) {
$dev = new SensorDevice();
$dev->setName($data[1].$sname);
if (preg_match("/(.*\s*)ALARM\s*$/", $data[2], $aldata)) {
$dev->setEvent("Alarm");
if ((count($aldata)>1) && trim($aldata[1]!=="")) {
$dev->setValue(trim($aldata[1]));
} else {
$dev->setValue($data[2]);
}
} else {
$dev->setValue($data[2]);
}
$this->mbinfo->setMbOther($dev);
}
}
}
}
 
$i = 0;
foreach($ar_buf as $line) {
unset($data);
if (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)\)", $line, $data));
elseif (ereg("(.*):(.*) V \((.*)=(.*) V,(.*)=(.*) V\)(.*)", $line, $data));
else ereg("(.*):(.*) V$", $line, $data);
if(isset($data[1])) {
$results[$i]['label'] = trim($data[1]);
$results[$i]['value'] = trim($data[2]);
$results[$i]['min'] = isset($data[4]) ? trim($data[4]) : 0;
$results[$i]['max'] = isset($data[6]) ? trim($data[6]) : 0;
$i++;
}
/**
* 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();
}
return $results;
}
}
 
?>
/web/acc/phpsysinfo/includes/mb/class.mbm5.inc.php
1,79 → 1,119
<?php
//
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// $Id: class.mbm5.inc.php,v 1.7 2007/02/18 19:11:31 bigmichi1 Exp $
<?php
/**
* MBM5 sensor class, getting information from Motherboard Monitor 5 information retrival through csv file
*
* 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 MBM5 extends Sensors
{
/**
* array with the names of the labels
*
* @var array
*/
private $_buf_label = array();
 
class mbinfo {
var $buf_label;
var $buf_value;
/**
* array withe the values
*
* @var array
*/
private $_buf_value = array();
 
function mbinfo() {
$buffer = rfts( APP_ROOT . "/data/MBM5.csv" );
if( strpos( $buffer, ";") === false ) {
$delim = ",";
} else {
$delim = ";";
}
$buffer = explode( "\n", $buffer );
$this->buf_label = explode( $delim, $buffer[0] );
$this->buf_value = explode( $delim, $buffer[1] );
}
function temperature() {
$results = array();
$intCount = 0;
for( $intPosi = 3; $intPosi < 6; $intPosi++ ) {
$results[$intCount]['label'] = $this->buf_label[$intPosi];
$results[$intCount]['value'] = $this->buf_value[$intPosi];
$results[$intCount]['limit'] = '70.0';
$intCount++;
}
return $results;
}
function fans() {
$results = array();
$intCount = 0;
for( $intPosi = 13; $intPosi < 16; $intPosi++ ) {
$results[$intCount]['label'] = $this->buf_label[$intPosi];
$results[$intCount]['value'] = $this->buf_value[$intPosi];
$results[$intCount]['min'] = '3000';
$intCount++;
}
return $results;
}
function voltage() {
$results = array();
$intCount = 0;
for( $intPosi = 6; $intPosi < 13; $intPosi++ ) {
$results[$intCount]['label'] = $this->buf_label[$intPosi];
$results[$intCount]['value'] = $this->buf_value[$intPosi];
$results[$intCount]['min'] = '0.00';
$results[$intCount]['max'] = '0.00';
$intCount++;
}
return $results;
}
}
/**
* read the MBM5.csv file and fill the private arrays
*/
public function __construct()
{
parent::__construct();
$delim = "/;/";
CommonFunctions::rfts(PSI_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);
}
 
?>
/**
* 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();
}
}
/web/acc/phpsysinfo/includes/mb/class.mbmon.inc.php
1,99 → 1,132
<?php
/**
* mbmon sensor class, getting information from mbmon
*
* 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 MBMon extends Sensors
{
/**
* content to parse
*
* @var array
*/
private $_lines = array();
 
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
/**
* fill the private content var through tcp, command or data access
*/
public function __construct()
{
parent::__construct();
switch (defined('PSI_SENSOR_MBMON_ACCESS')?strtolower(PSI_SENSOR_MBMON_ACCESS):'command') {
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 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/mbmon.txt', $lines)) {
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
}
break;
default:
$this->error->addConfigError('__construct()', '[sensor_mbmon] ACCESS');
break;
}
}
 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
// This class was created by Z. Frombach ( zoltan at frombach dot com )
 
// $Id: class.mbmon.inc.php,v 1.5 2007/02/18 19:11:31 bigmichi1 Exp $
 
class mbinfo {
var $lines;
 
function temperature() {
$results = array();
 
if (!isset($this->lines) ) {
$this->lines = explode("\n", execute_program('mbmon', '-c 1 -r'));
}
 
$i = 0;
foreach($this->lines as $line) {
if (preg_match('/^(TEMP\d*)\s*:\s*(.*)$/D', $line, $data)) {
if ($data[2]<>'0') {
$results[$i]['label'] = $data[1];
$results[$i]['limit'] = '70.0';
if($data[2] > 250) {
$results[$i]['value'] = 0;
$results[$i]['percent'] = 0;
} else {
$results[$i]['value'] = $data[2];
$results[$i]['percent'] = $results[$i]['value'] * 100 / $results[$i]['limit'];
}
$i++;
/**
* 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);
}
}
}
}
}
return $results;
}
 
function fans() {
$results = array();
 
if (!isset($this->lines) ) {
$this->lines = explode("\n", execute_program('mbmon', '-c 1 -r'));
}
 
$i = 0;
foreach($this->lines as $line) {
if (preg_match('/^(FAN\d*)\s*:\s*(.*)$/D', $line, $data)) {
if ($data[2]<>'0') {
$results[$i]['label'] = $data[1];
$results[$i]['value'] = $data[2];
$results[$i]['min'] = '3000';
$i++;
/**
* 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);
}
}
}
}
}
return $results;
}
 
function voltage() {
$results = array();
 
if (!isset($this->lines) ) {
$this->lines = explode("\n", execute_program('mbmon', '-c 1 -r'));
}
 
$i = 0;
foreach($this->lines as $line) {
if (preg_match('/^(V.*)\s*:\s*(.*)$/D', $line, $data)) {
if ($data[2]<>'+0.00') {
$results[$i]['label'] = $data[1];
$results[$i]['value'] = $data[2];
$results[$i]['min'] = '0.00';
$results[$i]['max'] = '0.00';
$i++;
/**
* 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);
}
}
}
}
}
 
return $results;
}
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
}
}
 
?>
/web/acc/phpsysinfo/includes/mb/class.ohm.inc.php
0,0 → 1,122
<?php
/**
* Open Hardware Monitor sensor class, getting information from Open Hardware Monitor
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @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 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;
try {
// initialize the wmi object
$objLocator = new COM('WbemScripting.SWbemLocator');
$_wmi = $objLocator->ConnectServer('', 'root\OpenHardwareMonitor');
} catch (Exception $e) {
$this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data.");
}
if ($_wmi) {
$tmpbuf = CommonFunctions::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'];
}
}
}
}
 
/**
* get temperature information
*
* @return void
*/
private function _temperature()
{
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);
}
}
 
/**
* get voltage information
*
* @return void
*/
private function _voltage()
{
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);
}
}
 
/**
* get fan information
*
* @return void
*/
private function _fans()
{
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);
}
}
 
/**
* get power information
*
* @return void
*/
private function _power()
{
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);
}
}
 
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
$this->_power();
}
}
/web/acc/phpsysinfo/includes/mb/class.pitemp.inc.php
0,0 → 1,64
<?php
/**
* pitemp sensor class
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @author Marc Hillesheim <hawkeyexp@gmail.com>
* @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
{
private function _temperature()
{
$temp = null;
$temp_max = null;
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) && (($temp = trim($temp)) != "")) {
$dev = new SensorDevice();
$dev->setName("CPU 1");
$dev->setValue($temp / 1000);
if (!is_null($temp_max) && (($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, 1, 4096, false) && !is_null($volt) && (($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, 1, 4096, false) && !is_null($current) && (($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();
}
}
/web/acc/phpsysinfo/includes/mb/class.qtssnmp.inc.php
0,0 → 1,81
<?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 (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .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." 127.0.0.1 .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." 127.0.0.1 .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 (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .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()
{
$this->_temperature();
$this->_fans();
}
}
/web/acc/phpsysinfo/includes/mb/class.sensors.inc.php
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 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
*/
/**
* 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 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
abstract class Sensors implements PSI_Interface_Sensor
{
/**
* object for error handling
*
* @var PSI_Error
*/
protected $error;
 
/**
* object for the information
*
* @var MBInfo
*/
protected $mbinfo;
 
/**
* build the global Error object
*/
public function __construct()
{
$this->error = PSI_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;
}
}
/web/acc/phpsysinfo/includes/mb/class.speedfan.inc.php
0,0 → 1,126
<?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();
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::rfts(PSI_APP_ROOT.'/data/speedfan.txt', $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');
break;
}
}
 
/**
* 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();
}
}
/web/acc/phpsysinfo/includes/mb/class.thermalzone.inc.php
0,0 → 1,139
<?php
/**
* Thermal Zone sensor class, getting information from Thermal Zone WMI class
*
* PHP version 5
*
* @category PHP
* @package PSI_Sensor
* @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
*/
private $_buf = array();
 
/**
* fill the private content var
*/
public function __construct()
{
parent::__construct();
if (PSI_OS == 'WINNT') {
$_wmi = null;
try {
// initialize the wmi object
$objLocator = new COM('WbemScripting.SWbemLocator');
$_wmi = $objLocator->ConnectServer('', 'root\WMI');
} 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 {
$notwas = true;
$thermalzones = glob('/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, 1, 4096, false) && !is_null($temp) && (($temp = trim($temp)) != "")) {
if ($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, 1, 4096, false) && !is_null($temp_type) && (($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, 1, 4096, false) && !is_null($temp_max) && (($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);
}
} else {
$this->mbinfo->setMbTemp($dev);
}
$notwas = false;
}
}
}
if ($notwas) {
$thermalzones = glob('/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) && !is_null($temp) && (($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);
}
}
}
}
}
 
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
}
}
/web/acc/phpsysinfo/includes/mb/class.thinkpad.inc.php
0,0 → 1,34
<?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') {
$hwpaths = glob("/sys/devices/platform/thinkpad_hwmon/", GLOB_NOSORT);
if (is_array($hwpaths) && (count($hwpaths) == 1)) {
$this->_temperature($hwpaths[0]);
$this->_fans($hwpaths[0]);
}
}
}
}