Subversion Repositories ALCASAR

Rev

Rev 325 | Rev 2976 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 325 Rev 2770
Line 1... Line 1...
1
<?php 
1
<?php
2
 
2
/**
3
// phpSysInfo - A PHP System Information Script
3
 * healthd sensor class, getting information from healthd
-
 
4
 *
4
// http://phpsysinfo.sourceforge.net/
5
 * PHP version 5
5
 
6
 *
-
 
7
 * @category  PHP
-
 
8
 * @package   PSI_Sensor
6
// This program is free software; you can redistribute it and/or
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
-
 
10
 * @copyright 2009 phpSysInfo
7
// modify it under the terms of the GNU General Public License
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
8
// as published by the Free Software Foundation; either version 2
13
 * @link      http://phpsysinfo.sourceforge.net
-
 
14
 */
9
// of the License, or (at your option) any later version.
15
class Healthd extends Sensors
10
 
16
{
-
 
17
    /**
11
// This program is distributed in the hope that it will be useful,
18
     * content to parse
-
 
19
     *
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
     * @var array
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
     */
14
// GNU General Public License for more details.
22
    private $_values = array();
15
 
23
 
-
 
24
    /**
16
// You should have received a copy of the GNU General Public License
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':
17
// along with this program; if not, write to the Free Software
32
            if (CommonFunctions::executeProgram('healthdc', '-t', $lines)) {
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33
                $lines0 = preg_split("/\n/", $lines, 1, PREG_SPLIT_NO_EMPTY);
19
 
-
 
-
 
34
                if (count($lines0) == 1) {
20
// $Id: class.healthd.inc.php,v 1.6 2007/02/18 19:11:31 bigmichi1 Exp $
35
                    $this->_values = preg_split("/\t+/", $lines0[0]);
21
 
-
 
-
 
36
                }
22
class mbinfo {
37
            }
23
    var $lines;
38
            break;
24
 
-
 
25
  function temperature() {
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]);
26
    $ar_buf = array();
44
                }
-
 
45
            }
27
    $results = array();
46
            break;
28
 
-
 
29
    if (!isset($this->lines)) {
47
        default:
30
      $this->lines = execute_program('healthdc', '-t');
48
            $this->error->addConfigError('__construct()', '[sensor_healthd] ACCESS');
-
 
49
            break;
-
 
50
        }
31
    }
51
    }
32
 
52
 
-
 
53
    /**
33
    $ar_buf = preg_split("/\t+/", $this->lines);
54
     * get temperature information
34
 
55
     *
35
    $results[0]['label'] = 'temp1';
56
     * @return void
-
 
57
     */
36
    $results[0]['value'] = $ar_buf[1];
58
    private function _temperature()
-
 
59
    {
37
    $results[0]['limit'] = '70.0';
60
        if (count($this->_values) == 14) {
38
    $results[0]['percent'] = $results[0]['value'] * 100 / $results[0]['limit'];
61
            $dev1 = new SensorDevice();
39
    $results[1]['label'] = 'temp2';
62
            $dev1->setName('temp1');
40
    $results[1]['value'] = $ar_buf[2];
63
            $dev1->setValue($this->_values[1]);
41
    $results[1]['limit'] = '70.0';
64
//            $dev1->setMax(70);
42
    $results[1]['percent'] = $results[1]['value'] * 100 / $results[1]['limit'];
-
 
43
    $results[2]['label'] = 'temp3';
65
            $this->mbinfo->setMbTemp($dev1);
44
    $results[2]['value'] = $ar_buf[3];
66
            $dev2 = new SensorDevice();
45
    $results[2]['limit'] = '70.0';
67
            $dev2->setName('temp1');
46
    $results[2]['percent'] = $results[2]['value'] * 100 / $results[2]['limit'];
68
            $dev2->setValue($this->_values[2]);
47
    return $results;
69
//            $dev2->setMax(70);
48
  } 
-
 
49
 
-
 
50
  function fans() {
70
            $this->mbinfo->setMbTemp($dev2);
51
    $ar_buf = array();
71
            $dev3 = new SensorDevice();
52
    $results = array();
72
            $dev3->setName('temp1');
53
 
-
 
54
    if (!isset($this->lines)) {
73
            $dev3->setValue($this->_values[3]);
-
 
74
//            $dev3->setMax(70);
55
      $this->lines = execute_program('healthdc', '-t');
75
            $this->mbinfo->setMbTemp($dev3);
-
 
76
        }
56
    }
77
    }
57
 
78
 
-
 
79
    /**
58
    $ar_buf = preg_split("/\t+/", $this->lines);
80
     * get fan information
59
 
81
     *
-
 
82
     * @return void
-
 
83
     */
60
    $results[0]['label'] = 'fan1';
84
    private function _fans()
-
 
85
    {
61
    $results[0]['value'] = $ar_buf[4];
86
        if (count($this->_values) == 14) {
62
    $results[0]['min'] = '3000';
87
            $dev1 = new SensorDevice();
63
    $results[1]['label'] = 'fan2';
88
            $dev1->setName('fan1');
64
    $results[1]['value'] = $ar_buf[5];
89
            $dev1->setValue($this->_values[4]);
65
    $results[1]['min'] = '3000';
90
//            $dev1->setMin(3000);
-
 
91
            $this->mbinfo->setMbFan($dev1);
-
 
92
            $dev2 = new SensorDevice();
66
    $results[2]['label'] = 'fan3';
93
            $dev2->setName('fan2');
67
    $results[2]['value'] = $ar_buf[6];
94
            $dev2->setValue($this->_values[5]);
68
    $results[2]['min'] = '3000';
95
//            $dev2->setMin(3000);
69
 
-
 
70
    return $results;
96
            $this->mbinfo->setMbFan($dev2);
71
  } 
-
 
72
 
-
 
73
  function voltage() {
97
            $dev3 = new SensorDevice();
74
    $ar_buf = array();
98
            $dev3->setName('fan3');
75
    $results = array();
99
            $dev3->setValue($this->_values[6]);
76
 
-
 
77
    if (!isset($this->lines)) {
100
//            $dev3->setMin(3000);
78
      $this->lines = execute_program('healthdc', '-t');
101
            $this->mbinfo->setMbFan($dev3);
-
 
102
        }
79
    }
103
    }
80
 
104
 
-
 
105
    /**
81
    $ar_buf = preg_split("/\t+/", $this->lines);
106
     * get voltage information
82
 
107
     *
83
    $results[0]['label'] = 'Vcore1';
108
     * @return void
-
 
109
     */
84
    $results[0]['value'] = $ar_buf[7];
110
    private function _voltage()
-
 
111
    {
85
    $results[0]['min'] = '0.00';
112
        if (count($this->_values) == 14) {
86
    $results[0]['max'] = '0.00';
113
            $dev1 = new SensorDevice();
87
    $results[1]['label'] = 'Vcore2';
114
            $dev1->setName('Vcore1');
88
    $results[1]['value'] = $ar_buf[8];
115
            $dev1->setValue($this->_values[7]);
89
    $results[1]['min'] = '0.00';
116
            $this->mbinfo->setMbVolt($dev1);
90
    $results[1]['max'] = '0.00';
117
            $dev2 = new SensorDevice();
91
    $results[2]['label'] = '3volt';
118
            $dev2->setName('Vcore2');
92
    $results[2]['value'] = $ar_buf[9];
119
            $dev2->setValue($this->_values[8]);
93
    $results[2]['min'] = '0.00';
120
            $this->mbinfo->setMbVolt($dev2);
94
    $results[2]['max'] = '0.00';
121
            $dev3 = new SensorDevice();
95
    $results[3]['label'] = '+5Volt';
122
            $dev3->setName('3volt');
96
    $results[3]['value'] = $ar_buf[10];
123
            $dev3->setValue($this->_values[9]);
97
    $results[3]['min'] = '0.00';
124
            $this->mbinfo->setMbVolt($dev3);
98
    $results[3]['max'] = '0.00';
125
            $dev4 = new SensorDevice();
99
    $results[4]['label'] = '+12Volt';
126
            $dev4->setName('+5Volt');
100
    $results[4]['value'] = $ar_buf[11];
127
            $dev4->setValue($this->_values[10]);
101
    $results[4]['min'] = '0.00';
128
            $this->mbinfo->setMbVolt($dev4);
102
    $results[4]['max'] = '0.00';
129
            $dev5 = new SensorDevice();
103
    $results[5]['label'] = '-12Volt';
130
            $dev5->setName('+12Volt');
104
    $results[5]['value'] = $ar_buf[12];
131
            $dev5->setValue($this->_values[11]);
105
    $results[5]['min'] = '0.00';
132
            $this->mbinfo->setMbVolt($dev5);
106
    $results[5]['max'] = '0.00';
133
            $dev6 = new SensorDevice();
107
    $results[6]['label'] = '-5Volt';
134
            $dev6->setName('-12Volt');
108
    $results[6]['value'] = $ar_buf[13];
135
            $dev6->setValue($this->_values[12]);
109
    $results[6]['min'] = '0.00';
136
            $this->mbinfo->setMbVolt($dev6);
110
    $results[6]['max'] = '0.00';
137
            $dev7 = new SensorDevice();
111
 
-
 
112
    return $results;
138
            $dev7->setName('-5Volt');
-
 
139
            $dev7->setValue($this->_values[13]);
-
 
140
            $this->mbinfo->setMbVolt($dev7);
113
  } 
141
        }
114
} 
142
    }
115
 
143
 
-
 
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();
-
 
156
    }
116
?>
157
}