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
/**
-
 
3
 * lmsensor sensor class, getting information from lmsensor
-
 
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 LMSensors extends Sensors
-
 
16
{
-
 
17
    /**
-
 
18
     * content to parse
-
 
19
     *
-
 
20
     * @var array
-
 
21
     */
-
 
22
    private $_lines = array();
-
 
23
 
-
 
24
    /**
-
 
25
     * fill the private content var through command or data access
-
 
26
     */
-
 
27
    public function __construct()
-
 
28
    {
-
 
29
        parent::__construct();
-
 
30
        $lines = "";
-
 
31
        switch (defined('PSI_SENSOR_LMSENSORS_ACCESS')?strtolower(PSI_SENSOR_LMSENSORS_ACCESS):'command') {
-
 
32
        case 'command':
-
 
33
            CommonFunctions::executeProgram("sensors", "", $lines);
-
 
34
            break;
-
 
35
        case 'data':
-
 
36
            CommonFunctions::rfts(PSI_APP_ROOT.'/data/lmsensors.txt', $lines);
-
 
37
            break;
-
 
38
        default:
-
 
39
            $this->error->addConfigError('__construct()', '[sensor_lmsensors] ACCESS');
-
 
40
            break;
-
 
41
        }
2
 
42
 
-
 
43
        if (trim($lines) !== "") {
3
// phpSysInfo - A PHP System Information Script
44
            $lines = str_replace(":\n", ":", $lines);
4
// http://phpsysinfo.sourceforge.net/
45
            $lines = str_replace("\n\n", "\n", $lines);
-
 
46
            $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
-
 
47
        }
-
 
48
    }
5
 
49
 
-
 
50
    /**
-
 
51
     * get temperature information
-
 
52
     *
-
 
53
     * @return void
-
 
54
     */
-
 
55
    private function _temperature()
-
 
