Subversion Repositories ALCASAR

Rev

Rev 3100 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3100 Rev 3179
1
<?php
1
<?php
2
/**
2
/**
3
 * XML Generation class
3
 * XML Generation class
4
 *
4
 *
5
 * PHP version 5
5
 * PHP version 5
6
 *
6
 *
7
 * @category  PHP
7
 * @category  PHP
8
 * @package   PSI_XML
8
 * @package   PSI_XML
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
10
 * @copyright 2009 phpSysInfo
10
 * @copyright 2009 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   SVN: $Id: class.XML.inc.php 699 2012-09-15 11:57:13Z namiltd $
12
 * @version   SVN: $Id: class.XML.inc.php 699 2012-09-15 11:57:13Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
14
 */
15
 /**
15
 /**
16
 * class for generation of the xml
16
 * class for generation of the xml
17
 *
17
 *
18
 * @category  PHP
18
 * @category  PHP
19
 * @package   PSI_XML
19
 * @package   PSI_XML
20
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
20
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
21
 * @copyright 2009 phpSysInfo
21
 * @copyright 2009 phpSysInfo
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
23
 * @version   Release: 3.0
23
 * @version   Release: 3.0
24
 * @link      http://phpsysinfo.sourceforge.net
24
 * @link      http://phpsysinfo.sourceforge.net
25
 */
25
 */
