![Nagios – “错误:无法打开配置目录”但权限正确且 selinux 是允许的](https://linux22.com/image/773033/Nagios%20%E2%80%93%20%E2%80%9C%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E6%89%93%E5%BC%80%E9%85%8D%E7%BD%AE%E7%9B%AE%E5%BD%95%E2%80%9D%E4%BD%86%E6%9D%83%E9%99%90%E6%AD%A3%E7%A1%AE%E4%B8%94%20selinux%20%E6%98%AF%E5%85%81%E8%AE%B8%E7%9A%84.png)
尝试设置一个单独的目录来存储我的 nagios 配置文件,当我尝试验证配置时出现以下错误。
错误:无法打开配置目录“/usr/local/nagios/etc/objects/corp/contacts.cfg”进行读取。
我相信权限是正确的,并且我的 selinux 处于宽容模式。
[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.
权限:
[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
[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
群组:
[root@NAGSRV objects]# cat /etc/group | grep nag
nagios:x:1000:
nagcmd:x:1001:apache,nagios
Selinux:
[root@NAGSRV objects]# getenforce
Permissive
nagios.cfg:
# NAGIOS USER
# This determines the effective user that Nagios should run as.
# You can either supply a username or a UID.
nagios_user=nagios
# NAGIOS GROUP
# This determines the effective group that Nagios should run as.
# You can either supply a group name or a GID.
nagios_group=nagcmd
如果我编辑nagios配置文件并从 cfg_dir= 中删除我的目录我可以验证。
答案1
cfg_dir=
期望目录,但您提供了配置的路径文件反而。
要么使用
cfg_file=/usr/local/nagios/etc/objects/corp/contacts.cfg
或者
cfg_dir=/usr/local/nagios/etc/objects/corp/