Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2770 → Rev 2769

/web/acc/phpsysinfo/includes/mb/class.hwmon.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.thermalzone.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.ipmitool.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.coretemp.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.ohm.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.speedfan.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.k8temp.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.pitemp.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.freeipmi.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.thinkpad.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.sensors.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.qtssnmp.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.ipmiutil.inc.php
File deleted
/web/acc/phpsysinfo/includes/mb/class.mbm5.inc.php
1,119 → 1,79
<?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();
<?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 $
 
/**
* array withe the values
*
* @var array
*/
private $_buf_value = array();
class mbinfo {
var $buf_label;
var $buf_value;
 
/**
* 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);
}
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;
}
}
 
/**
* 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.lmsensors.inc.php
1,419 → 1,175
<?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();
<?php
 
/**
* 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;
}
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
 
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 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()
{
$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";
}
// 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.
 
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";
}
}
}
// 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.
 
$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);
}
}
}
// $Id: class.lmsensors.inc.php,v 1.19 2007/02/18 19:11:31 bigmichi1 Exp $
if (!defined('IN_PHPSYSINFO')) {
die("No Hacking");
}
 
/**
* 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);
}
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 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);
}
$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));
 
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);
}
}
$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++;
}
 
/**
* 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]);
asort($results);
return array_values($results);
}
 
/* 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);
}
}
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;
}
}
}
}
 
/**
* 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);
}
}
$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 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);
}
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 the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
$this->_power();
$this->_current();
$this->_other();
$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++;
}
}
return $results;
}
}
 
?>
/web/acc/phpsysinfo/includes/mb/class.hddtemp.inc.php
1,124 → 1,114
<?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);
}
}
}
}
 
/**
* get the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
}
// 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;
}
}
?>
/web/acc/phpsysinfo/includes/mb/class.mbmon.inc.php
1,132 → 1,99
<?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();
 
/**
* 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;
}
}
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
 
/**
* 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);
}
}
// 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++;
}
}
}
return $results;
}
 
/**
* 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);
}
}
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++;
}
}
}
return $results;
}
 
/**
* 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);
}
}
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 the information
*
* @see PSI_Interface_Sensor::build()
*
* @return void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
}
return $results;
}
}
 
?>
/web/acc/phpsysinfo/includes/mb/index.html
--- class.healthd.inc.php (revision 2770)
+++ class.healthd.inc.php (revision 2769)
@@ -1,157 +1,116 @@
-<?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();
+<?php
- /**
- * 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;
- }
- }
+// phpSysInfo - A PHP System Information Script
+// http://phpsysinfo.sourceforge.net/
- /**
- * 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 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.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.hwsensors.inc.php
1,145 → 1,80
<?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();
<?php
 
/**
* 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);
}
// phpSysInfo - A PHP System Information Script
// http://phpsysinfo.sourceforge.net/
 
/**
* 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);
}
}
// 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 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 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 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 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 the information
*
* @see PSI_Interface_Sensor::build()
*
* @return Void
*/
public function build()
{
$this->_temperature();
$this->_voltage();
$this->_fans();
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;
}
}
 
?>