26
class XML
26
class XML
27
{
27
{
28
    /**
28
    /**
29
     * Sysinfo object where the information retrieval methods are included
29
     * Sysinfo object where the information retrieval methods are included
30
     *
30
     *
31
     * @var PSI_Interface_OS
31
     * @var PSI_Interface_OS
32
     */
32
     */
33
    private $_sysinfo;
33
    private $_sysinfo;
34
 
34
 
35
    /**
35
    /**
36
     * @var System
36
     * @var System
37
     */
37
     */
38
    private $_sys = null;
38
    private $_sys = null;
39
 
39
 
40
    /**
40
    /**
41
     * xml object with the xml content
41
     * xml object with the xml content
42
     *
42
     *
43
     * @var SimpleXMLExtended
43
     * @var SimpleXMLExtended
44
     */
44
     */
45
    private $_xml;
45
    private $_xml;
46
 
46
 
47
    /**
47
    /**
48
     * object for error handling
48
     * object for error handling
49
     *
49
     *
50
     * @var PSI_Error
50
     * @var PSI_Error
51
     */
51
     */
52
    private $_errors;
52
    private $_errors;
53
 
53
 
54
    /**
54
    /**
55
     * array with all enabled plugins (name)
55
     * array with all enabled plugins (name)
56
     *
56
     *
57
     * @var array
57
     * @var array
58
     */
58
     */
59
    private $_plugins;
59
    private $_plugins;
60
 
60
 
61
    /**
61
    /**
62
     * plugin name if pluginrequest
62
     * plugin name if pluginrequest
63
     *
63
     *
64
     * @var string
64
     * @var string
65
     */
65
     */
66
    private $_plugin = '';
66
    private $_plugin = '';
67
 
67
 
68
    /**
68
    /**
69
     * generate the entire xml with all plugins or only a part of the xml (main or plugin)
69
     * generate the entire xml with all plugins or only a part of the xml (main or plugin)
70
     *
70
     *
71
     * @var boolean
71
     * @var boolean
72
     */
72
     */
73
    private $_complete_request = false;
73
    private $_complete_request = false;
74
 
74
 
75
    /**
75
    /**
76
     * doing some initial tasks
76
     * doing some initial tasks
77
     * - generate the xml structure with the right header elements
77
     * - generate the xml structure with the right header elements
78
     * - get the error object for error output
78
     * - get the error object for error output
79
     * - get a instance of the sysinfo object
79
     * - get a instance of the sysinfo object
80
     *
80
     *
81
     * @param boolean $complete   generate xml with all plugins or not
81
     * @param boolean $complete   generate xml with all plugins or not
82
     * @param string  $pluginname name of the plugin
82
     * @param string  $pluginname name of the plugin
83
     *
83
     *
84
     * @return void
84
     * @return void
85
     */
85
     */
86
    public function __construct($complete = false, $pluginname = "", $blockname = false)
86
    public function __construct($complete = false, $pluginname = "", $blockname = false)
87
    {
87
    {
88
        $this->_errors = PSI_Error::singleton();
88
        $this->_errors = PSI_Error::singleton();
89
        $this->_plugin = $pluginname;
89
        $this->_plugin = $pluginname;
90
        if ($complete) {
90
        if ($complete) {
91
            $this->_complete_request = true;
91
            $this->_complete_request = true;
92
        } else {
92
        } else {
93
            $this->_complete_request = false;
93
            $this->_complete_request = false;
94
        }
94
        }
95
        if (defined('PSI_EMU_PORT')) {
95
        if (defined('PSI_EMU_PORT')) {
96
            $os = 'SSH';
96
            $os = 'SSH';
97
        } elseif (defined('PSI_EMU_HOSTNAME')) {
97
        } elseif (defined('PSI_EMU_HOSTNAME')) {
98
            $os = 'WINNT';
98
            $os = 'WINNT';
99
        } else {
99
        } else {
100
            $os = PSI_OS;
100
            $os = PSI_OS;
101
        }
101
        }
102
        $this->_sysinfo = new $os($blockname);
102
        $this->_sysinfo = new $os($blockname);
103
        $this->_plugins = CommonFunctions::getPlugins();
103
        $this->_plugins = CommonFunctions::getPlugins();
104
        $this->_xmlbody();
104
        $this->_xmlbody();
105
    }
105
    }
106
 
106
 
107
    /**
107
    /**
108
     * generate common information
108
     * generate common information
109
     *
109
     *
110
     * @return void
110
     * @return void
111
     */
111
     */
112
    private function _buildVitals()
112
    private function _buildVitals()
113
    {
113
    {
114
        $vitals = $this->_xml->addChild('Vitals');
114
        $vitals = $this->_xml->addChild('Vitals');
115
        $vitals->addAttribute('Hostname', $this->_sys->getHostname());
115
        $vitals->addAttribute('Hostname', $this->_sys->getHostname());
116
        $vitals->addAttribute('IPAddr', $this->_sys->getIp());
116
        $vitals->addAttribute('IPAddr', $this->_sys->getIp());
117
        $vitals->addAttribute('Kernel', $this->_sys->getKernel());
117
        $vitals->addAttribute('Kernel', $this->_sys->getKernel());
118
        $vitals->addAttribute('Distro', $this->_sys->getDistribution());
118
        $vitals->addAttribute('Distro', $this->_sys->getDistribution());
119
        $vitals->addAttribute('Distroicon', $this->_sys->getDistributionIcon());
119
        $vitals->addAttribute('Distroicon', $this->_sys->getDistributionIcon());
120
        $vitals->addAttribute('Uptime', $this->_sys->getUptime());
120
        $vitals->addAttribute('Uptime', $this->_sys->getUptime());
121
        $vitals->addAttribute('Users', $this->_sys->getUsers());
121
        $vitals->addAttribute('Users', $this->_sys->getUsers());
122
        $vitals->addAttribute('LoadAvg', $this->_sys->getLoad());
122
        $vitals->addAttribute('LoadAvg', $this->_sys->getLoad());
123
        if ($this->_sys->getLoadPercent() !== null) {
123
        if ($this->_sys->getLoadPercent() !== null) {
124
            $vitals->addAttribute('CPULoad', $this->_sys->getLoadPercent());
124
            $vitals->addAttribute('CPULoad', $this->_sys->getLoadPercent());
125
        }
125
        }
126
        if ($this->_sysinfo->getLanguage() !== null) {
126
        if ($this->_sysinfo->getLanguage() !== null) {
127
            $vitals->addAttribute('SysLang', $this->_sysinfo->getLanguage());
127
            $vitals->addAttribute('SysLang', $this->_sysinfo->getLanguage());
128
        }
128
        }
129
        if ($this->_sysinfo->getEncoding() !== null) {
129
        if ($this->_sysinfo->getEncoding() !== null) {
130
            $vitals->addAttribute('CodePage', $this->_sysinfo->getEncoding());
130
            $vitals->addAttribute('CodePage', $this->_sysinfo->getEncoding());
131
        }
131
        }
132
 
132
 
133
        //processes
133
        //processes
134
        if (($procss = $this->_sys->getProcesses()) !== null) {
134
        if (($procss = $this->_sys->getProcesses()) !== null) {
135
            if (isset($procss['*']) && (($procall = $procss['*']) > 0)) {
135
            if (isset($procss['*']) && (($procall = $procss['*']) > 0)) {
136
                $vitals->addAttribute('Processes', $procall);
136
                $vitals->addAttribute('Processes', $procall);
137
                if (!isset($procss[' ']) || !($procss[' '] > 0)) { // not unknown
137
                if (!isset($procss[' ']) || !($procss[' '] > 0)) { // not unknown
138
                    $procsum = 0;
138
                    $procsum = 0;
139
                    if (isset($procss['R']) && (($proctmp = $procss['R']) > 0)) {
139
                    if (isset($procss['R']) && (($proctmp = $procss['R']) > 0)) {
140
                        $vitals->addAttribute('ProcessesRunning', $proctmp);
140
                        $vitals->addAttribute('ProcessesRunning', $proctmp);
141
                        $procsum += $proctmp;
141
                        $procsum += $proctmp;
142
                    }
142
                    }
143
                    if (isset($procss['S']) && (($proctmp = $procss['S']) > 0)) {
143
                    if (isset($procss['S']) && (($proctmp = $procss['S']) > 0)) {
144
                        $vitals->addAttribute('ProcessesSleeping', $proctmp);
144
                        $vitals->addAttribute('ProcessesSleeping', $proctmp);
145
                        $procsum += $proctmp;
145
                        $procsum += $proctmp;
146
                    }
146
                    }
147
                    if (isset($procss['T']) && (($proctmp = $procss['T']) > 0)) {
147
                    if (isset($procss['T']) && (($proctmp = $procss['T']) > 0)) {
148
                        $vitals->addAttribute('ProcessesStopped', $proctmp);
148
                        $vitals->addAttribute('ProcessesStopped', $proctmp);
149
                        $procsum += $proctmp;
149
                        $procsum += $proctmp;
150
                    }
150
                    }
151
                    if (isset($procss['Z']) && (($proctmp = $procss['Z']) > 0)) {
151
                    if (isset($procss['Z']) && (($proctmp = $procss['Z']) > 0)) {
152
                        $vitals->addAttribute('ProcessesZombie', $proctmp);
152
                        $vitals->addAttribute('ProcessesZombie', $proctmp);
153
                        $procsum += $proctmp;
153
                        $procsum += $proctmp;
154
                    }
154
                    }
155
                    if (isset($procss['D']) && (($proctmp = $procss['D']) > 0)) {
155
                    if (isset($procss['D']) && (($proctmp = $procss['D']) > 0)) {
156
                        $vitals->addAttribute('ProcessesWaiting', $proctmp);
156
                        $vitals->addAttribute('ProcessesWaiting', $proctmp);
157
                        $procsum += $proctmp;
157
                        $procsum += $proctmp;
158
                    }
158
                    }
159
                    if (($proctmp = $procall - $procsum) > 0) {
159
                    if (($proctmp = $procall - $procsum) > 0) {
160
                        $vitals->addAttribute('ProcessesOther', $proctmp);
160
                        $vitals->addAttribute('ProcessesOther', $proctmp);
161
                    }
161
                    }
162
                }
162
                }
163
            }
163
            }
164
        }
164
        }
165
 
165
 
166
        if (($os = $this->_sys->getOS()) == 'Android') {
166
        if (($os = $this->_sys->getOS()) == 'Android') {
167
            $vitals->addAttribute('OS', 'Linux');
167
            $vitals->addAttribute('OS', 'Linux');
168
        } elseif ($os == 'GNU') {
168
        } elseif ($os == 'GNU') {
169
            $vitals->addAttribute('OS', 'Hurd');
169
            $vitals->addAttribute('OS', 'Hurd');
170
        } else {
170
        } else {
171
            $vitals->addAttribute('OS', $os);
171
            $vitals->addAttribute('OS', $os);
172
        }
172
        }
173
    }
173
    }
174
 
174
 
175
    /**
175
    /**
176
     * generate the network information
176
     * generate the network information
177
     *
177
     *
178
     * @return void
178
     * @return void
179
     */
179
     */
180
    private function _buildNetwork()
180
    private function _buildNetwork()
181
    {
181
    {
182
        $hideDevices = array();
182
        $hideDevices = array();
183
        $network = $this->_xml->addChild('Network');
183
        $network = $this->_xml->addChild('Network');
184
        if (defined('PSI_HIDE_NETWORK_INTERFACE')) {
184
        if (defined('PSI_HIDE_NETWORK_INTERFACE')) {
185
            if (is_string(PSI_HIDE_NETWORK_INTERFACE)) {
185
            if (is_string(PSI_HIDE_NETWORK_INTERFACE)) {
186
                if (preg_match(ARRAY_EXP, PSI_HIDE_NETWORK_INTERFACE)) {
186
                if (preg_match(ARRAY_EXP, PSI_HIDE_NETWORK_INTERFACE)) {
187
                    $hideDevices = eval(PSI_HIDE_NETWORK_INTERFACE);
187
                    $hideDevices = eval(PSI_HIDE_NETWORK_INTERFACE);
188
                } else {
188
                } else {
189
                    $hideDevices = array(PSI_HIDE_NETWORK_INTERFACE);
189
                    $hideDevices = array(PSI_HIDE_NETWORK_INTERFACE);
190
                }
190
                }
191
            } elseif (PSI_HIDE_NETWORK_INTERFACE === true) {
191
            } elseif (PSI_HIDE_NETWORK_INTERFACE === true) {
192
                return;
192
                return;
193
            }
193
            }
194
        }
194
        }
195
        foreach ($this->_sys->getNetDevices() as $dev) {
195
        foreach ($this->_sys->getNetDevices() as $dev) {
196
            if (defined('PSI_HIDE_NETWORK_INTERFACE_REGEX') && PSI_HIDE_NETWORK_INTERFACE_REGEX) {
196
            if (defined('PSI_HIDE_NETWORK_INTERFACE_REGEX') && PSI_HIDE_NETWORK_INTERFACE_REGEX) {
197
                $hide = false;
197
                $hide = false;
198
                foreach ($hideDevices as $hidedev) {
198
                foreach ($hideDevices as $hidedev) {
199
                    if (preg_match('/^'.$hidedev.'$/', trim($dev->getName()))) {
199
                    if (preg_match('/^'.$hidedev.'$/', trim($dev->getName()))) {
200
                        $hide = true;
200
                        $hide = true;
201
                        break;
201
                        break;
202
                    }
202
                    }
203
                }
203
                }
204
            } else {
204
            } else {
205
                $hide =in_array(trim($dev->getName()), $hideDevices);
205
                $hide =in_array(trim($dev->getName()), $hideDevices);
206
            }
206
            }
207
            if (!$hide) {
207
            if (!$hide) {
208
                $device = $network->addChild('NetDevice');
208
                $device = $network->addChild('NetDevice');
209
                $device->addAttribute('Name', $dev->getName());
209
                $device->addAttribute('Name', $dev->getName());
210
                $rxbytes = $dev->getRxBytes();
210
                $rxbytes = $dev->getRxBytes();
211
                $txbytes = $dev->getTxBytes();
211
                $txbytes = $dev->getTxBytes();
212
                $device->addAttribute('RxBytes', $rxbytes);
212
                $device->addAttribute('RxBytes', $rxbytes);
213
                $device->addAttribute('TxBytes', $txbytes);
213
                $device->addAttribute('TxBytes', $txbytes);
214
                if (defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') && PSI_SHOW_NETWORK_ACTIVE_SPEED) {
214
                if (defined('PSI_SHOW_NETWORK_ACTIVE_SPEED') && PSI_SHOW_NETWORK_ACTIVE_SPEED) {
215
                    if (($rxbytes == 0) && ($txbytes == 0)) {
215
                    if (($rxbytes == 0) && ($txbytes == 0)) {
216
                        $rxrate = $dev->getRxRate();
216
                        $rxrate = $dev->getRxRate();
217
                        $txrate = $dev->getTxRate();
217
                        $txrate = $dev->getTxRate();
218
                        if (($rxrate !== null) || ($txrate !== null)) {
218
                        if (($rxrate !== null) || ($txrate !== null)) {
219
                            if ($rxrate !== null) {
219
                            if ($rxrate !== null) {
220
                                $device->addAttribute('RxRate', $rxrate);
220
                                $device->addAttribute('RxRate', $rxrate);
221
                            } else {
221
                            } else {
222
                                $device->addAttribute('RxRate', 0);
222
                                $device->addAttribute('RxRate', 0);
223
                            }
223
                            }
224
                            if ($txrate !== null) {
224
                            if ($txrate !== null) {
225
                                $device->addAttribute('TxRate', $txrate);
225
                                $device->addAttribute('TxRate', $txrate);
226
                            } else {
226
                            } else {
227
                                $device->addAttribute('TxRate', 0);
227
                                $device->addAttribute('TxRate', 0);
228
                            }
228
                            }
229
                        }
229
                        }
230
                    }
230
                    }
231
                }
231
                }
232
                $device->addAttribute('Err', $dev->getErrors());
232
                $device->addAttribute('Err', $dev->getErrors());
233
                $device->addAttribute('Drops', $dev->getDrops());
233
                $device->addAttribute('Drops', $dev->getDrops());
-
 
234
                if (defined('PSI_SHOW_NETWORK_BRIDGE') && PSI_SHOW_NETWORK_BRIDGE && $dev->getBridge()) {
-
 
235
                    $device->addAttribute('Bridge', $dev->getBridge());
-
 
236
                }
234
                if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS && $dev->getInfo())
237
                if (defined('PSI_SHOW_NETWORK_INFOS') && PSI_SHOW_NETWORK_INFOS && $dev->getInfo()) {
235
                    $device->addAttribute('Info', $dev->getInfo());
238
                    $device->addAttribute('Info', $dev->getInfo());
-
 
239
                }
236
            }
240
            }
237
        }
241
        }
238
    }
242
    }
239
 
243
 
240
    /**
244
    /**
241
     * generate the hardware information
245
     * generate the hardware information
242
     *
246
     *
243
     * @return void
247
     * @return void
244
     */
248
     */
245
    private function _buildHardware()
249
    private function _buildHardware()
246
    {
250
    {
247
        $hardware = $this->_xml->addChild('Hardware');
251
        $hardware = $this->_xml->addChild('Hardware');
248
        if (($machine = $this->_sys->getMachine()) != "") {
252
        if (($machine = $this->_sys->getMachine()) != "") {
249
            $machine = trim(preg_replace("/\s+/", " ", preg_replace("/^\s*[\/,]*/", "", preg_replace("/\/\s+,/", "/,", $machine)))); // remove leading slash or comma and unnecessary spaces
253
            $machine = trim(preg_replace("/\s+/", " ", preg_replace("/^\s*[\/,]*/", "", preg_replace("/\/\s+,/", "/,", $machine)))); // remove leading slash or comma and unnecessary spaces
250
            if (preg_match('/, BIOS .*$/', $machine, $mbuf, PREG_OFFSET_CAPTURE)) {
254
            if (preg_match('/, BIOS .*$/', $machine, $mbuf, PREG_OFFSET_CAPTURE)) {
251
                $comapos = $mbuf[0][1];
255
                $comapos = $mbuf[0][1];
252
                $endstr = $mbuf[0][0];
256
                $endstr = $mbuf[0][0];
253
                $offset = 0;
257
                $offset = 0;
254
                while (($offset < $comapos)
258
                while (($offset < $comapos)
255
                     && (($slashpos = strpos($machine, "/", $offset)) !== false)
259
                     && (($slashpos = strpos($machine, "/", $offset)) !== false)
256
                     && ($slashpos < $comapos)) {
260
                     && ($slashpos < $comapos)) {
257
                    $len1 = $comapos - $slashpos - 1;
261
                    $len1 = $comapos - $slashpos - 1;
258
                    $str1 = substr($machine, $slashpos + 1, $len1);
262
                    $str1 = substr($machine, $slashpos + 1, $len1);
259
                    $begstr  = substr($machine, 0, $slashpos);
263
                    $begstr  = substr($machine, 0, $slashpos);
260
                    if ($len1 > 0) { // no empty
264
                    if ($len1 > 0) { // no empty
261
                        $str2 = substr($begstr, -$len1 - 1);
265
                        $str2 = substr($begstr, -$len1 - 1);
262
                    } else {
266
                    } else {
263
                        $str2 = " ";
267
                        $str2 = " ";
264
                    }
268
                    }
265
                    if ((" ".$str1 === $str2) || ($str1 === $begstr)) { // duplicates
269
                    if ((" ".$str1 === $str2) || ($str1 === $begstr)) { // duplicates
266
                        $machine = $begstr.$endstr;
270
                        $machine = $begstr.$endstr;
267
                        break;
271
                        break;
268
                    }
272
                    }
269
                    $offset = $slashpos + 1;
273
                    $offset = $slashpos + 1;
270
                }
274
                }
271
            }
275
            }
272
 
276
 
273
            if ($machine != "") {
277
            if ($machine != "") {
274
                $hardware->addAttribute('Name', $machine);
278
                $hardware->addAttribute('Name', $machine);
275
            }
279
            }
276
        }
280
        }
277
 
281
 
278
        if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
282
        if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
279
            $virt = $this->_sys->getVirtualizer();
283
            $virt = $this->_sys->getVirtualizer();
280
            $first = true;
284
            $first = true;
281
            $virtstring = "";
285
            $virtstring = "";
282
            foreach ($virt as $virtkey=>$virtvalue) if ($virtvalue) {
286
            foreach ($virt as $virtkey=>$virtvalue) if ($virtvalue) {
283
                if ($first) {
287
                if ($first) {
284
                    $first = false;
288
                    $first = false;
285
                } else {
289
                } else {
286
                    $virtstring .= ", ";
290
                    $virtstring .= ", ";
287
                }
291
                }
288
                if ($virtkey === 'microsoft') {
292
                if ($virtkey === 'microsoft') {
289
                    $virtstring .= 'hyper-v';
293
                    $virtstring .= 'hyper-v';
290
                } elseif ($virtkey === 'kvm') {
294
                } elseif ($virtkey === 'kvm') {
291
                    $virtstring .= 'qemu-kvm';
295
                    $virtstring .= 'qemu-kvm';
292
                } elseif ($virtkey === 'oracle') {
296
                } elseif ($virtkey === 'oracle') {
293
                    $virtstring .= 'virtualbox';
297
                    $virtstring .= 'virtualbox';
294
                } elseif ($virtkey === 'zvm') {
298
                } elseif ($virtkey === 'zvm') {
295
                    $virtstring .= 'z/vm';
299
                    $virtstring .= 'z/vm';
-
 
300
                } elseif ($virtkey === 'sre') {
-
 
301
                    $virtstring .= 'lmhs sre';
296
                } else {
302
                } else {
297
                    $virtstring .= $virtkey;
303
                    $virtstring .= $virtkey;
298
                }
304
                }
299
            }
305
            }
300
            if ($virtstring !== "") {
306
            if ($virtstring !== "") {
301
                $hardware->addAttribute('Virtualizer', $virtstring);
307
                $hardware->addAttribute('Virtualizer', $virtstring);
302
            }
308
            }
303
        }
309
        }
304
 
310
 
305
        $cpu = null;
311
        $cpu = null;
306
        $vendortab = null;
312
        $vendortab = null;
307
        foreach ($this->_sys->getCpus() as $oneCpu) {
313
        foreach ($this->_sys->getCpus() as $oneCpu) {
308
            if ($cpu === null) $cpu = $hardware->addChild('CPU');
314
            if ($cpu === null) $cpu = $hardware->addChild('CPU');
309
            $tmp = $cpu->addChild('CpuCore');
315
            $tmp = $cpu->addChild('CpuCore');
310
            $tmp->addAttribute('Model', $oneCpu->getModel());
316
            $tmp->addAttribute('Model', $oneCpu->getModel());
311
            if ($oneCpu->getVoltage() > 0) {
317
            if ($oneCpu->getVoltage() > 0) {
312
                $tmp->addAttribute('Voltage', $oneCpu->getVoltage());
318
                $tmp->addAttribute('Voltage', $oneCpu->getVoltage());
313
            }
319
            }
314
            if ($oneCpu->getCpuSpeed() > 0) {
320
            if ($oneCpu->getCpuSpeed() > 0) {
315
                $tmp->addAttribute('CpuSpeed', $oneCpu->getCpuSpeed());
321
                $tmp->addAttribute('CpuSpeed', $oneCpu->getCpuSpeed());
316
            } elseif ($oneCpu->getCpuSpeed() == -1) {
322
            } elseif ($oneCpu->getCpuSpeed() == -1) {
317
                $tmp->addAttribute('CpuSpeed', 0); // core stopped
323
                $tmp->addAttribute('CpuSpeed', 0); // core stopped
318
            }
324
            }
319
            if ($oneCpu->getCpuSpeedMax() > 0) {
325
            if ($oneCpu->getCpuSpeedMax() > 0) {
320
                $tmp->addAttribute('CpuSpeedMax', $oneCpu->getCpuSpeedMax());
326
                $tmp->addAttribute('CpuSpeedMax', $oneCpu->getCpuSpeedMax());
321
            }
327
            }
322
            if ($oneCpu->getCpuSpeedMin() > 0) {
328
            if ($oneCpu->getCpuSpeedMin() > 0) {
323
                $tmp->addAttribute('CpuSpeedMin', $oneCpu->getCpuSpeedMin());
329
                $tmp->addAttribute('CpuSpeedMin', $oneCpu->getCpuSpeedMin());
324
            }
330
            }
325
/*
331
/*
326
            if ($oneCpu->getTemp() !== null) {
332
            if ($oneCpu->getTemp() !== null) {
327
                $tmp->addAttribute('CpuTemp', $oneCpu->getTemp());
333
                $tmp->addAttribute('CpuTemp', $oneCpu->getTemp());
328
            }
334
            }
329
*/
335
*/
330
            if ($oneCpu->getBusSpeed() !== null) {
336
            if ($oneCpu->getBusSpeed() !== null) {
331
                $tmp->addAttribute('BusSpeed', $oneCpu->getBusSpeed());
337
                $tmp->addAttribute('BusSpeed', $oneCpu->getBusSpeed());
332
            }
338
            }
333
            if ($oneCpu->getCache() !== null) {
339
            if ($oneCpu->getCache() !== null) {
334
                $tmp->addAttribute('Cache', $oneCpu->getCache());
340
                $tmp->addAttribute('Cache', $oneCpu->getCache());
335
            }
341
            }
336
            if ($oneCpu->getVirt() !== null) {
342
            if ($oneCpu->getVirt() !== null) {
337
                $tmp->addAttribute('Virt', $oneCpu->getVirt());
343
                $tmp->addAttribute('Virt', $oneCpu->getVirt());
338
            }
344
            }
339
            if ($oneCpu->getVendorId() !== null) {
345
            if ($oneCpu->getVendorId() !== null) {
340
                if ($vendortab === null) $vendortab = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
346
                if ($vendortab === null) $vendortab = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
341
                $shortvendorid = $oneCpu->getVendorId();
347
                $shortvendorid = $oneCpu->getVendorId();
342
                if ($vendortab && ($shortvendorid != "") && isset($vendortab['manufacturer'][$shortvendorid])) {
348
                if ($vendortab && ($shortvendorid != "") && isset($vendortab['manufacturer'][$shortvendorid])) {
343
                    $tmp->addAttribute('Manufacturer', $vendortab['manufacturer'][$shortvendorid]);
349
                    $tmp->addAttribute('Manufacturer', $vendortab['manufacturer'][$shortvendorid]);
344
                }
350
                }
345
            }
351
            }
346
            if ($oneCpu->getBogomips() !== null) {
352
            if ($oneCpu->getBogomips() !== null) {
347
                $tmp->addAttribute('Bogomips', $oneCpu->getBogomips());
353
                $tmp->addAttribute('Bogomips', $oneCpu->getBogomips());
348
            }
354
            }
349
            if ($oneCpu->getLoad() !== null) {
355
            if ($oneCpu->getLoad() !== null) {
350
                $tmp->addAttribute('Load', $oneCpu->getLoad());
356
                $tmp->addAttribute('Load', $oneCpu->getLoad());
351
            }
357
            }
352
        }
358
        }
353
        $mem = null;
359
        $mem = null;
354
        foreach (System::removeDupsAndCount($this->_sys->getMemDevices()) as $dev) {
360
        foreach (System::removeDupsAndCount($this->_sys->getMemDevices()) as $dev) {
355
            if ($mem === null) $mem = $hardware->addChild('MEM');
361
            if ($mem === null) $mem = $hardware->addChild('MEM');
356
            $tmp = $mem->addChild('Chip');
362
            $tmp = $mem->addChild('Chip');
357
            $tmp->addAttribute('Name', $dev->getName());
363
            $tmp->addAttribute('Name', $dev->getName());
358
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
364
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
359
                if ($dev->getCapacity() !== null) {
365
                if ($dev->getCapacity() !== null) {
360
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
366
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
361
                }
367
                }
362
                if ($dev->getManufacturer() !== null) {
368
                if ($dev->getManufacturer() !== null) {
363
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
369
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
364
                }
370
                }
365
                if ($dev->getProduct() !== null) {
371
                if ($dev->getProduct() !== null) {
366
                    $tmp->addAttribute('Product', $dev->getProduct());
372
                    $tmp->addAttribute('Product', $dev->getProduct());
367
                }
373
                }
368
                if ($dev->getSpeed() !== null) {
374
                if ($dev->getSpeed() !== null) {
369
                    $tmp->addAttribute('Speed', $dev->getSpeed());
375
                    $tmp->addAttribute('Speed', $dev->getSpeed());
370
                }
376
                }
371
                if ($dev->getVoltage() !== null) {
377
                if ($dev->getVoltage() !== null) {
372
                    $tmp->addAttribute('Voltage', $dev->getVoltage());
378
                    $tmp->addAttribute('Voltage', $dev->getVoltage());
373
                }
379
                }
374
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
380
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
375
                    $tmp->addAttribute('Serial', $dev->getSerial());
381
                    $tmp->addAttribute('Serial', $dev->getSerial());
376
                }
382
                }
377
            }
