Installing and setting up nagios on centos 7

Created - 06/11/2015

Last Tested - N/A

OS: Centos

Install httpd

Command= yum install httpd

Command= systemctl start httpd.service

–auto start http at boot–

Command= systemctl enable httpd.service

allow firewall ports

I'm going to disable firewalld and fall back to iptables.

Command= yum install -y iptables-services

Command= systemctl mask firewalld

Command= systemctl enable iptables

Command= systemctl stop firewalld

Command= systemctl start iptables

allow port 80.

Command= iptables -I INPUT -p tcp –destination-port 80 -j ACCEPT

save iptables using the following command.

Command= iptables-save>/etc/sysconfig/iptables

Installing php

Command= yum install -y php

restart the php service.

Command= systemctl restart httpd.service

Install nagios pre reqs

Command= yum install gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel

Add user and groups

Command= useradd nagios

Command= groupadd nagcmd

Command= usermod -a -G nagcmd nagios

Install Nagios Core

Command= cd ~

Download Nagios

Latest stable release
curl -L -O
Latest release candidate
curl -L -O

Extract the Nagios

Command= tar xvf nagios-*.tar.gz

Command= cd nagios-*

Configure Nagios / remove the space in the following command between the two - -

Command= ./configure - -with-command-group=nagcmd

Command= make all

Command= make install

Command= make install-commandmode

Command= make install-init

Command= make install-config

Command= make install-webconf

add apache user to the nagcmd group.

Command= usermod -G nagcmd apache

Install Nagios Plugins

Command= cd ~

curl -L -O

Command= tar xvf nagios-plugins-*.tar.gz

Command= cd nagios-plugins-*

remove the space in the following command between the two - -

Command= ./configure - -with-nagios-user=nagios - -with-nagios-group=nagios - -with-openssl

Command= make

Command= make install

Install NRPE

Command= cd ~

curl -L -O

Check for latest version here:

Command= tar xvf nrpe-*.tar.gz

Command= cd nrpe-*

remove the space in the following command between the two - -

Command= ./configure - -enable-command-args - -with-nagios-user=nagios - -with-nagios-group=nagios - -with-ssl=/usr/bin/openssl - -with-ssl-lib=/usr/lib/x86_64-linux-gnu

Command= make all

Command= make install

Command= make install-xinetd

Command= make install-daemon-config

edit xinetd startup script

Command= nano /etc/xinetd.d/nrpe

only_from = ADD-IP-HERE

Save and Exit.

Command= service xinetd restart

Configure Nagios

Command= nano /usr/local/nagios/etc/nagios.cfg

Uncomment the following line.


Save and Exit.

Create the storage location for configuration files.

Command= mkdir /usr/local/nagios/etc/servers

Configure Nagios Contacts

Command= nano /usr/local/nagios/etc/objects/contacts.cfg

change nagios@localhost to your email address.

email                           nagios@localhost        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

Save and Exit.

Configure check_nrpe Command

Command= nano /usr/local/nagios/etc/objects/commands.cfg

Add the following to the end of the config file.

define command{
      command_name check_nrpe
      command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

Save and Exit.

Configure Apache

You can change nagiosadmin that will be your username. This will require more config HERE.

Command= htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Enter a password.

Restart nagios and apache service.

Command= sudo systemctl start nagios.service

Command= sudo systemctl restart httpd.service

setting nagios to run at boot.

Command= sudo chkconfig nagios on


changing user authorized for host.

change every nagiosadmin to your new username in the following file.

Comman= nano /usr/local/nagios/etc/cgi.cfg


Error: Could not stat() command file '/usr/local/nagios/var/rw/nagios.cmd'!

Command= setenforce 0

Permanent fix.

Command= nano /etc/sysconfig/selinux

change SELINUX=enforce to SELINUX=permissive

Adding Remote Linux Host to Nagios Server