Subversion Repositories ALCASAR

Rev

Rev 2770 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
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.FreeBSD.inc.php,v 1.17 2006/04/18 16:22:26 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_regexp1 = "";
30
  var $scsi_regexp2 = "";
31
  var $cpu_regexp2  = "";
32
 
33
  // Our contstructor
34
  // this function is run on the initialization of this class
35
  function sysinfo () {
36
    $this->bsd_common();
37
    $this->cpu_regexp = "CPU: (.*) \((.*)-MHz (.*)\)";
38
    $this->scsi_regexp1 = "^(.*): <(.*)> .*SCSI.*device";
39
    $this->scsi_regexp2 = "^(da[0-9]): (.*)MB ";
40
    $this->cpu_regexp2 = "/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/";
41
  } 
42
 
43
  function get_sys_ticks () {
44
    $s = explode(' ', $this->grab_key('kern.boottime'));
45
    $a = ereg_replace('{ ', '', $s[3]);
46
    $sys_ticks = time() - $a;
47
    return $sys_ticks;
48
  } 
49
 
50
  function network () {
51
    $netstat = execute_program('netstat', '-nibd | grep Link');
52
    $lines = explode("\n", $netstat);
53
    $results = array();
54
    for ($i = 0, $max = sizeof($lines); $i < $max; $i++) {
55
      $ar_buf = preg_split("/\s+/", $lines[$i]);
56
      if (!empty($ar_buf[0])) {
57
        $results[$ar_buf[0]] = array();
58
 
59
        if (strlen($ar_buf[3]) < 15) {
60
          $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5];
61
          $results[$ar_buf[0]]['rx_packets'] = $ar_buf[3];
62
          $results[$ar_buf[0]]['rx_errs'] = $ar_buf[4];
63
          $results[$ar_buf[0]]['rx_drop'] = $ar_buf[10];
64
 
65
          $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8];
66
          $results[$ar_buf[0]]['tx_packets'] = $ar_buf[6];
67
          $results[$ar_buf[0]]['tx_errs'] = $ar_buf[7];
68
          $results[$ar_buf[0]]['tx_drop'] = $ar_buf[10];
69
 
70
          $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7];
71
          $results[$ar_buf[0]]['drop'] = $ar_buf[10];
72
        } else {
73
          $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[6];
74
          $results[$ar_buf[0]]['rx_packets'] = $ar_buf[4];
75
          $results[$ar_buf[0]]['rx_errs'] = $ar_buf[5];
76
          $results[$ar_buf[0]]['rx_drop'] = $ar_buf[11];
77
 
78
          $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[9];
79
          $results[$ar_buf[0]]['tx_packets'] = $ar_buf[7];
80
          $results[$ar_buf[0]]['tx_errs'] = $ar_buf[8];
81
          $results[$ar_buf[0]]['tx_drop'] = $ar_buf[11];
82
 
83
          $results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[8];
84
          $results[$ar_buf[0]]['drop'] = $ar_buf[11];
85
        } 
86
      } 
87
    } 
88
    return $results;
89
  } 
90
 
91
  function distroicon () {
92
    $result = 'FreeBSD.png';
93
    return($result);
94
  }
95
 
96
  function memory_additional($results) {
97
    $pagesize = $this->grab_key("hw.pagesize");
98
    $results['ram']['cached'] = $this->grab_key("vm.stats.vm.v_cache_count") * $pagesize / 1024;
99
    $results['ram']['cached_percent'] = round( $results['ram']['cached'] * 100 / $results['ram']['total']);
100
    $results['ram']['app'] = $this->grab_key("vm.stats.vm.v_active_count") * $pagesize / 1024;
101
    $results['ram']['app_percent'] = round( $results['ram']['app'] * 100 / $results['ram']['total']);
102
    $results['ram']['buffers'] = $results['ram']['used'] - $results['ram']['app'] - $results['ram']['cached'];
103
    $results['ram']['buffers_percent'] = round( $results['ram']['buffers'] * 100 / $results['ram']['total']);
104
    return $results;
105
  }
106
} 
107
 
108
?>