Plugin check existing log and date check

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Plugin check existing log and date check

Postby welbp00 » Tue Apr 16, 2019 3:16 am

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.
welbp00
 
Posts: 22
Joined: Fri Mar 08, 2019 5:48 am

Re: Plugin check existing log and date check

Postby cdienger » Tue Apr 16, 2019 2:39 pm

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:

Code: Select all
ls cp_init.<filenamedate>.log | egrep [0-9]{8} -o


and then converted to epoch:

Code: Select all
date --date=<filenamedate> +%s


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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
cdienger
Support Tech
 
Posts: 2828
Joined: Tue Feb 07, 2017 11:26 am


Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 20 guests