# HG changeset patch # User Christian Arnold # Date 1299247632 -3600 # Node ID 331e5c3fd9d69383ca8c949cce7b94820179925e import to mercurial diff -r 000000000000 -r 331e5c3fd9d6 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,8 @@ +syntax: glob +*.swp +debian/files +check_rsnapshot + +syntax: regexp +(build|configure)-stamp$ +debian/nagios-plugin-rsnapshot[./] diff -r 000000000000 -r 331e5c3fd9d6 .perltitdy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.perltitdy Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,2 @@ +--paren-tightness=2 +--square-bracket-tightness=2 diff -r 000000000000 -r 331e5c3fd9d6 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,22 @@ +SCRIPTS = check_rsnapshot +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 331e5c3fd9d6 check_rsnapshot.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/check_rsnapshot.pl Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,150 @@ +#! /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 Date::Manip; +use Pod::Usage; +use if $ENV{DEBUG} => "Smart::Comments"; + +my %ERRORS = ( + OK => 0, + WARNING => 1, + CRITICAL => 2, + UNKNOWN => 3, + DEPENDENT => 4 +); + +sub get_status($); +sub report($); +sub version($$); + +my $ME = basename $0; +my $VERSION = "2.0"; + +my %opt = ( + binary => "/usr/bin/rsnapshot", + logfile => "/var/log/rsnapshot.log" +); + +MAIN: { + Getopt::Long::Configure('bundling'); + GetOptions( + "b|binary=s" => \$opt{binary}, + "l|logfile=s" => \$opt{logfile}, + "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} ); + + unless ( -x $opt{binary} ) { + print + "RSNAPSHOT CRITICAL: $opt{binary} - not found or not executable\n"; + exit $ERRORS{CRITICAL}; + } + + my $status = get_status( $opt{logfile} ); + report($status); +} + +sub get_status($) { + my $logfile = shift; + my $date = UnixDate( ParseDate("today"), "%d/%b/%Y" ); + my ( $found, $error ) = undef; + + open( FH, $logfile ) + or print "RSNAPSHOT CRITICAL: $logfile - $!\n" and exit $ERRORS{CRITICAL}; + while () { + unless ($found) { + /^\[$date:.*ERROR/ or next; + $found = 1; + $error = $_; + last; + } + } + close(FH); + + if ($found) { + print "RSNAPSHOT CRITICAL: $error\n"; + exit $ERRORS{CRITICAL}; + } + else { + print "RSNAPSHOT OK: no errors in $logfile\n"; + exit $ERRORS{OK}; + } +} + +=head1 NAME + +check_rsnapshot - nagios plugin to check for errors on rsnapshot logfile + +=head1 SYNOPSIS + +check_release [-b|--binary string] + [-l|--logfile string] + [-h|--help] + [-m|--man] + [-V|--version] + +=head1 OPTIONS + +=over + +=item B<-b>|B<--binary> I + +rsnapshot binary (default: /usr/bin/rsnapshot) + +=item B<-l>|B<--logfile> I + +rsnapshot logfile (default: /var/log/rsnapshot.log) + +=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 checks rsnapshot logfile for errors. + +=head1 VERSION + +This man page is current for version 2.0 of check_rsnapshot. + +=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 331e5c3fd9d6 debian/changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/changelog Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,12 @@ +nagios-plugin-rsnapshot (2.0) stable; urgency=low + + * now new code style + + -- Christian Arnold Fri, 04 Mar 2011 15:05:45 +0100 + +nagios-plugin-rsnapshot (1.0-1) stable; urgency=low + + * Initial release + + -- Christian Arnold Tue, 11 Nov 2008 10:49:16 +0100 + diff -r 000000000000 -r 331e5c3fd9d6 debian/compat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/compat Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,1 @@ +7 diff -r 000000000000 -r 331e5c3fd9d6 debian/control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/control Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,13 @@ +Source: nagios-plugin-rsnapshot +Section: net +Priority: extra +Maintainer: Christian Arnold +Build-Depends: debhelper (>= 7) +Standards-Version: 3.7.3 + +Package: nagios-plugin-rsnapshot +Architecture: all +Depends: perl-base, perl-doc, libdate-manip-perl +Suggests: libsmart-comments-perl +Description: nagios plugin to check rsnapshot + This is a nagios plugin to check rsnapshot logfile. diff -r 000000000000 -r 331e5c3fd9d6 debian/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/copyright Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,31 @@ +It was downloaded from https://keller.schlittermann.de/hg/ius/nagios/nagios-plugin-rsnapshot/ + +Upstream Author(s): + + Christian Arnold + +Copyright: + + + +License: + + This package 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 2 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2011, Christian Arnold and +is licensed under the GPL, see above. diff -r 000000000000 -r 331e5c3fd9d6 debian/dirs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/dirs Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff -r 000000000000 -r 331e5c3fd9d6 debian/docs diff -r 000000000000 -r 331e5c3fd9d6 debian/rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/rules Fri Mar 04 15:07:12 2011 +0100 @@ -0,0 +1,91 @@ +#!/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 + + + + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/nagios-plugin-rsnapshot.sgml > nagios-plugin-rsnapshot.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/nagios-plugin-rsnapshot. + $(MAKE) DESTDIR=$(CURDIR)/debian/nagios-plugin-rsnapshot install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure