Subversion Repositories ALCASAR

Rev

Rev 2976 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2976 Rev 3037
Line 38... Line 38...
38
                }
38
                }
39
            }
39
            }
40
            $this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
40
            $this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
41
            break;
41
            break;
42
        case 'data':
42
        case 'data':
43
            if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/ipmicfg.txt', $lines)) {
43
            if (CommonFunctions::rftsdata('ipmicfg.tmp', $lines)) {
44
                $this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
44
                $this->_lines = preg_split("/\r?\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
45
            }
45
            }
46
            break;
46
            break;
47
        default:
47
        default:
48
            $this->error->addConfigError('__construct()', '[sensor_ipmicfg] ACCESS');
48
            $this->error->addConfigError('__construct()', '[sensor_ipmicfg] ACCESS');
49
            break;
-
 
50
        }
49
        }
51
    }
50
    }
52
 
51
 
53
    /**
52
    /**
54
     * get temperature information
53
     * get temperature information
Line 58... Line 57...
58
    private function _temperature()
57
    private function _temperature()
59
    {
58
    {
60
        foreach ($this->_lines as $line) {
59
        foreach ($this->_lines as $line) {
61
            $buffer = preg_split("/\s*\|\s*/", $line);
60
            $buffer = preg_split("/\s*\|\s*/", $line);
62
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
61
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
63
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/",$buffer[2], $valbuff)) {
62
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[2], $valbuff)) {
64
                $dev = new SensorDevice();
63
                $dev = new SensorDevice();
65
                $dev->setName($namebuff[1]);
64
                $dev->setName($namebuff[1]);
66
                if ($valbuff[1]<-128) $valbuff[1]+=256; //+256 correction
65
                if ($valbuff[1]<-128) $valbuff[1]+=256; //+256 correction
67
                $dev->setValue($valbuff[1]);
66
                $dev->setValue($valbuff[1]);
68
                if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/",$buffer[3], $valbuffmin)) {
67
                if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[3], $valbuffmin)) {
69
                    if ($valbuffmin[1]<-128) $valbuffmin[1]+=256; //+256 correction
68
                    if ($valbuffmin[1]<-128) $valbuffmin[1]+=256; //+256 correction
70
                }
69
                }
71
                if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/",$buffer[4], $valbuffmax)) {
70
                if (preg_match("/^\s*([-\d]+)C\/[-\d]+F\s*$/", $buffer[4], $valbuffmax)) {
72
                    if ($valbuffmax[1]<-128) $valbuffmax[1]+=256; //+256 correction
71
                    if ($valbuffmax[1]<-128) $valbuffmax[1]+=256; //+256 correction
73
                    $dev->setMax($valbuffmax[1]);
72
                    $dev->setMax($valbuffmax[1]);
74
                }
73
                }
