Subversion Repositories ALCASAR

Rev

Rev 3037 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3037 Rev 3100
Line 19... Line 19...
19
     *
19
     *
20
     * @return void
20
     * @return void
21
     */
21
     */
22
    private function _temperature()
22
    private function _temperature()
23
    {
23
    {
-
 
24
        if (!defined('PSI_EMU_PORT')) {
-
 
25
            $address = '127.0.0.1';
-
 
26
        } else {
-
 
27
            $address = PSI_EMU_HOSTNAME;
-
 
28
        }
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)
29
        if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.5.0", $buffer, PSI_DEBUG)
25
           && preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
30
           && preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
26
            $dev = new SensorDevice();
31
            $dev = new SensorDevice();
27
            $dev->setName("CPU");
32
            $dev->setName("CPU");
28
            $dev->setValue($data[1]);
33
            $dev->setValue($data[1]);
29
            $this->mbinfo->setMbTemp($dev);
34
            $this->mbinfo->setMbTemp($dev);
30
        }
35
        }
31
 
36
 
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)
37
        if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.6.0", $buffer, PSI_DEBUG)
33
           && preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
38
           && preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
34
            $dev = new SensorDevice();
39
            $dev = new SensorDevice();
35
            $dev->setName("System");
40
            $dev->setName("System");
36
            $dev->setValue($data[1]);
41
            $dev->setValue($data[1]);
37
            $this->mbinfo->setMbTemp($dev);
42
            $this->mbinfo->setMbTemp($dev);
38
        }
43
        }
39
 
44
 
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)) {
45
        if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.11.1.3", $buffer, PSI_DEBUG)) {
41
            $lines = preg_split('/\r?\n/', $buffer);
46
            $lines = preg_split('/\r?\n/', $buffer);
42
            foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sC/', $line, $data)) {
47
            foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sC/', $line, $data)) {
43
                $dev = new SensorDevice();
48
                $dev = new SensorDevice();
44
                $dev->setName("HDD ".$data[1]);
49
                $dev->setName("HDD ".$data[1]);
45
                $dev->setValue($data[2]);
50
                $dev->setValue($data[2]);
Line 53... Line 58...
53
     *
58
     *
54
     * @return void
59
     * @return void
55
     */
60
     */
56
    private function _fans()
61
    private function _fans()
57
    {
62
    {
-
 
63
        if (!defined('PSI_EMU_PORT')) {
-
 
64
            $address = '127.0.0.1';
-
 
65
        } else {
-
 
66
            $address = PSI_EMU_HOSTNAME;
-
 
67
        }
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)) {
68
        if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$address." .1.3.6.1.4.1.24681.1.2.15.1.3", $buffer, PSI_DEBUG)) {
59
            $lines = preg_split('/\r?\n/', $buffer);
69
            $lines = preg_split('/\r?\n/', $buffer);
60
            foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sRPM/', $line, $data)) {
70
            foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sRPM/', $line, $data)) {
61
                $dev = new SensorDevice();
71
                $dev = new SensorDevice();
62
                $dev->setName("Fan ".$data[1]);
72
                $dev->setName("Fan ".$data[1]);
63
                $dev->setValue($data[2]);
73
                $dev->setValue($data[2]);
Line 73... Line 83...
73
     *
83
     *
74
     * @return void
84
     * @return void
75
     */
85
     */
76
    public function build()
86
    public function build()
77
    {
87
    {
78
        if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
88
        if ((PSI_OS == 'Linux') && (!defined('PSI_EMU_HOSTNAME') || defined('PSI_EMU_PORT'))) {
79
            $this->_temperature();
89
            $this->_temperature();
80
            $this->_fans();
90
            $this->_fans();
81
        }
91
        }
82
    }
92
    }
83
}
93
}