Detecting a string in a file

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Detecting a string in a file

Post by Box293 »

You have to compile it, follow the instructions in the check_log3 download.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Detecting a string in a file

Post by RIDS_I2MP »

Hi Team,

Kindly let me know how to implement it.

I am having check_log3.pl file and need to monitor a string in the log file of a windows host.
Thanks & Regards,
I2MP Team.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Detecting a string in a file

Post by rkennedy »

More details regarding it can be read on the plugin page here - http://exchange.nagios.org/directory/Pl ... pl/details

Another place to download the files is here - https://sourceforge.net/projects/pma-os ... s-plugins/
Former Nagios Employee
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Detecting a string in a file

Post by lmiltchev »

Here's a working example:

I placed the Windows executable (check_log3.exe) in the NSClient++ scripts directory. I defined the "check_log3" command under the [/settings/external scripts/scripts] section in the nsclient.ini as such:

Code: Select all

check_log3 = scripts\check_log3.exe -l $ARG1$ -p $ARG2$
I placed a "test" log file in the C: directory ("C:\test.log") which contained bunch of lines similar to this one:

Code: Select all

[1459314000] CURRENT HOST STATE: Debian;UP;HARD;1;2, failed
Next, I tested it from Nagios XI CLI:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_log3 -a "c:\test.log" "failed"
WARNING: Found 18 lines (limit=1/0): [1459314000] CURRENT HOST STATE: Debian;UP;HARD;1;2, failed|'lines'=18
Note: The second time you run the check, you will see:

Code: Select all

OK: Found 0 lines (limit=1/0): No matches found.|'lines'=0
If more lines, containing "failed" show up in the log file, the check would show you the number of the new lines (containing the pattern you are searching for).

Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Detecting a string in a file

Post by RIDS_I2MP »

Hi Team,

I have made the suggested configuration but I am receiving attached message:

Kindly suggest.
You do not have the required permissions to view the files attached to this post.
Thanks & Regards,
I2MP Team.
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Detecting a string in a file

Post by RIDS_I2MP »

kindly also review the nsclient.log file.
You do not have the required permissions to view the files attached to this post.
Thanks & Regards,
I2MP Team.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Detecting a string in a file

Post by lmiltchev »

Make sure that you have the following two lines under BOTH sections in nsclient.ini - [/settings/NRPE/server] and [/settings/external scripts]

Code: Select all

allow arguments = 1
allow nasty characters = 1
Restart NSClient++ service, so that changes can take effect.
Be sure to check out our Knowledgebase for helpful articles and solutions!
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Detecting a string in a file

Post by RIDS_I2MP »

Hi Team,

I have made required changes now its not returning me any error message but it is not providing me required output.

It is not performing the check correctly, the string which I am passing in the command is present in the file but in output of command it says no matches, refer the snapshot attached.
You do not have the required permissions to view the files attached to this post.
Thanks & Regards,
I2MP Team.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Detecting a string in a file

Post by lmiltchev »

I have made required changes now its not returning me any error message but it is not providing me required output.
The results are cached, so if this is not a "new" entry, the check will not show any results. What happens if you add a few new lines to the "base.txt" file, containing "HOTFIX", and rerun the check? Does it find the new strings?
Be sure to check out our Knowledgebase for helpful articles and solutions!
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Detecting a string in a file

Post by RIDS_I2MP »

Hi Team,

Can we apply thresholds?
Thanks & Regards,
I2MP Team.
Locked