the correct permission for /usr/local/nagios/etc/nagios.cfg

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
choongweing
Posts: 1
Joined: Mon Mar 15, 2021 9:00 am

the correct permission for /usr/local/nagios/etc/nagios.cfg

Post by choongweing »

i always get error for my nagios config file when check using configtest command:
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]# service nagios configtest

Nagios Core 4.4.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2018-08-16
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Unable to open main config file '/usr/local/nagios/etc/nagios.cfg'
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data definitions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.

You have mail in /var/spool/mail/root
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]#
However i believe my file permission is correct:
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]# ls -ltr /usr/local/nagios/etc/nagios.cfg
-rwxrwxr-x 1 nagios nagios 45846 Sep 30 23:58 /usr/local/nagios/etc/nagios.cfg
You have mail in /var/spool/mail/root
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]#
No error is shown in log:
[1632931200] LOG ROTATION: DAILY
[1632931200] LOG VERSION: 2.0
[1632931200] CURRENT HOST STATE: localhost;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 0.07 ms
[1632931200] CURRENT SERVICE STATE: localhost;Current Load;OK;HARD;1;OK - load average: 0.05, 0.07, 0.19
[1632931200] CURRENT SERVICE STATE: localhost;Current Users;OK;HARD;1;USERS OK - 0 users currently logged in
[1632931200] CURRENT SERVICE STATE: localhost;HTTP;CRITICAL;HARD;4;connect to address 127.0.0.1 and port 80: Connection refused
[1632931200] CURRENT SERVICE STATE: localhost;PING;OK;HARD;1;PING OK - Packet loss = 0%, RTA = 0.06 ms
[1632931200] CURRENT SERVICE STATE: localhost;Root Partition;OK;HARD;1;DISK OK - free space: / 7661 MB (50.52% inode=89%):
[1632931200] CURRENT SERVICE STATE: localhost;SSH;CRITICAL;HARD;4;connect to address 127.0.0.1 and port 22: Connection refused
[1632931200] CURRENT SERVICE STATE: localhost;Swap Usage;OK;HARD;1;SWAP OK - 100% free (8099 MB out of 8099 MB)
[1632931200] CURRENT SERVICE STATE: localhost;Total Processes;OK;HARD;1;PROCS OK: 90 processes with STATE = RSZDT
[1632934128] Auto-save of retention data completed successfully.
[1632937728] Auto-save of retention data completed successfully.
[1632941328] Auto-save of retention data completed successfully.
[1632944928] Auto-save of retention data completed successfully.
[1632948528] Auto-save of retention data completed successfully.
[1632952128] Auto-save of retention data completed successfully.
[1632955728] Auto-save of retention data completed successfully.
[1632959328] Auto-save of retention data completed successfully.
[1632962928] Auto-save of retention data completed successfully.
[1632966528] Auto-save of retention data completed successfully.
[1632970128] Auto-save of retention data completed successfully.
[1632973728] Auto-save of retention data completed successfully.
[1632977328] Auto-save of retention data completed successfully.
[1632980928] Auto-save of retention data completed successfully.
[1632984528] Auto-save of retention data completed successfully.
[1632988128] Auto-save of retention data completed successfully.
[1632991728] Auto-save of retention data completed successfully.
[1632995328] Auto-save of retention data completed successfully.
[1632998928] Auto-save of retention data completed successfully.
[1633002528] Auto-save of retention data completed successfully.
[1633006128] Auto-save of retention data completed successfully.
[1633008820] Caught SIGTERM, shutting down...
[1633008820] Caught SIGTERM, shutting down...
[1633008820] Successfully shutdown... (PID=1637)
[1633015632] Error: failed to access() /usr/local/nagios/bin/nagios: Permission denied
[1633015632] Error: Spawning workers will be impossible. Aborting.
/usr/local/nagios/var/nagios.log (END)
**** although it says "Permission denied" for "/usr/local/nagios/bin/nagios" but actually the user and permission for it is correct as well:
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]# ls -ltr /usr/local/nagios/bin/nagios
-rwxrwxr-- 1 nagios nagios 709008 Sep 30 23:15 /usr/local/nagios/bin/nagios
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]#
Lastly my group for nagios user is correct:
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]# groups nagios
nagios : apache nagios nagcmd
You have mail in /var/spool/mail/root
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]#
I tried to enable debug file but unfortunately it doesnt generate any debug log (could be cannot start nagios service in the first place that's why no debug log is generated)
debug_level=1248

# DEBUG VERBOSITY
# This option determines how verbose the debug log out will be.
# Values: 0 = Brief output
# 1 = More detailed
# 2 = Very detailed

debug_verbosity=1



# DEBUG FILE
# This option determines where Nagios should write debugging information.

debug_file=/usr/local/nagios/var/nagios.debug
*** debug file is empty(0 size)
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]# ls -ltr /usr/local/nagios/var/nagios.debug
-rwxr-xr-x 1 nagios nagios 0 May 14 21:18 /usr/local/nagios/var/nagios.debug
[root@x01simnwnagc1a nagioscore-nagios-4.4.2]#

Is there other good way/idea to check what could the reason/error?

Regards,
ChoongWei
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: the correct permission for /usr/local/nagios/etc/nagios.

Post by gormank »

I'd try doing the ls checks on the files as the nagios user rather than root, and check the permissions on the dirs the files are in.

ls -la /usr/local/nagios/etc/nagios.cfg
ls -la /usr/local/nagios/bin/nagios
Locked