56
    {
-
 
57
        $applesmc = false;
-
 
58
        $sname = '';
-
 
59
        foreach ($this->_lines as $line) {
-
 
60
            if ((trim($line) !== "") && (strpos($line, ':') === false)) {
-
 
61
                //$applesmc = preg_match("/^applesmc-/", $line);
-
 
62
                $sname = trim($line);
-
 
63
                $applesmc =  ($sname === "applesmc-isa-0300");
-
 
64
                if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
-
 
65
                    $sname = ' ('.$snamebuf[1].')';
-
 
66
                } else {
-
 
67
                    $sname = '';
-
 
68
                }
-
 
69
            }
-
 
70
            $data = array();
-
 
71
            if (preg_match("/^(.+):(.+).C\s*\((.+)=(.+).C,(.+)=(.+).C\)(.*)\)/", $line, $data)) {
-
 
72
                ;
-
 
73
            } elseif (preg_match("/^(.+):(.+).C\s*\((.+)=(.+).C,(.+)=(.+).C\)(.*)/", $line, $data)) {
-
 
74
                ;
-
 
75
            } elseif (preg_match("/^(.+):(.+).C\s*\((.+)=(.+).C\)(.*)/", $line, $data)) {
-
 
76
                ;
-
 
77
            } elseif (preg_match("/^(.+):(.+).C\s*\(/", $line, $data)) {
-
 
78
                ;
-
 
79
            } else {
-
 
80
                preg_match("/^(.+):(.+).C$/", $line, $data);
-
 
81
            }
-
 
82
            if (count($data)>2) {
-
 
83
                foreach ($data as $key=>$value) {
-
 
84
                    if (preg_match("/^\+?(-?[0-9\.]+).?$/", trim($value), $newvalue)) {
6
// This program is free software; you can redistribute it and/or
85
                        $data[$key] = 0+trim($newvalue[1]);
-
 
86
                    } else {
-
 
87
                        $data[$key] = trim($value);
-
 
88
                    }
-
 
89
                }
-
 
90
                if ($applesmc && (strlen($data[1]) == 4)) {
-
 
91
                    if ($data[1][0] == "T") {
-
 
92
                        if ($data[1][1] == "A") {
7
// modify it under the terms of the GNU General Public License
93
                            $data[1] = $data[1] . " Ambient";
-
 
94
                        } elseif ($data[1][1] == "B") {
8
// as published by the Free Software Foundation; either version 2
95
                            $data[1] = $data[1] . " Battery";
-
 
96
                        } elseif ($data[1][1] == "C") {
9
// of the License, or (at your option) any later version.
97
                            $data[1] = $data[1] . " CPU";
10
 
-
 
-
 
98
                        } elseif ($data[1][1] == "G") {
-
 
99
                            $data[1] = $data[1] . " GPU";
-
 
100
                        } elseif ($data[1][1] == "H") {
-
 
101
                            $data[1] = $data[1] . " Harddisk Bay";
-
 
102
                        } elseif ($data[1][1] == "h") {
11
// This program is distributed in the hope that it will be useful,
103
                            $data[1] = $data[1] . " Heatpipe";
-
 
104
                        } elseif ($data[1][1] == "L") {
-
 
105
                            $data[1] = $data[1] . " LCD";
-
 
106
                        } elseif ($data[1][1] == "M") {
-
 
107
                            $data[1] = $data[1] . " Memory";
-
 
108
                        } elseif ($data[1][1] == "m") {
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
109
                            $data[1] = $data[1] . " Memory Contr.";
-
 
110
                        } elseif ($data[1][1] == "N") {
-
 
111
                            $data[1] = $data[1] . " Northbridge";
-
 
112
                        } elseif ($data[1][1] == "O") {
-
 
113
                            $data[1] = $data[1] . " Optical Drive";
-
 
114
                        } elseif ($data[1][1] == "p") {
-
 
115
                            $data[1] = $data[1] . " Power supply";
-
 
116
                        } elseif ($data[1][1] == "S") {
-
 
117
                            $data[1] = $data[1] . " Slot";
-
 
118
                        } elseif ($data[1][1] == "s") {
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
119
                            $data[1] = $data[1] . " Slot";
14
// GNU General Public License for more details.
120
                        } elseif ($data[1][1] == "W") {
-
 
121
                            $data[1] = $data[1] . " Airport";
-
 
122
                        }
15
 
123
 
-
 
124
                        if ($data[1][3] == "H") {
16
// You should have received a copy of the GNU General Public License
125
                            $data[1] = $data[1] . " Heatsink";
-
 
126
                        } elseif ($data[1][3] == "P") {
17
// along with this program; if not, write to the Free Software
127
                            $data[1] = $data[1] . " Proximity";
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
128
                        } elseif ($data[1][3] == "D") {
-
 
129
                            $data[1] = $data[1] . " Die";
-
 
130
                        }
-
 
131
                    }
-
 
132
                }
19
 
133
 
-
 
134
                $dev = new SensorDevice();
-
 
135
                $dev->setName($data[1].$sname);
-
 
136
                $dev->setValue($data[2]);
-
 
137
                if (isset($data[6]) && $data[2] <= $data[6]) {
-
 
138
                    $dev->setMax(max($data[4], $data[6]));
20
// $Id: class.lmsensors.inc.php,v 1.19 2007/02/18 19:11:31 bigmichi1 Exp $
139
                } elseif (isset($data[4]) && $data[2] <= $data[4]) {
21
if (!defined('IN_PHPSYSINFO')) {
140
                    $dev->setMax($data[4]);
-
 
141
                }
-
 
142
                if (preg_match("/\sALARM\s*$/", $line) || preg_match("/\sALARM\s+sensor\s+=/", $line)) {
-
 
143
                    $dev->setEvent("Alarm");
22
    die("No Hacking");
144
                }
-
 
145
                $this->mbinfo->setMbTemp($dev);
-
 
146
            }
-
 
147
        }
23
}
148
    }
24
 
149
 
-
 
150
    /**
-
 
151
     * get fan information
-
 
152
     *
-
 
153
     * @return void
-
 
154
     */
-
 
155
    private function _fans()
-
 
156
    {
-
 
157
        $sname = '';
-
 
158
        foreach ($this->_lines as $line) {
-
 
159
            if ((trim($line) !== "") && (strpos($line, ':') === false)) {
-
 
160
                $sname = trim($line);
-
 
161
                if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
-
 
162
                    $sname = ' ('.$snamebuf[1].')';
-
 
163
                } else {
-
 
164
                    $sname = '';
-
 
165
                }
-
 
166
            }
-
 
167
            $data = array();
-
 
168
            if (preg_match("/^(.+):(.+) RPM\s*\((.+)=(.+) RPM,(.+)=(.+)\)(.*)\)/", $line, $data)) {
-
 
169
                ;
-
 
170
            } elseif (preg_match("/^(.+):(.+) RPM\s*\((.+)=(.+) RPM,(.+)=(.+)\)(.*)/", $line, $data)) {
-
 
171
                ;
-
 
172
            } elseif (preg_match("/^(.+):(.+) RPM\s*\((.+)=(.+) RPM\)(.*)/", $line, $data)) {
-
 
173
                ;
-
 
174
            } elseif (preg_match("/^(.+):(.+) RPM\s*\(/", $line, $data)) {
-
 
175
                ;
-
 
176
            } else {
-
 
177
                preg_match("/^(.+):(.+) RPM$/", $line, $data);
-
 
178
            }
-
 
179
            if (count($data)>2) {
-
 
180
                 foreach ($data as $key=>$value) {
-
 
181
                    if (preg_match("/^\+?(-?[0-9\.]+).?$/", trim($value), $newvalue)) {
25
require_once(APP_ROOT . "/includes/common_functions.php");
182
                        $data[$key] = 0+trim($newvalue[1]);
-
 
183
                    } else {
-
 
184
                        $data[$key] = trim($value);
-
 
185
                    }
-
 
186
                }
-
 
187
                $dev = new SensorDevice();
-
 
188
                $dev->setName($data[1].$sname);
-
 
189
                $dev->setValue(trim($data[2]));
-
 
190
                if (isset($data[4])) {
-
 
191
                    $dev->setMin(trim($data[4]));
-
 
192
                }
-
 
193
                if (preg_match("/\sALARM\s*$/", $line)) {
-
 
194
                    $dev->setEvent("Alarm");
-
 
195
                }
-
 
196
                $this->mbinfo->setMbFan($dev);
-
 
197
            }
-
 
198
        }
-
 
199
    }
26
 
200
 
-
 
201
    /**
-
 
202
     * get voltage information
-
 
203
     *
-
 
204
     * @return void
-
 
205
     */
-
 
206
    private function _voltage()
-
 
207
    {
-
 
208
        $sname = '';
-
 
209
        foreach ($this->_lines as $line) {
-
 
210
            if ((trim($line) !== "") && (strpos($line, ':') === false)) {
-
 
211
                $sname = trim($line);
-
 
212
                if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
-
 
213
                    $sname = ' ('.$snamebuf[1].')';
-
 
214
                } else {
-
 
215
                    $sname = '';
-
 
216
                }
27
class mbinfo {
217
            }
-
 
218
            $data = array();
-
 
219
            if (preg_match("/^(.+):(.+) V\s*\((.+)=(.+) V,(.+)=(.+) V\)(.*)\)/", $line, $data)) {
-
 
220
                ;
-
 
221
            } elseif (preg_match("/^(.+):(.+) V\s*\((.+)=(.+) V,(.+)=(.+) V\)(.*)/", $line, $data)) {
-
 
222
                ;
-
 
223
            } elseif (preg_match("/^(.+):(.+) V\s*\(/", $line, $data)) {
-
 
224
                ;
-
 
225
            } else {
-
 
226
                preg_match("/^(.+):(.+) V$/", $line, $data);
-
 
227
            }
-
 
228
 
-
 
229
            if (count($data)>2) {
-
 
230
                foreach ($data as $key=>$value) {
-
 
231
                    if (preg_match("/^\+?(-?[0-9\.]+)$/", trim($value), $newvalue)) {
-
 
232
                        $data[$key] = 0+trim($newvalue[1]);
-
 
233
                    } else {
-
 
234
                        $data[$key] = trim($value);
-
 
235
                    }
-
 
236
                }
-
 
237
                $dev = new SensorDevice();
-
 
238
                $dev->setName($data[1].$sname);
-
 
239
                $dev->setValue($data[2]);
-
 
240
                if (isset($data[4])) {
-
 
241
                    $dev->setMin($data[4]);
-
 
242
                }
-
 
243
                if (isset($data[6])) {
-
 
244
                    $dev->setMax($data[6]);
-
 
245
                }
-
 
246
                if (preg_match("/\sALARM\s*$/", $line)) {
-
 
247
                    $dev->setEvent("Alarm");
-
 
248
                }
-
 
249
                $this->mbinfo->setMbVolt($dev);
28
  var $lines;
250
            }
-
 
251
        }
-
 
252
    }
