Increase Timeout for systemd supporting legacy init.d nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Pradeeps
Posts: 38
Joined: Thu Dec 22, 2016 11:05 am

Increase Timeout for systemd supporting legacy init.d nagios

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Pradeeps
Posts: 38
Joined: Thu Dec 22, 2016 11:05 am

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

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

Looks like you changed version to 4.4.2 now which contains the systemd file. This should work fine
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked