Linux

check_drbd

Description:

Checks the state of DRBD devices

Current Version

Last Release Date

June 16, 2009

Compatible With


Project Files
Project Notes
+++ 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) Add a Review
Bug in drbd version >8.3
by mirQ, December 31, 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



Checking for local Role failes
by drbd_nagios_user, April 30, 2014

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?



Check for out of sync small patch
by giner, March 31, 2014

--- /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");



"-d all" option?
by hostingnuggets, November 30, 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.



Working like a charm
by janfai, October 31, 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



8.4
by mmarodin, April 30, 2012

When will be released checker for DRBD 8.4.x release? Thanks, bye! Morgan



Thanks!
by pbr, August 31, 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



good but not perfect
by gmastap, July 31, 2010

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



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.3 (12)
Favorites
3
Views
171,369