--- /dev/null
+#!/usr/bin/perl -w
+
+############################## check_pgbackup.pl ##################################
+# Version : 0.1
+# Date : September 12th, 2013
+# Author : Michael Peters <mpeters@emeralddata.net>
+# 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 <http://www.gnu.org/licenses/>.
+##################################################################################
+
+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"}
+}
+