Hi everyone,
I need to run a script running every minute on a Linux machine. My goal is to track how long it takes to complete. Lets say, under 5 seconds, ok, under 15, warning and over 30 critical. Which kind of plugin/script should I use? The ones I find are to check services uptime and stuff like that.
Thanks for the help,
Rodrigo
Check script duration
Re: Check script duration
This is pretty easy to do with a bit of Bash:
https://stackoverflow.com/questions/385 ... -the-shell
https://unix.stackexchange.com/question ... ffectively
Have the script store it's runtime in some temp file via redirection. You could either parse that file's contents in a simple Bash script which returns Nagios-friendly information, or leverage one of the various "file age" plugins to see how frequently that file is written with the idea being that the file is written every time the script runs and the age of the file represents the approximate runtime (minus 60 seconds or whatever the execution interval is):
https://exchange.nagios.org/directory/P ... ck/details
https://github.com/nagios-plugins/nagio ... ile_age.pl
Though for your particular use-case, it is worth mentioning that Nagios Core works off of a 60-second interval by default (interval_length). So catching all of those 15/30 second runtimes is going to require a bit of luck.
https://stackoverflow.com/questions/385 ... -the-shell
https://unix.stackexchange.com/question ... ffectively
Have the script store it's runtime in some temp file via redirection. You could either parse that file's contents in a simple Bash script which returns Nagios-friendly information, or leverage one of the various "file age" plugins to see how frequently that file is written with the idea being that the file is written every time the script runs and the age of the file represents the approximate runtime (minus 60 seconds or whatever the execution interval is):
https://exchange.nagios.org/directory/P ... ck/details
https://github.com/nagios-plugins/nagio ... ile_age.pl
Though for your particular use-case, it is worth mentioning that Nagios Core works off of a 60-second interval by default (interval_length). So catching all of those 15/30 second runtimes is going to require a bit of luck.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Check script duration
thanks @mcapra