383
            }
378
            if ($dev->getCount() > 1) {
384
            if ($dev->getCount() > 1) {
379
                $tmp->addAttribute('Count', $dev->getCount());
385
                $tmp->addAttribute('Count', $dev->getCount());
380
            }
386
            }
381
        }
387
        }
382
        $pci = null;
388
        $pci = null;
383
        foreach (System::removeDupsAndCount($this->_sys->getPciDevices()) as $dev) {
389
        foreach (System::removeDupsAndCount($this->_sys->getPciDevices()) as $dev) {
384
            if ($pci === null) $pci = $hardware->addChild('PCI');
390
            if ($pci === null) $pci = $hardware->addChild('PCI');
385
            $tmp = $pci->addChild('Device');
391
            $tmp = $pci->addChild('Device');
386
            $tmp->addAttribute('Name', $dev->getName());
392
            $tmp->addAttribute('Name', $dev->getName());
387
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
393
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
388
                if ($dev->getManufacturer() !== null) {
394
                if ($dev->getManufacturer() !== null) {
389
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
395
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
390
                }
396
                }
391
                if ($dev->getProduct() !== null) {
397
                if ($dev->getProduct() !== null) {
392
                    $tmp->addAttribute('Product', $dev->getProduct());
398
                    $tmp->addAttribute('Product', $dev->getProduct());
393
                }
399
                }
394
            }
400
            }
