Subversion Repositories ALCASAR

Rev

Rev 3037 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2770 rexy 1
<?php
2
/**
3
 * healthd sensor class, getting information from healthd
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI_Sensor
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
10
 * @copyright 2009 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
12
 * @version   Release: 3.0
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
class Healthd extends Sensors
16
{
17
    /**
18
     * content to parse
19
     *
20
     * @var array
21
     */
22
    private $_values = array();
325 richard 23
 
2770 rexy 24
    /**
25
     * fill the private content var through command or data access
26
     */
27
    public function __construct()
28
    {
29
        parent::__construct();
2976 rexy 30
        if (PSI_OS == 'FreeBSD') switch (defined('PSI_SENSOR_HEALTHD_ACCESS')?strtolower(PSI_SENSOR_HEALTHD_ACCESS):'command') {
2770 rexy 31
        case 'command':
32
            if (CommonFunctions::executeProgram('healthdc', '-t', $lines)) {
33
                $lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
34
                if (count($lines0) == 1) {
35
                    $this->_values = preg_split("/\t+/", $lines0[0]);
36
                }
37
            }
38
            break;
39
        case 'data':
3100 rexy 40
            if (!defined('PSI_EMU_PORT') && CommonFunctions::rftsdata('healthd.tmp', $lines)) {
2770 rexy 41
                $lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
42
                if (count($lines0) == 1) {
43
                    $this->_values = preg_split("/\t+/", $lines0[0]);
44
                }
45
            }
46
            break;
47
        default:
48
            $this->error->addConfigError('__construct()', '[sensor_healthd] ACCESS');
49
        }
50
    }
325 richard 51
 
2770 rexy 52
    /**
53
     * get temperature information
54
     *
55
     * @return void
56
     */
57
    private function _temperature()
58
    {
59
        if (count($this->_values) == 14) {
60
            $dev1 = new SensorDevice();
61
            $dev1->setName('temp1');
62
            $dev1->setValue($this->_values[1]);
63
//            $dev1->setMax(70);
64
            $this->mbinfo->setMbTemp($dev1);
65
            $dev2 = new SensorDevice();
66
            $dev2->setName('temp1');
67
            $dev2->setValue($this->_values[2]);
68
//            $dev2->setMax(70);
69
            $this->mbinfo->setMbTemp($dev2);
70
            $dev3 = new SensorDevice();
71
            $dev3->setName('temp1');
72
            $dev3->setValue($this->_values[3]);
73
//            $dev3->setMax(70);
74
            $this->mbinfo->setMbTemp($dev3);
75
        }
76
    }
325 richard 77
 
2770 rexy 78
    /**
79
     * get fan information
80
     *
81
     * @return void
82
     */
83
    private function _fans()
84
    {
85
        if (count($this->_values) == 14) {
86
            $dev1 = new SensorDevice();
87
            $dev1->setName('fan1');
88
            $dev1->setValue($this->_values[4]);
89
//            $dev1->setMin(3000);
90
            $this->mbinfo->setMbFan($dev1);
91
            $dev2 = new SensorDevice();
92
            $dev2->setName('fan2');
93
            $dev2->setValue($this->_values[5]);
94
//            $dev2->setMin(3000);
95
            $this->mbinfo->setMbFan($dev2);
96
            $dev3 = new SensorDevice();
97
            $dev3->setName('fan3');
98
            $dev3->setValue($this->_values[6]);
99
//            $dev3->setMin(3000);
100
            $this->mbinfo->setMbFan($dev3);
101
        }
325 richard 102
    }
103
 
2770 rexy 104
    /**
105
     * get voltage information
106
     *
107
     * @return void
108
     */
109
    private function _voltage()
110
    {
111
        if (count($this->_values) == 14) {
112
            $dev1 = new SensorDevice();
113
            $dev1->setName('Vcore1');
114
            $dev1->setValue($this->_values[7]);
115
            $this->mbinfo->setMbVolt($dev1);
116
            $dev2 = new SensorDevice();
117
            $dev2->setName('Vcore2');
118
            $dev2->setValue($this->_values[8]);
119
            $this->mbinfo->setMbVolt($dev2);
120
            $dev3 = new SensorDevice();
121
            $dev3->setName('3volt');
122
            $dev3->setValue($this->_values[9]);
123
            $this->mbinfo->setMbVolt($dev3);
124
            $dev4 = new SensorDevice();
125
            $dev4->setName('+5Volt');
126
            $dev4->setValue($this->_values[10]);
127
            $this->mbinfo->setMbVolt($dev4);
128
            $dev5 = new SensorDevice();
129
            $dev5->setName('+12Volt');
130
            $dev5->setValue($this->_values[11]);
131
            $this->mbinfo->setMbVolt($dev5);
132
            $dev6 = new SensorDevice();
133
            $dev6->setName('-12Volt');
134
            $dev6->setValue($this->_values[12]);
135
            $this->mbinfo->setMbVolt($dev6);
136
            $dev7 = new SensorDevice();
137
            $dev7->setName('-5Volt');
138
            $dev7->setValue($this->_values[13]);
139
            $this->mbinfo->setMbVolt($dev7);
140
        }
325 richard 141
    }
142
 
2770 rexy 143
    /**
144
     * get the information
145
     *
146
     * @see PSI_Interface_Sensor::build()
147
     *
3037 rexy 148
     * @return void
2770 rexy 149
     */
150
    public function build()
151
    {
152
        $this->_temperature();
153
        $this->_fans();
154
        $this->_voltage();
325 richard 155
    }
2770 rexy 156
}