nagiosxi check logfile for unix

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

nagiosxi check logfile for unix

Post by michaelli »

Dear support,

I have a problem about nagios XI use "check_nrpe!check_logfiles" for checking unix's system logging message.

Eg. I have set 3 mins for checking messages periodically. If there are many error find in message file within 3mins. Nagios XI only display the latest error.

Our operation team request to display all error in nagios. Does it possible to do that?

Or I suggest it can display all error/warning within 2 hours.

Thanks.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: nagiosxi check logfile for unix

Post by abrist »

See: http://labs.consol.de/nagios/check_logfiles/
michaelli wrote:Our operation team request to display all error in nagios. Does it possible to do that?
You can set the plugin to generate multiline output:
–report=[short|long|html]This option turns on multiline output (Default: off). The setting html generates a table which display the last hits in the service details view.
michaelli wrote: Or I suggest it can display all error/warning within 2 hours.
You will most likely have to write, and then subsequently call, a custom script from check_logfiles. Take a look at the link above (a few pages down), there is an example of calling an external script from check_logfiles. Just a warning, this can get complex quickly.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

Re: nagiosxi check logfile for unix

Post by michaelli »

Hi abrist,

Thanks. It is work for add $options = 'report=long, maxlength=1024'; in cfg file.

But how to configure all errors are display in State History?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: nagiosxi check logfile for unix

Post by abrist »

I do not believe you can do so. First, state history is limited to non-multiline output, also, the plugin will only output the max you have configured.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

Re: nagiosxi check logfile for unix

Post by michaelli »

Hi abrist,

I hope this feature can be added to future version because system support do no need to login hosts to review the error messages.

Moreover, Does it possible to show all error entry in "Operations Center" and "Operations Screen"?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: nagiosxi check logfile for unix

Post by tmcdonald »

I don't think a feature request of this sort will make it in, because we have another product specifically for log analysis: Nagios Log Server

It's painless to set up, and does an incredible job of taking in logs, storing them, and allowing for later retrieval. It's a much better solution than trying to force a scheduled active check to look back over a period of time.
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: nagiosxi check logfile for unix

Post by eloyd »

Maybe I'll take all the custom programming I've done and turn them into plugins on the nagios exchange, but here's what I do (in English, not in code):

Fire off a check that does:

Code: Select all

comm -13 <old file in temp dir> <new file> | grep -c <thing we are looking for>; cp <new log file> <old file in temp dir>
This is a quick and dirty way to see what's in the new file that wasn't in the old file, grep for the error condition I'm trying to find, and then count the numbers. Process the exit status for OK WARNING CRITICAL and you have yourself a plugin.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

Re: nagiosxi check logfile for unix

Post by michaelli »

Hi eloyd,

Thanks for your reply. Do you mean we can use your method to allow nagios display all error in same state?

Could you describe more detail which file used for compare and update which file for nagios read.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: nagiosxi check logfile for unix

Post by eloyd »

I will use /var/log/maillog as an example, and pretend that you are looking for "Aborted" logins. You first have to copy /var/log/maillog to a temporary file, and then you can run this:

Code: Select all

[ ! -r "/tmp/mailog" ] && cp /var/log/maillog /tmp/maillog && exit
comm -13 /tmp/maillog /var/log/maillog | grep -c "Aborted"
cp /var/log/maillog /tmp/maillog
That will tell you how many times the word "Aborted" appeared since the last time the check was run. This is very basic, but I think it is what you are trying to do. Wrap this into a more robust script that checks error codes and warning/critical values and you have yourself a Naigos plugin.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: nagiosxi check logfile for unix

Post by tmcdonald »

eloyd's post will work for showing a total count, but if you need a comprehensive historical log of the results then you either need to check very frequently and hope your interval catches them all, or implement rsyslog and send to Logserver. Not trying to push a product on you, but that's one of the many reasons we launched Logserver in the first place.
Former Nagios employee
Locked