592 |
stephane |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
// phpSysInfo - A PHP System Information Script
|
|
|
4 |
// http://phpsysinfo.sourceforge.net/
|
|
|
5 |
|
|
|
6 |
// This program is free software; you can redistribute it and/or
|
|
|
7 |
// modify it under the terms of the GNU General Public License
|
|
|
8 |
// as published by the Free Software Foundation; either version 2
|
|
|
9 |
// of the License, or (at your option) any later version.
|
|
|
10 |
|
|
|
11 |
// This program is distributed in the hope that it will be useful,
|
|
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
14 |
// GNU General Public License for more details.
|
|
|
15 |
|
|
|
16 |
// You should have received a copy of the GNU General Public License
|
|
|
17 |
// along with this program; if not, write to the Free Software
|
|
|
18 |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
19 |
|
|
|
20 |
// This class was created by Z. Frombach ( zoltan at frombach dot com )
|
|
|
21 |
|
|
|
22 |
// $Id: class.mbmon.inc.php,v 1.5 2007/02/18 19:11:31 bigmichi1 Exp $
|
|
|
23 |
|
|
|
24 |
class mbinfo {
|
|
|
25 |
var $lines;
|
|
|
26 |
|
|
|
27 |
function temperature() {
|
|
|
28 |
$results = array();
|
|
|
29 |
|
|
|
30 |
if (!isset($this->lines) ) {
|
|
|
31 |
$this->lines = explode("\n", execute_program('mbmon', '-c 1 -r'));
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
$i = 0;
|
|
|
35 |
foreach($this->lines as $line) {
|
|
|
36 |
if (preg_match('/^(TEMP\d*)\s*:\s*(.*)$/D', $line, $data)) {
|
|
|
37 |
if ($data[2]<>'0') {
|
|
|
38 |
$results[$i]['label'] = $data[1];
|
|
|
39 |
$results[$i]['limit'] = '70.0';
|
|
|
40 |
if($data[2] > 250) {
|
|
|
41 |
$results[$i]['value'] = 0;
|
|
|
42 |
$results[$i]['percent'] = 0;
|
|
|
43 |
} else {
|
|
|
44 |
$results[$i]['value'] = $data[2];
|
|
|
45 |
$results[$i]['percent'] = $results[$i]['value'] * 100 / $results[$i]['limit'];
|
|
|
46 |
}
|
|
|
47 |
$i++;
|
|
|
48 |
}
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
return $results;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
function fans() {
|
|
|
55 |
$results = array();
|
|
|
56 |
|
|
|
57 |
if (!isset($this->lines) ) {
|
|
|
58 |
$this->lines = explode("\n", execute_program('mbmon', '-c 1 -r'));
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
$i = 0;
|
|
|
62 |
foreach($this->lines as $line) {
|
|
|
63 |
if (preg_match('/^(FAN\d*)\s*:\s*(.*)$/D', $line, $data)) {
|
|
|
64 |
if ($data[2]<>'0') {
|
|
|
65 |
$results[$i]['label'] = $data[1];
|
|
|
66 |
$results[$i]['value'] = $data[2];
|
|
|
67 |
$results[$i]['min'] = '3000';
|
|
|
68 |
$i++;
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
return $results;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
function voltage() {
|
|
|
76 |
$results = array();
|
|
|
77 |
|
|
|
78 |
if (!isset($this->lines) ) {
|
|
|
79 |
$this->lines = explode("\n", execute_program('mbmon', '-c 1 -r'));
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
$i = 0;
|
|
|
83 |
foreach($this->lines as $line) {
|
|
|
84 |
if (preg_match('/^(V.*)\s*:\s*(.*)$/D', $line, $data)) {
|
|
|
85 |
if ($data[2]<>'+0.00') {
|
|
|
86 |
$results[$i]['label'] = $data[1];
|
|
|
87 |
$results[$i]['value'] = $data[2];
|
|
|
88 |
$results[$i]['min'] = '0.00';
|
|
|
89 |
$results[$i]['max'] = '0.00';
|
|
|
90 |
$i++;
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
return $results;
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
?>
|