29
 
253
 
-
 
254
    /**
30
  function mbinfo() {
255
     * get power information
-
 
256
     *
-
 
257
     * @return void
-
 
258
     */
31
   $lines = execute_program("sensors", "");
259
    private function _power()
-
 
260
    {
-
 
261
        $sname = '';
32
   // Martijn Stolk: Dirty fix for misinterpreted output of sensors, 
262
        foreach ($this->_lines as $line) {
33
   // where info could come on next line when the label is too long.
263
            if ((trim($line) !== "") && (strpos($line, ':') === false)) {
34
   $lines = str_replace(":\n", ":", $lines);
264
                $sname = trim($line);
-
 
265
                if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
35
   $lines = str_replace("\n\n", "\n", $lines);
266
                    $sname = ' ('.$snamebuf[1].')';
-
 
267
                } else {
36
   $this->lines = explode("\n", $lines);
268
                    $sname = '';
37
  }
269
                }
38
  
270
            }
39
  function temperature() {
271
            $data = array();
-
 
272
/* not tested yet
-
 
273
            if (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W,(.+)=(.+) W\)(.*)\)/", $line, $data)) {
40
    $ar_buf = array();
274
                ;
-
 
275
            } elseif (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W,(.+)=(.+) W\)(.*)/", $line, $data)) {
41
    $results = array();
276
                ;
42
 
-
 
43
    $sensors_value = $this->lines;
277
            } else
44
 
278
*/
45
    foreach($sensors_value as $line) {
279
            if (preg_match("/^(.+):(.+) W\s*\((.+)=(.+) W\)(.*)/", $line, $data)) {
46
      $data = array();
280
                ;
47
      if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)) ;
281
            } elseif (preg_match("/^(.+):(.+) W\s*\(/", $line, $data)) {
-
 
282
                ;
-
 
283
            } else {
48
      elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)) ;
284
                preg_match("/^(.+):(.+) W$/", $line, $data);
-
 
285
            }
-
 
286
            if (count($data)>2) {
49
      else (ereg("(.*):(.*)", $line, $data));
287
                foreach ($data as $key=>$value) {
-
 
288
                    if (preg_match("/^\+?(-?[0-9\.]+).?$/", trim($value), $newvalue)) {
-
 
289
                        $data[$key] = 0+trim($newvalue[1]);
50
      if (count($data) > 1) {
290
                    } else {
-
 
291
                        $data[$key] = trim($value);
-
 
292
                    }
-
 
293
                }
-
 
294
                $dev = new SensorDevice();
51
        $temp = substr(trim($data[2]), -1);
295
                $dev->setName($data[1].$sname);
-
 
296
                $dev->setValue($data[2]);
-
 
297
 
-
 
298
/* not tested yet
-
 
299
                if (isset($data[6]) && $data[2] <= $data[6]) {
-
 
300
                    $dev->setMax(max($data[4], $data[6]));
52
        switch ($temp) {
301
                } else
-
 
302
*/
-
 
303
                if (isset($data[4]) && $data[2] <= $data[4]) {
-
 
304
                    $dev->setMax($data[4]);
53
          case "C";
305
                }
-
 
306
                if (preg_match("/\sALARM\s*$/", $line)) {
-
 
307
                    $dev->setEvent("Alarm");
54
          case "F":
308
                }
55
            array_push($ar_buf, $line);
309
                $this->mbinfo->setMbPower($dev);
56
            break;
310
            }
57
        }
311
        }
58
      }
-
 
59
    }
312
    }
60
 
313
 
61
    $i = 0;
