Support retrieving sensors thresholds and fix sensors conf

tags/zabbix-agent-addons-0.2.20-1
Daniel Berteaud 12 years ago
parent 105b0d2d82
commit 9980952270
  1. 2
      zabbix_conf/sensors.conf
  2. 29
      zabbix_scripts/check_sensors_sudo

@ -3,4 +3,4 @@
UserParameter=hardware.sensor.discovery,/var/lib/zabbix/bin/disco_sensors UserParameter=hardware.sensor.discovery,/var/lib/zabbix/bin/disco_sensors
# Sensors # Sensors
UserParameter=hardware.sensor[*],/usr/bin/sudo /var/lib/zabbix/bin/check_sensors $1 UserParameter=hardware.sensor[*],/usr/bin/sudo /var/lib/zabbix/bin/check_sensors_sudo $1 $2

@ -1,13 +1,10 @@
#!/usr/bin/perl -w #!/usr/bin/perl -w
my $what = $ARGV[0]; my $what = $ARGV[0];
my $thres = $ARGV[1];
unless (defined $what){ unless (defined $what){
print <<"EOF"; usage();
Usage: $0 sensor_name
EOF
exit(1); exit(1);
} }
@ -19,7 +16,29 @@ my $ret = 'ZBX_NOTSUPPORTED';
foreach (<SENSORS>){ foreach (<SENSORS>){
next unless (/^$what(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/); next unless (/^$what(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/);
my $cmd = $3; my $cmd = $3;
my $high = $4;
my $low = $5;
if (!defined $thres){
$ret = `$cmd`; $ret = `$cmd`;
}
elsif ($thres eq 'high'){
$ret = $high
}
elsif ($thres eq 'low'){
$ret = $low;
}
else {
usage();
exit(1);
}
} }
print $ret; print $ret;
exit(0); exit(0);
sub usage {
print <<"EOF";
Usage: $0 sensor_name [high|low]
EOF
}

Loading…
Cancel
Save