Page 1 of 2

Forced to authenticate to start nagios, but still fails

Posted: Wed Nov 13, 2019 11:42 am
by Zippyduda
Good afternoon all.

When I try and do anything with nagios now all of a sudden I am being forced to authenticate, but the service never completes the start/stop/restart/status anyway.

service nagios start
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'nagios.service'.
Authenticating as: notroot
Password:
notroot@nagios:/root$


I don't know where this is coming from but it seems to be preventing nagios from starting. It was not prompting me last week.

I've seen online about polkit (tried disabling it), sudoers file (tried no entry, both all and nopasswd), which group the nagios user is in (nagios and www-data)

I wasn't being prompted to authenticate previously.

Tried these solution as well:

https://askubuntu.com/questions/98006/h ... a-password

usermod -aG sudo nagios
usermod -aG sudo notroot

Created a systemd file:

/etc/systemd/system/multi-user.target.wants/nagios.service

Code: Select all

[Unit]
Description=Nagios
BindTo=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=nagios
Group=nagios
Type=simple
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
This seems to symlink to /etc/systemd/system/nagios.service

lrwxrwxrwx 1 root root 34 Nov 13 15:58 /etc/systemd/system/multi-user.target.wants/nagios.service -> /etc/systemd/system/nagios.service

Code: Select all

[Unit]
Description=Nagios Core 4.4.5
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=/bin/kill -s TERM ${MAINPID}
ExecStopPost=/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd
ExecReload=/bin/kill -s HUP ${MAINPID}

[Install]
WantedBy=multi-user.target
Here is my /etc/passwd file:

nagios:x:1001:999::/home/nagios:/bin/bash

And /etc/group file:

sudo:x:27:notroot,nagios
www-data:x:33:nagios
nagios:x:999:www-data

Config check:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.4.5
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-08-20
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Checked 94 services.
Checked 73 hosts.
Checked 37 host groups.
Checked 3 service groups.
Checked 9 contacts.
Checked 3 contact groups.
Checked 38 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 73 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

Re: Forced to authenticate to start nagios, but still fails

Posted: Wed Nov 13, 2019 5:46 pm
by ssax
Does it ask when you do it as the root account?

Code: Select all

su - root
systemctl start nagios
If you're doing it with a non-root account you'll likely need to use sudo and update your /etc/sudoers accordingly:

Code: Select all

sudo systemctl start nagios
Please PM a copy of your /etc/sudoers.

Re: Forced to authenticate to start nagios, but still fails

Posted: Thu Nov 14, 2019 4:33 am
by Zippyduda
It doesn't prompt me which is normal but it doesn't actually start the service:

Code: Select all

root@nagios:/# ps -ef | grep nagios
nagios    1355     1  0 Nov06 ?        00:00:09 /usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg
nagios   28007  1670  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start
nagios   28008  1670  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start
root     48131 20594  0 09:29 pts/2    00:00:00 grep --color=auto nagios

root@nagios:/# systemctl start nagios

root@nagios:/# ps -ef | grep nagios
nagios    1355     1  0 Nov06 ?        00:00:09 /usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg
nagios   28007  1670  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start
nagios   28008  1670  0 06:25 ?        00:00:00 /usr/sbin/apache2 -k start
root     48168 20594  0 09:30 pts/2    00:00:00 grep --color=auto nagios

root@nagios:/# service nagios status
● nagios.service - Nagios
   Loaded: loaded (/etc/systemd/system/nagios.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-11-14 09:30:00 UTC; 41s ago
  Process: 48134 ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg (code=exited, status=1/FAILURE)
 Main PID: 48134 (code=exited, status=1/FAILURE)

Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: livestatus: Please visit us at http://mathias-kettner.de/
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: livestatus: Hint: please try out OMD - the Open Monitoring Distribution
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: livestatus: Please visit OMD at http://omdistro.org
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: livestatus: Finished initialization. Further log messages go to /usr/local/nagios/var/livestatus.log
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: Event broker module '/usr/local/nagios/lib/mk-livestatus/livestatus.o' initialized successfully.
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: Error: Module loading failed. Aborting.
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: livestatus: deinitializing
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: livestatus: Logfile cache: flushing complete cache.
Nov 14 09:29:58 nagios.lhasalimited.org nagios[48134]: Event broker module '/usr/local/nagios/lib/mk-livestatus/livestatus.o' deinitialized successfully.
Nov 14 09:30:00 nagios.lhasalimited.org systemd[1]: nagios.service: Failed with result 'exit-code'.
As per nagios instructions it says to not set a password for the nagios user (I believe it is a "locked" account by default?) so when I do

nagios@nagios:~$ sudo systemctl start nagios

It prompts for a password I can't provide. Should I just set one?

So confused why this has changed all of a sudden...

Will send my sudoers file now.

Additionally the service doesn't start after reboot either :(

Also tried this solution with no effect: https://askubuntu.com/questions/98006/h ... a-password

Re: Forced to authenticate to start nagios, but still fails

Posted: Thu Nov 14, 2019 10:35 am
by Zippyduda
Something is definitely broken as when I restore the VM from snapshot (Hyper-V) it is fine but as soon as I reboot the VM or try and restart the service it runs into the same issue of the Nagios service not starting and no useful info from the nagios log...

Re: Forced to authenticate to start nagios, but still fails

Posted: Thu Nov 14, 2019 10:55 am
by Zippyduda
Seemed to have fixed the service not starting/restarting by disabling pnp4nagios (which was fine last week) in the nagios config as was seeing this:

Error: Module '/usr/lib/pnp4nagios/npcdmod.o' is using an old or unspecified version of the event broker API. Module will be unloaded

For some reason am still getting this prompt for nagios user though:

nagios@nagios:/usr/local/nagios/var$ service nagios restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'nagios.service'.
Authenticating as: notroot
Password:

Re: Forced to authenticate to start nagios, but still fails

Posted: Thu Nov 14, 2019 12:48 pm
by Zippyduda
To note doing the following prompts for password:

service nagios restart

But doing the following doesn't:

sudo service nagios restart

This wasn't the case last week.

Re: Forced to authenticate to start nagios, but still fails

Posted: Fri Nov 15, 2019 1:45 pm
by ssax
Try removing your livestatus module from your nagios.cfg file and see if nagios starts all the way.

Try adding these and rebooting your server:

Code: Select all

Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/bin/systemctl, /usr/sbin/service
Then test again.

Re: Forced to authenticate to start nagios, but still fails

Posted: Mon Nov 18, 2019 4:43 am
by Zippyduda
Stupid question but where am I adding those two lines?

Re: Forced to authenticate to start nagios, but still fails

Posted: Mon Nov 18, 2019 5:16 pm
by cdienger
Those should be added to the sudoers file.

Re: Forced to authenticate to start nagios, but still fails

Posted: Tue Nov 19, 2019 4:26 am
by Zippyduda
Thanks :) I've added those lines but still getting prompted sadly:

nagios@nagios:/$ service nagios restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'nagios.service'.
Authenticating as: notroot
Password: