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.
55 lines
1.2 KiB
55 lines
1.2 KiB
12 years ago
|
#!/usr/bin/perl
|
||
|
|
||
|
$first = 1;
|
||
|
|
||
|
print "{\n";
|
||
|
print "\t\"data\":[\n\n";
|
||
|
|
||
|
my $cmd;
|
||
|
my $re;
|
||
|
# On Linux, parse /proc/mounts
|
||
|
if (-e "/proc/mounts"){
|
||
|
$cmd = 'cat /proc/mounts';
|
||
12 years ago
|
$re = qr/(\S+) (\S+) (\S+)/;
|
||
12 years ago
|
}
|
||
|
# On BSD (at least pfsense), there's no /proc/mounts
|
||
|
# parse the mount output
|
||
|
else{
|
||
|
$cmd = '/sbin/mount';
|
||
12 years ago
|
$re = qr/(\S+) on (\S+) \((\S+), /;
|
||
12 years ago
|
}
|
||
|
for (`$cmd`){
|
||
12 years ago
|
($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+$/);
|
||
|
}
|
||
12 years ago
|
$fsname =~ s!/!\\/!g;
|
||
|
|
||
|
print "\t,\n" if not $first;
|
||
|
$first = 0;
|
||
|
|
||
|
print "\t{\n";
|
||
|
print "\t\t\"{#FSNAME}\":\"$fsname\",\n";
|
||
|
print "\t\t\"{#FSTYPE}\":\"$fstype\"\n";
|
||
12 years ago
|
print "\t\t\"{#FSDEVICE}\":\"$block\"\n";
|
||
|
print "\t\t\"{#FSWARNTHRES}\":\"$warning\"\n";
|
||
|
print "\t\t\"{#FSCRITTHRES}\":\"$critical\"\n";
|
||
12 years ago
|
print "\t}\n";
|
||
|
}
|
||
|
|
||
|
print "\n\t]\n";
|
||
|
print "}\n";
|