예제 #1
0
 function network()
 {
     $netstat_b = execute_program('netstat', '-nbdi | cut -c1-25,44- | grep Link | grep -v \'* \'');
     $netstat_n = execute_program('netstat', '-ndi | cut -c1-25,44- | grep Link | grep -v \'* \'');
     $lines_b = split("\n", $netstat_b);
     $lines_n = split("\n", $netstat_n);
     $results = array();
     for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) {
         $ar_buf_b = preg_split("/\\s+/", $lines_b[$i]);
         $ar_buf_n = preg_split("/\\s+/", $lines_n[$i]);
         if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) {
             $results[$ar_buf_b[0]] = array();
             $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3];
             $results[$ar_buf_b[0]]['rx_packets'] = $ar_buf_n[3];
             $results[$ar_buf_b[0]]['rx_errs'] = $ar_buf_n[4];
             $results[$ar_buf_b[0]]['rx_drop'] = $ar_buf_n[8];
             $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4];
             $results[$ar_buf_b[0]]['tx_packets'] = $ar_buf_n[5];
             $results[$ar_buf_b[0]]['tx_errs'] = $ar_buf_n[6];
             $results[$ar_buf_b[0]]['tx_drop'] = $ar_buf_n[8];
             $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6];
             $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8];
         }
     }
     return $results;
 }
 function memory()
 {
     $s = $this->grab_key('hw.physmem');
     $pagesize = $this->grab_key('hw.pagesize');
     $results['ram'] = array();
     $pstat = execute_program('vmstat', '-s');
     $lines = split("\n", $pstat);
     for ($i = 0, $max = sizeof($lines); $i < $max; $i++) {
         $ar_buf = preg_split("/\\s+/", $lines[$i], 19);
         if ($i == 3) {
             $results['ram']['free'] = $ar_buf[1] * $pagesize / 1024;
         } elseif ($i == 19) {
             $results['swap']['total'] = $ar_buf[1] * $pagesize / 1024;
         } elseif ($i == 20) {
             $results['swap']['used'] = $ar_buf[1] * $pagesize / 1024;
         }
     }
     $results['ram']['total'] = $s / 1024;
     $results['ram']['shared'] = 0;
     $results['ram']['buffers'] = 0;
     $results['ram']['used'] = $results['ram']['total'] - $results['ram']['free'];
     $results['ram']['cached'] = 0;
     $results['ram']['t_used'] = $results['ram']['used'];
     $results['ram']['t_free'] = $results['ram']['free'];
     $results['ram']['percent'] = round($results['ram']['used'] * 100 / $results['ram']['total']);
     $results['swap']['free'] = $results['swap']['total'] - $results['swap']['used'];
     $results['swap']['percent'] = round($results['swap']['used'] * 100 / $results['swap']['total']);
     return $results;
 }
예제 #3
0
 public function network()
 {
     if (!execute_program('netstat', '-nibd | grep Link', $netstat, $this->debug)) {
         $netstat = '';
     }
     $lines = split("\n", $netstat);
     $results = array();
     for ($i = 0, $max = sizeof($lines); $i < $max; $i++) {
         $ar_buf = preg_split("/\\s+/", $lines[$i]);
         if (!empty($ar_buf[0])) {
             $results[$ar_buf[0]] = array();
             if (strlen($ar_buf[3]) < 15) {
                 $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5];
                 $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8];
                 $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7];
                 $results[$ar_buf[0]]['drop'] = $ar_buf[10];
             } else {
                 $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[6];
                 $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[9];
                 $results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[8];
                 $results[$ar_buf[0]]['drop'] = $ar_buf[11];
             }
         }
     }
     return $results;
 }
 function parse_filesystems()
 {
     global $show_bind, $show_inodes;
     $j = 0;
     $df = execute_program('df', '-k' . $this->df_param);
     $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
     if ($show_inodes) {
         $df2 = execute_program('df', '-i' . $this->df_param);
         $df2 = preg_split("/\n/", $df2, -1, PREG_SPLIT_NO_EMPTY);
     }
     $mount = execute_program('mount');
     $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($df as $df_line) {
         $df_buf1 = preg_split("/(\\%\\s)/", $df_line, 2);
         if (count($df_buf1) != 2) {
             continue;
         }
         preg_match("/(.*)(\\s+)(([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)(\\s+)([0-9]+)\$)/", $df_buf1[0], $df_buf2);
         $df_buf = array($df_buf2[1], $df_buf2[4], $df_buf2[6], $df_buf2[8], $df_buf2[10], $df_buf1[1]);
         if ($show_inodes) {
             preg_match_all("/([0-9]+)%/", $df2[$j + 1], $inode_buf, PREG_SET_ORDER);
         }
         if (count($df_buf) == 6) {
             if (hide_mount($df_buf[5])) {
                 continue;
             }
             $df_buf[0] = trim(str_replace("\$", "\\\$", $df_buf[0]));
             $df_buf[5] = trim($df_buf[5]);
             $current = 0;
             foreach ($mount as $mount_line) {
                 $current++;
                 if (preg_match("#" . $df_buf[0] . " on " . $df_buf[5] . " type (.*) \\((.*)\\)#", $mount_line, $mount_buf)) {
                     $mount_buf[1] .= "," . $mount_buf[2];
                 } elseif (!preg_match("#" . $df_buf[0] . "(.*) on " . $df_buf[5] . " \\((.*)\\)#", $mount_line, $mount_buf)) {
                     continue;
                 }
                 if ($show_bind || !stristr($mount_buf[2], "bind")) {
                     $results[$j] = array();
                     $results[$j]['disk'] = str_replace("\\\$", "\$", $df_buf[0]);
                     $results[$j]['size'] = $df_buf[1];
                     $results[$j]['used'] = $df_buf[2];
                     $results[$j]['free'] = $df_buf[3];
                     $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']);
                     $results[$j]['mount'] = $df_buf[5];
                     $results[$j]['fstype'] = substr($mount_buf[1], 0, strpos($mount_buf[1], ","));
                     $results[$j]['options'] = substr($mount_buf[1], strpos($mount_buf[1], ",") + 1, strlen($mount_buf[1]));
                     if ($show_inodes && isset($inode_buf[count($inode_buf) - 1][1])) {
                         $results[$j]['inodes'] = $inode_buf[count($inode_buf) - 1][1];
                     }
                     $j++;
                     unset($mount[$current - 1]);
                     sort($mount);
                     break;
                 }
             }
         }
     }
     return $results;
 }
예제 #5
0
 function mbinfo() {
  $lines = execute_program("sensors", "");
  // Martijn Stolk: Dirty fix for misinterpreted output of sensors, 
  // where info could come on next line when the label is too long.
  $lines = str_replace(":\n", ":", $lines);
  $lines = str_replace("\n\n", "\n", $lines);
  $this->lines = explode("\n", $lines);
 }
예제 #6
0
 function __construct()
 {
     if (execute_program('sysctl', '-w hw.sensors', $this->lines)) {
         $this->lines = explode("\n", $this->lines);
     } else {
         $this->lines = array();
     }
 }
예제 #7
0
 public function __construct()
 {
     $output = array();
     $upses = explode(',', PSI_UPSINFO_APCUPSD_UPS_LIST);
     $temp = '';
     for ($i = 0; $i < count($upses); $i++) {
         execute_program('apcaccess', 'status ' . trim($upses[$i]), $temp);
         if (isset($temp) && !empty($temp)) {
             $this->output[$i] = $temp;
         }
     }
 }
