How to monitor a log file that generates a random id?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
warsiders23
Posts: 1
Joined: Tue Nov 20, 2018 1:10 am

How to monitor a log file that generates a random id?

Post by warsiders23 »

This the log file that I want to monitor:

Code: Select all

/test/James-2018-11-16_15215125111115-16.15.41.111-appserver0.log
I want Nagios to read it this log file so I can monitor a specific string.

The issue is with **15215125111115** this is the random id that gets generated

Here is my script where the Nagios is checking for the **Logfile** path:

**Veriables:**

HOSTNAMEIP=$(/bin/hostname -i)
DATE=$(date +%F)
..

Code: Select all

> CHECK=$(/usr/lib64/nagios/plugins/check_logfiles/check_logfiles --tag='failorder' --logfile=/test/james-${date +"%F"}_-${HOSTNAMEIP}-appserver0.log
....

I am getting the following output in nagios:

*`could not find logfile /test/James-2018-11-16_-16.15.41.111-appserver0.log`*

**15215125111115** This number is always generated randomly but I don't know how to get nagios to identify it. Is there a way to add a variable for this or something? I tried adding an asterisk "*" but that didn't work.

Any ideas would be much appreciated.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to monitor a log file that generates a random id?

Post by scottwilkerson »

What about this?

Code: Select all

HOSTNAMEIP=$(/bin/hostname -i)
DATE=$(date +%F)
CHECK=$(/usr/lib64/nagios/plugins/check_logfiles/check_logfiles --tag='failorder' --logfile=`ls /test/James-${DATE}_*-${HOSTNAMEIP}-appserver0.log`)
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked