Page 1 of 1
Variable Date Macro?
Posted: Thu Apr 07, 2011 11:54 am
by bpablo
I am attempting to set up a check command to monitor a log file. The issue I am having is the log file has a variable date. And I have not been able to find a marco that can accommodate this. Any suggestions?
define service{
service_description Intergation Sever Broker connection
hostgroup_name opstest-is
use log-service
servicegroups opstest-websphere-logs
contact_groups ese-contactgroup
check_command check_nrpe!check_logfiles!/var/log/ops/wmlogs/server$CL_DATE_YYYY$$CL_DATE_MM$$CL_DATE_DD$.log $HOSTNAME$_log "JMS: Lost connection to Broker"
)
Re: Variable Date Macro?
Posted: Thu Apr 07, 2011 2:18 pm
by rdedon
Here is a large list of usable macros for you:
http://nagios.sourceforge.net/docs/3_0/macrolist.html
There are some time specific related ones if you hit F3 and enter
Date/Time Macros
Hope this helps! Feel free to post if you have any additional questions or issues.

Re: Variable Date Macro?
Posted: Thu Apr 07, 2011 4:27 pm
by bpablo
Thanks, Unfortunately it doesn't put it in the format I need. The only options for those is :
Format: date_format=<option>
Example: date_format=us
This option allows you to specify what kind of date/time format Nagios should use in the web interface and date/time macros. Possible options (along with example output) include:
Option Output Format Sample Output
us MM/DD/YYYY HH:MM:SS 06/30/2002 03:15:00
euro DD/MM/YYYY HH:MM:SS 30/06/2002 03:15:00
iso8601 YYYY-MM-DD HH:MM:SS 2002-06-30 03:15:00
strict-iso8601 YYYY-MM-DDTHH:MM:SS 2002-06-30T03:15:00
I need to have YYYYMMDD with no dashes, backslashes or hr-mm-ss. Any idea how to set to that?
Re: Variable Date Macro?
Posted: Tue Apr 12, 2011 10:16 am
by tonyyarusso
Skip the macros entirely, and just use this:
Code: Select all
check_command check_nrpe!check_logfiles!/var/log/ops/wmlogs/server`date +%Y%m%d`$.log $HOSTNAME$_log "JMS: Lost connection to Broker"