From 376db5167c60ed465b4f4c8ed1f67a56f6e8d74e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 22 Jan 2020 14:27:57 +0100 Subject: [PATCH] Use head -1 to be sure to get a single value for sensors Some can report 2 values, and Zabbix won't be able to parse it --- zabbix_scripts/util_generate_sensors_ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zabbix_scripts/util_generate_sensors_ini b/zabbix_scripts/util_generate_sensors_ini index 8c80c80..bde08f2 100755 --- a/zabbix_scripts/util_generate_sensors_ini +++ b/zabbix_scripts/util_generate_sensors_ini @@ -124,7 +124,7 @@ if ($ipmitool && -x $ipmitool){ $sensor->{description} = $name; $sensor->{type} = 'temp'; $sensor->{unit} = '°C'; - $sensor->{cmd} = "$ipmitool sdr get '$name' | grep 'Sensor Reading' | awk '{print \$4}'"; + $sensor->{cmd} = "$ipmitool sdr get '$name' | grep 'Sensor Reading' | awk '{print \$4}' | head -1"; my $id = sensor_name($name); $sensors->{$id} = $sensor; print "Found a temperature sensor using IPMI: $name\n"; @@ -174,7 +174,7 @@ if ($ipmitool && -x $ipmitool){ $sensor->{description} = $name; $sensor->{type} = 'fan'; $sensor->{unit} = ($value =~ m/percent|%/ || $val < 100) ? '%' : 'rpm'; - $sensor->{cmd} = "$ipmitool sdr get '$name' | grep 'Sensor Reading' | awk '{print \$4}'"; + $sensor->{cmd} = "$ipmitool sdr get '$name' | grep 'Sensor Reading' | awk '{print \$4}' | head -1"; my $id = sensor_name($name); $sensors->{$id} = $sensor; print "Found a fan sensor using IPMI: $name\n"; @@ -224,7 +224,7 @@ if ($ipmitool && -x $ipmitool){ $sensor->{description} = $name; $sensor->{type} = 'power'; $sensor->{unit} = ($name =~ m/%/) ? '%' : 'Watt'; - $sensor->{cmd} = "$ipmitool sdr get '$name' | grep 'Sensor Reading' | awk '{print \$4}'"; + $sensor->{cmd} = "$ipmitool sdr get '$name' | grep 'Sensor Reading' | awk '{print \$4}' | head -1"; my $id = sensor_name($name); $sensors->{$id} = $sensor; print "Found a power sensor using IPMI: $name\n"; @@ -271,7 +271,7 @@ if ($lmsensor && -x $lmsensor){ $sensor->{description} = $name; $sensor->{type} = 'temp'; $sensor->{unit} = '°C'; - $sensor->{cmd} = "$lmsensor | grep '$name:' | cut -d+ -f2 | cut -d. -f1"; + $sensor->{cmd} = "$lmsensor | grep '$name:' | cut -d+ -f2 | cut -d. -f1 | head -1"; my $id = sensor_name($name); $sensors->{$id} = $sensor; print "Found a temperature sensor using lm_sensors: $name\n";