395
            if ($dev->getCount() > 1) {
401
            if ($dev->getCount() > 1) {
396
                $tmp->addAttribute('Count', $dev->getCount());
402
                $tmp->addAttribute('Count', $dev->getCount());
397
            }
403
            }
398
        }
404
        }
399
        $ide = null;
405
        $ide = null;
400
        foreach (System::removeDupsAndCount($this->_sys->getIdeDevices()) as $dev) {
406
        foreach (System::removeDupsAndCount($this->_sys->getIdeDevices()) as $dev) {
401
            if ($ide === null) $ide = $hardware->addChild('IDE');
407
            if ($ide === null) $ide = $hardware->addChild('IDE');
402
            $tmp = $ide->addChild('Device');
408
            $tmp = $ide->addChild('Device');
403
            $tmp->addAttribute('Name', $dev->getName());
409
            $tmp->addAttribute('Name', $dev->getName());
404
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
410
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
405
                if ($dev->getCapacity() !== null) {
411
                if ($dev->getCapacity() !== null) {
406
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
412
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
407
                }
413
                }
408
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
414
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
409
                    $tmp->addAttribute('Serial', $dev->getSerial());
415
                    $tmp->addAttribute('Serial', $dev->getSerial());
410
                }
416
                }
411
            }
417
            }
412
            if ($dev->getCount() > 1) {
418
            if ($dev->getCount() > 1) {
413
                $tmp->addAttribute('Count', $dev->getCount());
419
                $tmp->addAttribute('Count', $dev->getCount());
414
            }
420
            }
415
        }
421
        }
416
        $scsi = null;
422
        $scsi = null;
417
        foreach (System::removeDupsAndCount($this->_sys->getScsiDevices()) as $dev) {
423
        foreach (System::removeDupsAndCount($this->_sys->getScsiDevices()) as $dev) {
418
            if ($scsi === null) $scsi = $hardware->addChild('SCSI');
424
            if ($scsi === null) $scsi = $hardware->addChild('SCSI');
419
            $tmp = $scsi->addChild('Device');
425
            $tmp = $scsi->addChild('Device');
420
            $tmp->addAttribute('Name', $dev->getName());
426
            $tmp->addAttribute('Name', $dev->getName());
421
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
427
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
422
                if ($dev->getCapacity() !== null) {
428
                if ($dev->getCapacity() !== null) {
423
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
429
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
424
                }
430
                }
425
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
431
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
426
                    $tmp->addAttribute('Serial', $dev->getSerial());
432
                    $tmp->addAttribute('Serial', $dev->getSerial());
427
                }
433
                }
428
            }
434
            }
429
            if ($dev->getCount() > 1) {
435
            if ($dev->getCount() > 1) {
430
                $tmp->addAttribute('Count', $dev->getCount());
436
                $tmp->addAttribute('Count', $dev->getCount());
431
            }
437
            }
432
        }
438
        }
433
        $nvme = null;
439
        $nvme = null;
434
        foreach (System::removeDupsAndCount($this->_sys->getNvmeDevices()) as $dev) {
440
        foreach (System::removeDupsAndCount($this->_sys->getNvmeDevices()) as $dev) {
435
            if ($nvme === null) $nvme = $hardware->addChild('NVMe');
441
            if ($nvme === null) $nvme = $hardware->addChild('NVMe');
436
            $tmp = $nvme->addChild('Device');
442
            $tmp = $nvme->addChild('Device');
437
            $tmp->addAttribute('Name', $dev->getName());
443
            $tmp->addAttribute('Name', $dev->getName());
438
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
444
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
439
                if ($dev->getCapacity() !== null) {
445
                if ($dev->getCapacity() !== null) {
440
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
446
                    $tmp->addAttribute('Capacity', $dev->getCapacity());
441
                }
447
                }
442
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
448
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
443
                    $tmp->addAttribute('Serial', $dev->getSerial());
449
                    $tmp->addAttribute('Serial', $dev->getSerial());
444
                }
450
                }
445
            }
451
            }
446
            if ($dev->getCount() > 1) {
452
            if ($dev->getCount() > 1) {
447
                $tmp->addAttribute('Count', $dev->getCount());
453
                $tmp->addAttribute('Count', $dev->getCount());
448
            }
454
            }
449
        }
455
        }
450
        $usb = null;
456
        $usb = null;
451
        foreach (System::removeDupsAndCount($this->_sys->getUsbDevices()) as $dev) {
457
        foreach (System::removeDupsAndCount($this->_sys->getUsbDevices()) as $dev) {
452
            if ($usb === null) $usb = $hardware->addChild('USB');
458
            if ($usb === null) $usb = $hardware->addChild('USB');
453
            $tmp = $usb->addChild('Device');
459
            $tmp = $usb->addChild('Device');
454
            $tmp->addAttribute('Name', $dev->getName());
460
            $tmp->addAttribute('Name', $dev->getName());
455
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
461
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
456
                if ($dev->getManufacturer() !== null) {
462
                if ($dev->getManufacturer() !== null) {
457
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
463
                    $tmp->addAttribute('Manufacturer', $dev->getManufacturer());
458
                }
464
                }
459
                if ($dev->getProduct() !== null) {
465
                if ($dev->getProduct() !== null) {
460
                    $tmp->addAttribute('Product', $dev->getProduct());
466
                    $tmp->addAttribute('Product', $dev->getProduct());
461
                }
467
                }
462
                if ($dev->getSpeed() !== null) {
468
                if ($dev->getSpeed() !== null) {
463
                    $tmp->addAttribute('Speed', $dev->getSpeed());
469
                    $tmp->addAttribute('Speed', $dev->getSpeed());
464
                }
470
                }
465
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
471
                if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL && ($dev->getSerial() !== null)) {
466
                    $tmp->addAttribute('Serial', $dev->getSerial());
472
                    $tmp->addAttribute('Serial', $dev->getSerial());
467
                }
473
                }
468
            }
474
            }
469
            if ($dev->getCount() > 1) {
475
            if ($dev->getCount() > 1) {
470
                $tmp->addAttribute('Count', $dev->getCount());
476
                $tmp->addAttribute('Count', $dev->getCount());
471
            }
477
            }
472
        }
478
        }
473
        $tb = null;
479
        $tb = null;
474
        foreach (System::removeDupsAndCount($this->_sys->getTbDevices()) as $dev) {
480
        foreach (System::removeDupsAndCount($this->_sys->getTbDevices()) as $dev) {
475
            if ($tb === null) $tb = $hardware->addChild('TB');
481
            if ($tb === null) $tb = $hardware->addChild('TB');
476
            $tmp = $tb->addChild('Device');
482
            $tmp = $tb->addChild('Device');
477
            $tmp->addAttribute('Name', $dev->getName());
483
            $tmp->addAttribute('Name', $dev->getName());
478
            if ($dev->getCount() > 1) {
484
            if ($dev->getCount() > 1) {
479
                $tmp->addAttribute('Count', $dev->getCount());
485
                $tmp->addAttribute('Count', $dev->getCount());
480
            }
486
            }
481
        }
487
        }
482
        $i2c = null;
488
        $i2c = null;
483
        foreach (System::removeDupsAndCount($this->_sys->getI2cDevices()) as $dev) {
489
        foreach (System::removeDupsAndCount($this->_sys->getI2cDevices()) as $dev) {
484
            if ($i2c === null) $i2c = $hardware->addChild('I2C');
490
            if ($i2c === null) $i2c = $hardware->addChild('I2C');
485
            $tmp = $i2c->addChild('Device');
491
            $tmp = $i2c->addChild('Device');
486
            $tmp->addAttribute('Name', $dev->getName());
492
            $tmp->addAttribute('Name', $dev->getName());
487
            if ($dev->getCount() > 1) {
493
            if ($dev->getCount() > 1) {
488
                $tmp->addAttribute('Count', $dev->getCount());
494
                $tmp->addAttribute('Count', $dev->getCount());
489
            }
495
            }
490
        }
496
        }
491
    }
497
    }
492
 
498
 
493
    /**
499
    /**
494
     * generate the memory information
500
     * generate the memory information
495
     *
501
     *
496
     * @return void
502
     * @return void
497
     */
503
     */
498
    private function _buildMemory()
504
    private function _buildMemory()
499
    {
505
    {
500
        $memory = $this->_xml->addChild('Memory');
506
        $memory = $this->_xml->addChild('Memory');
501
        $memory->addAttribute('Free', $this->_sys->getMemFree());
507
        $memory->addAttribute('Free', $this->_sys->getMemFree());
502
        $memory->addAttribute('Used', $this->_sys->getMemUsed());
508
        $memory->addAttribute('Used', $this->_sys->getMemUsed());
503
        $memory->addAttribute('Total', $this->_sys->getMemTotal());
509
        $memory->addAttribute('Total', $this->_sys->getMemTotal());
504
        $memory->addAttribute('Percent', $this->_sys->getMemPercentUsed());
510
        $memory->addAttribute('Percent', $this->_sys->getMemPercentUsed());
505
        if (($this->_sys->getMemApplication() !== null) || ($this->_sys->getMemBuffer() !== null) || ($this->_sys->getMemCache() !== null)) {
511
        if (($this->_sys->getMemApplication() !== null) || ($this->_sys->getMemBuffer() !== null) || ($this->_sys->getMemCache() !== null)) {
506
            $details = $memory->addChild('Details');
512
            $details = $memory->addChild('Details');
507
            if ($this->_sys->getMemApplication() !== null) {
513
            if ($this->_sys->getMemApplication() !== null) {
508
                $details->addAttribute('App', $this->_sys->getMemApplication());
514
                $details->addAttribute('App', $this->_sys->getMemApplication());
509
                $details->addAttribute('AppPercent', $this->_sys->getMemPercentApplication());
515
                $details->addAttribute('AppPercent', $this->_sys->getMemPercentApplication());
510
            }
516
            }
511
            if ($this->_sys->getMemBuffer() !== null) {
517
            if ($this->_sys->getMemBuffer() !== null) {
512
                $details->addAttribute('Buffers', $this->_sys->getMemBuffer());
518
                $details->addAttribute('Buffers', $this->_sys->getMemBuffer());
513
                $details->addAttribute('BuffersPercent', $this->_sys->getMemPercentBuffer());
519
                $details->addAttribute('BuffersPercent', $this->_sys->getMemPercentBuffer());
514
            }
520
            }
515
            if ($this->_sys->getMemCache() !== null) {
521
            if ($this->_sys->getMemCache() !== null) {
516
                $details->addAttribute('Cached', $this->_sys->getMemCache());
522
                $details->addAttribute('Cached', $this->_sys->getMemCache());
517
                $details->addAttribute('CachedPercent', $this->_sys->getMemPercentCache());
523
                $details->addAttribute('CachedPercent', $this->_sys->getMemPercentCache());
518
            }
524
            }
519
        }
525
        }
520
        if (count($this->_sys->getSwapDevices()) > 0) {
526
        if (count($this->_sys->getSwapDevices()) > 0) {
521
            $swap = $memory->addChild('Swap');
527
            $swap = $memory->addChild('Swap');
522
            $swap->addAttribute('Free', $this->_sys->getSwapFree());
528
            $swap->addAttribute('Free', $this->_sys->getSwapFree());
523
            $swap->addAttribute('Used', $this->_sys->getSwapUsed());
529
            $swap->addAttribute('Used', $this->_sys->getSwapUsed());
524
            $swap->addAttribute('Total', $this->_sys->getSwapTotal());
530
            $swap->addAttribute('Total', $this->_sys->getSwapTotal());
525
            $swap->addAttribute('Percent', $this->_sys->getSwapPercentUsed());
531
            $swap->addAttribute('Percent', $this->_sys->getSwapPercentUsed());
526
            $i = 1;
532
            $i = 1;
527
            foreach ($this->_sys->getSwapDevices() as $dev) {
533
            foreach ($this->_sys->getSwapDevices() as $dev) {
528
                $swapMount = $swap->addChild('Mount');
534
                $swapMount = $swap->addChild('Mount');
529
                $this->_fillDevice($swapMount, $dev, $i++);
535
                $this->_fillDevice($swapMount, $dev, $i++);
530
            }
536
            }
531
        }
537
        }
532
    }
538
    }
