Additional scripts for Zabbix agent on Linux to discover and monitor several services
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

41 lines
896 B

#!/usr/bin/perl -w
use Config::Simple;
use Getopt::Long;
use JSON;
my $type = 'temp';
GetOptions(
"type:s" => \$type
);
# empty means temp
$type = ($type eq '') ? 'temp' : $type;
my $json;
@{$json->{data}} = ();
my $cfg = new Config::Simple;
$cfg->read('/etc/zabbix/sensors.ini');
$cfg->syntax('ini');
my %sensors = ();
foreach my $k (keys %{$cfg->vars}){
$k =~ s/\..*$//;
$sensors{$k} = 1 unless $sensors{$k};
}
foreach my $k (keys %sensors){
my $sensor = $cfg->get_block($k);
next if ($type ne 'all' && $type ne $sensor->{type});
push @{$json->{data}}, {
"{#SENSORNAME}" => $k,
"{#SENSORDESC}" => $sensor->{description},
"{#SENSORTHRESHIGH}" => $sensor->{threshold_high},
"{#SENSORTHRESLOW}" => $sensor->{threshold_low},
"{#SENSORTYPE}" => $sensor->{type},
"{#SENSORUNIT}" => $sensor->{unit}
};
}
print to_json($json);
exit(0);