Hello,
i am looking for a plugin wich checks the existing of a specifick log-fle (cp_init.20190414.log), and does a check if the date in the name of the file, is younger than a week from today.
Any help would be very nice. The servers are Linux redhat 7. Nagios core 4.
Thnx.
Regards Paul.
Plugin check existing log and date check
Re: Plugin check existing log and date check
I'm not aware of anything that will extract the date from filename and treat it as a date or number, so it looks like one would need to be created.
On a Linux system the date can be extracted with:
and then converted to epoch:
you'd then need to add 604800 seconds to the returned filenamedate and compare it to the system's current epoch time.
Here are some useful documents to help get you started on creating custom plugins:
https://assets.nagios.com/downloads/nag ... inapi.html
http://nagios-plugins.org/doc/guidelines.html
https://library.nagios.com/library/prod ... s-in-perl/
https://exchange.nagios.org/directory/T ... pt/details
On a Linux system the date can be extracted with:
Code: Select all
ls cp_init.<filenamedate>.log | egrep [0-9]{8} -o
Code: Select all
date --date=<filenamedate> +%s
Here are some useful documents to help get you started on creating custom plugins:
https://assets.nagios.com/downloads/nag ... inapi.html
http://nagios-plugins.org/doc/guidelines.html
https://library.nagios.com/library/prod ... s-in-perl/
https://exchange.nagios.org/directory/T ... pt/details
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.