Page 1 of 5
Fresh Install Nagios 4 "Error in configuration file"
Posted: Thu Feb 04, 2016 3:51 pm
by t3dus
So I'm working on installing Nagios 4 on a fresh Centos 7 VM and I did all the steps as outlind in this article
http://tecadmin.net/install-nagios-core ... ntos-rhel/# but I'm stuck at step 6 which is to verify Nagios install by running the command below
Code: Select all
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Which results in this error
Code: Select all
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL
Website: https://www.nagios.org
Reading configuration data...
Error in configuration file '/usr/local/nagios/etc/nagios.cfg' - Line 452 (Check result path '/usr/local/nagios/var/spool/checkresults' is not a valid directory)
Error processing main config file!
Anyways I know very little about CentOS but I need to resolve this issue and need advice on how to go about doing it.
Thank You in advance.
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Thu Feb 04, 2016 10:08 pm
by Box293
What is the output of these commands:
Code: Select all
ls -al /usr/local/nagios
ls -alR /usr/local/nagios/var
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Thu Feb 04, 2016 10:26 pm
by t3dus
Code: Select all
# ls -al /usr/local/nagios
total 16
drwxr-xr-x. 9 root root 87 Feb 4 15:38 .
drwxr-xr-x. 13 root root 4096 Feb 4 15:29 ..
drwxrwxr-x. 2 nagios nagios 36 Feb 4 15:29 bin
drwxrwxr-x. 3 nagios nagios 70 Feb 4 15:29 etc
drwxr-xr-x. 2 root root 6 Feb 4 15:38 include
drwxr-xr-x. 2 root root 4096 Feb 4 15:38 libexec
drwxrwxr-x. 2 nagios nagios 4096 Feb 4 15:29 sbin
drwxrwxr-x. 15 nagios nagios 4096 Feb 4 15:38 share
drwxr-xr-x. 3 root root 39 Feb 4 15:43 var
Code: Select all
]# ls -alR /usr/local/nagios/var
/usr/local/nagios/var:
total 4
drwxr-xr-x. 3 root root 39 Feb 4 15:43 .
drwxr-xr-x. 9 root root 87 Feb 4 15:38 ..
-rw-r--r--. 1 nagios nagios 255 Feb 4 15:43 nagios.configtest
drwxrwsr-x. 2 nagios nagcmd 6 Feb 4 15:29 rw
/usr/local/nagios/var/rw:
total 0
drwxrwsr-x. 2 nagios nagcmd 6 Feb 4 15:29 .
drwxr-xr-x. 3 root root 39 Feb 4 15:43 ..
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Fri Feb 05, 2016 10:44 am
by rkennedy
i ran through a fresh install, and made the mistake of not disabling SELinux the other day. I ran into the exact same issue. Can you confirm that SELinux is running on your machine with the command getenforce?
I'm setting up a test machine to replicate this now, as well.
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Fri Feb 05, 2016 10:53 am
by t3dus
I ran this command and got these results.
Code: Select all
# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Fri Feb 05, 2016 1:19 pm
by hsmith
What happens if you run the command setenforce 0, and then try to start nagios once more.
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Fri Feb 05, 2016 1:23 pm
by rkennedy
I ran through testing this morning, and the underlying issue is having SELinux enabled when you compile Nagios. It ends up not creating some folders / files, as well as permissions. I wrote up these instructions this morning. You will be better off to install it the proper way. While they are not official yet (still have to go through testing) they should work.
These assume a fresh install of Centos 7, minimal. I am disabling SELinux in these instructions.
SELINUX:
setenforce 0
nano /etc/selinux/config
change enforcing -> disabled, save and close.
INSTALL PRE-REQS:
yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl-devel wget unzip -y
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
DOWNLOAD & INSTALL NAGIOS:
cd /tmp
wget
https://assets.nagios.com/downloads/nag ... 1.1.tar.gz
wget
http://www.nagios-plugins.org/download/ ... 1.1.tar.gz
tar zxf nagios-4.1.1.tar.gz
tar zxf nagios-plugins-2.1.1.tar.gz
cd nagios-4.1.1
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd start
service nagios start
PLUGINS:
cd /tmp/nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make all
make install
service nagios restart
POSSIBLE ERRORS:
Can't access web page? Check firewalld and at port 80 through.
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Still can't access web page? Check IPV6 listening in the apache configuration.
modify /etc/httpd/conf/httpd.conf
Listen 0.0.0.0:80
service httpd restart
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Fri Feb 05, 2016 2:09 pm
by t3dus
hsmith wrote:What happens if you run the command setenforce 0, and then try to start nagios once more.
I get this error when verifying
Code: Select all
# /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
/usr/bin/install: cannot stat ‘sample-config/httpd.conf’: No such file or directory
And this error when trying to start Nagios
Code: Select all
# service nagios start
Starting nagios (via systemctl): Job for nagios.service failed because the control process exited with error code. See "systemctl status nagios.service" and "journalctl -xe" for details.
[FAILED]
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Fri Feb 05, 2016 2:10 pm
by t3dus
rkennedy wrote:I ran through testing this morning, and the underlying issue is having SELinux enabled when you compile Nagios. It ends up not creating some folders / files, as well as permissions. I wrote up these instructions this morning. You will be better off to install it the proper way. While they are not official yet (still have to go through testing) they should work.
These assume a fresh install of Centos 7, minimal. I am disabling SELinux in these instructions.
SELINUX:
setenforce 0
nano /etc/selinux/config
change enforcing -> disabled, save and close.
INSTALL PRE-REQS:
yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl-devel wget unzip -y
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
DOWNLOAD & INSTALL NAGIOS:
cd /tmp
wget
https://assets.nagios.com/downloads/nag ... 1.1.tar.gz
wget
http://www.nagios-plugins.org/download/ ... 1.1.tar.gz
tar zxf nagios-4.1.1.tar.gz
tar zxf nagios-plugins-2.1.1.tar.gz
cd nagios-4.1.1
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd start
service nagios start
PLUGINS:
cd /tmp/nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make all
make install
service nagios restart
POSSIBLE ERRORS:
Can't access web page? Check firewalld and at port 80 through.
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Still can't access web page? Check IPV6 listening in the apache configuration.
modify /etc/httpd/conf/httpd.conf
Listen 0.0.0.0:80
service httpd restart
I'll try to do a fresh install again with your instructions and see how that works for me.
Thanks
Re: Fresh Install Nagios 4 "Error in configuration file"
Posted: Fri Feb 05, 2016 2:10 pm
by hsmith
Let us know how it works. Thanks!