[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
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.OpenBSD.inc.php 21228 2006-04-06 13:52:08Z ralfbecker $ 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->cpu_regexp = "^cpu(.*) (.*) MHz"; 34 $this->scsi_regexp1 = "^(.*) at scsibus.*: <(.*)> .*"; 35 $this->scsi_regexp2 = "^(da[0-9]): (.*)MB "; 36 } 37 38 function get_sys_ticks () { 39 $a = $this->grab_key('kern.boottime'); 40 $sys_ticks = time() - $a; 41 return $sys_ticks; 42 } 43 // get the pci device information out of dmesg 44 function pci () { 45 $results = array(); 46 47 for ($i = 0, $s = 0, $max = count($this->read_dmesg()); $i < $max; $i++) { 48 $buf = $this->dmesg[$i]; 49 if (preg_match('/(.*) at pci[0-9] .* "(.*)"/', $buf, $ar_buf)) { 50 $results[$s++] = $ar_buf[1] . ": " . $ar_buf[2]; 51 } elseif (preg_match('/"(.*)" (.*).* at [.0-9]+ irq/', $buf, $ar_buf)) { 52 $results[$s++] = $ar_buf[1] . ": " . $ar_buf[2]; 53 } 54 } 55 56 $results = array_unique($results); 57 asort($results); 58 return $results; 59 } 60 61 function network () { 62 $netstat_b = execute_program('netstat', '-nbdi | cut -c1-25,44- | grep Link | grep -v \'* \''); 63 $netstat_n = execute_program('netstat', '-ndi | cut -c1-25,44- | grep Link | grep -v \'* \''); 64 $lines_b = split("\n", $netstat_b); 65 $lines_n = split("\n", $netstat_n); 66 $results = array(); 67 for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) { 68 $ar_buf_b = preg_split("/\s+/", $lines_b[$i]); 69 $ar_buf_n = preg_split("/\s+/", $lines_n[$i]); 70 if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) { 71 $results[$ar_buf_b[0]] = array(); 72 73 $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3]; 74 $results[$ar_buf_b[0]]['rx_packets'] = $ar_buf_n[3]; 75 $results[$ar_buf_b[0]]['rx_errs'] = $ar_buf_n[4]; 76 $results[$ar_buf_b[0]]['rx_drop'] = $ar_buf_n[8]; 77 78 $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4]; 79 $results[$ar_buf_b[0]]['tx_packets'] = $ar_buf_n[5]; 80 $results[$ar_buf_b[0]]['tx_errs'] = $ar_buf_n[6]; 81 $results[$ar_buf_b[0]]['tx_drop'] = $ar_buf_n[8]; 82 83 $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6]; 84 $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8]; 85 } 86 } 87 return $results; 88 } 89 // get the ide device information out of dmesg 90 function ide () { 91 $results = array(); 92 93 $s = 0; 94 for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) { 95 $buf = $this->dmesg[$i]; 96 if (preg_match('/^(.*) at pciide[0-9] (.*): <(.*)>/', $buf, $ar_buf)) { 97 $s = $ar_buf[1]; 98 $results[$s]['model'] = $ar_buf[3]; 99 $results[$s]['media'] = 'Hard Disk'; 100 // now loop again and find the capacity 101 for ($j = 0, $max1 = count($this->read_dmesg()); $j < $max1; $j++) { 102 $buf_n = $this->dmesg[$j]; 103 if (preg_match("/^($s): (.*), (.*), (.*)MB, .*$/", $buf_n, $ar_buf_n)) { 104 $results[$s]['capacity'] = $ar_buf_n[4] * 2048 * 1.049;; 105 } 106 } 107 } 108 } 109 asort($results); 110 return $results; 111 } 112 113 function distroicon () { 114 $result = 'OpenBSD.png'; 115 return($result); 116 } 117 118 } 119 120 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |