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