533
 
539
 
534
    /**
540
    /**
535
     * fill a xml element with atrributes from a disk device
541
     * fill a xml element with atrributes from a disk device
536
     *
542
     *
537
     * @param SimpleXmlExtended $mount Xml-Element
543
     * @param SimpleXmlExtended $mount Xml-Element
538
     * @param DiskDevice        $dev   DiskDevice
544
     * @param DiskDevice        $dev   DiskDevice
539
     * @param int               $i     counter
545
     * @param int               $i     counter
540
     *
546
     *
541
     * @return void
547
     * @return void
542
     */
548
     */
543
    private function _fillDevice(SimpleXMLExtended $mount, DiskDevice $dev, $i)
549
    private function _fillDevice(SimpleXMLExtended $mount, DiskDevice $dev, $i)
544
    {
550
    {
545
        $mount->addAttribute('MountPointID', $i);
551
        $mount->addAttribute('MountPointID', $i);
546
        if ($dev->getFsType()!=="") {
552
        if ($dev->getFsType()!=="") {
547
            $mount->addAttribute('FSType', $dev->getFsType());
553
            $mount->addAttribute('FSType', $dev->getFsType());
548
        }
554
        }
549
        $mount->addAttribute('Name', $dev->getName());
555
        $mount->addAttribute('Name', $dev->getName());
550
        $mount->addAttribute('Free', sprintf("%.0f", $dev->getFree()));
556
        $mount->addAttribute('Free', sprintf("%.0f", $dev->getFree()));
551
        $mount->addAttribute('Used', sprintf("%.0f", $dev->getUsed()));
557
        $mount->addAttribute('Used', sprintf("%.0f", $dev->getUsed()));
552
        $mount->addAttribute('Total', sprintf("%.0f", $dev->getTotal()));
558
        $mount->addAttribute('Total', sprintf("%.0f", $dev->getTotal()));
553
        $percentUsed = $dev->getPercentUsed();
559
        $percentUsed = $dev->getPercentUsed();
554
        $mount->addAttribute('Percent', $percentUsed);
560
        $mount->addAttribute('Percent', $percentUsed);
555
        if ($dev->getPercentInodesUsed() !== null) {
561
        if ($dev->getPercentInodesUsed() !== null) {
556
            $mount->addAttribute('Inodes', $dev->getPercentInodesUsed());
562
            $mount->addAttribute('Inodes', $dev->getPercentInodesUsed());
557
        }
563
        }
558
        if ($dev->getIgnore() > 0) $mount->addAttribute('Ignore', $dev->getIgnore());
564
        if ($dev->getIgnore() > 0) $mount->addAttribute('Ignore', $dev->getIgnore());
559
        if (PSI_SHOW_MOUNT_OPTION) {
565
        if (PSI_SHOW_MOUNT_OPTION) {
560
            if ($dev->getOptions() !== null) {
566
            if ($dev->getOptions() !== null) {
561
                $mount->addAttribute('MountOptions', preg_replace("/,/", ", ", $dev->getOptions()));
567
                $mount->addAttribute('MountOptions', preg_replace("/,/", ", ", $dev->getOptions()));
562
            }
568
            }
563
        }
569
        }
564
        if (PSI_SHOW_MOUNT_POINT && ($dev->getMountPoint() !== null)) {
570
        if (PSI_SHOW_MOUNT_POINT && ($dev->getMountPoint() !== null)) {
565
            $mount->addAttribute('MountPoint', $dev->getMountPoint());
571
            $mount->addAttribute('MountPoint', $dev->getMountPoint());
566
        }
572
        }
567
    }
573
    }
568
 
574
 
569
    /**
575
    /**
570
     * generate the filesysteminformation
576
     * generate the filesysteminformation
571
     *
577
     *
572
     * @return void
578
     * @return void
573
     */
579
     */
574
    private function _buildFilesystems()
580
    private function _buildFilesystems()
575
    {
581
    {
576
        $hideMounts = $hideFstypes = $hideDisks = $ignoreFree = $ignoreTotal = $ignoreUsage = $ignoreThreshold = array();
582
        $hideMounts = $hideFstypes = $hideDisks = $ignoreFree = $ignoreTotal = $ignoreUsage = $ignoreThreshold = array();
577
        if (defined('PSI_HIDE_MOUNTS') && is_string(PSI_HIDE_MOUNTS)) {
583
        if (defined('PSI_HIDE_MOUNTS') && is_string(PSI_HIDE_MOUNTS)) {
578
            if (preg_match(ARRAY_EXP, PSI_HIDE_MOUNTS)) {
584
            if (preg_match(ARRAY_EXP, PSI_HIDE_MOUNTS)) {
579
                $hideMounts = eval(PSI_HIDE_MOUNTS);
585
                $hideMounts = eval(PSI_HIDE_MOUNTS);
580
            } else {
586
            } else {
581
                $hideMounts = array(PSI_HIDE_MOUNTS);
587
                $hideMounts = array(PSI_HIDE_MOUNTS);
582
            }
588
            }
583
        }
589
        }
584
        if (defined('PSI_HIDE_FS_TYPES') && is_string(PSI_HIDE_FS_TYPES)) {
590
        if (defined('PSI_HIDE_FS_TYPES') && is_string(PSI_HIDE_FS_TYPES)) {
585
            if (preg_match(ARRAY_EXP, PSI_HIDE_FS_TYPES)) {
591
            if (preg_match(ARRAY_EXP, PSI_HIDE_FS_TYPES)) {
586
                $hideFstypes = eval(PSI_HIDE_FS_TYPES);
592
                $hideFstypes = eval(PSI_HIDE_FS_TYPES);
587
            } else {
593
            } else {
588
                $hideFstypes = array(PSI_HIDE_FS_TYPES);
594
                $hideFstypes = array(PSI_HIDE_FS_TYPES);
589
            }
595
            }
590
        }
596
        }
591
        if (defined('PSI_HIDE_DISKS')) {
597
        if (defined('PSI_HIDE_DISKS')) {
592
            if (is_string(PSI_HIDE_DISKS)) {
598
            if (is_string(PSI_HIDE_DISKS)) {
593
                if (preg_match(ARRAY_EXP, PSI_HIDE_DISKS)) {
599
                if (preg_match(ARRAY_EXP, PSI_HIDE_DISKS)) {
594
                    $hideDisks = eval(PSI_HIDE_DISKS);
600
                    $hideDisks = eval(PSI_HIDE_DISKS);
595
                } else {
601
                } else {
596
                    $hideDisks = array(PSI_HIDE_DISKS);
602
                    $hideDisks = array(PSI_HIDE_DISKS);
597
                }
603
                }
598
            } elseif (PSI_HIDE_DISKS === true) {
604
            } elseif (PSI_HIDE_DISKS === true) {
599
                return;
605
                return;
600
            }
606
            }
601
        }
607
        }
602
        if (defined('PSI_IGNORE_FREE') && is_string(PSI_IGNORE_FREE)) {
608
        if (defined('PSI_IGNORE_FREE') && is_string(PSI_IGNORE_FREE)) {
603
            if (preg_match(ARRAY_EXP, PSI_IGNORE_FREE)) {
609
            if (preg_match(ARRAY_EXP, PSI_IGNORE_FREE)) {
604
                $ignoreFree = eval(PSI_IGNORE_FREE);
610
                $ignoreFree = eval(PSI_IGNORE_FREE);
605
            } else {
611
            } else {
606
                $ignoreFree = array(PSI_IGNORE_FREE);
612
                $ignoreFree = array(PSI_IGNORE_FREE);
607
            }
613
            }
608
        }
614
        }
609
        if (defined('PSI_IGNORE_TOTAL') && is_string(PSI_IGNORE_TOTAL)) {
615
        if (defined('PSI_IGNORE_TOTAL') && is_string(PSI_IGNORE_TOTAL)) {
610
            if (preg_match(ARRAY_EXP, PSI_IGNORE_TOTAL)) {
616
            if (preg_match(ARRAY_EXP, PSI_IGNORE_TOTAL)) {
611
                $ignoreTotal = eval(PSI_IGNORE_TOTAL);
617
                $ignoreTotal = eval(PSI_IGNORE_TOTAL);
612
            } else {
618
            } else {
613
                $ignoreTotal = array(PSI_IGNORE_TOTAL);
619
                $ignoreTotal = array(PSI_IGNORE_TOTAL);
614
            }
620
            }
615
        }
621
        }
616
        if (defined('PSI_IGNORE_USAGE') && is_string(PSI_IGNORE_USAGE)) {
622
        if (defined('PSI_IGNORE_USAGE') && is_string(PSI_IGNORE_USAGE)) {
617
            if (preg_match(ARRAY_EXP, PSI_IGNORE_USAGE)) {
623
            if (preg_match(ARRAY_EXP, PSI_IGNORE_USAGE)) {
618
                $ignoreUsage = eval(PSI_IGNORE_USAGE);
624
                $ignoreUsage = eval(PSI_IGNORE_USAGE);
619
            } else {
625
            } else {
620
                $ignoreUsage = array(PSI_IGNORE_USAGE);
626
                $ignoreUsage = array(PSI_IGNORE_USAGE);
621
            }
627
            }
622
        }
628
        }
623
        if (defined('PSI_IGNORE_THRESHOLD_FS_TYPES') && is_string(PSI_IGNORE_THRESHOLD_FS_TYPES)) {
629
        if (defined('PSI_IGNORE_THRESHOLD_FS_TYPES') && is_string(PSI_IGNORE_THRESHOLD_FS_TYPES)) {
624
            if (preg_match(ARRAY_EXP, PSI_IGNORE_THRESHOLD_FS_TYPES)) {
630
            if (preg_match(ARRAY_EXP, PSI_IGNORE_THRESHOLD_FS_TYPES)) {
625
                $ignoreThreshold = eval(PSI_IGNORE_THRESHOLD_FS_TYPES);
631
                $ignoreThreshold = eval(PSI_IGNORE_THRESHOLD_FS_TYPES);
626
            } else {
632
            } else {
627
                $ignoreThreshold = array(PSI_IGNORE_THRESHOLD_FS_TYPES);
633
                $ignoreThreshold = array(PSI_IGNORE_THRESHOLD_FS_TYPES);
628
            }
634
            }
629
        }
635
        }
630
        $fs = $this->_xml->addChild('FileSystem');
636
        $fs = $this->_xml->addChild('FileSystem');
631
        $i = 1;
637
        $i = 1;
632
        foreach ($this->_sys->getDiskDevices() as $disk) {
638
        foreach ($this->_sys->getDiskDevices() as $disk) {
633
            if (!in_array($disk->getMountPoint(), $hideMounts, true) && !in_array($disk->getFsType(), $hideFstypes, true) && !in_array($disk->getName(), $hideDisks, true)) {
639
            if (!in_array($disk->getMountPoint(), $hideMounts, true) && !in_array($disk->getFsType(), $hideFstypes, true) && !in_array($disk->getName(), $hideDisks, true)) {
634
                $mount = $fs->addChild('Mount');
640
                $mount = $fs->addChild('Mount');
635
                if (in_array($disk->getFsType(), $ignoreThreshold, true)) {
641
                if (in_array($disk->getFsType(), $ignoreThreshold, true)) {
636
                    $disk->setIgnore(4);
642
                    $disk->setIgnore(4);
637
                } elseif (in_array($disk->getMountPoint(), $ignoreUsage, true)) {
643
                } elseif (in_array($disk->getMountPoint(), $ignoreUsage, true)) {
638
                    $disk->setIgnore(3);
644
                    $disk->setIgnore(3);
639
                } elseif (in_array($disk->getMountPoint(), $ignoreTotal, true)) {
645
                } elseif (in_array($disk->getMountPoint(), $ignoreTotal, true)) {
640
                    $disk->setIgnore(2);
646
                    $disk->setIgnore(2);
641
                } elseif (in_array($disk->getMountPoint(), $ignoreFree, true)) {
647
                } elseif (in_array($disk->getMountPoint(), $ignoreFree, true)) {
642
                    $disk->setIgnore(1);
648
                    $disk->setIgnore(1);
643
                }
649
                }
644
                $this->_fillDevice($mount, $disk, $i++);
650
                $this->_fillDevice($mount, $disk, $i++);
645
            }
651
            }
646
        }
652
        }
647
    }
653
    }
