Minor simplification in sensors generator

tags/zabbix-agent-addons-0.2.20-1
Daniel Berteaud 9 years ago
parent 39038b97c7
commit 20b5b3aaa6
  1. 6
      zabbix_scripts/util_generate_sensors_ini

@ -214,7 +214,7 @@ if ($smartctl && -x $smartctl){
next if ($? != 0); next if ($? != 0);
foreach my $l (@lines){ foreach my $l (@lines){
if ($l =~ /Temperature_Celsius/){ if ($l =~ /Temperature_Celsius/){
my $sensor = { $sensors->{$block} = {
description => "$block temperature", description => "$block temperature",
threshold_low => $def_temp_thres_high-$temp_hd_hyst, threshold_low => $def_temp_thres_high-$temp_hd_hyst,
threshold_high => $def_temp_thres_high, threshold_high => $def_temp_thres_high,
@ -222,7 +222,6 @@ if ($smartctl && -x $smartctl){
unit => '°C', unit => '°C',
cmd => "$smartctl -A /dev/$block | grep Temperature_Celsius | awk '{print \$10}'" cmd => "$smartctl -A /dev/$block | grep Temperature_Celsius | awk '{print \$10}'"
}; };
$sensors->{$block} = $sensor;
print "Found a temperature sensor using smartctl: $block\n"; print "Found a temperature sensor using smartctl: $block\n";
last; last;
} }
@ -236,7 +235,7 @@ if ($smartctl && -x $smartctl){
next if ($? != 0); next if ($? != 0);
foreach my $l (@res){ foreach my $l (@res){
if ($l =~ m/Drive\sTrip\sTemperature:\s+(\d+)\s/){ if ($l =~ m/Drive\sTrip\sTemperature:\s+(\d+)\s/){
my $sensor = { $sensors->{'sda-' . $i} = {
description => "Temperature for disk No $i on sda", description => "Temperature for disk No $i on sda",
type => 'temp', type => 'temp',
threshold_high => $1-$temp_hd_margin, threshold_high => $1-$temp_hd_margin,
@ -244,7 +243,6 @@ if ($smartctl && -x $smartctl){
unit => '°C', unit => '°C',
cmd => "$smartctl -A -d megaraid,$i /dev/sda | grep 'Current Drive Temperature' | awk '{print \$4}'" cmd => "$smartctl -A -d megaraid,$i /dev/sda | grep 'Current Drive Temperature' | awk '{print \$4}'"
}; };
$sensors->{'sda-' . $i} = $sensor;
print "Found a temperature sensor using smartctl (megaraid): sda-$i\n"; print "Found a temperature sensor using smartctl (megaraid): sda-$i\n";
} }
} }

Loading…
Cancel
Save