314
    /**
62
    foreach($ar_buf as $line) {
-
 
63
      unset($data);
315
     * get current information
64
      if (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)", $line, $data)) ;
-
 
65
      elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)", $line, $data)) ;
-
 
66
      elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)", $line, $data)) ;
-
 
67
      else (ereg("(.*):(.*).C", $line, $data));
-
 
68
 
-
 
69
      $results[$i]['label'] = $data[1];
-
 
70
      $results[$i]['value'] = trim($data[2]);
-
 
71
      if ( isset( $data[6] ) && trim( $data[2] ) > trim( $data[6] ) ) {
-
 
72
        $results[$i]['limit'] = "+75";
-
 
73
        $results[$i]['perce'] = "+75";
-
 
74
      } else {
-
 
75
        $results[$i]['limit'] = isset($data[4]) ? trim($data[4]) : "+75";
-
 
76
        $results[$i]['perce'] = isset($data[6]) ? trim($data[6]) : "+75";
-
 
77
      }
316
     *
78
      if ($results[$i]['limit'] < $results[$i]['perce']) {	 	
-
 
79
         $results[$i]['limit'] = $results[$i]['perce'];	 	
-
 
80
       }      
317
     * @return void
81
      $i++;
-
 
82
    }
318
     */
83
 
-
 
84
    asort($results);
-
 
85
    return array_values($results);
319
    private function _current()
86
  }
320
    {
87
 
-
 
88
  function fans() {
-
 
89
    $ar_buf = array();
-
 
90
    $results = array();
321
        $sname = '';
91
 
-
 
92
    $sensors_value = $this->lines;
-
 
93
 
-
 
94
    foreach($sensors_value as $line) {
322
        foreach ($this->_lines as $line) {
95
      $data = array();
-
 
96
      if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data));
-
 
97
      elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data));
323
            if ((trim($line) !== "") && (strpos($line, ':') === false)) {
98
      else ereg("(.*):(.*)", $line, $data);
-
 
99
 
-
 
100
      if (count($data) > 1) {
-
 
101
        $temp = explode(" ", trim($data[2]));
324
                $sname = trim($line);
102
        if (count($temp) == 1)
-
 
103
          $temp = explode("\xb0", trim($data[2]));
325
                if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
104
	if(isset($temp[1])) {
-
 
105
          switch ($temp[1]) {
326
                    $sname = ' ('.$snamebuf[1].')';
106
            case "RPM":
327
                } else {
107
              array_push($ar_buf, $line);
328
                    $sname = '';
108
              break;
329
                }
109
          }
330
            }
110
	}
-
 
111
      }
-
 
112
    }
-
 
113
 
-
 
114
    $i = 0;
-
 
115
    foreach($ar_buf as $line) {
-
 
116
      unset($data);
331
            $data = array();
117
      if (ereg("(.*):(.*) RPM  \((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)", $line, $data));
332
            if (preg_match("/^(.+):(.+) A\s*\((.+)=(.+) A,(.+)=(.+) A\)(.*)\)/", $line, $data)) {
118
      elseif (ereg("(.*):(.*) RPM  \((.*)=(.*) RPM,(.*)=(.*)\)(.*)", $line, $data));
333
                ;
119
      elseif (ereg("(.*):(.*) RPM  \((.*)=(.*) RPM\)(.*)", $line, $data));
334
            } elseif (preg_match("/^(.+):(.+) A\s*\((.+)=(.+) A,(.+)=(.+) A\)(.*)/", $line, $data)) {
120
      else ereg("(.*):(.*) RPM", $line, $data);
335
                ;
121
 
-
 
122
      $results[$i]['label'] = trim($data[1]);
-
 
123
      $results[$i]['value'] = trim($data[2]);
-
 
124
      $results[$i]['min'] = isset($data[4]) ? trim($data[4]) : 0;
336
            } elseif (preg_match("/^(.+):(.+) A\s*\(/", $line, $data)) {
125
      $i++;
337
                ;
126
    }
-
 
127
 
-
 
128
    asort($results);
338
            } else {
129
    return array_values($results);
339
                preg_match("/^(.+):(.+) A$/", $line, $data);
130
  }
-
 
131
 
-
 
132
  function voltage() {
340
            }
133
    $ar_buf = array();
