Hello,
After a fair bit of googling I can't find an obvious way to change the format of the $DATE$ variable.
Trying to monitor log files whose names end with YYYYMMDD, $DATE$ gives me MM-DD-YYYY.
Thank you.
How to change $DATE variable format
-
gsl_ops_practice
- Posts: 151
- Joined: Thu Apr 09, 2015 9:14 pm
Re: How to change $DATE variable format
There are a few options to change it, but none appear to match what you need:
http://nagios.sourceforge.net/docs/3_0/ ... ate_format
We can put in a Core feature request for additional formats if you would like, but that would take some time to implement. The faster option, if possible depending on how you are using this, is to use a wrapper script to provide the date format.
http://nagios.sourceforge.net/docs/3_0/ ... ate_format
We can put in a Core feature request for additional formats if you would like, but that would take some time to implement. The faster option, if possible depending on how you are using this, is to use a wrapper script to provide the date format.
Former Nagios employee
-
gsl_ops_practice
- Posts: 151
- Joined: Thu Apr 09, 2015 9:14 pm
Re: How to change $DATE variable format
Hi,
Can you please how I would go about setting up a wrapper script? Definitely faster than waiting for a feature to be added
Thanks,
Alex
Can you please how I would go about setting up a wrapper script? Definitely faster than waiting for a feature to be added
Thanks,
Alex
Re: How to change $DATE variable format
Sure thing. First I need to see how you are monitoring these logs. Can you post the check command and plugin you are using? The more info I have about the setup the better.
Former Nagios employee
-
gsl_ops_practice
- Posts: 151
- Joined: Thu Apr 09, 2015 9:14 pm
Re: How to change $DATE variable format
This is my command definition, we deployed a check_file_age script on all of our hosts that we need to monitor.
check_nrpe!check_file_age!-a '-w 3600 -c 5400 -f /home/application/apps/cli/log/cli-message-details.log.$DATE$'!!!!!!
check_nrpe!check_file_age!-a '-w 3600 -c 5400 -f /home/application/apps/cli/log/cli-message-details.log.$DATE$'!!!!!!
Re: How to change $DATE variable format
You could create a bash script, i.e. "check_file_age_wrapper".
and use it as such:
Code: Select all
#!/bin/bash
d=`date +%Y%m%d`
/usr/local/nagios/libexec/check_file_age -w $1 -c $2 -f $3.$dCode: Select all
/usr/local/nagios/libexec/check_file_age_wrapper 3600 5400 /home/application/apps/cli/log/cli-message-details.logBe sure to check out our Knowledgebase for helpful articles and solutions!
-
gsl_ops_practice
- Posts: 151
- Joined: Thu Apr 09, 2015 9:14 pm
Re: How to change $DATE variable format
I had to add a new check with a new name and then the wrapper script started to return valid results.
Thank for your help, please mark this thread closed.
Thank for your help, please mark this thread closed.