check_monitored_cron

Nagios plugin to check a monitored cron

This repository provide a way to monitor the execution of a cron.

To monitor it, you have to run it with the provider launcher run_monitored_cron by prefixing the command executed by crond. Crontab example:

*/5 * * * * root /path/to/run_monitored_cron /path/to/monitored_cron [monitored cron args...]

This launcher will maintain three files named base on monitored cron basename:

  • a status file : Empty file updated on each successfully execution (Default: /run/[name].stat)
  • a PID file : Present only when the cron is running and contain the PID of the running process (Default: /run/[name].pid)
  • an errors file : Present only when error(s) occured in previous executions and contains details on this error(s) (Default: /run/[name].err)

You will able to monitor the execution of this script using the provide check_monitored_cron script:

Usage : check_monitored_cron [-D files_path_format] -n [name]
    -n [name]       Specify the name of the monitored cron
    -h          Show this help message
    -D [path]       Specify the directory where run_monitored_cron store state files (default : /run)
    -w [minutes]        Specify WARNING time in minutes for status file (default : 30)
    -c [minutes]        Specify CRITICAL time in minutes for status file (default : 120)
    -W [minutes]        Specify WARNING time in minutes for PID file (default : 5)
    -C [minutes]        Specify CRITICAL time in minutes for PID file (default : 10)

Installation

apt install awk git
git clone https://git.easter-eggs.org/brenard/check_monitored_cron.git /usr/local/src/check_monitored_cron
mkdir -p /usr/local/lib/nagios/plugins
ln -s /usr/local/src/check_monitored_cron/check_monitored_cron /usr/local/lib/nagios/plugins/
ln -s /usr/local/src/check_monitored_cron/run_monitored_cron /usr/local/bin/

Copyright

Copyright (c) 2023 Benjamin Renard

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.

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.