/modules/System/includes/os/class.NetBSD.inc.php

https://bitbucket.org/yousef_fadila/vtiger · PHP · 111 lines · 75 code · 18 blank · 18 comment · 8 complexity · ef8bcd3c6f66a543e1b14cb26c626aec MD5 · raw file

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