Bug 12902 - Cronjob monitoring script, nagios3 compatible
Summary: Cronjob monitoring script, nagios3 compatible
Status: RESOLVED WONTFIX
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Olli-Antti Kivilahti
QA Contact: Galen Charlton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-10 14:41 UTC by Olli-Antti Kivilahti
Modified: 2023-07-15 21:15 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
initial patch (20.36 KB, patch)
2014-09-10 14:41 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Olli-Antti Kivilahti 2014-09-10 14:41:57 UTC
Created attachment 31509 [details] [review]
initial patch

After having issues with cronjobs not always running or getting regression issues, I decided to give a try to create a cronjobs monitoring solution.

This patch introduces a wrapper script to log and time cronjobs.

The wrapper script's log output is used to analyze whther cronjobs ran and if there were any errors.
Also cronjobs timings can be validated to prevent nasty errors with for. ex. expiring waiting holds one day too early/late.
This check can also be integrated to nagios!

Also provided is a scaffold to start introducing more nagios-checks, with example command and service configurations.


This patch introduces a koha_cronjobs-script to read the /var/spool/cron/crontabs/koha and analysz its contents.
Then one can validate whether the cronjob timings are right (this is not mentioned in the manual at all) and what is right is (currently) based on my honest feelings.
Then each cronjobs frequency is determined and the cronjobs log output is checked based on the script parameters.
Currently the cronjob frequencies are split to minutely, hourly, daily, etc.
Koha_cronjobs-script is meant to be ran on those intervals to catch errors ASAP.

I would also like to hear what kind of cronjob timings other libraries use?
Comment 1 Olli-Antti Kivilahti 2014-09-10 14:45:52 UTC
Here are some example crontab configurations to get started using this feature:

0 * * * *      $KOHA_CRONJOB_TRIGGER cronjobs/holds/build_holds_queue.pl -v
5 0 * * *      $KOHA_CRONJOB_TRIGGER cronjobs/holds/cancel_expired_holds.pl
4 0 * * *      $KOHA_CRONJOB_TRIGGER cronjobs/holds/auto_unsuspend_holds.pl
30 0 * * *     $KOHA_CRONJOB_TRIGGER cronjobs/fines.pl -v
10 1 * * *     $KOHA_CRONJOB_TRIGGER cronjobs/update_totalissues.pl --incremental --use-stats
45 0 * * *     $KOHA_CRONJOB_TRIGGER cronjobs/create_koc_db.pl --sqlite3 --force --file  /home/koha/kohaclone/koha-tmpl/static_content/borrowers.db
0 0 * * 7      $KOHA_CRONJOB_TRIGGER cronjobs/removeShortLoanStatus.pl -v
*/30 * * * *   $KOHA_CRONJOB_TRIGGER cronjobs/smsalertnumberFromPhone.pl --verbose --confirm

0 0 * * *      $KOHA_CRONJOB_TRIGGER cronjobs/delete_expired_opac_registrations.pl -c

* * * * *      $KOHA_CRONJOB_TRIGGER cronjobs/process_message_queue.pl -v
25 0 * * *     $KOHA_CRONJOB_TRIGGER cronjobs/advance_notices.pl -c
35 0 * * *     $KOHA_CRONJOB_TRIGGER cronjobs/overdue_notices.pl --triggered
Comment 2 I'm just a bot 2016-03-06 21:38:26 UTC
Patch applied cleanly\n
Comment 3 Katrin Fischer 2017-10-07 23:48:47 UTC
Patch still applies, but I don't know how to test this. Someone using Nagios maybe?
Comment 4 David Cook 2019-01-23 06:11:41 UTC
(In reply to Katrin Fischer from comment #3)
> Patch still applies, but I don't know how to test this. Someone using Nagios
> maybe?

1. I don't think this really has a place in Koha. People can monitor however they like, so I don't think we should include Nagios specifically.

2. I use Nagios, but I don't have any interest in testing this.

3. It's not clear from the description what this patch does, although after reviewing the code, it seems like it's trying to do too much. 

4. That all said, it wouldn't hurt to make cronjobs log in some way that is friendly for monitoring apps. We have cronlogaction now, but maybe that could be improved. 

Olli, are you still interested in this in 2019?
Comment 5 Katrin Fischer 2023-07-15 21:15:33 UTC
(In reply to David Cook from comment #4)
> (In reply to Katrin Fischer from comment #3)
> > Patch still applies, but I don't know how to test this. Someone using Nagios
> > maybe?
> 
> 1. I don't think this really has a place in Koha. People can monitor however
> they like, so I don't think we should include Nagios specifically.
> 
> 2. I use Nagios, but I don't have any interest in testing this.
> 
> 3. It's not clear from the description what this patch does, although after
> reviewing the code, it seems like it's trying to do too much. 
> 
> 4. That all said, it wouldn't hurt to make cronjobs log in some way that is
> friendly for monitoring apps. We have cronlogaction now, but maybe that
> could be improved. 
> 
> Olli, are you still interested in this in 2019?

I am closing this as there has been no reply in another 4 years.