Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 324 → Rev 325

/web/acc/phpsysinfo/includes/mb/class.mbm5.inc.php
0,0 → 1,79
<?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 $
 
class mbinfo {
var $buf_label;
var $buf_value;
 
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;
}
}
 
?>
/web/acc/phpsysinfo/includes/mb/class.lmsensors.inc.php
0,0 → 1,175
<?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.lmsensors.inc.php,v 1.19 2007/02/18 19:11:31 bigmichi1 Exp $
if (!defined('IN_PHPSYSINFO')) {
die("No Hacking");
}
 
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;
}
}
}
 
$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));
 
$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++;
}
 
asort($results);
return array_values($results);
}
 
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;
}
}
}
}
 
$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++;
}
 
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;
}
}
}
}
 
$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
0,0 → 1,114
<?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.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
0,0 → 1,99
<?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.
 
// 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;
}
 
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;
}
 
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++;
}
}
}
 
return $results;
}
}
 
?>
/web/acc/phpsysinfo/includes/mb/index.html
--- class.healthd.inc.php (nonexistent)
+++ class.healthd.inc.php (revision 325)
@@ -0,0 +1,116 @@
+<?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.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');
+ }
+
+ $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');
+ }
+
+ $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');
+ }
+
+ $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
0,0 → 1,80
<?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.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);
}
 
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;
}
 
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;
}
 
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;
}
}
 
?>