Skip to content

Instantly share code, notes, and snippets.

@pfigue
Created July 6, 2012 15:53
Show Gist options
  • Save pfigue/3061023 to your computer and use it in GitHub Desktop.
Save pfigue/3061023 to your computer and use it in GitHub Desktop.
Icinga Plugin to monitor if cron is alive
#!/bin/bash
# Determine if cron is running
# Comes from https://gist.github.com/3061023
UNKNOWN_STATE=3
CRITICAL_STATE=2
WARNING_STATE=1
OK_STATE=0
CAT=/bin/cat
GREP=/bin/grep
TAIL=/usr/bin/tail
PS=/bin/ps
$PS aux | $GREP 'cron$' | $GREP -v grep
if [ $? == 0 ]; then
echo "[$(date)] cron is alive!"
exit ${OK_STATE}
else
echo "[$(date)] Cron is not there :'("
echo "[$(date)] /proc/loadavg: $(cat /proc/loadavg)"
echo "[$(date)] looking for OOM killer victims... (only 15 results, if any)"
$GREP -i 'killed process' /var/log/*.log | $TAIL -n 15
echo "[$(date)] finished listing of OOM killer victims"
exit ${CRITICAL_STATE}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment