I am looking for a plugin which checks at the latest log file and looks for errors in it.
for example:
log1.txt 12/1/2014 6:54AM
log2.txt 12/2/2014 12:02PM
log3.txt 12/4/2014 4:00 PM
log4.txt 12/4/2014 5:00 PM
Here the latest log file is log4.txt and it contains ERROR in it. Then nagios needs to alert. I tried file_age plugin and it works but cannot tell it to look for error and alert.
check latest file for error
Re: check latest file for error
Is there a specific log file or files(s) that you want to perform this check against?
Re: check latest file for error
sample log file.. need to look for failed.
Sun Dec 03 22:21:25 2017 started 0 svr:4184 2881097816 Standard 10.35.4.74:-18496 Archives \\testserver1\Input$\tandem\IVA STATISTICS 0514233722000105 $RJA.05142 >>SIS<< $RJA R:IVA STATISTICS FORM: 12/01/2017 IVA STATISTICS 0514233722000105 REPORT ID: IVASTATTIC
800A0 0 8192 0
Sun Dec 03 22:21:25 2017 completed 0 svr:4184 2881097816 Standard 10.35.4.74:-18496 Archives \\testserver1\Input$\tandem\IVA STATISTICS 0514233722000105 $RJA.05142 >>SIS<< $RJA R:IVA STATISTICS FORM: 12/01/2017 IVA STATISTICS 0514233722000105 REPORT ID: IVASTATTIC
800A0 0 8192 0
Sun Dec 03 22:22:30 2017 started 0 cli:13819 4010751483 Standard 10.35.4.74:25533 STANDARD F:\Program Files (x86)\example\ColdFusionServiceInstaller\RenamedList.txt $LDAT9.RJDL.COLDJOBS 8020 0 8192 0
Sun Dec 03 22:22:30 2017 failed 137 cli:13819 4010751483 Standard 10.35.4.74:25533 STANDARD F:\Program Files (x86)\example\ColdFusionServiceInstaller\RenamedList.txt $LDAT9.RJDL.COLDJOBS 8020 0 8192 0
Sun Dec 03 22:22:30 2017 terminated 0 cli:13819 4010751483 Standard 10.35.4.74:25533 STANDARD F:\Program Files (x86)\example\ColdFusionServiceInstaller\RenamedList.txt $LDAT9.RJDL.COLDJOBS 8020 0 8192 0
Sun Dec 03 22:21:25 2017 started 0 svr:4184 2881097816 Standard 10.35.4.74:-18496 Archives \\testserver1\Input$\tandem\IVA STATISTICS 0514233722000105 $RJA.05142 >>SIS<< $RJA R:IVA STATISTICS FORM: 12/01/2017 IVA STATISTICS 0514233722000105 REPORT ID: IVASTATTIC
800A0 0 8192 0
Sun Dec 03 22:21:25 2017 completed 0 svr:4184 2881097816 Standard 10.35.4.74:-18496 Archives \\testserver1\Input$\tandem\IVA STATISTICS 0514233722000105 $RJA.05142 >>SIS<< $RJA R:IVA STATISTICS FORM: 12/01/2017 IVA STATISTICS 0514233722000105 REPORT ID: IVASTATTIC
800A0 0 8192 0
Sun Dec 03 22:22:30 2017 started 0 cli:13819 4010751483 Standard 10.35.4.74:25533 STANDARD F:\Program Files (x86)\example\ColdFusionServiceInstaller\RenamedList.txt $LDAT9.RJDL.COLDJOBS 8020 0 8192 0
Sun Dec 03 22:22:30 2017 failed 137 cli:13819 4010751483 Standard 10.35.4.74:25533 STANDARD F:\Program Files (x86)\example\ColdFusionServiceInstaller\RenamedList.txt $LDAT9.RJDL.COLDJOBS 8020 0 8192 0
Sun Dec 03 22:22:30 2017 terminated 0 cli:13819 4010751483 Standard 10.35.4.74:25533 STANDARD F:\Program Files (x86)\example\ColdFusionServiceInstaller\RenamedList.txt $LDAT9.RJDL.COLDJOBS 8020 0 8192 0
Re: check latest file for error
You could try using this plugin to look for a pattern in a log file or files?
https://exchange.nagios.org/directory/P ... pl/details
https://exchange.nagios.org/directory/P ... pl/details
Re: check latest file for error
Thanks. I am going to try this..
Re: check latest file for error
Sounds good let us know!
I should have mentioned, where is this log located? Windows? Linux?
There are many other plugins on the Nagios Exchange you could look at as well.
Otherwise, Nagios Log Server is a good option to check for errors in multiple logs.
https://www.nagios.com/products/nagios-log-server/
I should have mentioned, where is this log located? Windows? Linux?
There are many other plugins on the Nagios Exchange you could look at as well.
Otherwise, Nagios Log Server is a good option to check for errors in multiple logs.
https://www.nagios.com/products/nagios-log-server/
Re: check latest file for error
Please see Kevin's recommendation. This plugin will check for an occurrence of specific text in a specific file. However, if you need to identify the most recent of files of a specific filename pattern and search that file for the "failed" text, I'm not able to find anything on the Nagios Exchange. If you could tell us the filename pattern of the files for which you need to identify the most recent, I could perhaps be of some assistance. The basic recipe would be to find the most recent file matching the filename pattern and then search that file for "failed" and if "failed" is found, return the filename and a critical status. If you're on RHEL or CentOS, run the following command from the CLI of your host. and you'll get the idea:
Code: Select all
ls -lt /var/log/message* | awk {'print $9 '} | head -1 | xargs grep 'Warning' | awk '{ if ($1 != "") print "Found Warning";}' | head -1
Re: check latest file for error
Thanks. the plugin check_log3 worked. Also this was on windows server. I should have mentioned it.. You can close this thread.
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: check latest file for error
Closing this thread as resolved.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.