Subversion Repositories ALCASAR

Rev

Rev 325 | Rev 2976 | Go to most recent revision | 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();
30
        switch (defined('PSI_SENSOR_HEALTHD_ACCESS')?strtolower(PSI_SENSOR_HEALTHD_ACCESS):'command') {
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':
40
            if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/healthd.txt', $lines)) {
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
            break;
50
        }
51
    }
325 richard 52
 
2770 rexy 53
    /**
54
     * get temperature information
55
     *
56
     * @return void
57
     */
58
    private function _temperature()
59
    {
60
        if (count($this->_values) == 14) {
61
            $dev1 = new SensorDevice();
62
            $dev1->setName('temp1');
63
            $dev1->setValue($this->_values[1]);
64
//            $dev1->setMax(70);
65
            $this->mbinfo->setMbTemp($dev1);
66
            $dev2 = new SensorDevice();
67
            $dev2->setName('temp1');
68
            $dev2->setValue($this->_values[2]);
69
//            $dev2->setMax(70);
70
            $this->mbinfo->setMbTemp($dev2);
71
            $dev3 = new SensorDevice();
72
            $dev3->setName('temp1');
73
            $dev3->setValue($this->_values[3]);
74
//            $dev3->setMax(70);
75
            $this->mbinfo->setMbTemp($dev3);
76
        }
77
    }
325 richard 78
 
2770 rexy 79
    /**
80
     * get fan information
81
     *
82
     * @return void
83
     */
84
    private function _fans()
85
    {
86
        if (count($this->_values) == 14) {
87
            $dev1 = new SensorDevice();
88
            $dev1->setName('fan1');
89
            $dev1->setValue($this->_values[4]);
90
//            $dev1->setMin(3000);
91
            $this->mbinfo->setMbFan($dev1);
92
            $dev2 = new SensorDevice();
93
            $dev2->setName('fan2');
94
            $dev2->setValue($this->_values[5]);
95
//            $dev2->setMin(3000);
96
            $this->mbinfo->setMbFan($dev2);
97
            $dev3 = new SensorDevice();
98
            $dev3->setName('fan3');
99
            $dev3->setValue($this->_values[6]);
100
//            $dev3->setMin(3000);
101
            $this->mbinfo->setMbFan($dev3);
102
        }
325 richard 103
    }
104
 
2770 rexy 105
    /**
106
     * get voltage information
107
     *
108
     * @return void
109
     */
110
    private function _voltage()
111
    {
112
        if (count($this->_values) == 14) {
113
            $dev1 = new SensorDevice();
114
            $dev1->setName('Vcore1');
115
            $dev1->setValue($this->_values[7]);
116
            $this->mbinfo->setMbVolt($dev1);
117
            $dev2 = new SensorDevice();
118
            $dev2->setName('Vcore2');
119
            $dev2->setValue($this->_values[8]);
120
            $this->mbinfo->setMbVolt($dev2);
121
            $dev3 = new SensorDevice();
122
            $dev3->setName('3volt');
123
            $dev3->setValue($this->_values[9]);
124
            $this->mbinfo->setMbVolt($dev3);
125
            $dev4 = new SensorDevice();
126
            $dev4->setName('+5Volt');
127
            $dev4->setValue($this->_values[10]);
128
            $this->mbinfo->setMbVolt($dev4);
129
            $dev5 = new SensorDevice();
130
            $dev5->setName('+12Volt');
131
            $dev5->setValue($this->_values[11]);
132
            $this->mbinfo->setMbVolt($dev5);
133
            $dev6 = new SensorDevice();
134
            $dev6->setName('-12Volt');
135
            $dev6->setValue($this->_values[12]);
136
            $this->mbinfo->setMbVolt($dev6);
137
            $dev7 = new SensorDevice();
138
            $dev7->setName('-5Volt');
139
            $dev7->setValue($this->_values[13]);
140
            $this->mbinfo->setMbVolt($dev7);
141
        }
325 richard 142
    }
143
 
2770 rexy 144
    /**
145
     * get the information
146
     *
147
     * @see PSI_Interface_Sensor::build()
148
     *
149
     * @return Void
150
     */
151
    public function build()
152
    {
153
        $this->_temperature();
154
        $this->_fans();
155
        $this->_voltage();
325 richard 156
    }
2770 rexy 157
}