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.
 
 

49 lines
1.0 KiB

#!/usr/bin/perl
use JSON;
my $json;
@{$json->{data}} = ();
my $cmd;
my $re;
# On Linux, parse /proc/mounts
if (-e "/proc/mounts"){
$cmd = 'cat /proc/mounts';
$re = qr/(\S+) (\S+) (\S+)/;
}
# On BSD (at least pfsense), there's no /proc/mounts
# parse the mount output
else{
$cmd = '/sbin/mount';
$re = qr/(\S+) on (\S+) \((\S+), /;
}
for (`$cmd`){
($block, $fsname, $fstype) = m/$re/;
# Default warning and critical level (%)
my $warning = 85;
my $critical = 95;
my $t;
if (open WARN, "$fsname/.zbx_warning"){
$t = join "", <WARN>;
close WARN;
chomp($t);
$warning = $t if ($t =~ m/^\d+$/);
}
if (open CRIT, "$fsname/.zbx_critical"){
$t = join "", <CRIT>;
close CRIT;
chomp($t);
$critical = $t if ($t =~ m/^\d+$/);
}
push @{$json->{data}}, {
"{#FSNAME}" => $fsname,
"{#FSTYPE}" => $fstype,
"{#FSDEVICE}" => $block,
"{#FSWARNTHRES}" => $warning,
"{#FSCRITTHRES}" => $critical
};
}
print to_json($json);
exit(0);