648
 
654
 
649
    /**
655
    /**
650
     * generate the motherboard information
656
     * generate the motherboard information
651
     *
657
     *
652
     * @return void
658
     * @return void
653
     */
659
     */
654
    private function _buildMbinfo()
660
    private function _buildMbinfo()
655
    {
661
    {
656
        $mbinfo = $this->_xml->addChild('MBInfo');
662
        $mbinfo = $this->_xml->addChild('MBInfo');
657
        $temp = $fan = $volt = $power = $current = $other = null;
663
        $temp = $fan = $volt = $power = $current = $other = null;
658
 
664
 
659
        if (sizeof(unserialize(PSI_MBINFO))>0) {
665
        if (sizeof(unserialize(PSI_MBINFO))>0) {
660
            foreach (unserialize(PSI_MBINFO) as $mbinfoclass) {
666
            foreach (unserialize(PSI_MBINFO) as $mbinfoclass) {
661
                $mbinfo_data = new $mbinfoclass();
667
                $mbinfo_data = new $mbinfoclass();
662
                $mbinfo_detail = $mbinfo_data->getMBInfo();
668
                $mbinfo_detail = $mbinfo_data->getMBInfo();
663
 
669
 
664
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='temperature') foreach ($mbinfo_detail->getMbTemp() as $dev) {
670
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='temperature') foreach ($mbinfo_detail->getMbTemp() as $dev) {
665
                    if ($temp == null) {
671
                    if ($temp == null) {
666
                        $temp = $mbinfo->addChild('Temperature');
672
                        $temp = $mbinfo->addChild('Temperature');
667
                    }
673
                    }
668
                    $item = $temp->addChild('Item');
674
                    $item = $temp->addChild('Item');
669
                    $item->addAttribute('Label', $dev->getName());
675
                    $item->addAttribute('Label', $dev->getName());
670
                    $item->addAttribute('Value', $dev->getValue());
676
                    $item->addAttribute('Value', $dev->getValue());
671
                    $alarm = false;
677
                    $alarm = false;
672
                    if ($dev->getMax() !== null) {
678
                    if ($dev->getMax() !== null) {
673
                        $item->addAttribute('Max', $dev->getMax());
679
                        $item->addAttribute('Max', $dev->getMax());
674
                        $alarm = true;
680
                        $alarm = true;
675
                    }
681
                    }
676
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
682
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
677
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
683
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
678
                    }
684
                    }
679
                }
685
                }
680
 
686
 
681
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='fans') foreach ($mbinfo_detail->getMbFan() as $dev) {
687
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='fans') foreach ($mbinfo_detail->getMbFan() as $dev) {
682
                    if ($fan == null) {
688
                    if ($fan == null) {
683
                        $fan = $mbinfo->addChild('Fans');
689
                        $fan = $mbinfo->addChild('Fans');
684
                    }
690
                    }
685
                    $item = $fan->addChild('Item');
691
                    $item = $fan->addChild('Item');
686
                    $item->addAttribute('Label', $dev->getName());
692
                    $item->addAttribute('Label', $dev->getName());
687
                    $item->addAttribute('Value', $dev->getValue());
693
                    $item->addAttribute('Value', $dev->getValue());
688
                    $alarm = false;
694
                    $alarm = false;
689
                    if ($dev->getMin() !== null) {
695
                    if ($dev->getMin() !== null) {
690
                        $item->addAttribute('Min', $dev->getMin());
696
                        $item->addAttribute('Min', $dev->getMin());
691
                        $alarm = true;
697
                        $alarm = true;
692
                    }
698
                    }
693
                    if ($dev->getUnit() !== "") {
699
                    if ($dev->getUnit() !== "") {
694
                        $item->addAttribute('Unit', $dev->getUnit());
700
                        $item->addAttribute('Unit', $dev->getUnit());
695
                    }
701
                    }
696
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
702
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
697
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
703
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
698
                    }
704
                    }
699
                }
705
                }
700
 
706
 
701
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='voltage') foreach ($mbinfo_detail->getMbVolt() as $dev) {
707
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='voltage') foreach ($mbinfo_detail->getMbVolt() as $dev) {
702
                    if ($volt == null) {
708
                    if ($volt == null) {
703
                        $volt = $mbinfo->addChild('Voltage');
709
                        $volt = $mbinfo->addChild('Voltage');
704
                    }
710
                    }
705
                    $item = $volt->addChild('Item');
711
                    $item = $volt->addChild('Item');
706
                    $item->addAttribute('Label', $dev->getName());
712
                    $item->addAttribute('Label', $dev->getName());
707
                    $item->addAttribute('Value', $dev->getValue());
713
                    $item->addAttribute('Value', $dev->getValue());
708
                    $alarm = false;
714
                    $alarm = false;
709
                    if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
715
                    if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
710
                        if ($dev->getMin() !== null) {
716
                        if ($dev->getMin() !== null) {
711
                            $item->addAttribute('Min', $dev->getMin());
717
                            $item->addAttribute('Min', $dev->getMin());
712
                            $alarm = true;
718
                            $alarm = true;
713
                        }
719
                        }
714
                        if ($dev->getMax() !== null) {
720
                        if ($dev->getMax() !== null) {
715
                            $item->addAttribute('Max', $dev->getMax());
721
                            $item->addAttribute('Max', $dev->getMax());
716
                            $alarm = true;
722
                            $alarm = true;
717
                        }
723
                        }
718
                    }
724
                    }
719
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
725
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
720
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
726
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
721
                    }
727
                    }
722
                }
728
                }
723
 
729
 
724
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='power') foreach ($mbinfo_detail->getMbPower() as $dev) {
730
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='power') foreach ($mbinfo_detail->getMbPower() as $dev) {
725
                    if ($power == null) {
731
                    if ($power == null) {
726
                        $power = $mbinfo->addChild('Power');
732
                        $power = $mbinfo->addChild('Power');
727
                    }
733
                    }
728
                    $item = $power->addChild('Item');
734
                    $item = $power->addChild('Item');
729
                    $item->addAttribute('Label', $dev->getName());
735
                    $item->addAttribute('Label', $dev->getName());
730
                    $item->addAttribute('Value', $dev->getValue());
736
                    $item->addAttribute('Value', $dev->getValue());
731
                    $alarm = false;
737
                    $alarm = false;
732
                    if ($dev->getMax() !== null) {
738
                    if ($dev->getMax() !== null) {
733
                        $item->addAttribute('Max', $dev->getMax());
739
                        $item->addAttribute('Max', $dev->getMax());
734
                        $alarm = true;
740
                        $alarm = true;
735
                    }
741
                    }
736
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
742
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
737
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
743
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
738
                    }
744
                    }
739
                }
745
                }
740
 
746
 
741
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='current') foreach ($mbinfo_detail->getMbCurrent() as $dev) {
747
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='current') foreach ($mbinfo_detail->getMbCurrent() as $dev) {
742
                    if ($current == null) {
748
                    if ($current == null) {
743
                        $current = $mbinfo->addChild('Current');
749
                        $current = $mbinfo->addChild('Current');
744
                    }
750
                    }
745
                    $item = $current->addChild('Item');
751
                    $item = $current->addChild('Item');
746
                    $item->addAttribute('Label', $dev->getName());
752
                    $item->addAttribute('Label', $dev->getName());
747
                    $item->addAttribute('Value', $dev->getValue());
753
                    $item->addAttribute('Value', $dev->getValue());
748
                    $alarm = false;
754
                    $alarm = false;
749
                    if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
755
                    if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) {
750
                        if ($dev->getMin() !== null) {
756
                        if ($dev->getMin() !== null) {
751
                            $item->addAttribute('Min', $dev->getMin());
757
                            $item->addAttribute('Min', $dev->getMin());
752
                            $alarm = true;
758
                            $alarm = true;
753
                        }
759
                        }
754
                        if ($dev->getMax() !== null) {
760
                        if ($dev->getMax() !== null) {
755
                            $item->addAttribute('Max', $dev->getMax());
761
                            $item->addAttribute('Max', $dev->getMax());
756
                            $alarm = true;
762
                            $alarm = true;
757
                        }
763
                        }
758
                    }
