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; |
} |
} |
|
?> |
} |