sending nagios logs to rsyslog

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mns
Posts: 4
Joined: Thu Jul 31, 2014 4:52 am

sending nagios logs to rsyslog

Post by mns »

Hi,

I am a newbie to installing and setting up nagios and I am trying to set up Nagios 4.0.7 to send warnings and critical messages to /var/log/messages (RHEL6.5). When I use user.info in /etc/rsyslogd.conf I get thousands of messages.

1. Are there any another rsyslog facilities that I can use besides user.info?

2. Is there a way that I can set it to log everything to the nagios log file but only the first HARD WARNINGS AND CRITICALS, the first OK AFTER HARD WARNINGS AND CRITICALS to /var/log/messages?

3. Is there a way to have each host group it's own thesholds for the checks rather than having to go individually to each server config file?

Cheers

MNS
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: sending nagios logs to rsyslog

Post by eloyd »

mns wrote:Hi,
Hi.
1. Are there any another rsyslog facilities that I can use besides user.info?
Yes, but that is a topic for http://linux.die.net/man/8/rsyslogd.
2. Is there a way that I can set it to log everything to the nagios log file but only the first HARD WARNINGS AND CRITICALS, the first OK AFTER HARD WARNINGS AND CRITICALS to /var/log/messages?
Not that I know of. Nagios wants to log to one place. And it wants to log everything to that place. You could, however, put an event handler on the service/host checks that, when a HARD WARNING or HARD CRITICAL occurs, the event handler adds something to your /var/log/messages file. That's what I'd do.
3. Is there a way to have each host group it's own thesholds for the checks rather than having to go individually to each server config file?
Assign your hosts to hostgroups. Assign your services to servicegroups. Assign servicegroups to hostgroups. Use templates for service definitions, and then you can simply things greatly. Look at http://nagios.sourceforge.net/docs/3_0/ ... tance.html for more information.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
mns
Posts: 4
Joined: Thu Jul 31, 2014 4:52 am

Re: sending nagios logs to rsyslog

Post by mns »

Thanks Eloyd.

That was very helpful. I will look at your suggestion of using the event handler, that sounds perfect.

What I was trying to do with rsyslog would not work because it would still send all of the messages, only to a different facility.

I will also take a look at servicegroups and hostgroups once I get it working generally.

Thanks again.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: sending nagios logs to rsyslog

Post by eloyd »

A quick pseudo-code event handler to do what you want:

Code: Select all

<start>
  is STATE=OK or STATE=CRITICAL?
    if yes, then is ATTEMPT=1?
      If yes, then log something to /var/log/messages
<end>
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
mmiltchev
Posts: 10
Joined: Tue Jun 18, 2013 2:16 pm

Re: sending nagios logs to rsyslog

Post by mmiltchev »

Thanks for your post eloyd. Did you have any more questions mns?
Locked