764
                    }
759
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
765
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) {
760
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
766
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
761
                    }
767
                    }
762
                }
768
                }
763
 
769
 
764
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='other') foreach ($mbinfo_detail->getMbOther() as $dev) {
770
                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='other') foreach ($mbinfo_detail->getMbOther() as $dev) {
765
                    if ($other == null) {
771
                    if ($other == null) {
766
                        $other = $mbinfo->addChild('Other');
772
                        $other = $mbinfo->addChild('Other');
767
                    }
773
                    }
768
                    $item = $other->addChild('Item');
774
                    $item = $other->addChild('Item');
769
                    $item->addAttribute('Label', $dev->getName());
775
                    $item->addAttribute('Label', $dev->getName());
770
                    $item->addAttribute('Value', $dev->getValue());
776
                    $item->addAttribute('Value', $dev->getValue());
771
                    if ($dev->getUnit() !== "") {
777
                    if ($dev->getUnit() !== "") {
772
                        $item->addAttribute('Unit', $dev->getUnit());
778
                        $item->addAttribute('Unit', $dev->getUnit());
773
                    }
779
                    }
774
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
780
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
775
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
781
                        $item->addAttribute('Event', ucfirst(strtolower($dev->getEvent())));
776
                    }
782
                    }
777
                }
783
                }
778
            }
784
            }
779
        }
785
        }
780
    }
786
    }
781
 
787
 
782
    /**
788
    /**
783
     * generate the ups information
789
     * generate the ups information
784
     *
790
     *
785
     * @return void
791
     * @return void
786
     */
792
     */
787
    private function _buildUpsinfo()
793
    private function _buildUpsinfo()
788
    {
794
    {
789
        $upsinfo = $this->_xml->addChild('UPSInfo');
795
        $upsinfo = $this->_xml->addChild('UPSInfo');
790
        if (!defined('PSI_EMU_HOSTNAME') && defined('PSI_UPS_APCUPSD_CGI_ENABLE') && PSI_UPS_APCUPSD_CGI_ENABLE) {
796
        if (!defined('PSI_EMU_HOSTNAME') && defined('PSI_UPS_APCUPSD_CGI_ENABLE') && PSI_UPS_APCUPSD_CGI_ENABLE) {
791
            $upsinfo->addAttribute('ApcupsdCgiLinks', true);
797
            $upsinfo->addAttribute('ApcupsdCgiLinks', true);
792
        }
798
        }
793
        if (sizeof(unserialize(PSI_UPSINFO))>0) {
799
        if (sizeof(unserialize(PSI_UPSINFO))>0) {
794
            foreach (unserialize(PSI_UPSINFO) as $upsinfoclass) {
800
            foreach (unserialize(PSI_UPSINFO) as $upsinfoclass) {
795
                $upsinfo_data = new $upsinfoclass();
801
                $upsinfo_data = new $upsinfoclass();
796
                $upsinfo_detail = $upsinfo_data->getUPSInfo();
802
                $upsinfo_detail = $upsinfo_data->getUPSInfo();
797
                foreach ($upsinfo_detail->getUpsDevices() as $ups) {
803
                foreach ($upsinfo_detail->getUpsDevices() as $ups) {
798
                    $item = $upsinfo->addChild('UPS');
804
                    $item = $upsinfo->addChild('UPS');
799
                    $item->addAttribute('Name', $ups->getName());
805
                    $item->addAttribute('Name', $ups->getName());
800
                    if ($ups->getModel() !== "") {
806
                    if ($ups->getModel() !== "") {
801
                        $item->addAttribute('Model', $ups->getModel());
807
                        $item->addAttribute('Model', $ups->getModel());
802
                    }
808
                    }
803
                    if ($ups->getMode() !== "") {
809
                    if ($ups->getMode() !== "") {
804
                        $item->addAttribute('Mode', $ups->getMode());
810
                        $item->addAttribute('Mode', $ups->getMode());
805
                    }
811
                    }
806
                    if ($ups->getStartTime() !== "") {
812
                    if ($ups->getStartTime() !== "") {
807
                        $item->addAttribute('StartTime', $ups->getStartTime());
813
                        $item->addAttribute('StartTime', $ups->getStartTime());
808
                    }
814
                    }
809
                    $item->addAttribute('Status', $ups->getStatus());
815
                    $item->addAttribute('Status', $ups->getStatus());
810
                    if ($ups->getBeeperStatus() !== null) {
816
                    if ($ups->getBeeperStatus() !== null) {
811
                        $item->addAttribute('BeeperStatus', $ups->getBeeperStatus());
817
                        $item->addAttribute('BeeperStatus', $ups->getBeeperStatus());
812
                    }
818
                    }
813
                    if ($ups->getTemperatur() !== null) {
819
                    if ($ups->getTemperatur() !== null) {
814
                        $item->addAttribute('Temperature', $ups->getTemperatur());
820
                        $item->addAttribute('Temperature', $ups->getTemperatur());
815
                    }
821
                    }
816
                    if ($ups->getOutages() !== null) {
822
                    if ($ups->getOutages() !== null) {
817
                        $item->addAttribute('OutagesCount', $ups->getOutages());
823
                        $item->addAttribute('OutagesCount', $ups->getOutages());
818
                    }
824
                    }
819
                    if ($ups->getLastOutage() !== null) {
825
                    if ($ups->getLastOutage() !== null) {
820
                        $item->addAttribute('LastOutage', $ups->getLastOutage());
826
                        $item->addAttribute('LastOutage', $ups->getLastOutage());
821
                    }
827
                    }
822
                    if ($ups->getLastOutageFinish() !== null) {
828
                    if ($ups->getLastOutageFinish() !== null) {
823
                        $item->addAttribute('LastOutageFinish', $ups->getLastOutageFinish());
829
                        $item->addAttribute('LastOutageFinish', $ups->getLastOutageFinish());
824
                    }
830
                    }
825
                    if ($ups->getLineVoltage() !== null) {
831
                    if ($ups->getLineVoltage() !== null) {
826
                        $item->addAttribute('LineVoltage', $ups->getLineVoltage());
832
                        $item->addAttribute('LineVoltage', $ups->getLineVoltage());
827
                    }
833
                    }
828
                    if ($ups->getLineFrequency() !== null) {
834
                    if ($ups->getLineFrequency() !== null) {
829
                        $item->addAttribute('LineFrequency', $ups->getLineFrequency());
835
                        $item->addAttribute('LineFrequency', $ups->getLineFrequency());
830
                    }
836
                    }
831
                    if ($ups->getLoad() !== null) {
837
                    if ($ups->getLoad() !== null) {
832
                        $item->addAttribute('LoadPercent', $ups->getLoad());
838
                        $item->addAttribute('LoadPercent', $ups->getLoad());
833
                    }
839
                    }
834
                    if ($ups->getBatteryDate() !== null) {
840
                    if ($ups->getBatteryDate() !== null) {
835
                        $item->addAttribute('BatteryDate', $ups->getBatteryDate());
841
                        $item->addAttribute('BatteryDate', $ups->getBatteryDate());
836
                    }
842
                    }
837
                    if ($ups->getBatteryVoltage() !== null) {
843
                    if ($ups->getBatteryVoltage() !== null) {
838
                        $item->addAttribute('BatteryVoltage', $ups->getBatteryVoltage());
844
                        $item->addAttribute('BatteryVoltage', $ups->getBatteryVoltage());
839
                    }
845
                    }
840
                    if ($ups->getBatterCharge() !== null) {
846
                    if ($ups->getBatterCharge() !== null) {
841
                        $item->addAttribute('BatteryChargePercent', $ups->getBatterCharge());
847
                        $item->addAttribute('BatteryChargePercent', $ups->getBatterCharge());
842
                    }
848
                    }
843
                    if ($ups->getTimeLeft() !== null) {
849
                    if ($ups->getTimeLeft() !== null) {
844
                        $item->addAttribute('TimeLeftMinutes', $ups->getTimeLeft());
850
                        $item->addAttribute('TimeLeftMinutes', $ups->getTimeLeft());
845
                    }
851
                    }
846
                }
852
                }
847
            }
853
            }
848
        }
854
        }
849
    }
855
    }
850
 
856
 
851
    /**
857
    /**
852
     * generate the xml document
858
     * generate the xml document
853
     *
859
     *
854
     * @return void
860
     * @return void
855
     */
861
     */
856
    private function _buildXml()
862
    private function _buildXml()
857
    {
863
    {
858
        if (($this->_plugin == '') || $this->_complete_request) {
864
        if (($this->_plugin == '') || $this->_complete_request) {
859
            if ($this->_sys === null) {
865
            if ($this->_sys === null) {
860
                if (PSI_DEBUG) {
866
                if (PSI_DEBUG) {
861
                    // unstable version check
867
                    // unstable version check
862
                    if (!is_numeric(substr(PSI_VERSION, -1))) {
868
                    if (!is_numeric(substr(PSI_VERSION, -1))) {
863
                        $this->_errors->addWarning("This is an unstable version of phpSysInfo, some things may not work correctly");
869
                        $this->_errors->addWarning("This is an unstable version of phpSysInfo, some things may not work correctly");
864
                    }
870
                    }
865
 
871
 
866
                    // Safe mode check
872
                    // Safe mode check
867
                    $safe_mode = @ini_get("safe_mode") ? true : false;
873
                    $safe_mode = @ini_get("safe_mode") ? true : false;
868
                    if ($safe_mode) {
874
                    if ($safe_mode) {
869
                        $this->_errors->addError("WARN", "PhpSysInfo requires to set off 'safe_mode' in 'php.ini'");
875
                        $this->_errors->addError("WARN", "PhpSysInfo requires to set off 'safe_mode' in 'php.ini'");
870
                    }
876
                    }
871
                    // Include path check
877
                    // Include path check
872
                    $include_path = @ini_get("include_path");
878
                    $include_path = @ini_get("include_path");
873
                    if ($include_path && ($include_path!="")) {
879
                    if ($include_path && ($include_path!="")) {
874
                        $include_path = preg_replace("/(:)|(;)/", "\n", $include_path);
880
                        $include_path = preg_replace("/(:)|(;)/", "\n", $include_path);
875
                        if (preg_match("/^\.$/m", $include_path)) {
881
                        if (preg_match("/^\.$/m", $include_path)) {
876
                            $include_path = ".";
882
                            $include_path = ".";
877
                        }
883
                        }
878
                    }
884
                    }
879
                    if ($include_path != ".") {
885
                    if ($include_path != ".") {
880
                        $this->_errors->addError("WARN", "PhpSysInfo requires '.' inside the 'include_path' in php.ini");
886
                        $this->_errors->addError("WARN", "PhpSysInfo requires '.' inside the 'include_path' in php.ini");
881
                    }
887
                    }
882
                    // popen mode check
888
                    // popen mode check
883
                    if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
889
                    if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
884
                        $this->_errors->addError("WARN", "Installed version of PHP does not support proc_open() function, popen() is used");
890
                        $this->_errors->addError("WARN", "Installed version of PHP does not support proc_open() function, popen() is used");
885
                    }
891
                    }
886
                }
892
                }
887
                $this->_sys = $this->_sysinfo->getSys();
893
                $this->_sys = $this->_sysinfo->getSys();
888
            }
894
            }
889
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='vitals') $this->_buildVitals();
895
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='vitals') $this->_buildVitals();
890
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='network') $this->_buildNetwork();
896
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='network') $this->_buildNetwork();
891
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='hardware') $this->_buildHardware();
897
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='hardware') $this->_buildHardware();
892
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='memory') $this->_buildMemory();
898
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='memory') $this->_buildMemory();
893
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='filesystem') $this->_buildFilesystems();
899
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='filesystem') $this->_buildFilesystems();
894
            if (!$this->_sysinfo->getBlockName() || in_array($this->_sysinfo->getBlockName(), array('voltage','current','temperature','fans','power','other'))) $this->_buildMbinfo();
