325 |
richard |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
// phpSysInfo - A PHP System Information Script
|
|
|
4 |
// http://phpsysinfo.sourceforge.net/
|
|
|
5 |
|
|
|
6 |
// This program is free software; you can redistribute it and/or
|
|
|
7 |
// modify it under the terms of the GNU General Public License
|
|
|
8 |
// as published by the Free Software Foundation; either version 2
|
|
|
9 |
// of the License, or (at your option) any later version.
|
|
|
10 |
|
|
|
11 |
// This program is distributed in the hope that it will be useful,
|
|
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
14 |
// GNU General Public License for more details.
|
|
|
15 |
|
|
|
16 |
// You should have received a copy of the GNU General Public License
|
|
|
17 |
// along with this program; if not, write to the Free Software
|
|
|
18 |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
19 |
|
|
|
20 |
// $Id: class.NetBSD.inc.php,v 1.18 2006/04/18 16:57:32 bigmichi1 Exp $
|
|
|
21 |
if (!defined('IN_PHPSYSINFO')) {
|
|
|
22 |
die("No Hacking");
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php');
|
|
|
26 |
|
|
|
27 |
class sysinfo extends bsd_common {
|
|
|
28 |
var $cpu_regexp;
|
|
|
29 |
var $scsi_regexp;
|
|
|
30 |
// Our contstructor
|
|
|
31 |
// this function is run on the initialization of this class
|
|
|
32 |
function sysinfo () {
|
|
|
33 |
$this->bsd_common();
|
|
|
34 |
|
|
|
35 |
$this->cpu_regexp = "^cpu(.*)\, (.*) MHz";
|
|
|
36 |
$this->scsi_regexp1 = "^(.*) at scsibus.*: <(.*)> .*";
|
|
|
37 |
$this->scsi_regexp2 = "^(da[0-9]): (.*)MB ";
|
|
|
38 |
$this->cpu_regexp2 = "/user = (.*), nice = (.*), sys = (.*), intr = (.*), idle = (.*)/";
|
|
|
39 |
$this->pci_regexp1 = '/(.*) at pci[0-9] dev [0-9]* function [0-9]*: (.*)$/';
|
|
|
40 |
$this->pci_regexp2 = '/"(.*)" (.*).* at [.0-9]+ irq/';
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
function get_sys_ticks () {
|
|
|
44 |
$a = $this->grab_key('kern.boottime');
|
|
|
45 |
$sys_ticks = time() - $a;
|
|
|
46 |
return $sys_ticks;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
function network () {
|
|
|
50 |
$netstat_b = execute_program('netstat', '-nbdi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"');
|
|
|
51 |
$netstat_n = execute_program('netstat', '-ndi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"');
|
|
|
52 |
$lines_b = explode("\n", $netstat_b);
|
|
|
53 |
$lines_n = explode("\n", $netstat_n);
|
|
|
54 |
$results = array();
|
|
|
55 |
for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) {
|
|
|
56 |
$ar_buf_b = preg_split("/\s+/", $lines_b[$i]);
|
|
|
57 |
$ar_buf_n = preg_split("/\s+/", $lines_n[$i]);
|
|
|
58 |
if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) {
|
|
|
59 |
$results[$ar_buf_b[0]] = array();
|
|
|
60 |
|
|
|
61 |
$results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3];
|
|
|
62 |
$results[$ar_buf_b[0]]['rx_packets'] = $ar_buf_n[3];
|
|
|
63 |
$results[$ar_buf_b[0]]['rx_errs'] = $ar_buf_n[4];
|
|
|
64 |
$results[$ar_buf_b[0]]['rx_drop'] = $ar_buf_n[8];
|
|
|
65 |
|
|
|
66 |
$results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4];
|
|
|
67 |
$results[$ar_buf_b[0]]['tx_packets'] = $ar_buf_n[5];
|
|
|
68 |
$results[$ar_buf_b[0]]['tx_errs'] = $ar_buf_n[6];
|
|
|
69 |
$results[$ar_buf_b[0]]['tx_drop'] = $ar_buf_n[8];
|
|
|
70 |
|
|
|
71 |
$results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6];
|
|
|
72 |
$results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8];
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
return $results;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
// get the ide device information out of dmesg
|
|
|
79 |
function ide () {
|
|
|
80 |
$results = array();
|
|
|
81 |
|
|
|
82 |
$s = 0;
|
|
|
83 |
for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) {
|
|
|
84 |
$buf = $this->dmesg[$i];
|
|
|
85 |
if (preg_match('/^(.*) at (pciide|wdc|atabus|atapibus)[0-9] (.*): <(.*)>/', $buf, $ar_buf)) {
|
|
|
86 |
$s = $ar_buf[1];
|
|
|
87 |
$results[$s]['model'] = $ar_buf[4];
|
|
|
88 |
$results[$s]['media'] = 'Hard Disk';
|
|
|
89 |
// now loop again and find the capacity
|
|
|
90 |
for ($j = 0, $max1 = count($this->read_dmesg()); $j < $max1; $j++) {
|
|
|
91 |
$buf_n = $this->dmesg[$j];
|
|
|
92 |
if (preg_match("/^($s): (.*), (.*), (.*)MB, .*$/", $buf_n, $ar_buf_n)) {
|
|
|
93 |
$results[$s]['capacity'] = $ar_buf_n[4] * 2048 * 1.049;
|
|
|
94 |
} elseif (preg_match("/^($s): (.*) MB, (.*), (.*), .*$/", $buf_n, $ar_buf_n)) {
|
|
|
95 |
$results[$s]['capacity'] = $ar_buf_n[2] * 2048;
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
asort($results);
|
|
|
101 |
return $results;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
function distroicon () {
|
|
|
105 |
$result = 'NetBSD.png';
|
|
|
106 |
return($result);
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
?>
|