예제 #8
0
 function temperature($hddtemp_avail)
 {
     $ar_buf = array();
     $results = array();
     switch ($hddtemp_avail) {
         case "tcp":
             // Timo van Roermund: connect to the hddtemp daemon, use a 5 second timeout.
             $fp = fsockopen('localhost', 7634, $errno, $errstr, 5);
             // if connected, read the output of the hddtemp daemon
             if ($fp) {
                 // read output of the daemon
                 $lines = '';
                 while (!feof($fp)) {
                     $lines .= fread($fp, 1024);
                 }
                 // close the connection
                 fclose($fp);
             } else {
                 die("HDDTemp error: " . $errno . ", " . $errstr);
             }
             $lines = str_replace("||", "|\n|", $lines);
             $ar_buf = explode("\n", $lines);
             break;
         case "suid":
             $hddtemp_value = execute_program("hddtemp", "{$this->strDrives}");
             $hddtemp_value = explode("\n", $hddtemp_value);
             foreach ($hddtemp_value as $line) {
                 $temp = preg_split("/:\\s/", $line, 3);
                 if (preg_match("/^[0-9]/", $temp[2])) {
                     list($temp[2], $temp[3]) = preg_split("/\\s/", $temp[2]);
                     array_push($ar_buf, "|" . implode("|", $temp) . "|");
                 }
             }
             break;
         default:
             die("Bad hddtemp configuration in config.php");
     }
     // Timo van Roermund: parse the info from the hddtemp daemon.
     $i = 0;
     foreach ($ar_buf as $line) {
         $data = array();
         if (ereg("\\|(.*)\\|(.*)\\|(.*)\\|(.*)\\|", $line, $data)) {
             if (trim($data[3]) != "ERR") {
                 // get the info we need
                 $results[$i]['label'] = $data[1];
                 $results[$i]['value'] = $data[3];
                 $results[$i]['model'] = $data[2];
                 $i++;
             }
         }
     }
     return $results;
 }
예제 #9
0
 function temperature()
 {
     $results = array();
     $smp = 1;
     execute_program('sysctl', '-n kern.smp.cpus', $smp);
     for ($i = 0; $i < $smp; $i++) {
         $temp = 0;
         if (execute_program('sysctl', '-n dev.cpu.' . $i . '.temperature', $temp)) {
             $results[$i]['label'] = "CPU " . ($i + 1);
             $results[$i]['value'] = $temp;
             $results[$i]['limit'] = '70.0';
             $results[$i]['percent'] = $results[$i]['value'] * 100 / $results[$i]['limit'];
         }
     }
     return $results;
 }
 function voltage()
 {
     $lines = array();
     $results = array();
     $lines = explode("\n", execute_program('mbmon', '-c 1 -r'));
     $i = 0;
     foreach ($lines as $line) {
         if (preg_match('/^(V.*)\\s*:\\s*(.*)$/D', $line, $data)) {
             if ($data[2] != '+0.00') {
                 $results[$i]['label'] = $data[1];
                 $results[$i]['value'] = $data[2];
                 $results[$i]['min'] = '0.00';
                 $results[$i]['max'] = '0.00';
                 $i++;
             }
         }
     }
     return $results;
 }
 function voltage()
 {
     $buf = array();
     $ar_buf = array();
     $lines = array();
     $results = array();
     $buf = execute_program('sysctl', '-w hw.sensors');
     $lines = explode("\n", $buf);
     for ($i = 0, $j = 0, $max = sizeof($lines); $i < $max; $i++) {
         $ar_buf = preg_split("/[\\s,]+/", $lines[$i]);
         if ($ar_buf[2] == 'volts_dc') {
             $results[$j]['label'] = $ar_buf[1];
             $results[$j]['value'] = $ar_buf[3];
             $results[$j]['min'] = '0.00';
             $results[$j]['max'] = '0.00';
             $j++;
         }
     }
     return $results;
 }
예제 #12
0
 public function network()
 {
     execute_program('netstat', '-nbdi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \\t].*Link"', $netstat_b);
     execute_program('netstat', '-ndi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \\t].*Link"', $netstat_n);
     $lines_b = explode("\n", $netstat_b);
     $lines_n = explode("\n", $netstat_n);
     $results = array();
     for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) {
         $ar_buf_b = preg_split("/\\s+/", $lines_b[$i]);
         $ar_buf_n = preg_split("/\\s+/", $lines_n[$i]);
         if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) {
             $results[$ar_buf_b[0]] = array();
             $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3];
             $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4];
             $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6];
             $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8];
         }
     }
     return $results;
 }
