Grep Logfile on RHEL Server

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
stonkers
Posts: 30
Joined: Tue Oct 31, 2017 9:58 am

Re: Grep Logfile on RHEL Server

Post by stonkers »

Thanks!!!
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Grep Logfile on RHEL Server

Post by npolovenko »

@stonkers, You're welcome! Let me know if it's ok to lock the thread.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
stonkers
Posts: 30
Joined: Tue Oct 31, 2017 9:58 am

Re: Grep Logfile on RHEL Server

Post by stonkers »

Ooops, sorry, a few more questions.
Last edited by stonkers on Fri Apr 27, 2018 9:22 am, edited 1 time in total.
stonkers
Posts: 30
Joined: Tue Oct 31, 2017 9:58 am

Re: Grep Logfile on RHEL Server

Post by stonkers »

I'm sorry, I do have questions about your values in the setup.

1) Are we able to use variables in the command setup or do we have to set up commands for each file we're going to monitor? We have a lot of these same files but they're in different directories, such as: /var/log/applogs/<serverName>/SystemOut.log
2) We won't be grepping logs on any localhost files, do we set "Manage Hosts" to IP address of the host we want to look at?

Sorry, I don't have the screens available so that I can play around and want to give explicit instructions or my nagios admin may go away and never come back... :(
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Grep Logfile on RHEL Server

Post by npolovenko »

@stonkers, Sure, you can split the command and use arguments:
Untitled.png
Untitled1.png
However, the "old log" file needs to be different for each serivce, so don't forget to change it($ARG3$).

2. You'd need some kind of agent to run the plugin on the remote host. For example, nrpe:
https://assets.nagios.com/downloads/nag ... _Agent.pdf
Have you configured the nrpe agent before?
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
stonkers
Posts: 30
Joined: Tue Oct 31, 2017 9:58 am

Re: Grep Logfile on RHEL Server

Post by stonkers »

Yes, we have NRPE set up on all of our hosts. Just from my vantage point, I'm unable to see how to instruct him to point to the correct servers. Thanks!
kyang

Re: Grep Logfile on RHEL Server

Post by kyang »

Great, since you have NRPE installed on all servers.

You would have to make sure that you have the check_log plugin on the other remote server.

Along with that, you need to add your XI ip address into the remote server's nrpe.cfg

After that, you have to make sure the correct command is inside the nrpe.cfg.

# most importantly, make sure you can execute the plugin using NRPE. Or at least test the connection from XI to the "correct servers"
# change ipAddress to your "correct server"

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H ipAddress
Make sure the above steps work before we go onto the next step.
stonkers
Posts: 30
Joined: Tue Oct 31, 2017 9:58 am

Re: Grep Logfile on RHEL Server

Post by stonkers »

Yep, those all work.
kyang

Re: Grep Logfile on RHEL Server

Post by kyang »

Okay,

You mentioned this before.
Just from my vantage point, I'm unable to see how to instruct him to point to the correct server
Since you have the plugin available on your remote host. Make sure you have the check_log command definitions defined on your remote host as well.
Something like this. Or you can hard code it.

Code: Select all

command[check_log]=/usr/local/nagios/libexec/check_log $ARG1$
Try using check_nrpe from the XI side to your remote host. Something like this. Make sure to replace the values for -F, -O and -q

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H remotehost -c check_log -a '-F /the/path -O /tmp/oldLog -q error'
stonkers
Posts: 30
Joined: Tue Oct 31, 2017 9:58 am

Re: Grep Logfile on RHEL Server

Post by stonkers »

Yep, that works on all the servers I want to run the test on.
Locked