Subversion Repositories ALCASAR

Rev

Rev 2976 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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