Page 1 of 1

NRPE logging to file

Posted: Fri Aug 15, 2014 4:36 am
by dylanharris
I want to use NRPE to monitor some of my software, but I don't have root access on the target server, so I can't change the syslog configuration. Trouble is, I want to see the log output. I'm not a unix geek, I didn't find any mechanism to control local syslog output when you don't have root access. There's a pretty good chance I missed it. It probably didn't help that the server runs an ancient version of centos (version -7.11, but I might have misread that).

So I've hacked the NRPE 2.15 source to log to a file, extending the existing feature to log to the syslog daemon. This is a dirty hack, and is not good enough to be submitted for consideration for the next version.

I've attached the code, should anyone want a look. To build it, replace nrpe.c from version 2.15 with the mangled version in the attached zip, add locallog.c and .h from the zip to your project, & modify the makefile to compile locallog.c in. I've not included the makefile; it's generated by autoconf and I don't have enough autoconf fu to play there.

To use the hack, amend the configuration file to set log_facility to name a file (I told you it was a dirty hack; I should have created a new variable), and set log_level to say how much logging you want. For example:

log_facility=/home/user/log/logfilename
log_level=3

My changes are licensed under the same licence as NRPE 2.15.
ll.zip
Dirty Hack for NRPE to output to a log file
(15.91 KiB) Downloaded 387 times

Re: NRPE logging to file

Posted: Tue Aug 26, 2014 1:39 pm
by tmcdonald
Thanks for the post! Hey, some of the coolest technologies started out as a quick hack to a problem.

Mod Note: Apologies for the delay. We haven't been getting alerted to responses in the Nagios Ideas forum, so we are moving this post to the appropriate section of the forum.