예제 #13
0
 function voltage()
 {
     $ar_buf = array();
     $results = array();
     if (!isset($this->lines)) {
         $this->lines = execute_program('healthdc', '-t');
     }
     $ar_buf = preg_split("/\t+/", $this->lines);
     $results[0]['label'] = 'Vcore1';
     $results[0]['value'] = $ar_buf[7];
     $results[0]['min'] = '0.00';
     $results[0]['max'] = '0.00';
     $results[1]['label'] = 'Vcore2';
     $results[1]['value'] = $ar_buf[8];
     $results[1]['min'] = '0.00';
     $results[1]['max'] = '0.00';
     $results[2]['label'] = '3volt';
     $results[2]['value'] = $ar_buf[9];
     $results[2]['min'] = '0.00';
     $results[2]['max'] = '0.00';
     $results[3]['label'] = '+5Volt';
     $results[3]['value'] = $ar_buf[10];
     $results[3]['min'] = '0.00';
     $results[3]['max'] = '0.00';
     $results[4]['label'] = '+12Volt';
     $results[4]['value'] = $ar_buf[11];
     $results[4]['min'] = '0.00';
     $results[4]['max'] = '0.00';
     $results[5]['label'] = '-12Volt';
     $results[5]['value'] = $ar_buf[12];
     $results[5]['min'] = '0.00';
     $results[5]['max'] = '0.00';
     $results[6]['label'] = '-5Volt';
     $results[6]['value'] = $ar_buf[13];
     $results[6]['min'] = '0.00';
     $results[6]['max'] = '0.00';
     return $results;
 }
 function network()
 {
     $netstat = execute_program('netstat', '-nbdi | cut -c1-24,42- | grep Link');
     $lines = split("\n", $netstat);
     $results = array();
     for ($i = 0; $i < sizeof($lines); $i++) {
         $ar_buf = preg_split("/\\s+/", $lines[$i]);
         if (!empty($ar_buf[0]) && !empty($ar_buf[3])) {
             $results[$ar_buf[0]] = array();
             $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5];
             $results[$ar_buf[0]]['rx_packets'] = $ar_buf[3];
             $results[$ar_buf[0]]['rx_errs'] = $ar_buf[4];
             $results[$ar_buf[0]]['rx_drop'] = $ar_buf[10];
             $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8];
             $results[$ar_buf[0]]['tx_packets'] = $ar_buf[6];
             $results[$ar_buf[0]]['tx_errs'] = $ar_buf[7];
             $results[$ar_buf[0]]['tx_drop'] = $ar_buf[10];
             $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7];
             $results[$ar_buf[0]]['drop'] = $ar_buf[10];
         }
     }
     return $results;
 }
예제 #15
0
 public function voltage()
 {
     $results = array();
     if (!isset($this->lines)) {
         execute_program('mbmon', '-c 1 -r', $this->lines);
         $this->lines = explode("\n", $this->lines);
     }
     if (empty($this->lines)) {
         return null;
     }
     $i = 0;
     foreach ($this->lines as $line) {
         if (preg_match('/^(V.*)\\s*:\\s*(.*)$/D', $line, $data)) {
             if ($data[2] != '+0.00') {
                 $results[$i]['label'] = $data[1];
                 $results[$i]['value'] = $data[2];
                 $results[$i]['min'] = '0.00';
                 $results[$i]['max'] = '0.00';
                 $i++;
             }
         }
     }
     return $results;
 }
예제 #16
0
 function usb()
 {
     $results = array();
     $devnum = -1;
     $bufr = execute_program('lsusb', '', false);
     if ($bufr == "ERROR") {
         $bufr = rfts('/proc/bus/usb/devices');
         if ($bufr != "ERROR") {
             $bufe = explode("\n", $bufr);
             foreach ($bufe as $buf) {
                 if (preg_match('/^T/', $buf)) {
                     $devnum += 1;
                     $results[$devnum] = "";
                 } elseif (preg_match('/^S:/', $buf)) {
                     list($key, $value) = split(': ', $buf, 2);
                     list($key, $value2) = split('=', $value, 2);
                     if (trim($key) != "SerialNumber") {
                         $results[$devnum] .= " " . trim($value2);
                         $devstring = 0;
                     }
                 }
             }
         }
     } else {
         $bufe = explode("\n", $bufr);
         foreach ($bufe as $buf) {
             $device = preg_split("/ /", $buf, 7);
             if (isset($device[6]) && trim($device[6]) != "") {
                 $results[$devnum++] = trim($device[6]);
             }
         }
     }
     return $results;
 }
