[ 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/mb/ -> class.lmsensors.inc.php (source)

   1  <?php 
   2  
   3  // phpSysInfo - A PHP System Information Script
   4  // http://phpsysinfo.sourceforge.net/
   5  
   6  // This program is free software; you can redistribute it and/or
   7  // modify it under the terms of the GNU General Public License
   8  // as published by the Free Software Foundation; either version 2
   9  // of the License, or (at your option) any later version.
  10  
  11  // This program is distributed in the hope that it will be useful,
  12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  // GNU General Public License for more details.
  15  
  16  // You should have received a copy of the GNU General Public License
  17  // along with this program; if not, write to the Free Software
  18  // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19  
  20  // $Id: class.lmsensors.inc.php,v 1.17 2006/01/25 19:26:50 bigmichi1 Exp $
  21  if (!defined('IN_PHPSYSINFO')) {
  22      die("No Hacking");
  23  }
  24  
  25  require_once(APP_ROOT . "/includes/common_functions.php");
  26  
  27  class mbinfo {
  28    var $lines;
  29  
  30    function mbinfo() {
  31     $lines = execute_program("sensors", "");
  32     // Martijn Stolk: Dirty fix for misinterpreted output of sensors, 
  33     // where info could come on next line when the label is too long.
  34     $lines = str_replace(":\n", ":", $lines);
  35     $lines = str_replace("\n\n", "\n", $lines);
  36     $this->lines = explode("\n", $lines);
  37    }
  38    
  39    function temperature() {
  40      $ar_buf = array();
  41      $results = array();
  42  
  43      $sensors_value = $this->lines;
  44  
  45      foreach($sensors_value as $line) {
  46        $data = array();
  47        if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data)) ;
  48        elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data)) ;
  49        else (ereg("(.*):(.*)", $line, $data));
  50        if (count($data) > 1) {
  51          $temp = substr(trim($data[2]), -1);
  52          switch ($temp) {
  53            case "C";
  54            case "F":
  55              array_push($ar_buf, $line);
  56              break;
  57          }
  58        }
  59      }
  60  
  61      $i = 0;
  62      foreach($ar_buf as $line) {
  63        unset($data);
  64        if (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)\)", $line, $data)) ;
  65        elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C,(.*)=(.*).C\)(.*)", $line, $data)) ;
  66        elseif (ereg("(.*):(.*).C[ ]*\((.*)=(.*).C\)(.*)", $line, $data)) ;
  67        else (ereg("(.*):(.*).C", $line, $data));
  68  
  69        $results[$i]['label'] = $data[1];
  70        $results[$i]['value'] = trim($data[2]);
  71        if ( trim( $data[2] ) > trim( $data[6] ) ) {
  72          $results[$i]['limit'] = "+75";
  73          $results[$i]['perce'] = "+75";
  74        } else {
  75          $results[$i]['limit'] = isset($data[4]) ? trim($data[4]) : "+75";
  76          $results[$i]['perce'] = isset($data[6]) ? trim($data[6]) : "+75";
  77        }
  78        if ($results[$i]['limit'] < $results[$i]['perce']) {         
  79           $results[$i]['limit'] = $results[$i]['perce'];         
  80         }      
  81        $i++;
  82      }
  83  
  84      asort($results);
  85      return array_values($results);
  86    }
  87  
  88    function fans() {
  89      $ar_buf = array();
  90      $results = array();
  91  
  92      $sensors_value = $this->lines;
  93  
  94      foreach($sensors_value as $line) {
  95        $data = array();
  96        if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data));
  97        elseif (ereg("(.*):(.*)\((.*)=(.*)\)(.*)", $line, $data));
  98        else ereg("(.*):(.*)", $line, $data);
  99  
 100        if (count($data) > 1) {
 101          $temp = explode(" ", trim($data[2]));
 102          if (count($temp) == 1)
 103            $temp = explode("\xb0", trim($data[2]));
 104      if(isset($temp[1])) {
 105            switch ($temp[1]) {
 106              case "RPM":
 107                array_push($ar_buf, $line);
 108                break;
 109            }
 110      }
 111        }
 112      }
 113  
 114      $i = 0;
 115      foreach($ar_buf as $line) {
 116        unset($data);
 117        if (ereg("(.*):(.*) RPM  \((.*)=(.*) RPM,(.*)=(.*)\)(.*)\)", $line, $data));
 118        elseif (ereg("(.*):(.*) RPM  \((.*)=(.*) RPM,(.*)=(.*)\)(.*)", $line, $data));
 119        elseif (ereg("(.*):(.*) RPM  \((.*)=(.*) RPM\)(.*)", $line, $data));
 120        else ereg("(.*):(.*) RPM", $line, $data);
 121  
 122        $results[$i]['label'] = trim($data[1]);
 123        $results[$i]['value'] = trim($data[2]);
 124        $results[$i]['min'] = isset($data[4]) ? trim($data[4]) : 0;
 125        $results[$i]['div'] = isset($data[6]) ? trim($data[6]) : 0;
 126        $i++;
 127      }
 128  
 129      asort($results);
 130      return array_values($results);
 131    }
 132  
 133    function voltage() {
 134      $ar_buf = array();
 135      $results = array();
 136  
 137      $sensors_value = $this->lines;
 138  
 139      foreach($sensors_value as $line) {
 140        $data = array();
 141        if (ereg("(.*):(.*)\((.*)=(.*),(.*)=(.*)\)(.*)", $line, $data));
 142        else ereg("(.*):(.*)", $line, $data);
 143        
 144        if (count($data) > 1) {
 145          $temp = explode(" ", trim($data[2]));
 146          if (count($temp) == 1)
 147            $temp = explode("\xb0", trim($data[2]));
 148          if (isset($temp[1])) {
 149            switch ($temp[1]) {
 150              case "V":
 151                array_push($ar_buf, $line);
 152                break;
 153        }
 154          }
 155        }
 156      }
 157  
 158      $i = 0;
 159      foreach($ar_buf as $line) {
 160        unset($data);
 161        if (ereg("(.*):(.*) V  \((.*)=(.*) V,(.*)=(.*) V\)(.*)\)", $line, $data));
 162        elseif (ereg("(.*):(.*) V  \((.*)=(.*) V,(.*)=(.*) V\)(.*)", $line, $data));
 163        else ereg("(.*):(.*) V$", $line, $data);
 164        if(isset($data[1])) {
 165          $results[$i]['label'] = trim($data[1]);
 166          $results[$i]['value'] = trim($data[2]);
 167          $results[$i]['min'] = isset($data[4]) ? trim($data[4]) : 0;
 168          $results[$i]['max'] = isset($data[6]) ? trim($data[6]) : 0;
 169          $i++;
 170        }
 171      }
 172      return $results;
 173    }
 174  }
 175  
 176  ?>


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