[ 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.SunOS.inc.php 21228 2006-04-06 13:52:08Z ralfbecker $ 21 22 $error->addError("WARN", "The SunOS version of phpSysInfo is work in progress, some things currently don't work"); 23 24 class sysinfo { 25 // Extract kernel values via kstat() interface 26 function kstat ($key) { 27 $m = execute_program('kstat', "-p d $key"); 28 list($key, $value) = split("\t", trim($m), 2); 29 return $value; 30 } 31 32 function vhostname () { 33 if (! ($result = getenv('SERVER_NAME'))) { 34 $result = 'N.A.'; 35 } 36 return $result; 37 } 38 // get our canonical hostname 39 function chostname () { 40 if ($result = execute_program('uname', '-n')) { 41 $result = gethostbyaddr(gethostbyname($result)); 42 } else { 43 $result = 'N.A.'; 44 } 45 return $result; 46 } 47 // get the IP address of our canonical hostname 48 function ip_addr () { 49 if (!($result = getenv('SERVER_ADDR'))) { 50 $result = gethostbyname($this->chostname()); 51 } 52 return $result; 53 } 54 55 function kernel () { 56 $os = execute_program('uname', '-s'); 57 $version = execute_program('uname', '-r'); 58 return $os . ' ' . $version; 59 } 60 61 function uptime () { 62 $result = time() - $this->kstat('unix:0:system_misc:boot_time'); 63 64 return $result; 65 } 66 67 function users () { 68 $who = split('=', execute_program('who', '-q')); 69 $result = $who[1]; 70 return $result; 71 } 72 73 function loadavg ($bar = false) { 74 $load1 = $this->kstat('unix:0:system_misc:avenrun_1min'); 75 $load5 = $this->kstat('unix:0:system_misc:avenrun_5min'); 76 $load15 = $this->kstat('unix:0:system_misc:avenrun_15min'); 77 $results['avg'] = array( round($load1/256, 2), round($load5/256, 2), round($load15/256, 2) ); 78 return $results; 79 } 80 81 function cpu_info () { 82 $results = array(); 83 $ar_buf = array(); 84 85 $results['model'] = execute_program('uname', '-i'); 86 $results['cpuspeed'] = $this->kstat('cpu_info:0:cpu_info0:clock_MHz'); 87 $results['cache'] = $this->kstat('cpu_info:0:cpu_info0:cpu_type'); 88 $results['cpus'] = $this->kstat('unix:0:system_misc:ncpus'); 89 90 return $results; 91 } 92 93 function pci () { 94 // FIXME 95 $results = array(); 96 return $results; 97 } 98 99 function ide () { 100 // FIXME 101 $results = array(); 102 return $results; 103 } 104 105 function scsi () { 106 // FIXME 107 $results = array(); 108 return $results; 109 } 110 111 function usb () { 112 // FIXME 113 $results = array(); 114 return $results; 115 } 116 117 function sbus () { 118 $results = array(); 119 $_results[0] = ""; 120 // TODO. Nothing here yet. Move along. 121 $results = $_results; 122 return $results; 123 } 124 125 function network () { 126 $results = array(); 127 128 $netstat = execute_program('netstat', '-ni | awk \'(NF ==10){print;}\''); 129 $lines = split("\n", $netstat); 130 $results = array(); 131 for ($i = 0, $max = sizeof($lines); $i < $max; $i++) { 132 $ar_buf = preg_split("/\s+/", $lines[$i]); 133 if ((!empty($ar_buf[0])) && ($ar_buf[0] != 'Name')) { 134 $results[$ar_buf[0]] = array(); 135 136 $results[$ar_buf[0]]['rx_bytes'] = 0; 137 $results[$ar_buf[0]]['rx_packets'] = $ar_buf[4]; 138 $results[$ar_buf[0]]['rx_errs'] = $ar_buf[5]; 139 $results[$ar_buf[0]]['rx_drop'] = 0; 140 141 $results[$ar_buf[0]]['tx_bytes'] = 0; 142 $results[$ar_buf[0]]['tx_packets'] = $ar_buf[6]; 143 $results[$ar_buf[0]]['tx_errs'] = $ar_buf[7]; 144 $results[$ar_buf[0]]['tx_drop'] = 0; 145 146 $results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[ 147 7]; 148 $results[$ar_buf[0]]['drop'] = 0; 149 150 preg_match('/^(\D+)(\d+)$/', $ar_buf[0], $intf); 151 $prefix = $intf[1] . ':' . $intf[2] . ':' . $intf[1] . $intf[2] . ':'; 152 $cnt = $this->kstat($prefix . 'drop'); 153 154 if ($cnt > 0) { 155 $results[$ar_buf[0]]['rx_drop'] = $cnt; 156 } 157 $cnt = $this->kstat($prefix . 'obytes64'); 158 159 if ($cnt > 0) { 160 $results[$ar_buf[0]]['tx_bytes'] = $cnt; 161 } 162 $cnt = $this->kstat($prefix . 'rbytes64'); 163 164 if ($cnt > 0) { 165 $results[$ar_buf[0]]['rx_bytes'] = $cnt; 166 } 167 } 168 } 169 return $results; 170 } 171 172 function memory () { 173 $results['devswap'] = array(); 174 175 $results['ram'] = array(); 176 177 $pagesize = $this->kstat('unix:0:seg_cache:slab_size'); 178 $results['ram']['total'] = $this->kstat('unix:0:system_pages:pagestotal') * $pagesize / 1024; 179 $results['ram']['used'] = $this->kstat('unix:0:system_pages:pageslocked') * $pagesize / 1024; 180 $results['ram']['free'] = $this->kstat('unix:0:system_pages:pagesfree') * $pagesize / 1024; 181 $results['ram']['shared'] = 0; 182 $results['ram']['buffers'] = 0; 183 $results['ram']['cached'] = 0; 184 185 $results['ram']['t_used'] = $results['ram']['used'] - $results['ram']['cached'] - $results['ram']['buffers']; 186 $results['ram']['t_free'] = $results['ram']['total'] - $results['ram']['t_used']; 187 $results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']); 188 189 $results['swap'] = array(); 190 $results['swap']['total'] = $this->kstat('unix:0:vminfo:swap_avail') / 1024 / 1024; 191 $results['swap']['used'] = $this->kstat('unix:0:vminfo:swap_alloc') / 1024 / 1024; 192 $results['swap']['free'] = $this->kstat('unix:0:vminfo:swap_free') / 1024 / 1024; 193 $results['swap']['percent'] = round(($ar_buf[1] * 100) / $ar_buf[0]); 194 $results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']); 195 return $results; 196 } 197 198 function filesystems () { 199 $df = execute_program('df', '-k'); 200 $mounts = split("\n", $df); 201 202 $dftypes = execute_program('df', '-n'); 203 $mounttypes = split("\n", $dftypes); 204 205 for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) { 206 $ar_buf = preg_split('/\s+/', $mounts[$i], 6); 207 $ty_buf = split(':', $mounttypes[$i-1], 2); 208 209 if (hide_mount($ar_buf[5])) { 210 continue; 211 } 212 213 $results[$j] = array(); 214 215 $results[$j]['disk'] = $ar_buf[0]; 216 $results[$j]['size'] = $ar_buf[1]; 217 $results[$j]['used'] = $ar_buf[2]; 218 $results[$j]['free'] = $ar_buf[3]; 219 $results[$j]['percent'] = round(($results[$j]['used'] * 100) / $results[$j]['size']); 220 $results[$j]['mount'] = $ar_buf[5]; 221 $results[$j]['fstype'] = $ty_buf[1]; 222 $j++; 223 } 224 return $results; 225 } 226 227 function distro () { 228 $result = 'SunOS'; 229 return($result); 230 } 231 232 function distroicon () { 233 $result = 'SunOS.png'; 234 return($result); 235 } 236 } 237 238 ?>
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 |