zabbix-agent-addons/zabbix_scripts/disco_sensors
2013-04-16 13:15:34 +02:00

22 lines
515 B
Perl

#!/usr/bin/perl -w
use JSON;
my $json;
open SENSORS, ('</etc/zabbix/sensors.conf') ||
die "Couldn't open /etc/zabbix/sensors.conf: $!\n";
foreach (<SENSORS>){
next unless (/^(\w+)(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)$/);
my ($sensor,$threshigh,$threslow) = ($1,$5,$6);
push @{$json->{data}}, {
"{#SENSORNAME}" => $sensor,
"{#SENSORTHRESHIGH}" => $threshigh,
"{#SENSORTHRESLOW}" => $threslow
};
}
close SENSORS;
print to_json($json) if (defined $json->{data});
exit(0);