Add basic scripts to monitor VDO volumes

tags/zabbix-agent-addons-0.2.75-1
Daniel Berteaud 6 years ago
parent 8f69d132e8
commit 6c012aece0
  1. 12
      zabbix_conf/vdo.conf
  2. 45
      zabbix_scripts/check_vdo_sudo
  3. 31
      zabbix_scripts/disco_vdo_sudo

@ -0,0 +1,12 @@
# Discover VDO volumes
# $1 not used for now
UserParameter=vfs.vdo.vol.discovery[*],/var/lib/zabbix/bin/disco_zfs --what=volumes
# Type: Agent or Agent (active)
# Key: vfs.vdo.vol[volume,item] where volume is the name of the volume to monitor
# item can be one of the valid keys (run manually without --value arg to see available keys)
UserParameter=vfs.vdo.vol[*],/var/lib/zabbix/bin/check_vdo_sudo --volume=$1 --value=$2
# Type: Agent or Agent (active)
# You can also get all the info about a vdo volume at once, in JSON
UserParameter=vfs.vdo.vol.all[*],/var/lib/zabbix/bin/check_vdo_sudo --volume=$1

@ -0,0 +1,45 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use JSON;
use Getopt::Long;
use File::Which;
my $vdostats = which('vdostats');
my $json = {};
my $pretty = 0;
my $volume = undef;
my $val = undef;
GetOptions(
'volume=s' => \$volume,
'value=s' => \$val,
'pretty' => \$pretty
);
if ($volume) {
if ($volume !~ m/^\w+$/){
die "Invalide volume name\n";
}
foreach my $line (qx($vdostats --all $volume)){
if ($line =~ m/^\s+([^:]+)\s+:\s+([\d\w]+)/){
my ($key,$val) = ($1,$2);
# Cleanup key
$key =~ s/\s+$//;
$key =~ s/\s+/_/g;
$key =~ s/\(|\)//g;
$key =~ s/%/pct/g;
$json->{lc $key} = $val;
}
}
} else {
print 'ZBX_NOTSUPPORTED';
exit 0;
}
if (defined $val) {
print $json->{$val} || 'ZBX_NOTSUPPORTED';
} else {
print to_json($json, { pretty => $pretty });
}
print "\n";

@ -0,0 +1,31 @@
#!/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";
Loading…
Cancel
Save