2770 |
rexy |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* qtstemp sensor class, getting hardware temperature information through snmpwalk
|
|
|
4 |
*
|
|
|
5 |
* PHP version 5
|
|
|
6 |
*
|
|
|
7 |
* @category PHP
|
|
|
8 |
* @package PSI_Sensor
|
|
|
9 |
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
|
|
|
10 |
* @copyright 2016 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 QTSsnmp extends Sensors
|
|
|
16 |
{
|
|
|
17 |
/**
|
|
|
18 |
* get temperature information
|
|
|
19 |
*
|
|
|
20 |
* @return void
|
|
|
21 |
*/
|
|
|
22 |
private function _temperature()
|
|
|
23 |
{
|
|
|
24 |
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.5.0", $buffer, PSI_DEBUG)
|
|
|
25 |
&& preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
|
|
|
26 |
$dev = new SensorDevice();
|
|
|
27 |
$dev->setName("CPU");
|
|
|
28 |
$dev->setValue($data[1]);
|
|
|
29 |
$this->mbinfo->setMbTemp($dev);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.6.0", $buffer, PSI_DEBUG)
|
|
|
33 |
&& preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
|
|
|
34 |
$dev = new SensorDevice();
|
|
|
35 |
$dev->setName("System");
|
|
|
36 |
$dev->setValue($data[1]);
|
|
|
37 |
$this->mbinfo->setMbTemp($dev);
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.11.1.3", $buffer, PSI_DEBUG)) {
|
|
|
41 |
$lines = preg_split('/\r?\n/', $buffer);
|
|
|
42 |
foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sC/', $line, $data)) {
|
|
|
43 |
$dev = new SensorDevice();
|
|
|
44 |
$dev->setName("HDD ".$data[1]);
|
|
|
45 |
$dev->setValue($data[2]);
|
|
|
46 |
$this->mbinfo->setMbTemp($dev);
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* get fan information
|
|
|
53 |
*
|
|
|
54 |
* @return void
|
|
|
55 |
*/
|
|
|
56 |
private function _fans()
|
|
|
57 |
{
|
|
|
58 |
if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.15.1.3", $buffer, PSI_DEBUG)) {
|
|
|
59 |
$lines = preg_split('/\r?\n/', $buffer);
|
|
|
60 |
foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sRPM/', $line, $data)) {
|
|
|
61 |
$dev = new SensorDevice();
|
|
|
62 |
$dev->setName("Fan ".$data[1]);
|
|
|
63 |
$dev->setValue($data[2]);
|
|
|
64 |
$this->mbinfo->setMbFan($dev);
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* get the information
|
|
|
71 |
*
|
|
|
72 |
* @see PSI_Interface_Sensor::build()
|
|
|
73 |
*
|
3037 |
rexy |
74 |
* @return void
|
2770 |
rexy |
75 |
*/
|
|
|
76 |
public function build()
|
|
|
77 |
{
|
2976 |
rexy |
78 |
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
|
|
|
79 |
$this->_temperature();
|
|
|
80 |
$this->_fans();
|
|
|
81 |
}
|
2770 |
rexy |
82 |
}
|
|
|
83 |
}
|