PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/yousef_fadila/vtiger
PHP | 108 lines | 74 code | 18 blank | 16 comment | 5 complexity | de9ea4586e2906ebd28bf761cbca3365 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.FreeBSD.inc.php,v 1.17 2006/04/18 16:22:26 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 = "^(.*): <(.*)> .*SCSI.*device";
  31. $this->scsi_regexp2 = "^(da[0-9]): (.*)MB ";
  32. $this->cpu_regexp2 = "/(.*) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)/";
  33. }
  34. function get_sys_ticks () {
  35. $s = explode(' ', $this->grab_key('kern.boottime'));
  36. $a = ereg_replace('{ ', '', $s[3]);
  37. $sys_ticks = time() - $a;
  38. return $sys_ticks;
  39. }
  40. function network () {
  41. $netstat = execute_program('netstat', '-nibd | grep Link');
  42. $lines = split("\n", $netstat);
  43. $results = array();
  44. for ($i = 0, $max = sizeof($lines); $i < $max; $i++) {
  45. $ar_buf = preg_split("/\s+/", $lines[$i]);
  46. if (!empty($ar_buf[0])) {
  47. $results[$ar_buf[0]] = array();
  48. if (strlen($ar_buf[3]) < 15) {
  49. $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[5];
  50. $results[$ar_buf[0]]['rx_packets'] = $ar_buf[3];
  51. $results[$ar_buf[0]]['rx_errs'] = $ar_buf[4];
  52. $results[$ar_buf[0]]['rx_drop'] = $ar_buf[10];
  53. $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[8];
  54. $results[$ar_buf[0]]['tx_packets'] = $ar_buf[6];
  55. $results[$ar_buf[0]]['tx_errs'] = $ar_buf[7];
  56. $results[$ar_buf[0]]['tx_drop'] = $ar_buf[10];
  57. $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[7];
  58. $results[$ar_buf[0]]['drop'] = $ar_buf[10];
  59. } else {
  60. $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[6];
  61. $results[$ar_buf[0]]['rx_packets'] = $ar_buf[4];
  62. $results[$ar_buf[0]]['rx_errs'] = $ar_buf[5];
  63. $results[$ar_buf[0]]['rx_drop'] = $ar_buf[11];
  64. $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[9];
  65. $results[$ar_buf[0]]['tx_packets'] = $ar_buf[7];
  66. $results[$ar_buf[0]]['tx_errs'] = $ar_buf[8];
  67. $results[$ar_buf[0]]['tx_drop'] = $ar_buf[11];
  68. $results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[8];
  69. $results[$ar_buf[0]]['drop'] = $ar_buf[11];
  70. }
  71. }
  72. }
  73. return $results;
  74. }
  75. function distroicon () {
  76. $result = 'FreeBSD.png';
  77. return($result);
  78. }
  79. function memory_additional($results) {
  80. $pagesize = $this->grab_key("hw.pagesize");
  81. $results['ram']['cached'] = $this->grab_key("vm.stats.vm.v_cache_count") * $pagesize / 1024;
  82. $results['ram']['cached_percent'] = round( $results['ram']['cached'] * 100 / $results['ram']['total']);
  83. $results['ram']['app'] = $this->grab_key("vm.stats.vm.v_active_count") * $pagesize / 1024;
  84. $results['ram']['app_percent'] = round( $results['ram']['app'] * 100 / $results['ram']['total']);
  85. $results['ram']['buffers'] = $results['ram']['used'] - $results['ram']['app'] - $results['ram']['cached'];
  86. $results['ram']['buffers_percent'] = round( $results['ram']['buffers'] * 100 / $results['ram']['total']);
  87. return $results;
  88. }
  89. }
  90. ?>