Monitor Cron job schedule failures/errors

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
vignesha
Posts: 115
Joined: Wed Oct 03, 2018 9:09 am

Monitor Cron job schedule failures/errors

Post by vignesha »

Hi Team,

There is one new requirement where we need to monitor the Cron job Schedule failures/errors which will be running on the Linux server.
How can we configure alerting on Nagios tool on this requirement. Can we achieve this?

Need your assistance here for the configuration.

Thanks in Advance!!!
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Monitor Cron job schedule failures/errors

Post by pbroste »

Hello @vignesha

Thanks for reaching out, understand that you want to monitor the exit codes on cron jobs.

There appears to be a "Monitoring Cronjob Exit Codes With Nagios" plugin that will work for your needs. Please take a look and let us know if you need anything further assistance.

Thanks,
Perry
vignesha
Posts: 115
Joined: Wed Oct 03, 2018 9:09 am

Re: Monitor Cron job schedule failures/errors

Post by vignesha »

Hi Team,
Please find below my requirement.

Script name: xxxx.sh (transfer encryption compress delete)
Script type: bash
Script location: /home/UHLI0DE/xxxx.sh
Cron: currently scheduled to execute at 04:05 BST everyday (we can change)
Source location: /data/catchall
Target location: /data/backups/ (we can change)
Source log Retention: 7 days
Target compression Retention: 90 days

Description :

1. Script finds *.log file from /data/catchall/ with more than 7 days and transfer them into /data/backups/ along with their parent directory.
2. If succeed step one, then It will delete *.log file from /data/catchall/ with more than 7 days.
3. Next it will find all *.log file from /data/backups/ and encrypt them as own filename.asc (*.log.asc) and will be stored in /data/backups/
4. Next it will find all *.log.asc file from /data/backups/ and compress them as Encrypted_todaydate.tar.gz and will be stored in /data/backups/
5. Then script will remove all *.log and *.log.asc files from /data/backups/
6. Next script will find all file from /data/backups/ with more than 90 days and delete them.
7. Step 1 to 6 all commands output and execution status are stored in separate log /var/log/Boobalan/date.log (we can change) and this log will be kept for 90 days.


As above mentioned, the script will perform the following activities and at the end all the logs are recorded as per the step 7.
How we can achieve in order to perform monitoring on this job schedule.
Here one concern is the log file will create dynamically daily with the format datexx-xxx-xx.log.
Do we have any mechanism to check daily that dynamic log is created and also to check some context in the log file. So that based on that we can trigger alert.

Please assist how can we achieve this monitoring in Nagios ?
Thanks in Advance!!!
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Monitor Cron job schedule failures/errors

Post by pbroste »

Hello @vignesha

Thanks for following and outlining the details.

The option to create a file check to see if the file was created and exists in the log directory. For example, using a plugin like "check_file_sha256.pl" (there are others) setting to check with the following options:

  • -f --file File to check
  • -n --no-compare Do not expect a checksum or compare to it (otherwise raises unknown if an expected checksum is not given)
[/icode]

Would not necessarily want to use the switch -c (c --checksum Checksum value to expect), as we don't necessarily know what the checksum value to expect.

Thanks,
Perry
Locked