Add simple scripts for monitoring DRBD resources

with auto-discovery
tags/zabbix-agent-addons-0.2.20-1 0.2.6_el5
Daniel Berteaud 9 years ago
parent 7cbbe74685
commit 2893a84635
  1. 6
      zabbix_conf/drbd.conf
  2. 46
      zabbix_scripts/check_drbd
  3. 26
      zabbix_scripts/disco_drbd

@ -0,0 +1,6 @@
# Discover DRBD resources
UserParameter=drbd.resource.discovery[*],/var/lib/zabbix/bin/disco_drbd
# DRBD status
UserParameter=drbd.resource.status[*],/var/lib/zabbix/bin/check_drbd --resource=$1 --what=$2

@ -0,0 +1,46 @@
#!/usr/bin/perl -w
use strict;
use File::Which;
use Getopt::Long;
my $what = 'cstate';
my $resource = undef;
my @supported = qw(cstate dstate role);
GetOptions(
"what=s" => \$what,
"resource=s" => \$resource
);
my $drbdadm = which('drbdadm');
unless($drbdadm){
die 'ZBX_NOTSUPPORTED';
}
sub usage(){
my $supp = join('|', @supported);
print <<"EOF";
usage: $0 --what=[$supp] --resource=<drbd resource name>
EOF
}
unless ((grep { $_ eq $what } @supported) && $resource){
usage();
exit 1;
}
open RES, '-|', $drbdadm, $what, $resource || die "Can't open pipe: $!";
my $out = join "", <RES>;
close RES || die "An error occured: $!\n";
chomp($out);
# We only want the state of the local node
if ($out =~ m{(.*)/.*}){
$out = $1;
}
print $out;
exit 0;

@ -0,0 +1,26 @@
#!/usr/bin/perl -w
use warnings;
use strict;
use File::Which;
use JSON;
my $json;
@{$json->{data}} = ();
my $drbdoverview = which('drbd-overview');
if ($drbdoverview){
open RES, "$drbdoverview |" || die "Couldn't execute $drbdoverview";
foreach my $l (<RES>){
if ($l =~ m{(\d+):(\w+)/\d+}){
push @{$json->{data}}, {
"{#DRBD_RES_ID}" => $1,
"{#DRBD_RES_NAME}" => $2
};
}
}
close RES;
}
print to_json($json);
exit(0);
Loading…
Cancel
Save