PageRenderTime 38ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/yousef_fadila/vtiger
PHP | 110 lines | 75 code | 17 blank | 18 comment | 8 complexity | 4d3dc1be8f37d61ee9510e1e8b392fd2 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  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.OpenBSD.inc.php,v 1.21 2006/04/18 17:46:15 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_regexp1 = "";
  23. var $scsi_regexp2 = "";
  24. var $cpu_regexp2 = "";
  25. // Our contstructor
  26. // this function is run on the initialization of this class
  27. function sysinfo () {
  28. $this->bsd_common();
  29. $this->cpu_regexp = "^cpu(.*) (.*) MHz";
  30. $this->scsi_regexp1 = "^(.*) at scsibus.*: <(.*)> .*";
  31. $this->scsi_regexp2 = "^(da[0-9]): (.*)MB ";
  32. $this->cpu_regexp2 = "/(.*),(.*),(.*),(.*),(.*)/";
  33. $this->pci_regexp1 = '/(.*) at pci[0-9] .* "(.*)"/';
  34. $this->pci_regexp2 = '/"(.*)" (.*).* at [.0-9]+ irq/';
  35. }
  36. function get_sys_ticks () {
  37. $a = $this->grab_key('kern.boottime');
  38. $sys_ticks = time() - $a;
  39. return $sys_ticks;
  40. }
  41. function network () {
  42. $netstat_b = execute_program('netstat', '-nbdi | cut -c1-25,44- | grep Link | grep -v \'* \'');
  43. $netstat_n = execute_program('netstat', '-ndi | cut -c1-25,44- | grep Link | grep -v \'* \'');
  44. $lines_b = split("\n", $netstat_b);
  45. $lines_n = split("\n", $netstat_n);
  46. $results = array();
  47. for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) {
  48. $ar_buf_b = preg_split("/\s+/", $lines_b[$i]);
  49. $ar_buf_n = preg_split("/\s+/", $lines_n[$i]);
  50. if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) {
  51. $results[$ar_buf_b[0]] = array();
  52. $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3];
  53. $results[$ar_buf_b[0]]['rx_packets'] = $ar_buf_n[3];
  54. $results[$ar_buf_b[0]]['rx_errs'] = $ar_buf_n[4];
  55. $results[$ar_buf_b[0]]['rx_drop'] = $ar_buf_n[8];
  56. $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4];
  57. $results[$ar_buf_b[0]]['tx_packets'] = $ar_buf_n[5];
  58. $results[$ar_buf_b[0]]['tx_errs'] = $ar_buf_n[6];
  59. $results[$ar_buf_b[0]]['tx_drop'] = $ar_buf_n[8];
  60. $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6];
  61. $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8];
  62. }
  63. }
  64. return $results;
  65. }
  66. // get the ide device information out of dmesg
  67. function ide () {
  68. $results = array();
  69. $s = 0;
  70. for ($i = 0, $max = count($this->read_dmesg()); $i < $max; $i++) {
  71. $buf = $this->dmesg[$i];
  72. if (preg_match('/^(.*) at pciide[0-9] (.*): <(.*)>/', $buf, $ar_buf)) {
  73. $s = $ar_buf[1];
  74. $results[$s]['model'] = $ar_buf[3];
  75. $results[$s]['media'] = 'Hard Disk';
  76. // now loop again and find the capacity
  77. for ($j = 0, $max1 = count($this->read_dmesg()); $j < $max1; $j++) {
  78. $buf_n = $this->dmesg[$j];
  79. if (preg_match("/^($s): (.*), (.*), (.*)MB, .*$/", $buf_n, $ar_buf_n)) {
  80. $results[$s]['capacity'] = $ar_buf_n[4] * 2048 * 1.049;;
  81. }
  82. }
  83. }
  84. }
  85. asort($results);
  86. return $results;
  87. }
  88. function distroicon () {
  89. $result = 'OpenBSD.png';
  90. return($result);
  91. }
  92. }
  93. ?>