function filesystems()
{
    $results = array();
    $df = execute_program('df', '-kP');
    $mounts = split("\n", $df);
    $fstype = array();
    if ($fd = fopen('/proc/mounts', 'r')) {
        while ($buf = fgets($fd, 4096)) {
            list($dev, $mpoint, $type) = preg_split('/\\s+/', trim($buf), 4);
            $fstype[$mpoint] = $type;
            $fsdev[$dev] = $type;
        }
        fclose($fd);
    }
    for ($i = 1; $i < sizeof($mounts); $i++) {
        $ar_buf = preg_split('/\\s+/', $mounts[$i], 6);
        $results[$i - 1] = array();
        $results[$i - 1]['disk'] = $ar_buf[0];
        $results[$i - 1]['size'] = $ar_buf[1];
        $results[$i - 1]['used'] = $ar_buf[2];
        $results[$i - 1]['free'] = $ar_buf[3];
        $results[$i - 1]['percent'] = round($results[$i - 1]['used'] * 100 / $results[$i - 1]['size']) . '%';
        $results[$i - 1]['mount'] = $ar_buf[5];
        $fstype[$ar_buf[5]] ? $results[$i - 1]['fstype'] = $fstype[$ar_buf[5]] : ($results[$i - 1]['fstype'] = $fsdev[$ar_buf[0]]);
    }
    return $results;
}
예제 #18
0
 public function network()
 {
     if (execute_program('netstat', '-nbdi | cut -c1-24,42- | grep Link', $netstat, $this->debug)) {
         $lines = split("\n", $netstat);
         $results = array();
         for ($i = 0, $max = sizeof($lines); $i < $max; $i++) {
             $ar_buf = preg_split("/\\s+/", $lines[$i], 10);
             if (!empty($ar_buf[0])) {
                 $results[$ar_buf[0]] = array();
                 $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5];
                 $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8];
                 $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7];
                 $results[$ar_buf[0]]['drop'] = isset($ar_buf[10]) ? $ar_buf[10] : 0;
             }
         }
         return $results;
     } else {
         return array();
     }
 }
 function filesystems()
 {
     $df = execute_program('df', '-k');
     $mounts = split("\n", $df);
     $fstype = array();
     $s = execute_program('mount');
     $lines = explode("\n", $s);
     $i = 0;
     while (list(, $line) = each($lines)) {
         ereg('(.*) \\((.*)\\)', $line, $a);
         $m = explode(' ', $a[0]);
         $fsdev[$m[0]] = $a[2];
     }
     for ($i = 1, $j = 0; $i < sizeof($mounts); $i++) {
         $ar_buf = preg_split("/\\s+/", $mounts[$i], 6);
         switch ($ar_buf[0]) {
             case 'automount':
                 // skip the automount entries
             // skip the automount entries
             case 'devfs':
                 // skip the dev filesystem
             // skip the dev filesystem
             case 'fdesc':
                 // skip the fdesc
             // skip the fdesc
             case 'procfs':
                 // skip the proc filesystem
             // skip the proc filesystem
             case '<volfs>':
                 // skip the vol filesystem
                 continue 2;
                 break;
         }
         $results[$j] = array();
         $results[$j]['disk'] = $ar_buf[0];
         $results[$j]['size'] = $ar_buf[1];
         $results[$j]['used'] = $ar_buf[2];
         $results[$j]['free'] = $ar_buf[3];
         $results[$j]['percent'] = $ar_buf[4];
         $results[$j]['mount'] = $ar_buf[5];
         $fstype[$ar_buf[5]] ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : ($results[$j]['fstype'] = $fsdev[$ar_buf[0]]);
         $j++;
     }
     return $results;
 }
예제 #20
0
 public function ScanNodes()
 {
     $result = array();
     $networks = $this->GetNetworks();
     if ($networks) {
         $node_manager = new LMSNodeManager($this->db, $this->auth, $this->cache, $this->syslog);
         foreach ($networks as $idx => $network) {
             if ($res = execute_program('nbtscan', '-q -s: ' . $network['address'] . '/' . $network['prefix'])) {
                 $out = explode("\n", $res);
                 foreach ($out as $line) {
                     list($ipaddr, $name, $null, $login, $mac) = explode(':', $line, 5);
                     $row['ipaddr'] = trim($ipaddr);
                     if ($row['ipaddr']) {
                         $row['name'] = trim($name);
                         $row['mac'] = strtoupper(str_replace('-', ':', trim($mac)));
                         if ($row['mac'] != "00:00:00:00:00:00" && !$node_manager->GetNodeIDByIP($row['ipaddr'])) {
                             $result[] = $row;
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
예제 #21
0
  function filesystems () {
    $df = execute_program('df', '-kP');
    $mounts = preg_split("/\n/", $df);
    $fstype = array();

    $s = execute_program('mount', '-v');
    $lines = explode("\n", $s);

    $i = 0;
    while (list(, $line) = each($lines)) {
      $a = preg_split('/ /', $line);
      $fsdev[$a[0]] = $a[4];
    } 

    for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) {
      $ar_buf = preg_split("/\s+/", $mounts[$i], 6);

      if (hide_mount($ar_buf[5])) {
        continue;
      }

      $results[$j] = array();

      $results[$j]['disk'] = $ar_buf[0];
      $results[$j]['size'] = $ar_buf[1];
      $results[$j]['used'] = $ar_buf[2];
      $results[$j]['free'] = $ar_buf[3];
      $results[$j]['percent'] = $ar_buf[4];
      $results[$j]['mount'] = $ar_buf[5];
      ($fstype[$ar_buf[5]]) ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : $results[$j]['fstype'] = $fsdev[$ar_buf[0]];
      $j++;
    } 
    return $results;
  } 
 function filesystems()
 {
     $df = execute_program('df', '-k');
     $mounts = split("\n", $df);
     $dftypes = execute_program('df', '-n');
     $mounttypes = split("\n", $dftypes);
     for ($i = 1, $max = sizeof($mounts); $i < $max; $i++) {
         $ar_buf = preg_split('/\\s+/', $mounts[$i], 6);
         $ty_buf = split(':', $mounttypes[$i - 1], 2);
         $results[$i - 1] = array();
         $results[$i - 1]['disk'] = $ar_buf[0];
         $results[$i - 1]['size'] = $ar_buf[1];
         $results[$i - 1]['used'] = $ar_buf[2];
         $results[$i - 1]['free'] = $ar_buf[3];
         $results[$i - 1]['percent'] = round($results[$i - 1]['used'] * 100 / $results[$i - 1]['size']) . '%';
         $results[$i - 1]['mount'] = $ar_buf[5];
         $results[$i - 1]['fstype'] = $ty_buf[1];
     }
     return $results;
 }
예제 #23
0
  function filesystems () {
    $df = execute_program('df', '-k');
    $mounts = preg_split("/\n/", $df);

    $dftypes = execute_program('df', '-n');
    $mounttypes = preg_split("/\n/", $dftypes);

    for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) {
      $ar_buf = preg_split('/\s+/', $mounts[$i], 6);
      $ty_buf = preg_split('/:/', $mounttypes[$i-1], 2);

      if (hide_mount($ar_buf[5])) {
        continue;
      }

      $results[$j] = array();

      $results[$j]['disk'] = $ar_buf[0];
      $results[$j]['size'] = $ar_buf[1];
      $results[$j]['used'] = $ar_buf[2];
      $results[$j]['free'] = $ar_buf[3];
      $results[$j]['percent'] = round(($results[$j]['used'] * 100) / $results[$j]['size']);
      $results[$j]['mount'] = $ar_buf[5];
      $results[$j]['fstype'] = $ty_buf[1];
      $j++;
    } 
    return $results;
  } 
 function voltage()
 {
     $ar_buf = array();
     $results = array();
     $sensors_value = explode("\n", execute_program("sensors", ""));
     foreach ($sensors_value as $line) {
         $data = array();
         ereg("(.*):(.*)\\((.*)=(.*),(.*)=(.*)\\)(.*)", $line, $data);
         $temp = explode(" ", trim($data[2]));
         if (count($temp) == 1) {
             $temp = explode("°", trim($data[2]));
         }
         switch ($temp[1]) {
             case "V":
                 array_push($ar_buf, $line);
                 break;
         }
     }
     $i = 0;
     foreach ($ar_buf as $line) {
         if (ereg("(.*):(.*) V  \\((.*)=(.*) V,(.*)=(.*) V\\)(.*)\\)", $line, $data)) {
         } else {
             ereg("(.*):(.*) V  \\((.*)=(.*) V,(.*)=(.*) V\\)(.*)", $line, $data);
         }
         $alarm = substr(trim($data[7]), 0, 5);
         $results[$i]['label'] = trim($data[1]);
         $results[$i]['value'] = trim($data[2]);
         $results[$i]['min'] = trim($data[4]);
         $results[$i]['max'] = trim($data[6]);
         $i++;
     }
     return $results;
 }
예제 #25
0
 function distro () { 
   $distro = execute_program('uname', '-s');                             
   $result = $distro;
   return($result);               
 }
예제 #26
0
 function users()
 {
     switch (PHP_OS) {
         case 'WinNT':
         case 'Win32':
             $result = 'N.A.';
         default:
             $who = explode('=', execute_program('who', '-q'));
             $result = $who[1];
             break;
     }
     if ($result == '') {
         $result = 'N.A.';
     }
     return $result;
 }
예제 #27
0
 public function filesystems()
 {
     if (!execute_program('df', '-k', $df, $this->debug)) {
         $df = '';
     }
     $mounts = split("\n", $df);
     if (!execute_program('df', '-n', $dftypes, $this->debug)) {
         $dftypes = '';
     }
     $mounttypes = split("\n", $dftypes);
     for ($i = 1, $j = 0, $max = sizeof($mounts); $i < $max; $i++) {
         $ar_buf = preg_split('/\\s+/', $mounts[$i], 6);
         $ty_buf = split(':', $mounttypes[$i - 1], 2);
         if (hide_mount($ar_buf[5])) {
             continue;
         }
         $results[$j] = array();
         $results[$j]['disk'] = $ar_buf[0];
         $results[$j]['size'] = $ar_buf[1];
         $results[$j]['used'] = $ar_buf[2];
         $results[$j]['free'] = $ar_buf[3];
         $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']);
         $results[$j]['mount'] = $ar_buf[5];
         $results[$j]['fstype'] = $ty_buf[1];
         $j++;
     }
     return $results;
 }
예제 #28
0
파일: common.php 프로젝트: pcela/lms
function bsd_grab_key($key)
{
    return execute_program('sysctl', '-n ' . $key);
}
예제 #29
0
 function temperature($hddtemp_avail)
 {
     $ar_buf = array();
     $results = array();
     switch ($hddtemp_avail) {
         case "tcp":
             // Timo van Roermund: connect to the hddtemp daemon, use a 5 second timeout.
             $fp = fsockopen('localhost', 7634, $errno, $errstr, 5);
             // if connected, read the output of the hddtemp daemon
             if ($fp) {
                 // read output of the daemon
                 $lines = '';
                 while (!feof($fp)) {
                     $lines .= fread($fp, 1024);
                 }
                 // close the connection
                 fclose($fp);
             } else {
                 die("HDDTemp error: " . $errno . ", " . $errstr);
             }
             $lines = str_replace("||", "|\n|", $lines);
             $ar_buf = explode("\n", $lines);
             break;
         case "suid":
             $strDrives = "";
             $strContent = rfts("/proc/diskstats", 0, 4096, false);
             if ($strContent != "ERROR") {
                 $arrContent = explode("\n", $strContent);
                 foreach ($arrContent as $strLine) {
                     preg_match("/^\\s(.*)\\s([a-z]*)\\s(.*)/", $strLine, $arrSplit);
                     if (!empty($arrSplit[2])) {
                         $strDrive = '/dev/' . $arrSplit[2];
                         if (file_exists($strDrive)) {
                             $strDrives = $strDrives . $strDrive . ' ';
                         }
                     }
                 }
             } else {
                 $strContent = rfts("/proc/partitions", 0, 4096, false);
                 if ($strContent != "ERROR") {
                     $arrContent = explode("\n", $strContent);
                     foreach ($arrContent as $strLine) {
                         if (!preg_match("/^\\s(.*)\\s([\\/a-z0-9]*(\\/disc))\\s(.*)/", $strLine, $arrSplit)) {
                             preg_match("/^\\s(.*)\\s([a-z]*)\\s(.*)/", $strLine, $arrSplit);
                         }
                         if (!empty($arrSplit[2])) {
                             $strDrive = '/dev/' . $arrSplit[2];
                             if (file_exists($strDrive)) {
                                 $strDrives = $strDrives . $strDrive . ' ';
                             }
                         }
                     }
                 }
             }
             if (trim($strDrives) == "") {
                 return array();
             }
             $hddtemp_value = execute_program("hddtemp", $strDrives);
             $hddtemp_value = explode("\n", $hddtemp_value);
             foreach ($hddtemp_value as $line) {
                 $temp = preg_split("/:\\s/", $line, 3);
                 if (count($temp) == 3 && preg_match("/^[0-9]/", $temp[2])) {
                     list($temp[2], $temp[3]) = preg_split("/\\s/", $temp[2]);
                     array_push($ar_buf, "|" . implode("|", $temp) . "|");
                 }
             }
             break;
         default:
             die("Bad hddtemp configuration in config.php");
     }
     // Timo van Roermund: parse the info from the hddtemp daemon.
     $i = 0;
     foreach ($ar_buf as $line) {
         $data = array();
         if (ereg("\\|(.*)\\|(.*)\\|(.*)\\|(.*)\\|", $line, $data)) {
             if (trim($data[3]) != "ERR") {
                 // get the info we need
                 $results[$i]['label'] = $data[1];
                 $results[$i]['value'] = $data[3];
                 $results[$i]['model'] = $data[2];
                 $i++;
             }
         }
     }
     return $results;
 }
예제 #30
0
 function filesystems()
 {
     global $show_bind;
     $fstype = array();
     $fsoptions = array();
     $df = execute_program('df', '-kP');
     $mounts = split("\n", $df);
     $buffer = execute_program("mount");
     $buffer = explode("\n", $buffer);
     $j = 0;
     foreach ($buffer as $line) {
         preg_match("/(.*) on (.*) type (.*) \\((.*)\\)/", $line, $result);
         if (count($result) == 5) {
             $dev = $result[1];
             $mpoint = $result[2];
             $type = $result[3];
             $options = $result[4];
             $fstype[$mpoint] = $type;
             $fsdev[$dev] = $type;
             $fsoptions[$mpoint] = $options;
             foreach ($mounts as $line2) {
                 if (preg_match("#^" . str_replace("\$", "\\\$", $result[1]) . "#", $line2)) {
                     $line2 = preg_replace("#^" . str_replace("\$", "\\\$", $result[1]) . "#", "", $line2);
                     $ar_buf = preg_split("/(\\s+)/", $line2, 6);
                     $ar_buf[0] = $result[1];
                     if (hide_mount($ar_buf[5]) || $ar_buf[0] == "") {
                         continue;
                     }
                     if ($show_bind || !stristr($fsoptions[$ar_buf[5]], "bind")) {
                         $results[$j] = array();
                         $results[$j]['disk'] = $ar_buf[0];
                         $results[$j]['size'] = $ar_buf[1];
                         $results[$j]['used'] = $ar_buf[2];
                         $results[$j]['free'] = $ar_buf[3];
                         $results[$j]['percent'] = round($results[$j]['used'] * 100 / $results[$j]['size']);
                         $results[$j]['mount'] = $ar_buf[5];
                         $fstype[$ar_buf[5]] ? $results[$j]['fstype'] = $fstype[$ar_buf[5]] : ($results[$j]['fstype'] = $fsdev[$ar_buf[0]]);
                         $results[$j]['options'] = $fsoptions[$ar_buf[5]];
                         $j++;
                     }
                 }
             }
         }
     }
     return $results;
 }