Skip to content

Instantly share code, notes, and snippets.

@openfirmware
Created July 27, 2015 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save openfirmware/eef76ea3ce1a4fcd4c9d to your computer and use it in GitHub Desktop.
Save openfirmware/eef76ea3ce1a4fcd4c9d to your computer and use it in GitHub Desktop.
Nagios-compatible script for reporting the replag of a mod_tile tile server
#!/bin/bash -e
# check_replag Nagios plugin for monitoring mod_tile replag value
# Copyright (c) 2015
# Written by James Badger
# Released under the GNU Public 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 2 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
WARN=600
CRIT=1800
STATEFILE=/var/lib/mod_tile/.osmosis/state.txt
if [ ! -f $STATEFILE ]; then
echo "CRIT - state file not found"
exit 3
fi
repdate=$(sed -e '/^timestamp=/!d' -e 's/.*=//' -e 's/Z//' -e 's/T/Z/' -e 's/\\//' -e 's/\\//' -e q $STATEFILE)
repsec=$(date --date=$repdate +%s)
nowsec=$(date +%s)
diff=$(expr $nowsec - $repsec)
if (( $diff > $CRIT )); then
echo "CRIT - OSM replag: ${diff}s | replag=${diff}s;$WARN;$CRIT;0"
exit 2
elif (( $diff > $WARN )); then
echo "WARN - OSM replag: ${diff}s | replag=${diff}s;$WARN;$CRIT;0"
exit 1
else
echo "OK - OSM replag: ${diff}s | replag=${diff}s;$WARN;$CRIT;0"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment