This the log file that I want to monitor:


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:


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


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_-

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.

  • are you going to have multiple file that start with "James-2018-11-16" ? – Sharuzzaman Ahmat Raslan Nov 20 '18 at 4:50
  • Correct. a new file with the same name formate gets generated every day. – Warsiders23 Nov 20 '18 at 5:53
  • Safe to assume you only want to monitor the latest one? – uSlackr Nov 20 '18 at 14:20
  • Could you use some scripting foo to determine the logfile name each day (say using cron) and set it as an ENV variable that this script accesses? (Doesn't really scale well if there are many of these to monitor) – uSlackr Nov 20 '18 at 14:24

I would run a separate script, via cron, that identifies the newest log file and makes a symlink to it (named something like "latest.log"). There are several ways you could do this (using ls -rt | tail or find -mtime, for example).

If the new logfile is created at the same time every day, schedule it to run right after that. If not, have it run every (minute, 5 minutes, whatever), checking for a new log file.

... And then have check_logfiles use that symlink.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.