From adabe04b75e36379c9e8e28695f43c15d975a64e Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Thu, 12 Sep 2013 15:07:13 -0400 Subject: [PATCH] check_pgbackup.pl Nagios / Icinga plugin A simple Nagios / Icinga plugin to check the existance of a backup gzip generated by eg-db-backup.sh on the particular day. Includes variables to report an OK status between midnight and the time the backup can be expected to be completed running. Signed-off-by: Michael Peters --- .../src/extras/nagios/plugins/check_pgbackup.pl | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 Open-ILS/src/extras/nagios/plugins/check_pgbackup.pl diff --git a/Open-ILS/src/extras/nagios/plugins/check_pgbackup.pl b/Open-ILS/src/extras/nagios/plugins/check_pgbackup.pl new file mode 100755 index 0000000000..ad7b22836c --- /dev/null +++ b/Open-ILS/src/extras/nagios/plugins/check_pgbackup.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl -w + +############################## check_pgbackup.pl ################################## +# Version : 0.1 +# Date : September 12th, 2013 +# Author : Michael Peters +# Use : A Nagios/Icinga plugin for monitoring the existence of Evergreen PostgreSQL +# backups generated by eg-db-backup.sh (http://git.evergreen-ils.org/?p=contrib/equinox.git;a=blob;f=ESI-Examples/sys/scripts/eg-db-backup.sh) +# Licence : 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 2, 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 . +################################################################################## + +package main; +use strict; +use Getopt::Long; +use POSIX; + +#get date info +#from http://git.evergreen-ils.org/?p=contrib/equinox.git;a=blob;f=eg-stats/parse-eg-stats.pl(GPL Licensed) +my ($SEC, $MIN, $HOUR, $DAY,$MONTH,$YEAR) = (localtime(time))[0,1,2,3,4,5,6]; +$YEAR+=1900; +$MONTH++; +if ($DAY < 10) { + $DAY = "0".$DAY; +} +if ($MONTH < 10) { + $MONTH = "0".$MONTH; +} + +my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); + +#### +# Prevent Nagios messages when backups haven't yet been run for the day. +# If the time(s) of the backup cronjob(s) are modified, or different from those +# below, adjust the values below accordingly. +### +if ( ( $HOUR == 0 && $MIN > 0 ) || ($HOUR == 8 && $MIN < 30 ) ) + { + exit $ERRORS{"OK"}; + } + +###### Check that backup snapshot gzip file for today exists ###### + +# adjust to be the output location of your eg-db-backup.sh backup gzips +my $file = "/var/dbBackups/killeen-postgres-backup-$YEAR-$MONTH-$DAY.cpio.gz"; + +if (-e $file) { + print "File " . $file . " exists."; + exit $ERRORS{"OK"} +} +else { + print "File " . $file . " does not exist."; + exit $ERRORS{"CRITICAL"} +} +if (! -e $file) { + print "File " . $file . " does not exist."; + exit $ERRORS{"OK"} +} +else { + print "File " . $file . " exists."; + exit $ERRORS{"CRITICAL"} +} + -- 2.11.0