Subversion Repositories ALCASAR

Rev

Rev 2770 | Rev 3037 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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