<div class="wp-block-image"><figure class="aligncenter is-resized"><img src="https://i2.wp.com/www.theurbanpenguin.com/wp-content/uploads/2016/09/nagios-core.png?resize=300%2C124&ssl=1" alt="" width="310" height="310"/></figure></div>
<p class="wp-block-paragraph">As soon as Nagios is managed by systemd, you have to change the passing environment variables from /etc/sysconfig/nagios to systemd</p>
<p class="wp-block-paragraph">Edit the file</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ vi /etc/systemd/system/multi-user.target.wants/nagios.service</pre>
<p class="wp-block-paragraph">Add <strong>Environment=””</strong> or <strong>EnvironmentFile=””</strong> to [<strong>service</strong>] section</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">[Service]
Type=forking
ExecStartPre=/usr/sbin/nagios -v /etc/nagios/nagios.cfg
ExecStart=/usr/sbin/nagios -d /etc/nagios/nagios.cfg
ExecStop=/usr/bin/kill -s TERM ${MAINPID}
ExecStopPost=/usr/bin/rm -f /var/spool/nagios/cmd/nagios.cmd
ExecReload=/usr/bin/kill -s HUP ${MAINPID}
Environment="PYTHONHTTPSVERIFY=1"</pre>
<p class="wp-block-paragraph">Restart systemd and nagios</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ sudo systemctl daemon-reload
$ sudo systemctl restart nagios</pre>
<p class="wp-block-paragraph">Check the process environment</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cat /proc/30195/environ
LANG=en_US.UTF-8PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/binPYTHONHTTPSVERIFY=1
$</pre>
<p class="wp-block-paragraph">That will pass all variables into Nagios daemon</p>
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><em>Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or registered trademarks owned by Nagios Enterprises. </em></p></blockquote>
<p class="wp-block-paragraph"><a href="https://www.vkafed.com/contacts/">Let me know</a> if you have any issues with monitoring. Will be glad to help :-)</p>
As soon as Nagios is managed by systemd, you have to change the passing environment variables from /etc/sysconfig/nagios to systemd
Edit the file
$ vi /etc/systemd/system/multi-user.target.wants/nagios.service
Add Environment=”” or EnvironmentFile=”” to [service] section
[Service]
Type=forking
ExecStartPre=/usr/sbin/nagios -v /etc/nagios/nagios.cfg
ExecStart=/usr/sbin/nagios -d /etc/nagios/nagios.cfg
ExecStop=/usr/bin/kill -s TERM ${MAINPID}
ExecStopPost=/usr/bin/rm -f /var/spool/nagios/cmd/nagios.cmd
ExecReload=/usr/bin/kill -s HUP ${MAINPID}
Environment="PYTHONHTTPSVERIFY=1"
Restart systemd and nagios
$ sudo systemctl daemon-reload
$ sudo systemctl restart nagios
Check the process environment
$ cat /proc/30195/environ
LANG=en_US.UTF-8PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/binPYTHONHTTPSVERIFY=1
$
That will pass all variables into Nagios daemon
Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or registered trademarks owned by Nagios Enterprises.
Let me know if you have any issues with monitoring. Will be glad to help 🙂