Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 505764 - net-analyzer/nrpe - add systemd unit file
Summary: net-analyzer/nrpe - add systemd unit file
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sysadmin Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: install-systemd-unit
  Show dependency tree
 
Reported: 2014-03-25 14:54 UTC by Stefan G. Weichinger
Modified: 2014-07-08 15:59 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan G. Weichinger 2014-03-25 14:54:19 UTC
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 -
Comment 1 Pacho Ramos gentoo-dev 2014-03-30 10:03:46 UTC
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)
Comment 2 Markos Chandras (RETIRED) gentoo-dev 2014-04-10 15:51:38 UTC
(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.
Comment 3 Pacho Ramos gentoo-dev 2014-04-12 10:09:49 UTC
When it runs in foreground you can simply drop "Type" line (as it's the same as "Type=simple")
Comment 4 Markos Chandras (RETIRED) gentoo-dev 2014-04-12 10:23:29 UTC
(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
Comment 5 Pacho Ramos gentoo-dev 2014-04-12 10:32:29 UTC
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 :)
Comment 6 Markos Chandras (RETIRED) gentoo-dev 2014-04-12 10:41:45 UTC
(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.
Comment 7 Pacho Ramos gentoo-dev 2014-04-12 10:51:04 UTC
When I saw the "-s" option looked to be related to AIX or similar :/
Comment 8 Markos Chandras (RETIRED) gentoo-dev 2014-04-12 10:59:55 UTC
(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.
Comment 9 Pacho Ramos gentoo-dev 2014-04-12 11:21:49 UTC
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
Comment 10 Markos Chandras (RETIRED) gentoo-dev 2014-04-12 11:51:39 UTC
(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
Comment 11 Pacho Ramos gentoo-dev 2014-04-12 11:58:41 UTC
Will try in my next "unit files addition round" ;)
Comment 12 Pacho Ramos gentoo-dev 2014-04-13 08:19:06 UTC
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
Comment 13 Markos Chandras (RETIRED) gentoo-dev 2014-05-21 19:09:47 UTC
i am not sure i understand the problem to be honest
Comment 14 Markos Chandras (RETIRED) gentoo-dev 2014-05-21 19:13:58 UTC
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
Comment 15 Pacho Ramos gentoo-dev 2014-05-22 06:55:19 UTC
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
Comment 16 Markos Chandras (RETIRED) gentoo-dev 2014-05-22 18:29:08 UTC
(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
Comment 17 Pacho Ramos gentoo-dev 2014-07-08 15:59:34 UTC
+*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)
+