-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added cronjob check #38
base: master
Are you sure you want to change the base?
Conversation
added cron check
added an additional check to monitor whether a cronjob ran inside of its defined timeframe.
Hello @yzapf and thank you for the PR. Can you please elaborate what the cronjob is for? The plugin was created to be run as a monitoring plugin for Nagios, Icinga2 and other monitoring solutions. Is this some other software or running standalone? Can you show some use case? |
Hi,
it is currently running as monitoring plugin for our icinga2 monitoring solution. I just added another check to monitor also the state of cronjobs running in a Kubernetes/rancher environment, because we are relying on some of our cronjobs to run inside their schedule. The check simply calls the attached python script which is only used for decoding the cron schedule to a timestamp which then can be further processed in the main plugin script.
Since it is reliably running in our monitoring for several Kubernetes cluster environments, so I thought this could be useful for others as well.
Regards
Yannick
Von: Claudio Kuenzler ***@***.***>
Gesendet: Montag, 24. Oktober 2022 11:41
An: Napsty/check_rancher2 ***@***.***>
Cc: Zapf, Yannick ***@***.***>; Mention ***@***.***>
Betreff: Re: [Napsty/check_rancher2] added cronjob check (PR #38)
Hello @yzapf<https://github.com/yzapf> and thank you for the PR. Can you please elaborate what the cronjob is for? The plugin was created to be run as a monitoring plugin for Nagios, Icinga2 and other monitoring solutions. Is this some other software or running standalone? Can you show some use case?
—
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZ6EXVVYH6377XLGXF2GM2TWEZKRLANCNFSM6AAAAAARIC7EFA>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
ah, I misunderstood the initial request, sorry. Got it :) Will test. |
I finally took some time to test the cron check type. The idea is great and helpful, thanks! It would be great if we could stick with the plugin to Shell requirement only. |
Hi,
my initial plan was to integrate the functionality completely in the shell script. However, I couldn’t figure it out, how to convert the cron schedule with shell. That’s where I stepped over croniter. Since the Kubernetes API is just mentioning the timestamp of the previous cron run, I need to calculate the next run in order to compare the timeframe between now and the last run with the calculated timeframe from the cron schedule.
It would be much easier, if Kubernetes would provide the information directly in the API, or if there is a way to efficiently convert the cron schedule within shell to make it “human readable” or comparable.
It can be possible, that I overlooked something or my expertise isn’t that deep. Do you have any idea?
Regards
Yannick
Von: Claudio Kuenzler ***@***.***>
Gesendet: Freitag, 6. Januar 2023 14:39
An: Napsty/check_rancher2 ***@***.***>
Cc: Zapf, Yannick ***@***.***>; Mention ***@***.***>
Betreff: Re: [Napsty/check_rancher2] added cronjob check (PR #38)
I finally took some time to test the cron check type. The idea is great and helpful, thanks!
However the additional Python dependency could be causing issues. Is there any way we can do this without the Python script and forcing the users to install Python (and the croniter module)?
As far as I can tell, the Python script is only here to create a run time interval?
It would be great if we could stick with the plugin to Shell requirement only.
—
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZ6EXVQXBJVWCSYMG34XOVDWRAN75ANCNFSM6AAAAAARIC7EFA>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Added a cronjob check to monitor whether a cronjob ran inside of its defined timeframe.
To make this possible I also wrote a helper script "convert_cron_schedule.py" to convert the cron schedule into a timeframe.
For that I used the "croniter" package, which is mandatory for that script.
This timeframe will then be compared with the elapsed time between now and the last run of the cronjob.
If the timeframe is bigger than the elapsed time everything is fine, else the check responds with a corresponding error code.
The cronjob state is also being checked.