Page 1 of 1

Monitoring Cron jobs

Posted: Fri Mar 23, 2018 3:14 am
by inas.labib
Hi Team,

We are using nagios 5.2.2

I would like to know how can we monitor cron jobs ran by oracle user in a particular time interval like between 8am and 11am. I believe this can be done with exit code results. i would like to know how this can be achieved and is there any plugin available.

Your suggestions would be helpful

Re: Monitoring Cron jobs

Posted: Fri Mar 23, 2018 11:57 am
by npolovenko
Hello, @inas.labib. Looks like someone wrote a plugin for that:

Code: Select all

https://github.com/bbuchalter/check_exit_code
And here's the manual on how to set it up:

Code: Select all

https://arkit.co.in/monitor-cronjob-execution-status-using-nagios/
between 8am and 11am
This is more than 24 hours. Did you mean to say 11 pm? Either way, consider creating a custom time period for this check:
Untitled.png
Untitled1.png
Now, as far as filtering out
cron jobs ran by oracle user
Consider this example:

Code: Select all

2>&1 > /var/log/cronjobname.log; echo "Exit code: $?" >> /var/log/cronjobname.log
You'd open the crontab and find all the crons that are supposed to be run by the oracle user. Then you change:

Code: Select all

>> /var/log/cronjobname.log
To some other file that is going to be dedicated to the Oracle entries:

Code: Select all

>> /var/log/oracleentries.log
Also, add:
echo "Exit code: $?"
To the each oracle cron.

Finally, run the plugin with:

Code: Select all

-f /var/log/oracleentries.log
That should do it.