2024-09-07 20:53:46 +10:00
|
|
|
<?php
|
|
|
|
/**
|
2025-05-14 16:14:01 +01:00
|
|
|
* healthd sensor class, getting information from healthd
|
2024-09-07 20:53:46 +10:00
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* @category PHP
|
|
|
|
* @package PSI_Sensor
|
|
|
|
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
|
|
|
* @copyright 2009 phpSysInfo
|
2025-05-14 16:14:01 +01:00
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
2024-09-07 20:53:46 +10:00
|
|
|
* @version Release: 3.0
|
|
|
|
* @link http://phpsysinfo.sourceforge.net
|
|
|
|
*/
|
|
|
|
class Healthd extends Sensors
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* content to parse
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2025-05-14 16:14:01 +01:00
|
|
|
private $_values = array();
|
2024-09-07 20:53:46 +10:00
|
|
|
|
|
|
|
/**
|
2025-05-14 16:14:01 +01:00
|
|
|
* fill the private content var through command or data access
|
2024-09-07 20:53:46 +10:00
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
2025-05-14 16:14:01 +01:00
|
|
|
if (PSI_OS == 'FreeBSD') switch (defined('PSI_SENSOR_HEALTHD_ACCESS')?strtolower(PSI_SENSOR_HEALTHD_ACCESS):'command') {
|
2024-09-07 20:53:46 +10:00
|
|
|
case 'command':
|
2025-05-14 16:14:01 +01:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
2024-09-07 20:53:46 +10:00
|
|
|
break;
|
2025-05-14 16:14:01 +01:00
|
|
|
case 'data':
|
|
|
|
if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('healthd.tmp', $lines)) {
|
|
|
|
$lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
if (count($lines0) == 1) {
|
|
|
|
$this->_values = preg_split("/\t+/", $lines0[0]);
|
|
|
|
}
|
2024-09-07 20:53:46 +10:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2025-05-14 16:14:01 +01:00
|
|
|
$this->error->addConfigError('__construct()', '[sensor_healthd] ACCESS');
|
2024-09-07 20:53:46 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get temperature information
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _temperature()
|
|
|
|
{
|
2025-05-14 16:14:01 +01:00
|
|
|
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);
|
|
|
|
}
|
2024-09-07 20:53:46 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get fan information
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _fans()
|
|
|
|
{
|
2025-05-14 16:14:01 +01:00
|
|
|
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);
|
|
|
|
}
|
2024-09-07 20:53:46 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get voltage information
|
|
|
|
*
|
2025-05-14 16:14:01 +01:00
|
|
|
* @return void
|
2024-09-07 20:53:46 +10:00
|
|
|
*/
|
|
|
|
private function _voltage()
|
|
|
|
{
|
2025-05-14 16:14:01 +01:00
|
|
|
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);
|
|
|
|
}
|
2024-09-07 20:53:46 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the information
|
|
|
|
*
|
|
|
|
* @see PSI_Interface_Sensor::build()
|
|
|
|
*
|
2025-05-14 16:14:01 +01:00
|
|
|
* @return void
|
2024-09-07 20:53:46 +10:00
|
|
|
*/
|
|
|
|
public function build()
|
|
|
|
{
|
|
|
|
$this->_temperature();
|
|
|
|
$this->_fans();
|
|
|
|
$this->_voltage();
|
|
|
|
}
|
|
|
|
}
|