75
                if ((isset($valbuffmin[1]) && ($valbuff[1]<=$valbuffmin[1])) || (isset($valbuffmax[1]) && ($valbuff[1]>=$valbuffmax[1]))) { //own range test due to errors with +256 correction
74
                if ((isset($valbuffmin[1]) && ($valbuff[1]<=$valbuffmin[1])) || (isset($valbuffmax[1]) && ($valbuff[1]>=$valbuffmax[1]))) { //own range test due to errors with +256 correction
76
                    $dev->setEvent("Alarm");
75
                    $dev->setEvent("Alarm");
Line 94... Line 93...
94
    private function _voltage()
93
    private function _voltage()
95
    {
94
    {
96
        foreach ($this->_lines as $line) {
95
        foreach ($this->_lines as $line) {
97
            $buffer = preg_split("/\s*\|\s*/", $line);
96
            $buffer = preg_split("/\s*\|\s*/", $line);
98
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
97
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
99
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sV\s*$/",$buffer[2], $valbuff)) {
98
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sV\s*$/", $buffer[2], $valbuff)) {
100
                $dev = new SensorDevice();
99
                $dev = new SensorDevice();
101
                $dev->setName($namebuff[1]);
100
                $dev->setName($namebuff[1]);
102
                $dev->setValue($valbuff[1]);
101
                $dev->setValue($valbuff[1]);
103
                if (preg_match("/^\s*([\d\.].+)\sV\s*$/",$buffer[3], $valbuffmin)) {
102
                if (preg_match("/^\s*([\d\.].+)\sV\s*$/", $buffer[3], $valbuffmin)) {
104
                    $dev->setMin($valbuffmin[1]);
103
                    $dev->setMin($valbuffmin[1]);
105
                }
104
                }
106
                if (preg_match("/^\s*([\d\.].+)\sV\s*$/",$buffer[4], $valbuffmax)) {
105
                if (preg_match("/^\s*([\d\.].+)\sV\s*$/", $buffer[4], $valbuffmax)) {
107
                    $dev->setMax($valbuffmax[1]);
106
                    $dev->setMax($valbuffmax[1]);
108
                }
107
                }
109
                if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
108
                if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
110
                $this->mbinfo->setMbVolt($dev);
109
                $this->mbinfo->setMbVolt($dev);
111
            }
110
            }
Line 120... Line 119...
120
    private function _fans()
119
    private function _fans()
121
    {
120
    {
122
        foreach ($this->_lines as $line) {
121
        foreach ($this->_lines as $line) {
123
            $buffer = preg_split("/\s*\|\s*/", $line);
122
            $buffer = preg_split("/\s*\|\s*/", $line);
124
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
123
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
125
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sRPM\s*$/",$buffer[2], $valbuff)) {
124
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sRPM\s*$/", $buffer[2], $valbuff)) {
126
                $dev = new SensorDevice();
125
                $dev = new SensorDevice();
127
                $dev->setName($namebuff[1]);
126
                $dev->setName($namebuff[1]);
128
                $dev->setValue($valbuff[1]);
127
                $dev->setValue($valbuff[1]);
129
                if (preg_match("/^\s*(\d+)\sRPM\s*$/",$buffer[3], $valbuffmin)) {
128
                if (preg_match("/^\s*(\d+)\sRPM\s*$/", $buffer[3], $valbuffmin)) {
130
                    $dev->setMin($valbuffmin[1]);
129
                    $dev->setMin($valbuffmin[1]);
131
                }
130
                }
132
                if ((trim($buffer[0]) != "OK") && isset($valbuffmin[1])) {
131
                if ((trim($buffer[0]) != "OK") && isset($valbuffmin[1])) {
133
                    $dev->setEvent(trim($buffer[0]));
132
                    $dev->setEvent(trim($buffer[0]));
134
                }
133
                }
Line 151... Line 150...
151
    private function _power()
150
    private function _power()
152
    {
151
    {
153
        foreach ($this->_lines as $line) {
152
        foreach ($this->_lines as $line) {
154
            $buffer = preg_split("/\s*\|\s*/", $line);
153
            $buffer = preg_split("/\s*\|\s*/", $line);
155
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
154
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
156
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sWatts\s*$/",$buffer[2], $valbuff)) {
155
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*(\d+)\sWatts\s*$/", $buffer[2], $valbuff)) {
157
                $dev = new SensorDevice();
156
                $dev = new SensorDevice();
158
                $dev->setName($namebuff[1]);
157
                $dev->setName($namebuff[1]);
159
                $dev->setValue($valbuff[1]);
158
                $dev->setValue($valbuff[1]);
160
                if (preg_match("/^\s*(\d+)\sWatts\s*$/",$buffer[4], $valbuffmax)) {
159
                if (preg_match("/^\s*(\d+)\sWatts\s*$/", $buffer[4], $valbuffmax)) {
161
                    $dev->setMax($valbuffmax[1]);
160
                    $dev->setMax($valbuffmax[1]);
162
                }
161
                }
163
                if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
162
                if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
164
                $this->mbinfo->setMbPower($dev);
163
                $this->mbinfo->setMbPower($dev);
165
            }
164
            }
Line 174... Line 173...
174
    private function _current()
173
    private function _current()
175
    {
174
    {
176
        foreach ($this->_lines as $line) {
175
        foreach ($this->_lines as $line) {
177
            $buffer = preg_split("/\s*\|\s*/", $line);
176
            $buffer = preg_split("/\s*\|\s*/", $line);
178
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
177
            if ((!defined('PSI_SENSOR_IPMICFG_PSFRUINFO') || (strtolower(PSI_SENSOR_IPMICFG_PSFRUINFO)!=="only")) &&
179
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sAmps\s*$/",$buffer[2], $valbuff)) {
178
               (count($buffer)==6) && preg_match("/^\s*\(\d+\)\s(.*)\s*$/", $buffer[1], $namebuff) && preg_match("/^\s*([\d\.]+)\sAmps\s*$/", $buffer[2], $valbuff)) {
180
                $dev = new SensorDevice();
179
                $dev = new SensorDevice();
181
                $dev->setName($namebuff[1]);
180
                $dev->setName($namebuff[1]);
182
                $dev->setValue($valbuff[1]);
181
                $dev->setValue($valbuff[1]);
183
                if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/",$buffer[3], $valbuffmin)) {
182
                if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/", $buffer[3], $valbuffmin)) {
184
                    $dev->setMin($valbuffmin[1]);
183
                    $dev->setMin($valbuffmin[1]);
185
                }
184
                }
186
                if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/",$buffer[4], $valbuffmax)) {
185
                if (preg_match("/^\s*([\d\.].+)\sAmps\s*$/", $buffer[4], $valbuffmax)) {
187
                    $dev->setMax($valbuffmax[1]);
186
                    $dev->setMax($valbuffmax[1]);
188
                }
187
                }
189
                if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
188
                if (trim($buffer[0]) != "OK") $dev->setEvent(trim($buffer[0]));
190
                $this->mbinfo->setMbCurrent($dev);
189
                $this->mbinfo->setMbCurrent($dev);
191
            }
190
            }
Line 223... Line 222...
223
    /**
222
    /**
224
     * get the information
223
     * get the information
225
     *
224
     *
226
     * @see PSI_Interface_Sensor::build()
225
     * @see PSI_Interface_Sensor::build()
227
     *
226
     *
228
     * @return Void
227
     * @return void
229
     */
228
     */
230
    public function build()
229
    public function build()
231
    {
230
    {
232
        $this->_temperature();
231
        $this->_temperature();
233
        $this->_voltage();
232
        $this->_voltage();