900
            if (!$this->_sysinfo->getBlockName() || in_array($this->_sysinfo->getBlockName(), array('voltage','current','temperature','fans','power','other'))) $this->_buildMbinfo();
895
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='ups') $this->_buildUpsinfo();
901
            if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='ups') $this->_buildUpsinfo();
896
        }
902
        }
897
        if (!$this->_sysinfo->getBlockName()) $this->_buildPlugins();
903
        if (!$this->_sysinfo->getBlockName()) $this->_buildPlugins();
898
        $this->_xml->combinexml($this->_errors->errorsAddToXML($this->_sysinfo->getEncoding()));
904
        $this->_xml->combinexml($this->_errors->errorsAddToXML($this->_sysinfo->getEncoding()));
899
    }
905
    }
900
 
906
 
901
    /**
907
    /**
902
     * get the xml object
908
     * get the xml object
903
     *
909
     *
904
     * @return SimpleXmlElement
910
     * @return SimpleXmlElement
905
     */
911
     */
906
    public function getXml()
912
    public function getXml()
907
    {
913
    {
908
        $this->_buildXml();
914
        $this->_buildXml();
909
 
915
 
910
        return $this->_xml->getSimpleXmlElement();
916
        return $this->_xml->getSimpleXmlElement();
911
    }
917
    }
912
 
918
 
913
    /**
919
    /**
914
     * include xml-trees of the plugins to the main xml
920
     * include xml-trees of the plugins to the main xml
915
     *
921
     *
916
     * @return void
922
     * @return void
917
     */
923
     */
918
    private function _buildPlugins()
924
    private function _buildPlugins()
919
    {
925
    {
920
        $pluginroot = $this->_xml->addChild("Plugins");
926
        $pluginroot = $this->_xml->addChild("Plugins");
921
        if ((($this->_plugin != '') || $this->_complete_request) && count($this->_plugins) > 0) {
927
        if ((($this->_plugin != '') || $this->_complete_request) && count($this->_plugins) > 0) {
922
            $plugins = array();
928
            $plugins = array();
923
            if ($this->_complete_request) {
929
            if ($this->_complete_request) {
924
                $plugins = $this->_plugins;
930
                $plugins = $this->_plugins;
925
            }
931
            }
926
            if (($this->_plugin != '')) {
932
            if (($this->_plugin != '')) {
927
                $plugins = array($this->_plugin);
933
                $plugins = array($this->_plugin);
928
            }
934
            }
929
            foreach ($plugins as $plugin) {
935
            foreach ($plugins as $plugin) {
-
 
936
                if (!$this->_complete_request ||
930
                if (!$this->_complete_request || !defined('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME') ||
937
                   (!defined('PSI_PLUGIN_'.strtoupper($plugin).'_SSH_HOSTNAME') && !defined('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME')) ||
-
 
938
                   (defined('PSI_SSH_HOSTNAME') && (PSI_SSH_HOSTNAME == constant('PSI_PLUGIN_'.strtoupper($plugin).'_SSH_HOSTNAME'))) ||
931
                   (defined('PSI_WMI_HOSTNAME') && (PSI_WMI_HOSTNAME == constant('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME')))) {
939
                   (defined('PSI_WMI_HOSTNAME') && (PSI_WMI_HOSTNAME == constant('PSI_PLUGIN_'.strtoupper($plugin).'_WMI_HOSTNAME')))) {
932
                    $object = new $plugin($this->_sysinfo->getEncoding());
940
                    $object = new $plugin($this->_sysinfo->getEncoding());
933
                    $object->execute();
941
                    $object->execute();
934
                    $oxml = $object->xml();
942
                    $oxml = $object->xml();
935
                    if (sizeof($oxml) > 0) {
943
                    if (sizeof($oxml) > 0) {
936
                        $pluginroot->combinexml($oxml);
944
                        $pluginroot->combinexml($oxml);
937
                    }
945
                    }
938
                }
946
                }
939
            }
947
            }
940
        }
948
        }
941
    }
949
    }
942
 
950
 
943
    /**
951
    /**
944
     * build the xml structure where the content can be inserted
952
     * build the xml structure where the content can be inserted
945
     *
953
     *
946
     * @return void
954
     * @return void
947
     */
955
     */
948
    private function _xmlbody()
956
    private function _xmlbody()
949
    {
957
    {
950
        $dom = new DOMDocument('1.0', 'UTF-8');
958
        $dom = new DOMDocument('1.0', 'UTF-8');
951
        $root = $dom->createElement("tns:phpsysinfo");
959
        $root = $dom->createElement("tns:phpsysinfo");
952
        $root->setAttribute('xmlns:tns', 'http://phpsysinfo.sourceforge.net/');
960
        $root->setAttribute('xmlns:tns', 'http://phpsysinfo.sourceforge.net/');
953
        $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
961
        $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
954
        $root->setAttribute('xsi:schemaLocation', 'http://phpsysinfo.sourceforge.net/ phpsysinfo3.xsd');
962
        $root->setAttribute('xsi:schemaLocation', 'http://phpsysinfo.sourceforge.net/ phpsysinfo3.xsd');
955
        $dom->appendChild($root);
963
        $dom->appendChild($root);
956
        $this->_xml = new SimpleXMLExtended(simplexml_import_dom($dom), $this->_sysinfo->getEncoding());
964
        $this->_xml = new SimpleXMLExtended(simplexml_import_dom($dom), $this->_sysinfo->getEncoding());
957
 
965
 
958
        $generation = $this->_xml->addChild('Generation');
966
        $generation = $this->_xml->addChild('Generation');
959
        $generation->addAttribute('version', PSI_VERSION_STRING);
967
        $generation->addAttribute('version', PSI_VERSION_STRING);
960
        $generation->addAttribute('timestamp', time());
968
        $generation->addAttribute('timestamp', time());
961
        $options = $this->_xml->addChild('Options');
969
        $options = $this->_xml->addChild('Options');
962
        $options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? strtolower(PSI_TEMP_FORMAT) : 'c');
970
        $options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? strtolower(PSI_TEMP_FORMAT) : 'c');
963
        $options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? strtolower(PSI_BYTE_FORMAT) : 'auto_binary');
971
        $options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? strtolower(PSI_BYTE_FORMAT) : 'auto_binary');
964
        $options->addAttribute('datetimeFormat', defined('PSI_DATETIME_FORMAT') ? strtolower(PSI_DATETIME_FORMAT) : 'utc');
972
        $options->addAttribute('datetimeFormat', defined('PSI_DATETIME_FORMAT') ? strtolower(PSI_DATETIME_FORMAT) : 'utc');
965
        if (defined('PSI_REFRESH')) {
973
        if (defined('PSI_REFRESH')) {
966
            $options->addAttribute('refresh', max(intval(PSI_REFRESH), 0));
974
            $options->addAttribute('refresh', max(intval(PSI_REFRESH), 0));
967
        } else {
975
        } else {
968
            $options->addAttribute('refresh', 60000);
976
            $options->addAttribute('refresh', 60000);
969
        }
977
        }
970
        if (defined('PSI_FS_USAGE_THRESHOLD')) {
978
        if (defined('PSI_FS_USAGE_THRESHOLD')) {
971
            if ((($fsut = intval(PSI_FS_USAGE_THRESHOLD)) >= 1) && ($fsut <= 99)) {
979
            if ((($fsut = intval(PSI_FS_USAGE_THRESHOLD)) >= 1) && ($fsut <= 99)) {
972
                $options->addAttribute('threshold', $fsut);
980
                $options->addAttribute('threshold', $fsut);
973
            }
981
            }
974
        } else {
982
        } else {
975
            $options->addAttribute('threshold', 90);
983
            $options->addAttribute('threshold', 90);
976
        }
984
        }
977
        if (count($this->_plugins) > 0) {
985
        if (count($this->_plugins) > 0) {
978
            if (($this->_plugin != '')) {
986
            if (($this->_plugin != '')) {
979
                $plug = $this->_xml->addChild('UsedPlugins');
987
                $plug = $this->_xml->addChild('UsedPlugins');
980
                $plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
988
                $plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
981
            } elseif ($this->_complete_request) {
989
            } elseif ($this->_complete_request) {
982
                $plug = $this->_xml->addChild('UsedPlugins');
990
                $plug = $this->_xml->addChild('UsedPlugins');
983
                foreach ($this->_plugins as $plugin) {
991
                foreach ($this->_plugins as $plugin) {
984
                    $plug->addChild('Plugin')->addAttribute('name', $plugin);
992
                    $plug->addChild('Plugin')->addAttribute('name', $plugin);
985
                }
993
                }
986
/*
994
/*
987
            } else {
995
            } else {
988
                $plug = $this->_xml->addChild('UnusedPlugins');
996
                $plug = $this->_xml->addChild('UnusedPlugins');
989
                foreach ($this->_plugins as $plugin) {
997
                foreach ($this->_plugins as $plugin) {
990
                    $plug->addChild('Plugin')->addAttribute('name', $plugin);
998
                    $plug->addChild('Plugin')->addAttribute('name', $plugin);
991
                }
999
                }
992
*/
1000
*/
993
            }
1001
            }
994
        }
1002
        }
995
    }
1003
    }
996
}
1004
}
997
 
1005