Create a Log File for NRPE

Mar 11, 2014

1 min read

NRPE haven’t got its own log file and writes its events in /var/log/messages. I will say yes why not but it will be a good idea to create a logfile for NRPE. In this post we’ll see how to create a specific log file for NRPE.

In a first time we’ll configure NRPE and in a second time we’ll configure Rsyslog configuration. It’s quite simple because NRPE have syslog facility.

Well stop the theory and let’s go !

NRPE configuration

You need to add the following lines in your NRPE configuration file. I my case the configuration file is /etc/nagios/nrpe.cfg :

log_facility=local1
debug=0

Congrats you have configured your NRPE server, you could go to the next step.

Rsyslog configuration

To allow Rsyslog or its equivalents to manage your log files correctly, you need update your configuration to log NRPE messages in a specific file.

So you need to add the following lines in your rsyslog configuration file. Im my case the configuration file is /etc/rsyslog.conf.

local1.*                                          /var/log/nrpe
Note: You could add this line at the end of the file.

That’s all for Rsyslog.

After you have made modifications, a restart of nrpe and rsyslog is needed. You need to run the following commands to restart them.

/etc/init.d/rsyslog restart
/etc/init.d/nrpe restart

Okay, you could check /var/log/nrpe to see NRPE logs. If you don’t see anything in this file a restart of nrpe could be performed to create events in log.

I was difficult ? Have fun with your NRPE log file. ;-)

Sharing is caring!