Fedora 25: 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.

#!/bin/sh

NAGIOS_PASSWD=nagios

sudo dnf install -y nagios nagios-plugins-*

# https://bugzilla.redhat.com/show_bug.cgi?id=1291718
sudo mkdir /var/log/nagios/rw
sudo chown nagios:nagios /var/log/nagios/rw
sudo chmod 700 /var/log/nagios/rw

# 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;
EOF
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

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.

/etc/apache2/conf-available/nagios3.conf

2 Access to Nagios

Access to Nagios via the following URL.

http://<server>/nagios

Input nagiosadmin user and NAGIOS_PASSWD.

0001_BasicAuth.png

Nagios is displayed.

0002_Nagios.png