# HG changeset patch # User Christian Arnold # Date 1314283849 -7200 # Node ID d2456e857a473f30bedef5e63142b16df0947e7a import to mercurial diff -r 000000000000 -r d2456e857a47 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,8 @@ +syntax: glob +*.swp +debian/files +check_drbd + +syntax: regexp +(build|configure)-stamp$ +debian/nagios-plugin-drbd[./] diff -r 000000000000 -r d2456e857a47 .perltitdy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.perltitdy Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,2 @@ +--paren-tightness=2 +--square-bracket-tightness=2 diff -r 000000000000 -r d2456e857a47 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,22 @@ +SCRIPTS = check_drbd +CLEANFILES = ${SCRIPTS} +DESTDIR = +prefix = /usr + +plugindir = ${prefix}/lib/nagios/plugins/ius + +.PHONY: all clean install + +all: ${SCRIPTS} + +clean: + -rm -f ${CLEANFILES} + +install: all + install -d -m 0755 ${DESTDIR}/${plugindir} + install -m 0755 $(SCRIPTS) ${DESTDIR}/${plugindir}/ + +%: %.pl + @perl -c $< + @cp -f $< $@ + @chmod +x $@ diff -r 000000000000 -r d2456e857a47 check_drbd.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/check_drbd.pl Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,176 @@ +#! /usr/bin/perl -w + +# Copyright (C) 2011 Christian Arnold +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Christian Arnold + +use strict; +use File::Basename; +use Getopt::Long; +use Pod::Usage; + +my %ERRORS = ( + OK => 0, + WARNING => 1, + CRITICAL => 2, + UNKNOWN => 3, + DEPENDENT => 4 +); + +sub check_status($); +sub version($$); + +my $ME = basename $0; +my $NAME = 'DRBD'; +my $VERSION = "2.0"; + +my %opt = ( file => "/proc/drbd" ); + +MAIN: { + Getopt::Long::Configure('bundling'); + GetOptions( + "f|file=s" => \$opt{file}, + "h|help" => sub { pod2usage( -verbose => 1, -exitval => $ERRORS{OK} ) }, + "m|man" => sub { pod2usage( -verbose => 2, -exitval => $ERRORS{OK} ) }, + "V|version" => sub { version( $ME, $VERSION ); exit $ERRORS{OK}; } + ) or pod2usage( -verbose => 1, -exitval => $ERRORS{CRITICAL} ); + + check_status( $opt{file} ); +} + +sub check_status($) { + my $file = shift; + my ( %drbd, @warning, @critical, @ok ) = (); + + unless ( -r $file ) { + print "$NAME CRITICAL: $file $!\n"; + exit $ERRORS{CRITICAL}; + } + + open( FH, $file ) + or print "$NAME CRITICAL: $file $!\n" and exit $ERRORS{CRITICAL}; + while () { + chomp; +/^.*(?(?\d+):\s+cs:(?\S+)\s+(?:st|ro):(?\S+)\s+(?:ds|ld):(?\S+))/ + or next; + $drbd{ $+{resource} } = { + line => $+{line}, + connection_state => $+{connection_state}, + roles => $+{roles}, + disk_states => $+{disk_states} + }; + } + close(FH); + + unless (%drbd) { + print "$NAME CRITICAL: $file found, but no entries\n"; + exit $ERRORS{CRITICAL}; + } + + foreach my $dev ( map { $drbd{$_} } sort keys %drbd ) { + $dev->{state} = "CRITICAL", next + if ( $dev->{roles} ne "Primary/Secondary" ) + and ( $dev->{roles} ne "Secondary/Primary" ); + + $dev->{state} = "CRITICAL", next + if ( $dev->{disk_states} ne "UpToDate/UpToDate" ) + and ( $dev->{disk_states} ne "Consistent" ); + + $dev->{state} = "WARNING", next + if $dev->{connection_state} ne "Connected"; + + $dev->{state} = "OK"; + } + + foreach my $dev ( map { $drbd{$_} } sort keys %drbd ) { + $dev->{state} eq "WARNING" and push( @warning, $dev->{line} ), next; + $dev->{state} eq "CRITICAL" and push( @critical, $dev->{line} ), next; + $dev->{state} eq "OK" and push( @ok, $dev->{line} ), next; + } + + print("$NAME CRITICAL: @critical\n"), exit $ERRORS{CRITICAL} if @critical; + print("$NAME WARNING: @warning\n"), exit $ERRORS{WARNING} if @warning; + print("$NAME OK: @ok\n"), exit $ERRORS{OK}; +} + +sub version($$) { + my $progname = shift; + my $version = shift; + + print <<_VERSION; +$progname version $version +Copyright (C) 2011 by Christian Arnold and Schlittermann internet & unix support. + +$ME comes with ABSOLUTELY NO WARRANTY. This is free software, +and you are welcome to redistribute it under certain conditions. +See the GNU General Public Licence for details. +_VERSION +} + +__END__ + +=head1 NAME + +check_drbd - nagios plugin to check drbd status + +=head1 SYNOPSIS + +check_drbd [-f|--file path] + [-h|--help] + [-m|--man] + [-V|--version] + +=head1 OPTIONS + +=over + +=item B<-f>|B<--file> I + +Absolute path of drbd status file. (default: /proc/drbd) + +=item B<-h>|B<--help> + +Print detailed help screen. + +=item B<-m>|B<--man> + +Print manual page. + +=item B<-V>|B<--version> + +Print version information. + +=back + +=head1 DESCRIPTION + +This plugin check drbd status. + +=head1 VERSION + +This man page is current for version 2.0 of check_drbd. + +=head1 AUTHOR + +Written by Christian Arnold L + +=head1 COPYRIGHT + +Copyright (C) 2011 by Christian Arnold and Schlittermann internet & unix support. +This is free software, and you are welcome to redistribute it under certain conditions. +See the GNU General Public Licence for details. + +=cut diff -r 000000000000 -r d2456e857a47 debian/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/README Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,6 @@ +The Debian Package nagios-plugin-drbd +---------------------------- + +Comments regarding the Package + + -- Christian Arnold Thu, 25 Aug 2011 16:30:59 +0200 diff -r 000000000000 -r d2456e857a47 debian/changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/changelog Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,5 @@ +nagios-plugin-drbd (2.0) etch lenny squeeze; urgency=low + + * Initial Release. + + -- Christian Arnold Thu, 25 Aug 2011 16:30:59 +0200 diff -r 000000000000 -r d2456e857a47 debian/compat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/compat Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,1 @@ +7 diff -r 000000000000 -r d2456e857a47 debian/control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/control Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,13 @@ +Source: nagios-plugin-drbd +Section: net +Priority: extra +Maintainer: Christian Arnold +Build-Depends: debhelper (>= 7.0.50~) +Standards-Version: 3.8.4 +Homepage: + +Package: nagios-plugin-drbd +Architecture: all +Depends: ${misc:Depends}, perl-base, perl-doc +Description: nagios plugin to check drbd status + This plugin check drbd status. diff -r 000000000000 -r d2456e857a47 debian/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/copyright Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,39 @@ +This work was packaged for Debian by: + + Christian Arnold on Thu, 25 Aug 2011 16:30:59 +0200 + +It was downloaded from: + + https://keller.schlittermann.de/hg/ius/nagios/nagios-plugin-drbd/ + +Upstream Author(s): + + Christian Arnold + +Copyright: + + Copyright (C) 2011 Christian Arnold and Schlittermann internet & unix support + +License: + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +On Debian systems, the complete text of the GNU General +Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +The Debian packaging is: + + Copyright (C) 2011 Christian Arnold + +and is licensed under the GPL version 3, see above. diff -r 000000000000 -r d2456e857a47 debian/docs diff -r 000000000000 -r d2456e857a47 debian/rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/rules Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,13 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ diff -r 000000000000 -r d2456e857a47 debian/source/format --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/source/format Thu Aug 25 16:50:49 2011 +0200 @@ -0,0 +1,1 @@ +3.0 (native)