fix array combine for sensors with non uniform data

This commit is contained in:
Derek Macias 2016-02-15 16:37:25 -07:00
parent 04620e6082
commit 7ace8136a6

View File

@ -52,11 +52,15 @@ function ipmi_sensors($options) {
'LowerCritical','LowerNonCrit','MinRange','MaxRange']; 'LowerCritical','LowerNonCrit','MinRange','MaxRange'];
$sensors = []; $sensors = [];
foreach($output as $line){ foreach($output as $line){
// add sensor keys as keys to ipmitool output // add sensor keys as keys to ipmitool output
$sensor = array_combine($keys, array_slice(explode(",", $line),0,18,true)); $sensor_raw = explode(",", $line);
$size_raw = sizeof($sensor_raw);
$sensor = ($size_raw < 18) ? []:
/*array_combine(array_slice($keys,0,$size_raw,true), $sensor_raw)*/
array_combine($keys, array_slice($sensor_raw,0,18,true));
// add sensor to array of sensors // add sensor to array of sensors
$sensors[] = $sensor; $sensors[] = $sensor;
@ -154,5 +158,5 @@ function ipmi_get_fans($sensors){
} }
return $fans; return $fans;
} }
//echo json_encode($ipmi_sensors);
?> ?>