CentOS 7: Install Nagios

This article will describe installing Nagios which is a web-base system monitor tool.

1 Install Nagios

The following script will install Nagios. NAGIOS_PASSWD will be used for Basic authentication password of nagiosadmin user.


sudo yum install -y epel-release
sudo yum install -y nagios nagios-plugins-*

# Apache2
sudo htpasswd -db /etc/nagios/passwd "nagiosadmin" ${NAGIOS_PASSWD}
sudo systemctl enable httpd
sudo systemctl restart httpd
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

# https://bugzilla.redhat.com/show_bug.cgi?id=1291734
cat <<EOF > nagios-socket.te
module nagios-socket 1.0;
require {
  type nagios_t;
  type nagios_log_t;
  class sock_file { write create unlink };
  class unix_stream_socket connectto;
allow nagios_t nagios_log_t:sock_file { write create unlink };
allow nagios_t self:unix_stream_socket connectto;
checkmodule -M -m -o nagios-socket.mod nagios-socket.te
semodule_package -m nagios-socket.mod -o nagios-socket.pp
sudo semodule -i nagios-socket.pp
rm -f nagios-socket.te nagios-socket.mod nagios-socket.pp

cat <<EOF > nagios-statusjsoncgi.te
module nagios-statusjsoncgi 1.0;
require {
  type nagios_script_t;
  type nagios_spool_t;
  class file { getattr read open };
allow nagios_script_t nagios_spool_t:file { getattr read open };
checkmodule -M -m -o nagios-statusjsoncgi.mod \
semodule_package -m nagios-statusjsoncgi.mod \
                 -o nagios-statusjsoncgi.pp
sudo semodule -i nagios-statusjsoncgi.pp
rm -f nagios-statusjsoncgi.te nagios-statusjsoncgi.mod \

sudo setsebool -P daemons_enable_cluster_mode 1

sudo systemctl enable nagios
sudo systemctl restart nagios

Nagios configuration to Apache2 is written in the following file. You can change Nagios configuration like Digest authentication.


2 Access to Nagios

Access to Nagios via the following URL.


Input nagiosadmin user and NAGIOS_PASSWD.


Nagios is displayed.