Fix disco_filesystem

and switch to JSON module instead of manually printing (invalid) JSON data
tags/zabbix-agent-addons-0.2.20-1 0.1.23_el5
Daniel Berteaud 10 years ago
parent 5bb736fac7
commit ba5d5b558e
  1. 29
      zabbix_scripts/disco_filesystems

@ -1,9 +1,8 @@
#!/usr/bin/perl #!/usr/bin/perl
$first = 1; use JSON;
my $json;
print "{\n"; @{$json->{data}} = ();
print "\t\"data\":[\n\n";
my $cmd; my $cmd;
my $re; my $re;
@ -36,19 +35,15 @@ for (`$cmd`){
chomp($t); chomp($t);
$critical = $t if ($t =~ m/^\d+$/); $critical = $t if ($t =~ m/^\d+$/);
} }
$fsname =~ s!/!\\/!g;
print "\t,\n" if not $first;
$first = 0;
print "\t{\n"; push @{$json->{data}}, {
print "\t\t\"{#FSNAME}\":\"$fsname\",\n"; "{#FSNAME}" => $fsname,
print "\t\t\"{#FSTYPE}\":\"$fstype\"\n"; "{#FSTYPE}" => $fstype,
print "\t\t\"{#FSDEVICE}\":\"$block\"\n"; "{#FSDEVICE}" => $block,
print "\t\t\"{#FSWARNTHRES}\":\"$warning\"\n"; "{#FSWARNTHRES}" => $warning,
print "\t\t\"{#FSCRITTHRES}\":\"$critical\"\n"; "{#FSCRITTHRES}" => $critical
print "\t}\n"; };
} }
print "\n\t]\n"; print to_json($json);
print "}\n"; exit(0);

Loading…
Cancel
Save