nrpe does not bring systemd unit files. I edited unit files from https://github.com/fukawi2/aur-packages/tree/master/nagios-nrpe ... works OK so far. Reproducible: Always Steps to Reproduce: 1. install nrpe 2. try to start it with systemd ;-) # cat nrpe.service [Unit] Description=Daemon to answer plugin requests from Nagios on remote hosts After=network.target Requires=network.target [Service] Type=forking User=nagios Group=nagios ExecStart=/usr/libexec/nrpe -c /etc/nagios/nrpe.cfg -d [Install] WantedBy=multi-user.target # cat /usr/lib/tmpfiles.d/nrpe.conf d /run/nrpe 0755 nagios nagios -
I wonder if it could be run with "-d -s" options to allow us to make it run without Type=forking... it looks to start for me, but I don't know if it's really working as expected (=> running in foreground)
(In reply to Pacho Ramos from comment #1) > I wonder if it could be run with "-d -s" options to allow us to make it run > without Type=forking... it looks to start for me, but I don't know if it's > really working as expected (=> running in foreground) What would you put in "Type=" if you add "-s". I am using nrpe with systemd so I can try that for you if you give me a systemd unit file. For the record, I would love to have an official systemd unit file in the ebuild instead of maintaing my own.
When it runs in foreground you can simply drop "Type" line (as it's the same as "Type=simple")
(In reply to Pacho Ramos from comment #3) > When it runs in foreground you can simply drop "Type" line (as it's the same > as "Type=simple") The nrpe does not accept a '-s' parameter as far as I can see[1]. I am not sure what changes you are suggesting to systemd file to be honest. What's wrong with Type=forking ? http://manpages.ubuntu.com/manpages/precise/en/man8/nrpe.8.html
In general we prefer to use Type=simple instead of forking to let systemd to handle all the forking work itself, it's a bit explained at: https://wiki.gentoo.org/wiki/Systemd/Ebuild_policy#Unit_file_guidelines Then, if we have options allowing to run the daemon in foreground, we try to use them, if not, then we go with Type=forking (like in this case) Then, we can go with the Stefan's work :)
(In reply to Pacho Ramos from comment #5) > In general we prefer to use Type=simple instead of forking to let systemd to > handle all the forking work itself, it's a bit explained at: > https://wiki.gentoo.org/wiki/Systemd/Ebuild_policy#Unit_file_guidelines > Ok thanks. Having said that, I am not sure where the '-s' switch is coming from. The man page I quoted above only lists '-d' as argument. I have no nrpe installed on this box to test it at the moment. I will need to check that on Monday from another machine. > Then, if we have options allowing to run the daemon in foreground, we try to > use them, if not, then we go with Type=forking (like in this case) > > Then, we can go with the Stefan's work :) Ok.
When I saw the "-s" option looked to be related to AIX or similar :/
(In reply to Pacho Ramos from comment #7) > When I saw the "-s" option looked to be related to AIX or similar :/ Right I don't see it applies here. In Arch linux they are also using the following unit file nrpe.service [Unit] Description=Daemon to answer plugin requests from Nagios on remote hosts After=network.target Requires=network.target [Service] Type=forking User=nrpe Group=nrpe ExecStart=/usr/bin/nrpe -c /etc/nrpe/nrpe.cfg -d [Install] WantedBy=multi-user.target I'd say we use something similar.
Stefan's unit file looks better to me as it's adapted to the user/group we use in gentoo and also our paths. I am a bit unsure about why a tmpfiles.d file is needed as seems that pid file will be created at parent /run (and, thus, shouldn't need any tmpfiles.d handling) and I see now equivalent in init.d file for creating that dir
(In reply to Pacho Ramos from comment #9) > Stefan's unit file looks better to me as it's adapted to the user/group we > use in gentoo and also our paths. I am a bit unsure about why a tmpfiles.d > file is needed as seems that pid file will be created at parent /run (and, > thus, shouldn't need any tmpfiles.d handling) and I see now equivalent in > init.d file for creating that dir Agreed. Stefan's service file works fine for me, so if anyone from systemd@ or sysadmin@ wants to commit it that would be nice
Will try in my next "unit files addition round" ;)
We need to move pidfile to that subdir, otherwise I get: # systemctl status nrpe ● nrpe.service - Daemon to answer plugin requests from Nagios on remote hosts Loaded: loaded (/usr/lib64/systemd/system/nrpe.service; disabled) Active: active (running) since dom 2014-04-13 10:14:16 CEST; 47s ago Process: 2856 ExecStart=/usr/libexec/nrpe -c /etc/nagios/nrpe.cfg -d (code=exited, status=0/SUCCESS) Main PID: 2857 (nrpe) CGroup: /system.slice/nrpe.service └─2857 /usr/libexec/nrpe -c /etc/nagios/nrpe.cfg -d abr 13 10:14:16 belkin5 systemd[1]: Starting Daemon to answer plugin requests from Nagios on remote hosts... abr 13 10:14:16 belkin5 systemd[1]: Started Daemon to answer plugin requests from Nagios on remote hosts. abr 13 10:14:16 belkin5 nrpe[2857]: Starting up daemon abr 13 10:14:16 belkin5 nrpe[2857]: Cannot write to pidfile '/run/nrpe.pid' - check your privileges. abr 13 10:14:16 belkin5 nrpe[2857]: Listening for connections on port 5666 abr 13 10:14:16 belkin5 nrpe[2857]: Allowing connections from: 127.0.0.1 This is similar to: https://bugzilla.redhat.com/show_bug.cgi?id=575544 But I need confirmation from maintainer as this also affects to openRC
i am not sure i understand the problem to be honest
I am using the following unit file: [Unit] Description=Daemon to answer plugin requests from Nagios on remote hosts After=network.target Requires=network.target [Service] Type=forking ExecStart=/usr/libexec/nrpe -c /etc/nagios/nrpe.cfg -d [Install] WantedBy=multi-user.target and it works fine systemctl status nrpe nrpe.service - Daemon to answer plugin requests from Nagios on remote hosts Loaded: loaded (/etc/systemd/system/nrpe.service; enabled) Active: active (running) since (null); 2h 35min ago Main PID: 7934 (nrpe) CGroup: /system.slice/nrpe.service └─7934 /usr/libexec/nrpe -c /etc/nagios/nrpe.cfg -d
It depends on the user that ends up running nrpe... root or an unprivileged user :/, if we are happy running nrpe as root, there won't be this problem
(In reply to Pacho Ramos from comment #15) > It depends on the user that ends up running nrpe... root or an unprivileged > user :/, if we are happy running nrpe as root, there won't be this problem I thought the user:group is determined by the /etc/nagios/nrpe.cfg configuration file
+*nrpe-2.15-r1 (08 Jul 2014) + + 08 Jul 2014; Pacho Ramos <pacho@gentoo.org> +files/nrpe.service, + +nrpe-2.15-r1.ebuild: + Add unit file (#505764 by Markos Chandras and Stefan G. Weichinger) +