Page 1 of 1

Increase Timeout for systemd supporting legacy init.d nagios

Posted: Thu Jan 31, 2019 9:33 am
by Pradeeps
Hello Folks,

I am dealing with a weird issue (atleast to me).
I am running nagios-core 4.2.4 and its using init.d script through systemd.

Code: Select all

[root@nagios-core ~]# systemctl status nagios
● nagios.service - LSB: Starts and stops the Nagios monitoring server
   Loaded: loaded ([b]/etc/rc.d/init.d/nagios[/b]; bad; vendor preset: disabled)
   Active: active (running) since Thu 2019-01-31 06:55:27 UTC; 7h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 49673 ExecStop=/etc/rc.d/init.d/nagios stop (code=exited, status=0/SUCCESS)
  Process: 50505 ExecStart=/etc/rc.d/init.d/nagios start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nagios.service
           ├─52109 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
           ├─52111 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh

As per my understanding "systemd-sysv-generator" creates a service unit for the scripts under "etc/rc.d/init.d/" which is supported by systemd. However I am trying to increase the timeout value of nagios service when started through systemd. The default is 5mins but considering number of devices/services it sometime takes more than that and fails.

Usually for the "nagios.service" under systemd I use "TimeoutSec=15min" to incerease the timeout. However I am not sure how to do this for this one. Can anyone shed some light on this please?

Re: Increase Timeout for systemd supporting legacy init.d na

Posted: Fri Feb 01, 2019 11:36 am
by scottwilkerson
It looks like there is a solution here
https://unix.stackexchange.com/question ... -systemctl

you would create a file /etc/systemd/system/nagios.service.d/reduce-timeout.conf
with contents something like this

Code: Select all

[Service]
TimeoutStartSec=600

Re: Increase Timeout for systemd supporting legacy init.d na

Posted: Fri Feb 08, 2019 8:41 am
by Pradeeps
I have made changes in "/usr/lib/systemd/system/nagios.service" since I see nagios daemon uses that file to load. Is it not he proper location?

Code: Select all

[Unit]
Description=Nagios Core 4.4.2
Documentation=https://www.nagios.org/documentation
After=network.target local-fs.target

[Service]
Type=forking
ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
ExecStop=/usr/bin/kill -s TERM ${MAINPID}
ExecStopPost=/usr/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd
ExecReload=/usr/bin/kill -s HUP ${MAINPID}
TimeoutSec=15min

[Install]
WantedBy=multi-user.target

Re: Increase Timeout for systemd supporting legacy init.d na

Posted: Fri Feb 08, 2019 8:46 am
by scottwilkerson
Looks like you changed version to 4.4.2 now which contains the systemd file. This should work fine