Could not open config directory [solved]

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
qroberts
Posts: 2
Joined: Thu Dec 09, 2021 11:04 am

Could not open config directory [solved]

Post by qroberts »

Trying to setup a separate directory to store my nagios configuration files and when I attempt to validate the configuration I get the below error.

Error: Could not open config directory '/usr/local/nagios/etc/objects/corp/contacts.cfg' for reading.

I believe the permissions are correct and I have selinux in permissive mode.

Code: Select all

    [root@NAGSRV objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    
    Nagios Core 4.4.6
    Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
    Copyright (c) 1999-2009 Ethan Galstad
    Last Modified: 2020-04-28
    License: GPL
    
    Website: https://www.nagios.org
    Reading configuration data...
       Read main config file okay...
    Error: Could not open config directory '/usr/local/nagios/etc/objects/corp/contacts.cfg' for reading.
    Error: Invalid max_check_attempts value for host 'localhost'
    Error: Could not register host (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 21)
       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.
Permissions:

Code: Select all

[root@NAGSRV objects]# ls -ld *
-rwxr-xr-x. 1 nagios nagcmd  6747 Dec  7 21:06 commands.cfg
-rwxr-xr-x. 1 nagios nagcmd  1794 Dec  7 21:35 contacts.cfg
-rwxr-xr-x. 1 nagios nagcmd  4777 Dec  7 21:06 localhost.cfg
-rwxr-xr-x. 1 nagios nagcmd  3001 Dec  7 21:06 printer.cfg
drwxr-xr-x. 2 nagios nagcmd    99 Dec  9 10:43 corp
-rwxr-xr-x. 1 nagios nagcmd  3484 Dec  7 21:06 switch.cfg
-rwxr-xr-x. 1 nagios nagcmd 12533 Dec  7 21:06 templates.cfg
-rwxr-xr-x. 1 nagios nagcmd  3512 Dec  7 21:06 timeperiods.cfg
-rwxr-xr-x. 1 nagios nagcmd  7630 Dec  9 10:17 windows.cfg

Code: Select all

[root@NAGSRV objects]# ls -ld ./corp/*
-rwxr-xr-x. 1 nagios nagcmd  1245 Dec  9 10:43 ./corp/contacts.cfg
-rwxr-xr-x. 1 nagios nagcmd  1124 Dec  9 10:39 ./corp/hostgroups.cfg
-rwxr-xr-x. 1 nagios nagcmd  3809 Dec  9 10:45 ./corp/hosts.cfg
-rwxr-xr-x. 1 nagios nagcmd 10967 Dec  9 10:41 ./corp/hosts-service-template.cfg
Groups:

Code: Select all

    [root@NAGSRV objects]# cat /etc/group | grep nag
    nagios:x:1000:
    nagcmd:x:1001:apache,nagios
Selinux:

Code: Select all

    [root@NAGSRV objects]# getenforce
    Permissive
If I edit the nagios.cfg and remove my directory from the cfg_dir= I am able to validate.
Last edited by qroberts on Thu Dec 09, 2021 1:27 pm, edited 1 time in total.
qroberts
Posts: 2
Joined: Thu Dec 09, 2021 11:04 am

Re: Could not open config directory

Post by qroberts »

Solved.

I was using cfg_dir= to specify a file instead of a directory. Using cfg_file= fixed it.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Could not open config directory [solved]

Post by benjaminsmith »

HI,

Thanks for updating the post with your solution.

Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked