zabbix-agent-addons/zabbix_scripts/disco_vdo_sudo
2019-05-21 11:57:45 +02:00

32 lines
501 B
Perl

#!/usr/bin/perl -w
use strict;
use warnings;
use JSON;
use File::Which;
use Getopt::Long;
my $json;
@{$json->{data}} = ();
my $what = 'volumes';
my $pretty = 0;
GetOptions(
'what=s' => \$what,
'pretty' => \$pretty
);
my $vdostats = which('vdostats');
if (defined $vdostats) {
foreach my $line (qx($vdostats)) {
if ($line =~ m|^/dev/mapper/([^\s]+)|) {
push @{$json->{data}}, {
'{#VDO_VOL}' => $1
};
}
}
}
print to_json($json, { pretty => $pretty }) . "\n";