Support temp sensors with negative values

Also enhance threshold detector
tags/zabbix-agent-addons-0.2.20-1 0.2.5_el5
Daniel Berteaud 9 years ago
parent 7fd870d984
commit 8747854686
  1. 19
      zabbix_scripts/util_generate_sensors_ini

@ -91,24 +91,33 @@ if ($ipmitool && -x $ipmitool){
my $val = undef; my $val = undef;
foreach my $d (@details){ foreach my $d (@details){
chomp $d; chomp $d;
if ($d =~ m/^\s*Sensor\sReading\s*:\s*(\w+)/){ if ($d =~ m/^\s*Sensor\sReading\s*:\s*(\-?\w+)/){
$val = $1; $val = $1;
print "Sensor $name has value: $val\n"; print "Sensor $name has value: $val\n";
if ($val !~ m/^\d+$/){ if ($val !~ m/^\-?\d+$/){
print "Skipping sensor $name, couldn't parse its value: $val\n"; print "Skipping sensor $name, couldn't parse its value: $val\n";
next SENSOR; next SENSOR;
} }
} }
elsif ($d =~ m/^\s*Upper\scritical\s*:\s*(\d+(\.\d+))/){ elsif ($d =~ m/^\s*Upper\scritical\s*:\s*(\-?\d+(\.\d+))/){
$sensor->{threshold_high} = $1-$temp_margin; $sensor->{threshold_high} = $1-$temp_margin;
} }
elsif ($d =~ m/^\s*Upper\snon\-critical\s*:\s*(\d+(\.\d+))/){ elsif ($d =~ m/^\s*Upper\snon\-critical\s*:\s*(\-?\d+(\.\d+))/){
$sensor->{threshold_low} = $1-$temp_margin; $sensor->{threshold_low} = $1-$temp_margin;
} }
} }
# Another loop to check for Normal max if Upper critical wasn't found
if (!$sensor->{threshold_high}){
foreach my $d (@details){
chomp $d;
if ($d =~ m/^\s*Normal\sMaximum\s*:\s*(\-?\d+(\.\d+))/){
$sensor->{threshold_high} = $1-$temp_margin;
}
}
}
next SENSOR unless $val; next SENSOR unless $val;
$sensor->{threshold_low} ||= ($sensor->{threshold_high}) ? $sensor->{threshold_high}-$temp_hyst : $def_temp_thres_high-$temp_hyst;
$sensor->{threshold_high} ||= $def_temp_thres_high; $sensor->{threshold_high} ||= $def_temp_thres_high;
$sensor->{threshold_low} ||= $def_temp_thres_high-$temp_hyst;
$sensor->{threshold_high} =~ s/\.0+$//; $sensor->{threshold_high} =~ s/\.0+$//;
$sensor->{threshold_low} =~ s/\.0+$//; $sensor->{threshold_low} =~ s/\.0+$//;
$sensor->{description} = $name; $sensor->{description} = $name;

Loading…
Cancel
Save