Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_drbd

Rating
12 votes
Favoured:
3
Hits
171517
Files:
FileDescription
check_drbd-0.5.2check_drbd v0.5.2
check_drbd-0.5.1check_drbd v0.5.1
check_drbdcheck_drbd v0.5.3
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Checks the state of DRBD devices
+++ Usage:
check_drbd [-d ] [-e expect] [-p proc] [-r role] [-o states] [-w states] [-c states] [--debug]
Options:
-d STRING [default: 0. Example: 0,1,2 ]
-p STRING [default: /proc/drbd. Use '-' for stdin]
-e STRING [Must be this connected state. Example: Connected]
-r STRING [Must be this node state. Example: Primary]
-o STRING [Change value to OK. Example: StandAlone]
-w STRING [Change value to WARNING. Example: SyncingAll]
-c STRING [Change value to CRITICAL. Example: Inconsistent,WFConnection]

+++ Example Output:
DRBD OK: Device 0 Primary Connected Consistent
+++ Notes:
* Version 0.5.x should work with DRBD 0.6, 0.7, 8.0, 8.2, and 8.3
* All versions require perl.
* If DRBD is running on remote host, plugin may require check_by_ssh, nrpe, or nsca.
* Use the --debug option to understand what effects the options have.

+++ ChangeLog:
++++ 0.5.3
* Added support for drbd 8.3 connection states
++++ 0.5.2
* Added support for drbd 8.2 connection states (patch from Norbert Tretkowski)
++++ 0.5.1
* Added support for monitoring multiple devices at once
++++ 0.5
* Added support for drbd 8.0
++++ 0.4.1
* Code cleanup, no new features
+++ Copyright
by Brandon Lee Poyner bpoyner / CCAC.edu
Reviews (8)
bymirQ, December 29, 2014
As other users have posted here, there is a bug in this script when use drbd version 8.4.

The output field identifier for role of node has changed in drbd version 8.3.
See: http://drbd.linbit.com/users-guide-8.3/ch-admin.html#id1369474

To use the script in version 8.3+, the role identifier needs to be changed from "st" to "ro".

Apply this patch:

--- check_drbd.orig 2014-12-29 18:03:37.000000000 +0100
+++ check_drbd 2014-12-29 18:03:59.000000000 +0100
@@ -217,7 +217,7 @@
if (/^s?(d+):.* cs:(w+)/) {
$cs{$1} = $2;
}
- if (/^s?(d+):.* st:(w+)//) {
+ if (/^s?(d+):.* ro:(w+)//) {
$st{$1} = $2;
}
if (/^s?(d+):.* ld:(w+)/) {

Can you fix it?

Regards
mirQ
The comparison of the local role and the expected role, with parameter "-r", doesn't work for me. It doesn't matter, which role were set with "-r", the result is always the same:

DRBD OK: Device 1 Connected UpToDate

The "--debug"-parameter shows maybe the bug. The expected role, set with "-r", were set in variable "DRBD Role", not in "DRBD Expect". The variable "DRBD Role" should contain the local Role and the Variable "DRBD Expect" the expected one, right?

So, is there a correction needed? Has someone another result?
--- /tmp/check_drbd.orig 2014-03-03 01:35:53.000000000 +0400
+++ check_drbd 2014-03-03 08:54:59.897998487 +0400
@@ -12,7 +12,7 @@
my $drbd_proc='/proc/drbd';
my $drbd_devices=0;
my ($drbd_expect, $drbd_role, $drbd_version, $debug_mode);
-my (%options, %cs, %st, %ld, %ds, %check, %warning, %critical);
+my (%options, %cs, %st, %ld, %ds, %oos, %check, %warning, %critical);

my $prog_name=basename($0);
my $prog_revision='0.5.3';
@@ -210,10 +210,17 @@
} else {
$input = "STDIN";
}
+ my $devnum;
while() {
if (/^version: (\d+).(\d+)/) {
$drbd_version = "$1.$2";
}
+ if (/^\s?(\d+):.*/) {
+ $devnum = $1;
+ }
+ if (defined($devnum) and /\soos:(\d+)/) {
+ $oos{$devnum} = $1;
+ }
if (/^\s?(\d+):.* cs:(\w+)/) {
$cs{$1} = $2;
}
@@ -248,11 +255,11 @@
#
my @devices;
if ($drbd_devices =~ /^all$/i) {
- for my $device ( keys %cs ) {
+ for my $device ( sort keys %cs ) {
push(@devices,$device);
}
} elsif ($drbd_devices =~ /^configured$/i) {
- for my $device ( keys %cs ) {
+ for my $device ( sort keys %cs ) {
next if ($cs{$device} eq "Unconfigured");
push(@devices,$device);
}
@@ -264,6 +271,9 @@
&myexit('UNKNOWN',"Could not find device $device");
}
$check{$device} = 1;
+ if (defined($oos{$device}) and $oos{$device} > 0) {
+ &myexit('WARNING',"Out of sync on device $device: $oos{$device} sectors");
+ }
}
if (int(keys %check) == 0) {
&myexit('UNKNOWN',"No configured devices found");
byhostingnuggets, November 13, 2013
This plugin crucially misses the option "-d all" to check all the DRBD devices from the /proc/drbd file. Having to manually adapt which devices to check for each node/server is annoying.
byjanfai, October 22, 2013
I have four resources and following command is doing it's excellent job.

check_drbd -d 1,2,3,4 -r Primary -o Primary -w StandAlone -c WFConnection
bymmarodin, April 19, 2012
When will be released checker for DRBD 8.4.x release?
Thanks, bye!
Morgan
bypbr, August 4, 2010
Hello,

thanks for the nice script. I use it to monitor a primary/primary device in a XenServer Cluster.


Here my solution to a bug I had using drbd82-8.2.6-1.el5.centos Package from the CentOS Repository:

The state in /proc/drbd is defined as "ro:" and not as "st:" as the script expects. I added the following lines to subroutine "parse_proc" within the while loop:

if (/^s?(d+):.* ro:(w+)//) {
$st{$1} = $2;
}

Works perfect! Best regards,

pbr
bygmastap, July 14, 2010
1 of 1 people found this review helpful
Hello,

I really like this plugin. It is easy to use and the syntax is very well written. But I can not use it on DRBD 8.3.

The Plugin does not show the correct role. A short look and I realized that the plugin does not use the correct pattern. To detect if a DRBD volume is Primary or Secondary the "old" "st:" string is checked. but this string does not exists anymore.

Theifore I just changed in line 213 from:
if (/^s?(d+):.* st:(w+)//) {

to

if (/^s?(d+):.* ro:(w+)//) {

Now as far as I can see it works perfectly with version 0.8.3

Best Regards,
Phil