| 2770 |
rexy |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* BSDCommon Class
|
|
|
4 |
*
|
|
|
5 |
* PHP version 5
|
|
|
6 |
*
|
|
|
7 |
* @category PHP
|
|
|
8 |
* @package PSI BSDCommon OS class
|
|
|
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.BSDCommon.inc.php 621 2012-07-29 18:49:04Z namiltd $
|
|
|
13 |
* @link http://phpsysinfo.sourceforge.net
|
|
|
14 |
*/
|
|
|
15 |
/**
|
|
|
16 |
* BSDCommon class
|
|
|
17 |
* get all the required information for BSD Like systems
|
|
|
18 |
* no need to implement in every class the same methods
|
|
|
19 |
*
|
|
|
20 |
* @category PHP
|
|
|
21 |
* @package PSI BSDCommon OS class
|
|
|
22 |
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
|
|
|
23 |
* @copyright 2009 phpSysInfo
|
|
|
24 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
|
|
25 |
* @version Release: 3.0
|
|
|
26 |
* @link http://phpsysinfo.sourceforge.net
|
|
|
27 |
*/
|
|
|
28 |
abstract class BSDCommon extends OS
|
|
|
29 |
{
|
|
|
30 |
/**
|
| 3037 |
rexy |
31 |
* Assoc array of all CPUs loads.
|
|
|
32 |
*/
|
|
|
33 |
private $_cpu_loads = null;
|
|
|
34 |
|
|
|
35 |
/**
|
| 2770 |
rexy |
36 |
* content of the syslog
|
|
|
37 |
*
|
|
|
38 |
* @var array
|
|
|
39 |
*/
|
|
|
40 |
private $_dmesg = null;
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* regexp1 for cpu information out of the syslog
|
|
|
44 |
*
|
|
|
45 |
* @var string
|
|
|
46 |
*/
|
|
|
47 |
private $_CPURegExp1 = "//";
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* regexp2 for cpu information out of the syslog
|
|
|
51 |
*
|
|
|
52 |
* @var string
|
|
|
53 |
*/
|
|
|
54 |
private $_CPURegExp2 = "//";
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* regexp1 for scsi information out of the syslog
|
|
|
58 |
*
|
|
|
59 |
* @var string
|
|
|
60 |
*/
|
|
|
61 |
private $_SCSIRegExp1 = "//";
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* regexp2 for scsi information out of the syslog
|
|
|
65 |
*
|
|
|
66 |
* @var string
|
|
|
67 |
*/
|
|
|
68 |
private $_SCSIRegExp2 = "//";
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* regexp3 for scsi information out of the syslog
|
|
|
72 |
*
|
|
|
73 |
* @var string
|
|
|
74 |
*/
|
|
|
75 |
private $_SCSIRegExp3 = "//";
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* regexp1 for pci information out of the syslog
|
|
|
79 |
*
|
|
|
80 |
* @var string
|
|
|
81 |
*/
|
|
|
82 |
private $_PCIRegExp1 = "//";
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* regexp1 for pci information out of the syslog
|
|
|
86 |
*
|
|
|
87 |
* @var string
|
|
|
88 |
*/
|
|
|
89 |
private $_PCIRegExp2 = "//";
|
|
|
90 |
|
|
|
91 |
/**
|
|
|
92 |
* setter for cpuregexp1
|
|
|
93 |
*
|
|
|
94 |
* @param string $value value to set
|
|
|
95 |
*
|
|
|
96 |
* @return void
|
|
|
97 |
*/
|
|
|
98 |
protected function setCPURegExp1($value)
|
|
|
99 |
{
|
|
|
100 |
$this->_CPURegExp1 = $value;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
/**
|
|
|
104 |
* setter for cpuregexp2
|
|
|
105 |
*
|
|
|
106 |
* @param string $value value to set
|
|
|
107 |
*
|
|
|
108 |
* @return void
|
|
|
109 |
*/
|
|
|
110 |
protected function setCPURegExp2($value)
|
|
|
111 |
{
|
|
|
112 |
$this->_CPURegExp2 = $value;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
/**
|
|
|
116 |
* setter for scsiregexp1
|
|
|
117 |
*
|
|
|
118 |
* @param string $value value to set
|
|
|
119 |
*
|
|
|
120 |
* @return void
|
|
|
121 |
*/
|
|
|
122 |
protected function setSCSIRegExp1($value)
|
|
|
123 |
{
|
|
|
124 |
$this->_SCSIRegExp1 = $value;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
/**
|
|
|
128 |
* setter for scsiregexp2
|
|
|
129 |
*
|
|
|
130 |
* @param string $value value to set
|
|
|
131 |
*
|
|
|
132 |
* @return void
|
|
|
133 |
*/
|
|
|
134 |
protected function setSCSIRegExp2($value)
|
|
|
135 |
{
|
|
|
136 |
$this->_SCSIRegExp2 = $value;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
/**
|
|
|
140 |
* setter for scsiregexp3
|
|
|
141 |
*
|
|
|
142 |
* @param string $value value to set
|
|
|
143 |
*
|
|
|
144 |
* @return void
|
|
|
145 |
*/
|
|
|
146 |
protected function setSCSIRegExp3($value)
|
|
|
147 |
{
|
|
|
148 |
$this->_SCSIRegExp3 = $value;
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
/**
|
|
|
152 |
* setter for pciregexp1
|
|
|
153 |
*
|
|
|
154 |
* @param string $value value to set
|
|
|
155 |
*
|
|
|
156 |
* @return void
|
|
|
157 |
*/
|
|
|
158 |
protected function setPCIRegExp1($value)
|
|
|
159 |
{
|
|
|
160 |
$this->_PCIRegExp1 = $value;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
/**
|
|
|
164 |
* setter for pciregexp2
|
|
|
165 |
*
|
|
|
166 |
* @param string $value value to set
|
|
|
167 |
*
|
|
|
168 |
* @return void
|
|
|
169 |
*/
|
|
|
170 |
protected function setPCIRegExp2($value)
|
|
|
171 |
{
|
|
|
172 |
$this->_PCIRegExp2 = $value;
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
/**
|
|
|
176 |
* read /var/run/dmesg.boot, but only if we haven't already
|
|
|
177 |
*
|
|
|
178 |
* @return array
|
|
|
179 |
*/
|
|
|
180 |
protected function readdmesg()
|
|
|
181 |
{
|
|
|
182 |
if ($this->_dmesg === null) {
|
| 2976 |
rexy |
183 |
if ((PSI_OS != 'Darwin') && (CommonFunctions::rfts('/var/run/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/log/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/run/dmesg.boot', $buf))) { // Once again but with debug
|
| 2770 |
rexy |
184 |
$parts = preg_split("/rebooting|Uptime/", $buf, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
185 |
$this->_dmesg = preg_split("/\n/", $parts[count($parts) - 1], -1, PREG_SPLIT_NO_EMPTY);
|
|
|
186 |
} else {
|
|
|
187 |
$this->_dmesg = array();
|
|
|
188 |
}
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
return $this->_dmesg;
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
/**
|
|
|
195 |
* get a value from sysctl command
|
|
|
196 |
*
|
|
|
197 |
* @param string $key key for the value to get
|
|
|
198 |
*
|
|
|
199 |
* @return string
|
|
|
200 |
*/
|
|
|
201 |
protected function grabkey($key)
|
|
|
202 |
{
|
|
|
203 |
$buf = "";
|
|
|
204 |
if (CommonFunctions::executeProgram('sysctl', "-n $key", $buf, PSI_DEBUG)) {
|
|
|
205 |
return $buf;
|
|
|
206 |
} else {
|
|
|
207 |
return '';
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
/**
|
|
|
212 |
* Virtual Host Name
|
|
|
213 |
*
|
|
|
214 |
* @return void
|
|
|
215 |
*/
|
|
|
216 |
protected function hostname()
|
|
|
217 |
{
|
| 3037 |
rexy |
218 |
if (PSI_USE_VHOST) {
|
| 2770 |
rexy |
219 |
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
|
|
|
220 |
} else {
|
|
|
221 |
if (CommonFunctions::executeProgram('hostname', '', $buf, PSI_DEBUG)) {
|
|
|
222 |
$this->sys->setHostname($buf);
|
|
|
223 |
}
|
|
|
224 |
}
|
|
|
225 |
}
|
|
|
226 |
|
|
|
227 |
/**
|
|
|
228 |
* Kernel Version
|
|
|
229 |
*
|
|
|
230 |
* @return void
|
|
|
231 |
*/
|
|
|
232 |
protected function kernel()
|
|
|
233 |
{
|
|
|
234 |
$s = $this->grabkey('kern.version');
|
| 3100 |
rexy |
235 |
$a = preg_split('/:/', $s, 4);
|
|
|
236 |
if (isset($a[3])) {
|
|
|
237 |
if (preg_match('/^(\d{2} [A-Z]{3});/', $a[3], $abuf) // eg. 19:58 GMT;...
|
|
|
238 |
|| preg_match('/^(\d{2} [A-Z]{3} \d{4})/', $a[3], $abuf)) { // eg. 26:31 PDT 2019...
|
|
|
239 |
$this->sys->setKernel($a[0].$a[1].':'.$a[2].':'.$abuf[1]);
|
|
|
240 |
} else {
|
|
|
241 |
$this->sys->setKernel($a[0].$a[1].':'.$a[2]);
|
|
|
242 |
}
|
|
|
243 |
} elseif (isset($a[2])) {
|
| 2770 |
rexy |
244 |
$this->sys->setKernel($a[0].$a[1].':'.$a[2]);
|
|
|
245 |
} else {
|
|
|
246 |
$this->sys->setKernel($s);
|
|
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
/**
|
| 3037 |
rexy |
251 |
* Virtualizer info
|
| 2770 |
rexy |
252 |
*
|
|
|
253 |
* @return void
|
|
|
254 |
*/
|
| 3037 |
rexy |
255 |
private function virtualizer()
|
| 2770 |
rexy |
256 |
{
|
| 3037 |
rexy |
257 |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
|
|
258 |
$testvirt = $this->sys->getVirtualizer();
|
|
|
259 |
$novm = true;
|
|
|
260 |
foreach ($testvirt as $virtkey=>$virtvalue) if ($virtvalue) {
|
|
|
261 |
$novm = false;
|
|
|
262 |
break;
|
|
|
263 |
}
|
|
|
264 |
// Detect QEMU cpu
|
|
|
265 |
if ($novm && isset($testvirt["cpuid:QEMU"])) {
|
|
|
266 |
$this->sys->setVirtualizer('qemu'); // QEMU
|
|
|
267 |
$novm = false;
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
if ($novm && isset($testvirt["hypervisor"])) {
|
|
|
271 |
$this->sys->setVirtualizer('unknown');
|
|
|
272 |
}
|
|
|
273 |
}
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
/**
|
|
|
277 |
* CPU usage
|
|
|
278 |
*
|
|
|
279 |
* @return void
|
|
|
280 |
*/
|
|
|
281 |
protected function cpuusage()
|
|
|
282 |
{
|
|
|
283 |
if (($this->_cpu_loads === null)) {
|
|
|
284 |
$this->_cpu_loads = array();
|
| 2976 |
rexy |
285 |
if (PSI_OS != 'Darwin') {
|
|
|
286 |
if ($fd = $this->grabkey('kern.cp_time')) {
|
|
|
287 |
// Find out the CPU load
|
|
|
288 |
// user + sys = load
|
|
|
289 |
// total = total
|
|
|
290 |
if (preg_match($this->_CPURegExp2, $fd, $res) && (sizeof($res) > 4)) {
|
|
|
291 |
$load = $res[2] + $res[3] + $res[4]; // cpu.user + cpu.sys
|
|
|
292 |
$total = $res[2] + $res[3] + $res[4] + $res[5]; // cpu.total
|
|
|
293 |
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
|
|
|
294 |
sleep(1);
|
|
|
295 |
$fd = $this->grabkey('kern.cp_time');
|
|
|
296 |
if (preg_match($this->_CPURegExp2, $fd, $res) && (sizeof($res) > 4)) {
|
|
|
297 |
$load2 = $res[2] + $res[3] + $res[4];
|
|
|
298 |
$total2 = $res[2] + $res[3] + $res[4] + $res[5];
|
| 3037 |
rexy |
299 |
if ($total2 != $total) {
|
|
|
300 |
$this->_cpu_loads['cpu'] = (100 * ($load2 - $load)) / ($total2 - $total);
|
|
|
301 |
} else {
|
|
|
302 |
$this->_cpu_loads['cpu'] = 0;
|
|
|
303 |
}
|
| 2976 |
rexy |
304 |
}
|
|
|
305 |
}
|
|
|
306 |
}
|
|
|
307 |
} else {
|
|
|
308 |
$ncpu = $this->grabkey('hw.ncpu');
|
| 3037 |
rexy |
309 |
if (($ncpu !== "") && ($ncpu >= 1) && CommonFunctions::executeProgram('ps', "-A -o %cpu", $pstable, false) && !empty($pstable)) {
|
| 2976 |
rexy |
310 |
$pslines = preg_split("/\n/", $pstable, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
311 |
if (!empty($pslines) && (count($pslines)>1) && (trim($pslines[0])==="%CPU")) {
|
|
|
312 |
array_shift($pslines);
|
|
|
313 |
$sum = 0;
|
|
|
314 |
foreach ($pslines as $psline) {
|
| 3100 |
rexy |
315 |
$sum+=str_replace(',', '.', trim($psline));
|
| 2976 |
rexy |
316 |
}
|
| 3037 |
rexy |
317 |
$this->_cpu_loads['cpu'] = min($sum/$ncpu, 100);
|
| 2976 |
rexy |
318 |
}
|
|
|
319 |
}
|
| 2770 |
rexy |
320 |
}
|
|
|
321 |
}
|
| 3037 |
rexy |
322 |
|
|
|
323 |
if (isset($this->_cpu_loads['cpu'])) {
|
|
|
324 |
return $this->_cpu_loads['cpu'];
|
|
|
325 |
} else {
|
|
|
326 |
return null;
|
|
|
327 |
}
|
| 2770 |
rexy |
328 |
}
|
|
|
329 |
|
|
|
330 |
/**
|
| 3037 |
rexy |
331 |
* Processor Load
|
|
|
332 |
* optionally create a loadbar
|
|
|
333 |
*
|
|
|
334 |
* @return void
|
|
|
335 |
*/
|
|
|
336 |
protected function loadavg()
|
|
|
337 |
{
|
|
|
338 |
$s = $this->grabkey('vm.loadavg');
|
|
|
339 |
$s = preg_replace('/{ /', '', $s);
|
|
|
340 |
$s = preg_replace('/ }/', '', $s);
|
| 3100 |
rexy |
341 |
$s = str_replace(',', '.', $s);
|
| 3037 |
rexy |
342 |
$this->sys->setLoad($s);
|
|
|
343 |
|
|
|
344 |
if (PSI_LOAD_BAR) {
|
|
|
345 |
$this->sys->setLoadPercent($this->cpuusage());
|
|
|
346 |
}
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
/**
|
| 2770 |
rexy |
350 |
* CPU information
|
|
|
351 |
*
|
|
|
352 |
* @return void
|
|
|
353 |
*/
|
|
|
354 |
protected function cpuinfo()
|
|
|
355 |
{
|
|
|
356 |
$dev = new CpuDevice();
|
| 3037 |
rexy |
357 |
$cpumodel = $this->grabkey('hw.model');
|
|
|
358 |
$dev->setModel($cpumodel);
|
|
|
359 |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
|
|
|
360 |
$this->sys->setVirtualizer("cpuid:QEMU", false);
|
| 2770 |
rexy |
361 |
}
|
|
|
362 |
|
|
|
363 |
$notwas = true;
|
|
|
364 |
foreach ($this->readdmesg() as $line) {
|
|
|
365 |
if ($notwas) {
|
| 3037 |
rexy |
366 |
$regexps = preg_split("/\n/", $this->_CPURegExp1, -1, PREG_SPLIT_NO_EMPTY); // multiple regexp separated by \n
|
|
|
367 |
foreach ($regexps as $regexp) {
|
|
|
368 |
if (preg_match($regexp, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
| 3100 |
rexy |
369 |
if ($dev->getCpuSpeed() == 0) {
|
| 3037 |
rexy |
370 |
$dev->setCpuSpeed(round($ar_buf[2]));
|
|
|
371 |
}
|
|
|
372 |
$notwas = false;
|
|
|
373 |
break;
|
| 2770 |
rexy |
374 |
}
|
|
|
375 |
}
|
|
|
376 |
} else {
|
| 3037 |
rexy |
377 |
if (preg_match("/^\s+Origin| Features/", $line, $ar_buf)) {
|
|
|
378 |
if (preg_match("/^\s+Origin[ ]*=[ ]*\"(.+)\"/", $line, $ar_buf)) {
|
|
|
379 |
$dev->setVendorId($ar_buf[1]);
|
|
|
380 |
} elseif (preg_match("/ Features2[ ]*=.*<(.+)>/", $line, $ar_buf)) {
|
| 2770 |
rexy |
381 |
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
|
|
|
382 |
foreach ($feats as $feat) {
|
|
|
383 |
if (($feat=="vmx") || ($feat=="svm")) {
|
|
|
384 |
$dev->setVirt($feat);
|
| 3037 |
rexy |
385 |
} elseif ($feat=="hv") {
|
|
|
386 |
if ($dev->getVirt() === null) {
|
|
|
387 |
$dev->setVirt('hypervisor');
|
|
|
388 |
}
|
|
|
389 |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
|
|
390 |
$this->sys->setVirtualizer("hypervisor", false);
|
|
|
391 |
}
|
| 2770 |
rexy |
392 |
}
|
|
|
393 |
}
|
|
|
394 |
}
|
|
|
395 |
} else break;
|
|
|
396 |
}
|
|
|
397 |
}
|
|
|
398 |
|
|
|
399 |
$ncpu = $this->grabkey('hw.ncpu');
|
| 3037 |
rexy |
400 |
if (($ncpu === "") || !($ncpu >= 1)) {
|
| 2770 |
rexy |
401 |
$ncpu = 1;
|
| 3037 |
rexy |
402 |
}
|
|
|
403 |
if (($ncpu == 1) && PSI_LOAD_BAR) {
|
|
|
404 |
$dev->setLoad($this->cpuusage());
|
|
|
405 |
}
|
| 2770 |
rexy |
406 |
for ($ncpu ; $ncpu > 0 ; $ncpu--) {
|
|
|
407 |
$this->sys->setCpus($dev);
|
|
|
408 |
}
|
|
|
409 |
}
|
|
|
410 |
|
|
|
411 |
/**
|
| 3037 |
rexy |
412 |
* Machine information
|
|
|
413 |
*
|
|
|
414 |
* @return void
|
|
|
415 |
*/
|
|
|
416 |
private function machine()
|
|
|
417 |
{
|
|
|
418 |
if ((PSI_OS == 'NetBSD') || (PSI_OS == 'OpenBSD')) {
|
|
|
419 |
$buffer = array();
|
|
|
420 |
if (PSI_OS == 'NetBSD') { // NetBSD
|
|
|
421 |
$buffer['Manufacturer'] = $this->grabkey('machdep.dmi.system-vendor');
|
|
|
422 |
$buffer['Model'] = $this->grabkey('machdep.dmi.system-product');
|
|
|
423 |
$buffer['Product'] = $this->grabkey('machdep.dmi.board-product');
|
|
|
424 |
$buffer['SMBIOSBIOSVersion'] = $this->grabkey('machdep.dmi.bios-version');
|
|
|
425 |
$buffer['ReleaseDate'] = $this->grabkey('machdep.dmi.bios-date');
|
|
|
426 |
} else { // OpenBSD
|
|
|
427 |
$buffer['Manufacturer'] = $this->grabkey('hw.vendor');
|
|
|
428 |
$buffer['Model'] = $this->grabkey('hw.product');
|
|
|
429 |
$buffer['Product'] = "";
|
|
|
430 |
$buffer['SMBIOSBIOSVersion'] = "";
|
|
|
431 |
$buffer['ReleaseDate'] = "";
|
|
|
432 |
}
|
|
|
433 |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
|
|
434 |
$vendor_array = array();
|
|
|
435 |
$vendor_array[] = $buffer['Model'];
|
|
|
436 |
$vendor_array[] = trim($buffer['Manufacturer']." ".$buffer['Model']);
|
|
|
437 |
if (PSI_OS == 'NetBSD') { // NetBSD
|
|
|
438 |
$vendor_array[] = $this->grabkey('machdep.dmi.board-vendor');
|
|
|
439 |
$vendor_array[] = $this->grabkey('machdep.dmi.bios-vendor');
|
|
|
440 |
}
|
|
|
441 |
$virt = CommonFunctions::decodevirtualizer($vendor_array);
|
|
|
442 |
if ($virt !== null) {
|
|
|
443 |
$this->sys->setVirtualizer($virt);
|
|
|
444 |
}
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
$buf = "";
|
|
|
448 |
if (($buffer['Manufacturer'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System manufacturer$|^Not Specified$/i", $buf2=trim($buffer['Manufacturer'])) && ($buf2 !== "")) {
|
|
|
449 |
$buf .= ' '.$buf2;
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
if (($buffer['Model'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^System Product Name$|^Not Specified$/i", $buf2=trim($buffer['Model'])) && ($buf2 !== "")) {
|
|
|
453 |
$model = $buf2;
|
|
|
454 |
$buf .= ' '.$buf2;
|
|
|
455 |
}
|
|
|
456 |
if (($buffer['Product'] !== "") && !preg_match("/^To be filled by O\.E\.M\.$|^BaseBoard Product Name$|^Not Specified$|^Default string$/i", $buf2=trim($buffer['Product'])) && ($buf2 !== "")) {
|
|
|
457 |
if ($buf2 !== $model) {
|
|
|
458 |
$buf .= '/'.$buf2;
|
|
|
459 |
} elseif (isset($buffer['SystemFamily']) && !preg_match("/^To be filled by O\.E\.M\.$|^System Family$|^Not Specified$/i", $buf2=trim($buffer['SystemFamily'])) && ($buf2 !== "")) {
|
|
|
460 |
$buf .= '/'.$buf2;
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
$bver = "";
|
|
|
465 |
$brel = "";
|
|
|
466 |
if (($buf2=trim($buffer['SMBIOSBIOSVersion'])) !== "") {
|
|
|
467 |
$bver .= ' '.$buf2;
|
|
|
468 |
}
|
|
|
469 |
if ($buffer['ReleaseDate'] !== "") {
|
|
|
470 |
if (preg_match("/^(\d{4})(\d{2})(\d{2})$/", $buffer['ReleaseDate'], $dateout)) {
|
|
|
471 |
$brel .= ' '.$dateout[2].'/'.$dateout[3].'/'.$dateout[1];
|
|
|
472 |
} elseif (preg_match("/^\d{2}\/\d{2}\/\d{4}$/", $buffer['ReleaseDate'])) {
|
|
|
473 |
$brel .= ' '.$buffer['ReleaseDate'];
|
|
|
474 |
}
|
|
|
475 |
}
|
|
|
476 |
if ((trim($bver) !== "") || (trim($brel) !== "")) {
|
|
|
477 |
$buf .= ', BIOS'.$bver.$brel;
|
|
|
478 |
}
|
|
|
479 |
|
|
|
480 |
if (trim($buf) !== "") {
|
|
|
481 |
$this->sys->setMachine(trim($buf));
|
|
|
482 |
}
|
|
|
483 |
} elseif ((PSI_OS == 'FreeBSD') && defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
|
|
|
484 |
$vendorid = $this->grabkey('hw.hv_vendor');
|
|
|
485 |
if (trim($vendorid) === "") {
|
|
|
486 |
foreach ($this->readdmesg() as $line) if (preg_match("/^Hypervisor: Origin = \"(.+)\"/", $line, $ar_buf)) {
|
|
|
487 |
if (trim($ar_buf[1]) !== "") {
|
|
|
488 |
$vendorid = $ar_buf[1];
|
|
|
489 |
}
|
|
|
490 |
break;
|
|
|
491 |
}
|
|
|
492 |
}
|
|
|
493 |
if (trim($vendorid) !== "") {
|
|
|
494 |
$virt = CommonFunctions::decodevirtualizer($vendorid);
|
|
|
495 |
if ($virt !== null) {
|
|
|
496 |
$this->sys->setVirtualizer($virt);
|
|
|
497 |
} else {
|
|
|
498 |
$this->sys->setVirtualizer('unknown');
|
|
|
499 |
}
|
|
|
500 |
}
|
|
|
501 |
}
|
|
|
502 |
}
|
|
|
503 |
|
|
|
504 |
/**
|
| 2770 |
rexy |
505 |
* SCSI devices
|
|
|
506 |
* get the scsi device information out of dmesg
|
|
|
507 |
*
|
|
|
508 |
* @return void
|
|
|
509 |
*/
|
|
|
510 |
protected function scsi()
|
|
|
511 |
{
|
|
|
512 |
foreach ($this->readdmesg() as $line) {
|
| 2976 |
rexy |
513 |
if (preg_match($this->_SCSIRegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
| 2770 |
rexy |
514 |
$dev = new HWDevice();
|
|
|
515 |
$dev->setName($ar_buf[1].": ".trim($ar_buf[2]));
|
|
|
516 |
$this->sys->setScsiDevices($dev);
|
| 2976 |
rexy |
517 |
} elseif (preg_match($this->_SCSIRegExp2, $line, $ar_buf) && (sizeof($ar_buf) > 1)) {
|
| 2770 |
rexy |
518 |
/* duplication security */
|
|
|
519 |
$notwas = true;
|
|
|
520 |
foreach ($this->sys->getScsiDevices() as $finddev) {
|
|
|
521 |
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
|
|
522 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
523 |
if (isset($ar_buf[3]) && ($ar_buf[3]==="G")) {
|
|
|
524 |
$finddev->setCapacity($ar_buf[2] * 1024 * 1024 * 1024);
|
| 2976 |
rexy |
525 |
} elseif (isset($ar_buf[2])) {
|
| 2770 |
rexy |
526 |
$finddev->setCapacity($ar_buf[2] * 1024 * 1024);
|
|
|
527 |
}
|
|
|
528 |
}
|
|
|
529 |
$notwas = false;
|
|
|
530 |
break;
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
if ($notwas) {
|
|
|
534 |
$dev = new HWDevice();
|
|
|
535 |
$dev->setName($ar_buf[1]);
|
|
|
536 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
537 |
if (isset($ar_buf[3]) && ($ar_buf[3]==="G")) {
|
|
|
538 |
$dev->setCapacity($ar_buf[2] * 1024 * 1024 * 1024);
|
| 2976 |
rexy |
539 |
} elseif (isset($ar_buf[2])) {
|
| 2770 |
rexy |
540 |
$dev->setCapacity($ar_buf[2] * 1024 * 1024);
|
|
|
541 |
}
|
|
|
542 |
}
|
|
|
543 |
$this->sys->setScsiDevices($dev);
|
|
|
544 |
}
|
| 2976 |
rexy |
545 |
} elseif (preg_match($this->_SCSIRegExp3, $line, $ar_buf) && (sizeof($ar_buf) > 1)) {
|
| 2770 |
rexy |
546 |
/* duplication security */
|
|
|
547 |
$notwas = true;
|
|
|
548 |
foreach ($this->sys->getScsiDevices() as $finddev) {
|
|
|
549 |
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
|
|
550 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
|
|
551 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
| 2976 |
rexy |
552 |
if (isset($ar_buf[2])) $finddev->setSerial(trim($ar_buf[2]));
|
| 2770 |
rexy |
553 |
}
|
|
|
554 |
$notwas = false;
|
|
|
555 |
break;
|
|
|
556 |
}
|
|
|
557 |
}
|
|
|
558 |
if ($notwas) {
|
|
|
559 |
$dev = new HWDevice();
|
|
|
560 |
$dev->setName($ar_buf[1]);
|
|
|
561 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
|
|
562 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
| 2976 |
rexy |
563 |
if (isset($ar_buf[2])) $dev->setSerial(trim($ar_buf[2]));
|
| 2770 |
rexy |
564 |
}
|
|
|
565 |
$this->sys->setScsiDevices($dev);
|
|
|
566 |
}
|
|
|
567 |
}
|
|
|
568 |
}
|
|
|
569 |
/* cleaning */
|
|
|
570 |
foreach ($this->sys->getScsiDevices() as $finddev) {
|
| 3037 |
rexy |
571 |
if (strpos($finddev->getName(), ': ') !== false)
|
|
|
572 |
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
|
| 2770 |
rexy |
573 |
}
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
/**
|
|
|
577 |
* parsing the output of pciconf command
|
|
|
578 |
*
|
|
|
579 |
* @return Array
|
|
|
580 |
*/
|
|
|
581 |
protected function pciconf()
|
|
|
582 |
{
|
|
|
583 |
$arrResults = array();
|
|
|
584 |
$intS = 0;
|
|
|
585 |
if (CommonFunctions::executeProgram("pciconf", "-lv", $strBuf, PSI_DEBUG)) {
|
|
|
586 |
$arrTemp = array();
|
|
|
587 |
$arrBlocks = preg_split("/\n\S/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
588 |
foreach ($arrBlocks as $strBlock) {
|
|
|
589 |
$arrLines = preg_split("/\n/", $strBlock, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
590 |
$vend = null;
|
|
|
591 |
foreach ($arrLines as $strLine) {
|
|
|
592 |
if (preg_match("/\sclass=0x([a-fA-F0-9]{4})[a-fA-F0-9]{2}\s.*\schip=0x([a-fA-F0-9]{4})([a-fA-F0-9]{4})\s/", $strLine, $arrParts)) {
|
|
|
593 |
$arrTemp[$intS] = 'Class '.$arrParts[1].': Device '.$arrParts[3].':'.$arrParts[2];
|
|
|
594 |
$vend = '';
|
|
|
595 |
} elseif (preg_match("/(.*) = '(.*)'/", $strLine, $arrParts)) {
|
|
|
596 |
if (trim($arrParts[1]) == "vendor") {
|
|
|
597 |
$vend = trim($arrParts[2]);
|
|
|
598 |
} elseif (trim($arrParts[1]) == "device") {
|
|
|
599 |
if (($vend !== null) && ($vend !== '')) {
|
|
|
600 |
$arrTemp[$intS] = $vend." - ".trim($arrParts[2]);
|
|
|
601 |
} else {
|
|
|
602 |
$arrTemp[$intS] = trim($arrParts[2]);
|
|
|
603 |
$vend = '';
|
|
|
604 |
}
|
|
|
605 |
}
|
|
|
606 |
}
|
|
|
607 |
}
|
|
|
608 |
if ($vend !== null) {
|
|
|
609 |
$intS++;
|
|
|
610 |
}
|
|
|
611 |
}
|
|
|
612 |
foreach ($arrTemp as $name) {
|
|
|
613 |
$dev = new HWDevice();
|
|
|
614 |
$dev->setName($name);
|
|
|
615 |
$arrResults[] = $dev;
|
|
|
616 |
}
|
|
|
617 |
}
|
|
|
618 |
|
|
|
619 |
return $arrResults;
|
|
|
620 |
}
|
|
|
621 |
|
|
|
622 |
/**
|
|
|
623 |
* PCI devices
|
|
|
624 |
* get the pci device information out of dmesg
|
|
|
625 |
*
|
|
|
626 |
* @return void
|
|
|
627 |
*/
|
|
|
628 |
protected function pci()
|
|
|
629 |
{
|
|
|
630 |
if ((!$results = Parser::lspci(false)) && (!$results = $this->pciconf())) {
|
|
|
631 |
foreach ($this->readdmesg() as $line) {
|
| 2976 |
rexy |
632 |
if (preg_match($this->_PCIRegExp1, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
| 2770 |
rexy |
633 |
$dev = new HWDevice();
|
|
|
634 |
$dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
|
|
635 |
$results[] = $dev;
|
| 2976 |
rexy |
636 |
} elseif (preg_match($this->_PCIRegExp2, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
|
| 2770 |
rexy |
637 |
$dev = new HWDevice();
|
|
|
638 |
$dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
|
|
639 |
$results[] = $dev;
|
|
|
640 |
}
|
|
|
641 |
}
|
|
|
642 |
}
|
|
|
643 |
foreach ($results as $dev) {
|
|
|
644 |
$this->sys->setPciDevices($dev);
|
|
|
645 |
}
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
/**
|
|
|
649 |
* IDE devices
|
|
|
650 |
* get the ide device information out of dmesg
|
|
|
651 |
*
|
|
|
652 |
* @return void
|
|
|
653 |
*/
|
|
|
654 |
protected function ide()
|
|
|
655 |
{
|
|
|
656 |
foreach ($this->readdmesg() as $line) {
|
|
|
657 |
if (preg_match('/^(ad[0-9]+): (.*)MB <(.*)> (.*) (.*)/', $line, $ar_buf)) {
|
|
|
658 |
$dev = new HWDevice();
|
|
|
659 |
$dev->setName($ar_buf[1].": ".trim($ar_buf[3]));
|
|
|
660 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
661 |
$dev->setCapacity($ar_buf[2] * 1024 * 1024);
|
|
|
662 |
}
|
|
|
663 |
$this->sys->setIdeDevices($dev);
|
|
|
664 |
} elseif (preg_match('/^(acd[0-9]+): (.*) <(.*)> (.*)/', $line, $ar_buf)) {
|
|
|
665 |
$dev = new HWDevice();
|
|
|
666 |
$dev->setName($ar_buf[1].": ".trim($ar_buf[3]));
|
|
|
667 |
$this->sys->setIdeDevices($dev);
|
|
|
668 |
} elseif (preg_match('/^(ada[0-9]+): <(.*)> (.*)/', $line, $ar_buf)) {
|
|
|
669 |
$dev = new HWDevice();
|
|
|
670 |
$dev->setName($ar_buf[1].": ".trim($ar_buf[2]));
|
|
|
671 |
$this->sys->setIdeDevices($dev);
|
|
|
672 |
} elseif (preg_match('/^(ada[0-9]+): (.*)MB \((.*)\)/', $line, $ar_buf)) {
|
|
|
673 |
/* duplication security */
|
|
|
674 |
$notwas = true;
|
|
|
675 |
foreach ($this->sys->getIdeDevices() as $finddev) {
|
|
|
676 |
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
|
|
677 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
678 |
$finddev->setCapacity($ar_buf[2] * 1024 * 1024);
|
|
|
679 |
}
|
|
|
680 |
$notwas = false;
|
|
|
681 |
break;
|
|
|
682 |
}
|
|
|
683 |
}
|
|
|
684 |
if ($notwas) {
|
|
|
685 |
$dev = new HWDevice();
|
|
|
686 |
$dev->setName($ar_buf[1]);
|
|
|
687 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
|
|
|
688 |
$dev->setCapacity($ar_buf[2] * 1024 * 1024);
|
|
|
689 |
}
|
|
|
690 |
$this->sys->setIdeDevices($dev);
|
|
|
691 |
}
|
|
|
692 |
} elseif (preg_match('/^(ada[0-9]+): Serial Number (.*)/', $line, $ar_buf)) {
|
|
|
693 |
/* duplication security */
|
|
|
694 |
$notwas = true;
|
|
|
695 |
foreach ($this->sys->getIdeDevices() as $finddev) {
|
|
|
696 |
if ($notwas && (substr($finddev->getName(), 0, strpos($finddev->getName(), ': ')) == $ar_buf[1])) {
|
|
|
697 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
|
|
698 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
|
|
699 |
$finddev->setSerial(trim($ar_buf[2]));
|
|
|
700 |
}
|
|
|
701 |
$notwas = false;
|
|
|
702 |
break;
|
|
|
703 |
}
|
|
|
704 |
}
|
|
|
705 |
if ($notwas) {
|
|
|
706 |
$dev = new HWDevice();
|
|
|
707 |
$dev->setName($ar_buf[1]);
|
|
|
708 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
|
|
709 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
|
|
710 |
$finddev->setSerial(trim($ar_buf[2]));
|
|
|
711 |
}
|
|
|
712 |
$this->sys->setIdeDevices($dev);
|
|
|
713 |
}
|
|
|
714 |
}
|
|
|
715 |
}
|
|
|
716 |
/* cleaning */
|
|
|
717 |
foreach ($this->sys->getIdeDevices() as $finddev) {
|
|
|
718 |
if (strpos($finddev->getName(), ': ') !== false)
|
|
|
719 |
$finddev->setName(substr(strstr($finddev->getName(), ': '), 2));
|
|
|
720 |
}
|
|
|
721 |
}
|
|
|
722 |
|
|
|
723 |
/**
|
|
|
724 |
* Physical memory information and Swap Space information
|
|
|
725 |
*
|
|
|
726 |
* @return void
|
|
|
727 |
*/
|
|
|
728 |
protected function memory()
|
|
|
729 |
{
|
| 3287 |
rexy |
730 |
if (PSI_OS == 'FreeBSD') {
|
|
|
731 |
$kos = $this->grabkey('kern.osrelease');
|
|
|
732 |
if (preg_match("/^(\d+\.\d+)/", $kos, $kver) && version_compare("14.1", $kver[1], "<=")) {
|
|
|
733 |
// vmstat on fbsd 14.1 or greater outputs bytes
|
|
|
734 |
$multiplier = 1;
|
|
|
735 |
} else {
|
|
|
736 |
// vmstat on fbsd 4.4 or greater outputs kbytes not hw.pagesize
|
|
|
737 |
// I should probably add some version checking here, but for now
|
|
|
738 |
// we only support fbsd 4.4
|
|
|
739 |
$$multiplier = 1024;
|
|
|
740 |
}
|
|
|
741 |
} elseif (PSI_OS == 'OpenBSD' || PSI_OS == 'NetBSD' || PSI_OS == 'DragonFly') {
|
|
|
742 |
$multiplier = 1024;
|
| 2770 |
rexy |
743 |
} else {
|
| 3287 |
rexy |
744 |
$multiplier = $this->grabkey('hw.pagesize');
|
| 2770 |
rexy |
745 |
}
|
|
|
746 |
if (CommonFunctions::executeProgram('vmstat', '', $vmstat, PSI_DEBUG)) {
|
|
|
747 |
$lines = preg_split("/\n/", $vmstat, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
748 |
$ar_buf = preg_split("/\s+/", trim($lines[2]), 19);
|
| 3287 |
rexy |
749 |
$this->sys->setMemFree($ar_buf[4] * $multiplier);
|
| 2770 |
rexy |
750 |
$this->sys->setMemTotal($this->grabkey('hw.physmem'));
|
|
|
751 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
|
|
752 |
|
|
|
753 |
if (((PSI_OS == 'OpenBSD' || PSI_OS == 'NetBSD') && CommonFunctions::executeProgram('swapctl', '-l -k', $swapstat, PSI_DEBUG)) || CommonFunctions::executeProgram('swapinfo', '-k', $swapstat, PSI_DEBUG)) {
|
|
|
754 |
$lines = preg_split("/\n/", $swapstat, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
755 |
foreach ($lines as $line) {
|
|
|
756 |
$ar_buf = preg_split("/\s+/", $line, 6);
|
|
|
757 |
if (($ar_buf[0] != 'Total') && ($ar_buf[0] != 'Device')) {
|
|
|
758 |
$dev = new DiskDevice();
|
|
|
759 |
$dev->setMountPoint($ar_buf[0]);
|
|
|
760 |
$dev->setName("SWAP");
|
|
|
761 |
$dev->setFsType('swap');
|
|
|
762 |
$dev->setTotal($ar_buf[1] * 1024);
|
|
|
763 |
$dev->setUsed($ar_buf[2] * 1024);
|
|
|
764 |
$dev->setFree($dev->getTotal() - $dev->getUsed());
|
|
|
765 |
$this->sys->setSwapDevices($dev);
|
|
|
766 |
}
|
|
|
767 |
}
|
|
|
768 |
}
|
|
|
769 |
}
|
|
|
770 |
}
|
|
|
771 |
|
|
|
772 |
/**
|
|
|
773 |
* USB devices
|
|
|
774 |
* get the ide device information out of dmesg
|
|
|
775 |
*
|
|
|
776 |
* @return void
|
|
|
777 |
*/
|
|
|
778 |
protected function usb()
|
|
|
779 |
{
|
| 2976 |
rexy |
780 |
$notwas = true;
|
|
|
781 |
if ((PSI_OS == 'FreeBSD') && CommonFunctions::executeProgram('usbconfig', '', $bufr, false)) {
|
|
|
782 |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
783 |
foreach ($lines as $line) {
|
|
|
784 |
if (preg_match('/^(ugen[0-9]+\.[0-9]+): <([^,]*)(.*)> at (usbus[0-9]+)/', $line, $ar_buf)) {
|
|
|
785 |
$notwas = false;
|
|
|
786 |
$dev = new HWDevice();
|
|
|
787 |
$dev->setName($ar_buf[2]);
|
|
|
788 |
$this->sys->setUSBDevices($dev);
|
|
|
789 |
}
|
|
|
790 |
}
|
|
|
791 |
}
|
|
|
792 |
if ($notwas) foreach ($this->readdmesg() as $line) {
|
| 2770 |
rexy |
793 |
// if (preg_match('/^(ugen[0-9\.]+): <(.*)> (.*) (.*)/', $line, $ar_buf)) {
|
|
|
794 |
// $dev->setName($ar_buf[1].": ".$ar_buf[2]);
|
|
|
795 |
if (preg_match('/^(u[a-z]+[0-9]+): <([^,]*)(.*)> on (usbus[0-9]+)/', $line, $ar_buf)) {
|
|
|
796 |
$dev = new HWDevice();
|
|
|
797 |
$dev->setName($ar_buf[2]);
|
|
|
798 |
$this->sys->setUSBDevices($dev);
|
|
|
799 |
}
|
|
|
800 |
}
|
|
|
801 |
}
|
|
|
802 |
|
|
|
803 |
/**
|
|
|
804 |
* filesystem information
|
|
|
805 |
*
|
|
|
806 |
* @return void
|
|
|
807 |
*/
|
|
|
808 |
protected function filesystems()
|
|
|
809 |
{
|
|
|
810 |
$arrResult = Parser::df();
|
|
|
811 |
foreach ($arrResult as $dev) {
|
|
|
812 |
$this->sys->setDiskDevices($dev);
|
|
|
813 |
}
|
|
|
814 |
}
|
|
|
815 |
|
|
|
816 |
/**
|
|
|
817 |
* Distribution
|
|
|
818 |
*
|
|
|
819 |
* @return void
|
|
|
820 |
*/
|
|
|
821 |
protected function distro()
|
|
|
822 |
{
|
|
|
823 |
if (CommonFunctions::executeProgram('uname', '-s', $result, PSI_DEBUG)) {
|
|
|
824 |
$this->sys->setDistribution($result);
|
|
|
825 |
}
|
|
|
826 |
}
|
|
|
827 |
|
|
|
828 |
/**
|
| 3037 |
rexy |
829 |
* UpTime
|
|
|
830 |
* time the system is running
|
|
|
831 |
*
|
|
|
832 |
* @return void
|
|
|
833 |
*/
|
|
|
834 |
private function uptime()
|
|
|
835 |
{
|
|
|
836 |
if ($kb = $this->grabkey('kern.boottime')) {
|
|
|
837 |
if (preg_match("/sec = ([0-9]+)/", $kb, $buf)) { // format like: { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004
|
|
|
838 |
$this->sys->setUptime(time() - $buf[1]);
|
|
|
839 |
} else {
|
|
|
840 |
date_default_timezone_set('UTC');
|
|
|
841 |
$kbt = strtotime($kb);
|
|
|
842 |
if (($kbt !== false) && ($kbt != -1)) {
|
|
|
843 |
$this->sys->setUptime(time() - $kbt); // format like: Sat Oct 2 10:56:40 2004
|
|
|
844 |
} else {
|
|
|
845 |
$this->sys->setUptime(time() - $kb); // format like: 1096732600
|
|
|
846 |
}
|
|
|
847 |
}
|
|
|
848 |
}
|
|
|
849 |
}
|
|
|
850 |
|
|
|
851 |
/**
|
| 2770 |
rexy |
852 |
* get the information
|
|
|
853 |
*
|
|
|
854 |
* @see PSI_Interface_OS::build()
|
|
|
855 |
*
|
| 3037 |
rexy |
856 |
* @return void
|
| 2770 |
rexy |
857 |
*/
|
|
|
858 |
public function build()
|
|
|
859 |
{
|
|
|
860 |
if (!$this->blockname || $this->blockname==='vitals') {
|
|
|
861 |
$this->distro();
|
|
|
862 |
$this->hostname();
|
|
|
863 |
$this->kernel();
|
|
|
864 |
$this->_users();
|
|
|
865 |
$this->loadavg();
|
| 3037 |
rexy |
866 |
$this->uptime();
|
| 2770 |
rexy |
867 |
}
|
|
|
868 |
if (!$this->blockname || $this->blockname==='hardware') {
|
| 3037 |
rexy |
869 |
$this->machine();
|
| 2770 |
rexy |
870 |
$this->cpuinfo();
|
| 3037 |
rexy |
871 |
$this->virtualizer();
|
| 2770 |
rexy |
872 |
$this->pci();
|
|
|
873 |
$this->ide();
|
|
|
874 |
$this->scsi();
|
|
|
875 |
$this->usb();
|
|
|
876 |
}
|
|
|
877 |
if (!$this->blockname || $this->blockname==='memory') {
|
|
|
878 |
$this->memory();
|
|
|
879 |
}
|
|
|
880 |
if (!$this->blockname || $this->blockname==='filesystem') {
|
|
|
881 |
$this->filesystems();
|
|
|
882 |
}
|
|
|
883 |
}
|
|
|
884 |
}
|