341
            if (count($data)>2) {
134
    $results = array();
342
                foreach ($data as $key=>$value) {
135
 
-
 
136
    $sensors_value = $this->lines;
343
                    if (preg_match("/^\+?([0-9\.]+).?$/", trim($value), $newvalue)) {
137
 
-
 
138
    foreach($sensors_value as $line) {
344
                        $data[$key] = trim($newvalue[1]);
139
      $data = array();
345
                    } else {
140
      if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data));
-
 
141
      else ereg("(.*):(.*)", $line, $data);
346
                        $data[$key] = trim($value);
142
      
347
                    }
143
      if (count($data) > 1) {
348
                }
144
        $temp = explode(" ", trim($data[2]));
349
                $dev = new SensorDevice();
145
        if (count($temp) == 1)
350
                $dev->setName($data[1].$sname);
146
          $temp = explode("\xb0", trim($data[2]));
351
                $dev->setValue($data[2]);
147
        if (isset($temp[1])) {
352
                if (isset($data[4])) {
148
          switch ($temp[1]) {
353
                    $dev->setMin($data[4]);
149
            case "V":
354
                }
150
              array_push($ar_buf, $line);
355
                if (isset($data[6])) {
151
              break;
356
                    $dev->setMax($data[6]);
152
	  }
-
 
153
        }
357
                }
154
      }
-
 
155
    }
-
 
156
 
-
 
157
    $i = 0;
-
 
158
    foreach($ar_buf as $line) {
358
                if (preg_match("/\sALARM\s*$/", $line)) {
159
      unset($data);
-
 
160
      if (ereg("(.*):(.*) V  \((.*)=(.*) V,(.*)=(.*) V\)(.*)\)", $line, $data));
-
 
161
      elseif (ereg("(.*):(.*) V  \((.*)=(.*) V,(.*)=(.*) V\)(.*)", $line, $data));
-
 
162
      else ereg("(.*):(.*) V$", $line, $data);
359
                    $dev->setEvent("Alarm");
163
      if(isset($data[1])) {
360
                }
164
        $results[$i]['label'] = trim($data[1]);
-
 
165
        $results[$i]['value'] = trim($data[2]);
361
                $this->mbinfo->setMbCurrent($dev);
166
        $results[$i]['min'] = isset($data[4]) ? trim($data[4]) : 0;
-
 
167
        $results[$i]['max'] = isset($data[6]) ? trim($data[6]) : 0;
-
 
168
        $i++;
362
            }
169
      }
363
        }
170
    }
364
    }
171
    return $results;
-
 
172
  }
-
 
173
}
-
 
174
 
365
 
-
 
366
    /**
-
 
367
     * get other information
-
 
368
     *
-
 
369
     * @return void
-
 
370
     */
-
 
371
    private function _other()
-
 
372
    {
-
 
373
        $sname = '';
-
 
374
        foreach ($this->_lines as $line) {
-
 
375
            if ((trim($line) !== "") && (strpos($line, ':') === false)) {
-
 
376
                $sname = trim($line);
-
 
377
                if (preg_match('/^([^-]+)-/', $sname, $snamebuf)) {
-
 
378
                    $sname = ' ('.$snamebuf[1].')';
-
 
379
                } else {
-
 
380
                    $sname = '';
-
 
381
                }
-
 
382
            }
-
 
383
            $data = array();
-
 
384
            preg_match("/^(.+):\s*([^\-\+\d\s].+)$/", $line, $data);
-
 
385
            if ((count($data)>2) && ($data[1]!=="Adapter")) {
-
 
386
                $dev = new SensorDevice();
-
 
387
                $dev->setName($data[1].$sname);
-
 
388
                if (preg_match("/(.*\s*)ALARM\s*$/", $data[2], $aldata)) {
-
 
389
                    $dev->setEvent("Alarm");
-
 
390
                    if ((count($aldata)>1) && trim($aldata[1]!=="")) {
-
 
391
                        $dev->setValue(trim($aldata[1]));
-
 
392
                    } else {
-
 
393
                        $dev->setValue($data[2]);
-
 
394
                    }
-
 
395
                } else {
-
 
396
                    $dev->setValue($data[2]);
-
 
397
                }
-
 
398
                $this->mbinfo->setMbOther($dev);
-
 
399
            }
-
 
400
        }
-
 
401
    }
-
 
402
 
-
 
403
    /**
-
 
404
     * get the information
-
 
405
     *
-
 
406
     * @see PSI_Interface_Sensor::build()
-
 
407
     *
-
 
408
     * @return Void
-
 
409
     */
-
 
410
    public function build()
-
 
411
    {
-
 
412
        $this->_temperature();
-
 
413
        $this->_voltage();
-
 
414
        $this->_fans();
-
 
415
        $this->_power();
-
 
416
        $this->_current();
-
 
417
        $this->_other();
-
 
418
    }
175
?>
419
}