"; $volts = pre_grep( "/ V /", $lines); $temps = pre_grep("/C /", $lines); $fans = pre_grep("/ RPM /", $lines); $others = array(); $j = 0; for ( $i = 0; $i < sizeof($lines); $i++ ) { if ( !preg_match("/\(min|\(limit/",$lines[$i])) { $others[$j] = $lines[$i]; $j++; } } $others = sys_cleanarray($others); $results['othercount'] = sizeof($others); for ( $i = 0; $i < sizeof($others); $i++ ) { list($label, $value) = split( ":", $others[$i]); $results['others'.$i]['label'] = trim($label.":"); $results['others'.$i]['current'] = trim($value); } // voltage $results['voltcount'] = sizeof($volts); for ( $i = 0; $i < sizeof($volts); $i++ ) { //$tmp = cho "$volts[$i]" |sed -e "s/ V).*//;s/=//g;s/min//g; s/max//g; s/(//; s/,//g; s/ V //g"; $tmparray[$i] = split( ":", $volts[$i]); $tmparray[$i][1] = ereg_replace("/|[)].*|[=(,]|min |max |V|/i", "", $tmparray[$i][1]); $results['volt'.$i]['label'] = $tmparray[$i][0].":"; $tmparray[$i] = preg_split( "/\s+/", trim($tmparray[$i][1]),3); $results['volt'.$i]['current'] = $tmparray[$i][0]." V"; $results['volt'.$i]['min'] = $tmparray[$i][1]." V"; $results['volt'.$i]['max'] = $tmparray[$i][2]." V"; if ( eregi_replace("[-+]","",$tmparray[$i][0]) < eregi_replace("[-+]","",$tmparray[$i][1]) || eregi_replace("[-+]","",$tmparray[$i][0]) > eregi_replace("[-+]","",$tmparray[$i][2])) { $results['volt'.$i]['status'] = "[RED ALERT]"; } else { $results['volt'.$i]['status'] = "[Normal]"; } } // fans $results['fancount'] = sizeof($fans); for ( $i = 1; $i < sizeof($fans) + 1; $i++ ) { //$tmp = cho "$fans[$i]" |sed -e "s/).*//;s/=//g;s/min//g; s/div//g; s/(//; s/,//g; s/ RPM //g"; $tmparray[$i] = split( ":", $fans[$i - 1]); $tmparray[$i][1] = ereg_replace("/|[)].*|[=(,]|min |div|RPM|/i", "", $tmparray[$i][1]); $results['fan'.$i]['label'] = $tmparray[$i][0].":"; $tmparray[$i] = preg_split( "/[\s+-]+/", trim($tmparray[$i][1]),3); $results['fan'.$i]['current'] = $tmparray[$i][0]." RPM"; $results['fan'.$i]['min'] = $tmparray[$i][1]." RPM"; $results['fan'.$i]['div'] = $tmparray[$i][2]; if ( $tmparray[$i][0] < $tmparray[$i][1] ) { $results['fan'.$i]['status'] = "[RED ALERT]"; } else { $results['fan'.$i]['status'] = "[Normal]"; } } // temparatures $results['tempcount'] = sizeof($temps); for ( $i = 1; $i < sizeof($temps) + 1; $i++ ) { //$tmp = cho "$lines[$i]" |sed -e "s/ C).*//;s/=//g;s/limit//g; s/hysteresis//g; s/(//; s/,//g; s/ C //g"; $tmparray[$i] = split( ":", $temps[$i - 1]); $tmparray[$i][1] = ereg_replace("/|[)].*|[=(,]|limit|hysteresis | C|/i", "", $tmparray[$i][1]); $results['temp'.$i]['label'] = $tmparray[$i][0].":"; $tmparray[$i] = preg_split( "/\s+/", eregi_replace("[+]","",trim($tmparray[$i][1])),3); $results['temp'.$i]['current'] = $tmparray[$i][0]."C".'
'."(".temp_conv($tmparray[$i][0],"F")." F)"; $results['temp'.$i]['min'] = $tmparray[$i][2]."C".'
'."(".temp_conv($tmparray[$i][2],"F")." F)"; $results['temp'.$i]['max'] = $tmparray[$i][1]."C".'
'."(".temp_conv($tmparray[$i][1],"F")." F)"; if ( $tmparray[$i][0] > $tmparray[$i][1] ) { $results['temp'.$i]['status'] = "[RED ALERT]"; } else if ( $tmparray[$i][0] >= $tmparray[$i][2] ) { $results['temp'.$i]['status'] = "[YELLOW ALERT]"; } else { $results['temp'.$i]['status'] = "[Normal]"; } } return $results; } ?>