/**
  * get temperature information
  *
  * @return void
  */
 private function _temperature()
 {
     if (PSI_OS == 'Linux') {
         $hwpaths = glob("/sys/devices/platform/coretemp.*/", GLOB_NOSORT);
         if (($totalh = count($hwpaths)) > 0) {
             $buf = "";
             for ($h = 0; $h < $totalh; $h++) {
                 $tempsensor = glob($hwpaths[$h] . "temp*_input", GLOB_NOSORT);
                 if (($total = count($tempsensor)) > 0) {
                     $buf = "";
                     for ($i = 0; $i < $total; $i++) {
                         if (CommonFunctions::rfts($tempsensor[$i], $buf, 1, 4096, false) && trim($buf) != "") {
                             $dev = new SensorDevice();
                             $dev->setValue(trim($buf) / 1000);
                             $label = preg_replace("/_input\$/", "_label", $tempsensor[$i]);
                             $crit = preg_replace("/_input\$/", "_crit", $tempsensor[$i]);
                             $max = preg_replace("/_input\$/", "_max", $tempsensor[$i]);
                             $crit_alarm = preg_replace("/_input\$/", "_crit_alarm", $tempsensor[$i]);
                             if (CommonFunctions::fileexists($label) && CommonFunctions::rfts($label, $buf, 1, 4096, false) && trim($buf) != "") {
                                 $dev->setName(trim($buf));
                             } else {
                                 $labelname = trim(preg_replace("/_input\$/", "", pathinfo($tempsensor[$i], PATHINFO_BASENAME)));
                                 if ($labelname !== "") {
                                     $dev->setName($labelname);
                                 } else {
                                     $dev->setName('unknown');
                                 }
                             }
                             if (CommonFunctions::fileexists($crit) && CommonFunctions::rfts($crit, $buf, 1, 4096, false) && trim($buf) != "") {
                                 $dev->setMax(trim($buf) / 1000);
                                 if (CommonFunctions::fileexists($crit_alarm) && CommonFunctions::rfts($crit_alarm, $buf, 1, 4096, false) && trim($buf) === "1") {
                                     $dev->setEvent("Critical Alarm");
                                 }
                             } elseif (CommonFunctions::fileexists($max) && CommonFunctions::rfts($max, $buf, 1, 4096, false) && trim($buf) != "") {
                                 $dev->setMax(trim($buf) / 1000);
                             }
                             $this->mbinfo->setMbTemp($dev);
                         }
                     }
                 }
             }
         }
     } else {
         $smp = 1;
         CommonFunctions::executeProgram('sysctl', '-n kern.smp.cpus', $smp);
         for ($i = 0; $i < $smp; $i++) {
             $temp = 0;
             if (CommonFunctions::executeProgram('sysctl', '-n dev.cpu.' . $i . '.temperature', $temp)) {
                 $temp = preg_replace('/C/', '', $temp);
                 $dev = new SensorDevice();
                 $dev->setName("CPU " . ($i + 1));
                 $dev->setValue($temp);
                 //                    $dev->setMax(70);
                 $this->mbinfo->setMbTemp($dev);
             }
         }
     }
 }
 /**
  * get current information
  *
  * @return void
  */
 private function _current()
 {
     foreach ($this->_lines as $line) {
         $buffer = preg_split("/\\s*\\|\\s*/", $line);
         if (isset($buffer[2]) && $buffer[2] == "Current" && $buffer[1] == "Full" && isset($buffer[6]) && preg_match("/^(\\S+)\\sA\$/", $buffer[6], $value)) {
             $dev = new SensorDevice();
             $dev->setName($buffer[4]);
             $dev->setValue($value[1]);
             if (isset($buffer[7]) && $buffer[7] == "Thresholds") {
                 if (isset($buffer[8]) && preg_match("/^hi-crit\\s(\\S+)\\s*\$/", $buffer[8], $limits) || isset($buffer[9]) && preg_match("/^hi-crit\\s(\\S+)\\s*\$/", $buffer[9], $limits) || isset($buffer[10]) && preg_match("/^hi-crit\\s(\\S+)\\s*\$/", $buffer[10], $limits) || isset($buffer[11]) && preg_match("/^hi-crit\\s(\\S+)\\s*\$/", $buffer[11], $limits)) {
                     $dev->setMax($limits[1]);
                 }
             }
             if ($buffer[5] != "OK") {
                 $dev->setEvent($buffer[5]);
             }
             $this->mbinfo->setMbCurrent($dev);
         }
     }
 }
 /**
  * get current information
  *
  * @return void
  */
 private function _current($hwpath)
 {
     $sensor = glob($hwpath . "curr*_input", GLOB_NOSORT);
     if (($total = count($sensor)) > 0) {
         $buf = "";
         for ($i = 0; $i < $total; $i++) {
             if (CommonFunctions::rfts($sensor[$i], $buf, 1, 4096, false) && trim($buf) != "") {
                 $dev = new SensorDevice();
                 $dev->setValue(trim($buf) / 1000);
                 $label = preg_replace("/_input\$/", "_label", $sensor[$i]);
                 $alarm = preg_replace("/_input\$/", "_alarm", $sensor[$i]);
                 $max = preg_replace("/_input\$/", "_max", $sensor[$i]);
                 $min = preg_replace("/_input\$/", "_min", $sensor[$i]);
                 if (CommonFunctions::fileexists($label) && CommonFunctions::rfts($label, $buf, 1, 4096, false) && trim($buf) != "") {
                     $dev->setName(trim($buf));
                 } else {
                     $labelname = trim(preg_replace("/_input\$/", "", pathinfo($sensor[$i], PATHINFO_BASENAME)));
                     if ($labelname !== "") {
                         $dev->setName($labelname);
                     } else {
                         $dev->setName('unknown');
                     }
                 }
                 if (CommonFunctions::fileexists($max) && CommonFunctions::rfts($max, $buf, 1, 4096, false) && trim($buf) != "") {
                     $dev->setMax(trim($buf) / 1000);
                 }
                 if (CommonFunctions::fileexists($min) && CommonFunctions::rfts($min, $buf, 1, 4096, false) && trim($buf) != "") {
                     $dev->setMin(trim($buf) / 1000);
                 }
                 if (CommonFunctions::fileexists($alarm) && CommonFunctions::rfts($alarm, $buf, 1, 4096, false) && trim($buf) === "1") {
                     $dev->setEvent("Alarm");
                 }
                 $this->mbinfo->setMbCurrent($dev);
             }
         }
     }
 }
 /**
  * get current information
  *
  * @return void
  */
 private function _current()
 {
     $ar_buf = array();
     foreach ($this->_lines as $line) {
         $data = array();
         if (preg_match("/(.*):(.*)\\((.*)=(.*),(.*)=(.*)\\)(.*)/", $line, $data)) {
         } elseif (preg_match("/(.*):(.*)\\((.*)=(.*)\\)(.*)/", $line, $data)) {
         } else {
             preg_match("/(.*):(.*)/", $line, $data);
         }
         if (count($data) > 1) {
             $temp = substr(trim($data[2]), -2);
             switch ($temp) {
                 case " A":
                     array_push($ar_buf, $line);
             }
         }
     }
     foreach ($ar_buf as $line) {
         $data = array();
         /* not tested yet
                     if (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A,(.*)=(.*) A\)(.*)\)/", $line, $data)) {
                         ;
                     } elseif (preg_match("/(.*):(.*) A[ ]*\((.*)=(.*) A,(.*)=(.*) A\)(.*)/", $line, $data)) {
                         ;
                     } else
         */
         if (preg_match("/(.*):(.*) A[ ]*\\((.*)=(.*) A\\)(.*)/", $line, $data)) {
         } elseif (preg_match("/(.*):(.*) A[ \t]+/", $line, $data)) {
         } else {
             preg_match("/(.*):(.*) A\$/", $line, $data);
         }
         foreach ($data as $key => $value) {
             if (preg_match("/^\\+?([0-9\\.]+).?\$/", trim($value), $newvalue)) {
                 $data[$key] = trim($newvalue[1]);
             } else {
                 $data[$key] = trim($value);
             }
         }
         $dev = new SensorDevice();
         $dev->setName($data[1]);
         $dev->setValue($data[2]);
         if (isset($data[6]) && $data[2] <= $data[6]) {
             $dev->setMax(max($data[4], $data[6]));
         } elseif (isset($data[4]) && $data[2] <= $data[4]) {
             $dev->setMax($data[4]);
         }
         if (preg_match("/\\sALARM(\\s*)\$/", $line)) {
             $dev->setEvent("Alarm");
         }
         $this->mbinfo->setMbCurrent($dev);
     }
 }
 /**
  * get current information
  *
  * @return void
  */
 private function _current()
 {
     foreach ($this->_lines as $line) {
         $buffer = preg_split("/\\s*\\|\\s*/", $line);
         if ($buffer[2] == "Current" && $buffer[11] != "N/A" && $buffer[4] == "A") {
             $dev = new SensorDevice();
             $dev->setName($buffer[1]);
             $dev->setValue($buffer[3]);
             if ($buffer[9] != "N/A") {
                 $dev->setMax($buffer[9]);
             }
             if ($buffer[11] != "'OK'") {
                 $dev->setEvent(trim($buffer[11], "'"));
             }
             $this->mbinfo->setMbCurrent($dev);
         }
     }
 }
 /**
  * get current information
  *
  * @return void
  */
 private function _current()
 {
     foreach ($this->_lines as $line) {
         $buffer = preg_split("/\\s*\\|\\s*/", $line);
         if ($buffer[2] == "Amps" && $buffer[3] != "na") {
             $dev = new SensorDevice();
             $dev->setName($buffer[0]);
             $dev->setValue($buffer[1]);
             if ($buffer[8] != "na") {
                 $dev->setMax($buffer[8]);
             }
             switch ($buffer[3]) {
                 case "nr":
                     $dev->setEvent("Non-Recoverable");
                     break;
                 case "cr":
                     $dev->setEvent("Critical");
                     break;
                 case "nc":
                     $dev->setEvent("Non-Critical");
                     break;
             }
             $this->mbinfo->setMbCurrent($dev);
         }
     }
 }