[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/System/includes/os/ -> class.WINNT.inc.bak.php (source)

   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  // WINNT implementation written by Carl C. Longnecker, longneck@iname.com
  16  // $Id: class.WINNT.inc.bak.php 5728 2006-05-03 21:19:46Z allanbush $
  17  class sysinfo {
  18    // winnt needs some special prep
  19    // $wmi holds the COM object that we pull all the WMI data from
  20    var $wmi; 
  21    // this constructor initialis the $wmi object
  22    function sysinfo ()
  23    {
  24      $this->wmi = new COM("WinMgmts:\\\\.");
  25    } 
  26    // get our apache SERVER_NAME or vhost
  27    function vhostname ()
  28    {
  29      if (! ($result = getenv('SERVER_NAME'))) {
  30        $result = 'N.A.';
  31      } 
  32      return $result;
  33    } 
  34    // get our canonical hostname
  35    function chostname ()
  36    {
  37      if (! ($result = getenv('SERVER_NAME'))) {
  38        $result = 'N.A.';
  39      } 
  40      return $result;
  41    } 
  42    // get the IP address of our canonical hostname
  43    function ip_addr ()
  44    {
  45      if (!($result = getenv('SERVER_ADDR'))) {
  46        $result = 'N.A.';
  47      } 
  48      return $result;
  49    } 
  50  
  51    function kernel ()
  52    {
  53      $objInstance = $this->wmi->InstancesOf("Win32_OperatingSystem");
  54      foreach ($objInstance as $obj) {
  55        $result = $obj->Version;
  56        if ($obj->ServicePackMajorVersion > 0) {
  57          $result .= ' SP' . $obj->ServicePackMajorVersion;
  58        } 
  59      } 
  60      return $result;
  61    } 
  62  
  63    function uptime ()
  64    {
  65      $objInstance = $this->wmi->InstancesOf("Win32_OperatingSystem");
  66      foreach ($objInstance as $obj) {
  67        $result = 0;
  68  
  69        $year = intval(substr($obj->LastBootUpTime, 0, 4));
  70        $month = intval(substr($obj->LastBootUpTime, 4, 2));
  71        $day = intval(substr($obj->LastBootUpTime, 6, 2));
  72        $hour = intval(substr($obj->LastBootUpTime, 8, 2));
  73        $minute = intval(substr($obj->LastBootUpTime, 10, 2));
  74        $seconds = intval(substr($obj->LastBootUpTime, 12, 2));
  75  
  76        $boottime = mktime($hour, $minute, $seconds, $month, $day, $year);
  77  
  78        $diff_seconds = mktime() - $boottime;
  79  
  80        $result = $diff_seconds;
  81      } 
  82      return $result;
  83    } 
  84  
  85    function users ()
  86    {
  87      $objInstance = $this->wmi->InstancesOf("Win32_PerfRawData_TermService_TerminalServices");
  88      foreach ($objInstance as $obj) {
  89        return $obj->TotalSessions;
  90      } 
  91    } 
  92  
  93    function loadavg ()
  94    {
  95      $objInstance = $this->wmi->InstancesOf("Win32_Processor");
  96  
  97      $cpuload = array();
  98      foreach ($objInstance as $obj) {
  99        $cpuload[] = $obj->LoadPercentage;
 100      } 
 101      // while
 102      return $cpuload;
 103    } 
 104  
 105    function cpu_info ()
 106    {
 107      $objInstance = $this->wmi->InstancesOf("Win32_Processor");
 108  
 109      foreach ($objInstance as $obj) {
 110        // still need bogomips (wtf are bogomips?)
 111        $results['cpus'] = getenv('NUMBER_OF_PROCESSORS');
 112        $results['model'] = $obj->Name;
 113        $results['cache'] = $obj->L2CacheSize;
 114        $results['mhz'] = $obj->CurrentClockSpeed . "/" . $obj->ExtClock;
 115      } 
 116      return $results;
 117    } 
 118  
 119    function pci ()
 120    {
 121      $objInstance = $this->wmi->InstancesOf("Win32_PnPEntity");
 122  
 123      $pci = array();
 124      foreach ($objInstance as $obj) {
 125        if (substr($obj->PNPDeviceID, 0, 4) == "PCI\\") {
 126          $pci[] = $obj->Name;
 127        } 
 128      } // while
 129      return $pci;
 130    } 
 131  
 132    function ide ()
 133    {
 134      $objInstance = $this->wmi->InstancesOf("Win32_PnPEntity");
 135  
 136      $ide = array();
 137      foreach ($objInstance as $obj) {
 138        if (substr($obj->PNPDeviceID, 0, 4) == "IDE\\") {
 139          $ide[]['model'] = $obj->Name;
 140        } 
 141      } // while
 142      return $ide;
 143    } 
 144  
 145    function scsi ()
 146    {
 147      $objInstance = $this->wmi->InstancesOf("Win32_PnPEntity");
 148  
 149      $scsi = array();
 150      foreach ($objInstance as $obj) {
 151        if (substr($obj->PNPDeviceID, 0, 5) == "SCSI\\") {
 152          $scsi[] = $obj->Name;
 153        } 
 154      } // while
 155      return $scsi;
 156    } 
 157  
 158    function usb ()
 159    {
 160      $objInstance = $this->wmi->InstancesOf("Win32_PnPEntity");
 161  
 162      $usb = array();
 163      foreach ($objInstance as $obj) {
 164        if (substr($obj->PNPDeviceID, 0, 4) == "USB\\") {
 165          $usb[] = $obj->Name;
 166        } 
 167      } // while
 168      return $usb;
 169    } 
 170  
 171    function sbus ()
 172    {
 173      $objInstance = $this->wmi->InstancesOf("Win32_PnPEntity");
 174  
 175      $sbus = array();
 176      foreach ($objInstance as $obj) {
 177        if (substr($obj->PNPDeviceID, 0, 5) == "SBUS\\") {
 178          $sbus[] = $obj->Name;
 179        } 
 180      } // while
 181      return $sbus;
 182    } 
 183  
 184    function network ()
 185    {
 186      /**
 187      * need this for documentation in case i find some better net stats
 188      * $results[$dev_name]['rx_bytes'] = $stats[0];
 189      * $results[$dev_name]['rx_packets'] = $stats[1];
 190      * $results[$dev_name]['rx_errs'] = $stats[2];
 191      * $results[$dev_name]['rx_drop'] = $stats[3];
 192      * 
 193      * $results[$dev_name]['tx_bytes'] = $stats[8];
 194      * $results[$dev_name]['tx_packets'] = $stats[9];
 195      * $results[$dev_name]['tx_errs'] = $stats[10];
 196      * $results[$dev_name]['tx_drop'] = $stats[11];
 197      * 
 198      * $results[$dev_name]['errs'] = $stats[2] + $stats[10];
 199      * $results[$dev_name]['drop'] = $stats[3] + $stats[11];
 200      */
 201  
 202      $objInstance = $this->wmi->InstancesOf("Win32_PerfRawData_Tcpip_NetworkInterface");
 203  
 204      $results = array();
 205      foreach ($objInstance as $obj) {
 206        $results[$obj->Name]['errs'] = $obj->PacketsReceivedErrors;
 207        $results[$obj->Name]['drop'] = $obj->PacketsReceivedDiscarded;
 208      } // while
 209      return $results;
 210    } 
 211  
 212    function memory ()
 213    {
 214      $objInstance = $this->wmi->InstancesOf("Win32_LogicalMemoryConfiguration");
 215      foreach ($objInstance as $obj) {
 216        $results['ram']['total'] = $obj->TotalPhysicalMemory;
 217      } 
 218      $objInstance = $this->wmi->InstancesOf("Win32_PerfRawData_PerfOS_Memory");
 219      foreach ($objInstance as $obj) {
 220        $results['ram']['free'] = $obj->AvailableKBytes;
 221      } 
 222      $results['ram']['used'] = $results['ram']['total'] - $results['ram']['free'];
 223      $results['ram']['t_used'] = $results['ram']['used'];
 224      $results['ram']['t_free'] = $results['ram']['total'] - $results['ram']['t_used'];
 225      $results['ram']['percent'] = round(($results['ram']['t_used'] * 100) / $results['ram']['total']);
 226  
 227      $results['swap']['total'] = 0;
 228      $results['swap']['used'] = 0;
 229      $results['swap']['free'] = 0;
 230  
 231      $objInstance = $this->wmi->InstancesOf("Win32_PageFileUsage");
 232  
 233      $k = 0;
 234      foreach ($objInstance as $obj) {
 235        $results['devswap'][$k]['dev'] = $obj->Name;
 236        $results['devswap'][$k]['total'] = $obj->AllocatedBaseSize * 1024;
 237        $results['devswap'][$k]['used'] = $obj->CurrentUsage * 1024;
 238        $results['devswap'][$k]['free'] = ($obj->AllocatedBaseSize - $obj->CurrentUsage) * 1024;
 239        $results['devswap'][$k]['percent'] = $obj->CurrentUsage / $obj->AllocatedBaseSize;
 240  
 241        $results['swap']['total'] += $results['devswap'][$k]['total'];
 242        $results['swap']['used'] += $results['devswap'][$k]['used'];
 243        $results['swap']['free'] += $results['devswap'][$k]['free'];
 244        $k += 1;
 245      } 
 246  
 247      $results['swap']['percent'] = round($results['swap']['used'] / $results['swap']['total'] * 100);
 248  
 249      return $results;
 250    } 
 251  
 252    function filesystems ()
 253    {
 254      $objInstance = $this->wmi->InstancesOf("Win32_LogicalDisk");
 255  
 256      $k = 0;
 257      foreach ($objInstance as $obj) {
 258        $results[$k]['mount'] = $obj->Name;
 259        $results[$k]['size'] = $obj->Size / 1024;
 260        $results[$k]['used'] = ($obj->Size - $obj->FreeSpace) / 1024;
 261        $results[$k]['free'] = $obj->FreeSpace / 1024;
 262        $results[$k]['percent'] = round($results[$k]['used'] / $results[$k]['size'] * 100);
 263        $results[$k]['fstype'] = $obj->FileSystem;
 264  
 265        $typearray = array("Unknown", "No Root Directory", "Removeable Disk",
 266          "Local Disk", "Network Drive", "Compact Disc", "RAM Disk");
 267        $floppyarray = array("Unknown", "5 1/4 in.", "3 1/2 in.", "3 1/2 in.",
 268          "3 1/2 in.", "3 1/2 in.", "5 1/4 in.", "5 1/4 in.", "5 1/4 in.",
 269          "5 1/4 in.", "5 1/4 in.", "Other", "HD", "3 1/2 in.", "3 1/2 in.",
 270          "5 1/4 in.", "5 1/4 in.", "3 1/2 in.", "3 1/2 in.", "5 1/4 in.",
 271          "3 1/2 in.", "3 1/2 in.", "8 in.");
 272  
 273        $results[$k]['disk'] = $typearray[$obj->DriveType];
 274        if ($obj->DriveType == 2) $results[$k]['disk'] .= " (" . $floppyarray[$obj->MediaType] . ")";
 275        $k += 1;
 276      } 
 277  
 278      return $results;
 279    } 
 280  
 281    function distro ()
 282    {
 283      $objInstance = $this->wmi->InstancesOf("Win32_OperatingSystem");
 284      foreach ($objInstance as $obj) {
 285        return $obj->Caption;
 286      } 
 287    } 
 288  
 289    function distroicon ()
 290    {
 291      return 'xp.gif';
 292    } 
 293  } 
 294  
 295  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7