Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

sensors do not work in OpenBSD 4.7

kal-kalch
2010-06-27
2013-08-30
  • kal-kalch
    kal-kalch
    2010-06-27

    Oh, I'm sorry. Something seems to be wrong.
    __construct()

    Wrong Value in config.php for PSI_SENSOR_ACCESS

    system
    OpenBSD 4.7 GENERIC#0 i386, PHP/5.2.12,  phpSysInfo - 3.0.5

    pico config.php
    define('PSI_SENSOR_PROGRAM', 'HWSensors');
    define('PSI_SENSOR_ACCESS', 'command');

    sysctl -w hw.sensors
    hw.sensors.acpitz0.temp0=21.80 degC (zone temperature)
    hw.sensors.it0.temp0=25.00 degC
    hw.sensors.it0.temp1=25.00 degC
    hw.sensors.it0.temp2=28.00 degC
    hw.sensors.it0.fan0=3668 RPM
    hw.sensors.it0.fan2=2033 RPM
    hw.sensors.it0.volt0=1.52 VDC (VCORE_A)
    hw.sensors.it0.volt1=2.54 VDC (VCORE_B)
    hw.sensors.it0.volt2=3.25 VDC (+3.3V)
    hw.sensors.it0.volt3=4.19 VDC (+5V)
    hw.sensors.it0.volt4=12.10 VDC (+12V)
    hw.sensors.it0.volt5=-9.42 VDC (-12V)
    hw.sensors.it0.volt6=-4.68 VDC (-5V)
    hw.sensors.it0.volt7=3.87 VDC (+5VSB)
    hw.sensors.it0.volt8=4.08 VDC (VBAT)

     
  • Erkan
    Erkan
    2010-06-28

    Hello,

    Can you try this please ?

    define('PSI_SENSOR_ACCESS', 'tcp');
    

    Regards,

     
  • kal-kalch
    kal-kalch
    2010-06-28

    Hello!

    Set this option, no errors, but on the main page does not display data from sensors.

     
  • I´ve installed phpSysInfo today on a 5.3 OpenBSD box, and just noticed that the hwsensors code is a bit buggy.

    I made some editing in the includes/mb/class.hwsensors.inc.php file, to correct the parsing of the sysctl command output, and to correct the phpsysinfo.ini setting (file says you must use "command", but php was waiting for "tcp").

    Here´s the diff -u:

    --- class.hwsensors.inc.php Wed Aug 28 20:56:42 2013
    +++ class.hwsensors.inc.php.original Thu Aug 29 03:05:20 2013
    @@ -39,7 +39,7 @@
    {
    parent::__construct();
    switch (strtolower(PSI_SENSOR_ACCESS)) {
    - case 'command':
    + case 'tcp':
    $lines = "";
    CommonFunctions::executeProgram('sysctl', '-w hw.sensors', $lines);
    $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
    @@ -58,13 +58,11 @@
    private function _temperature()
    {
    foreach ($this->_lines as $line) {
    - $ar_buf = preg_split("/ /", $line);
    - if ($ar_buf[1] == 'degC') {
    + $ar_buf = preg_split("/[\s,]+/", $line);
    + if (isset($ar_buf[3]) && $ar_buf[2] == 'temp') {
    $dev = new SensorDevice();
    - $ar_buf2 = preg_split("/[.=]/", $ar_buf[0]);
    - $ar_buf3 = preg_split("/[()]/", $line);
    - $dev->setName($ar_buf2[3].' ('.$ar_buf3[1].')');
    - $dev->setValue($ar_buf2[4]);
    + $dev->setName($ar_buf[1]);
    + $dev->setValue($ar_buf[3]);
    $dev->setMax(70);
    $this->mbinfo->setMbTemp($dev);
    }
    @@ -79,14 +77,11 @@
    private function _fans()
    {
    foreach ($this->_lines as $line) {
    - $ar_buf = preg_split("/ /", $line);
    - if ($ar_buf[1] == 'RPM') {
    + $ar_buf = preg_split("/[\s,]+/", $line);
    + if (isset($ar_buf[3]) && $ar_buf[2] == 'fanrpm') {
    $dev = new SensorDevice();
    - $ar_buf2 = preg_split("/[.=]/", $ar_buf[0]);
    - $ar_buf3 = preg_split("/[()]/", $line);
    - $dev->setName($ar_buf2[3].' ('.$ar_buf3[1].')');
    - $dev->setValue($ar_buf2[4]);
    - $dev->setMin(1800);
    + $dev->setName($ar_buf[1]);
    + $dev->setValue($ar_buf[3]);
    $this->mbinfo->setMbFan($dev);
    }
    }
    @@ -101,15 +96,10 @@
    {
    foreach ($this->_lines as $line) {
    $ar_buf = preg_split("/[\s,]+/", $line);
    - $ar_buf = preg_split("/ /", $line);
    - if ($ar_buf[1] == 'VDC') {
    + if (isset($ar_buf[3]) && $ar_buf[2] == 'volts_dc') {
    $dev = new SensorDevice();
    - $ar_buf2 = preg_split("/[.=]/", $ar_buf[0]);
    - $ar_buf3 = preg_split("/[()]/", $line);
    - $dev->setName($ar_buf2[3].' ('.$ar_buf3[1].')');
    - $dev->setValue($ar_buf2[4]);
    - $dev->setMin(2.80);
    - $dev->setMax(3.20);
    + $dev->setName($ar_buf[1]);
    + $dev->setValue($ar_buf[3]);
    $this->mbinfo->setMbVolt($dev);
    }
    }