NagiosEnterprises / ndoutils

NDOUtils - Database Output for Nagios Core
GNU General Public License v2.0
48 stars 21 forks source link

Solaris 11: ndo2db service will not start if nagios user home directory does not exist #35

Closed box293 closed 7 years ago

box293 commented 7 years ago

If the nagios user (--with-ndo2db-user) does not have a home directory, then the ndo2db service will not start. To demonstrate, disable the service and make it so there is no home directory:

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# svcadm disable ndo2db
root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# rm -f /usr/local/nagios/var/ndo.sock 
root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# mv /export/home/nagios /export/home/nagios2
root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# ls -la /export/home
total 9
drwxr-xr-x   3 root     root           3 May  8 17:41 .
drwxr-xr-x   3 root     root           3 Jun  8  2016 ..
drwxr-xr-x   2 nagios   nagios         2 May  8 15:51 nagios2

Now enable the service:

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# svcadm enable ndo2db

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# svcs -xv ndo2db
svc:/network/nagios/ndo2db:default (NDO2DB daemon)
 State: maintenance since May  8, 2017 05:41:28 PM EST
Reason: Start method exited with $SMF_EXIT_ERR_CONFIG.
   See: http://support.oracle.com/msg/SMF-8000-KS
   See: http://www.nagios.org
   See: /var/svc/log/network-nagios-ndo2db:default.log
Impact: This service is not running.

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# tail /var/svc/log/network-nagios-ndo2db:default.log
[ May  8 17:41:28 Enabled. ]
[ May  8 17:41:28 Executing start method ("/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg"). ]
[ May  8 17:41:28 svc.startd could not set context for method:  ]
chdir: No such file or directory

Now to make sure there is a home directory and start the service:

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# mv /export/home/nagios2 /export/home/nagios

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# svcadm clear ndo2db

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# svcs -xv ndo2db
svc:/network/nagios/ndo2db:default (NDO2DB daemon)
 State: online since May  8, 2017 05:47:17 PM EST
   See: http://www.nagios.org
   See: /var/svc/log/network-nagios-ndo2db:default.log
Impact: None.

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# tail -30 /var/svc/log/network-nagios-ndo2db:default.log
[ May  8 17:47:17 Leaving maintenance because clear requested. ]
[ May  8 17:47:17 Enabled. ]
[ May  8 17:47:17 Executing start method ("/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg"). ]
[ May  8 17:47:17 Method "start" exited with status 0. ]

root@core-041:/var/tmp/ndoutils-ndoutils-2.1.3# tail /usr/local/nagios/var/nagios.log  
[1494229624] ndomod: Still unable to connect to data sink.  0 items lost, 803 queued items to flush.
[1494229642] ndomod: Successfully connected to data sink.  829 queued items to flush.
[1494229644] ndomod: Successfully flushed 829 queued items to data sink.

I also tested this behavior on a CentOS 6.x server and the ndo2db service will run fine if the home directory does not exist.

jfrickson commented 7 years ago

SMF requires a home directory. If you run make install-groups-users it will create the home directory if that user does not yet exist. If an admin runs useradd without the -m flag, there's not much I can do about that. In theory, I could check if the /export/home/<userid> directory exists, but I don't think it's guaranteed to be in that location. It could be (for example) /export/home/n/nagios.

box293 commented 7 years ago

Thats a good point about make install-groups-users, I had not run it as I assumed Nagios Core had taken care of that when it was installed. I will re-visit my Nagios Core install steps to ensure the make install-groups-users is being run.

box293 commented 7 years ago

useradd -d localhost:/export/home/nagios -m nagios