Nagios Core Installation - wAlber47/Tech-Journal GitHub Wiki
This page describes how to install Nagios Core and Nagios Plugins on CentOS 7.
Disable SELinux
Security-Enhanced Linux is a Linux kernel security module that provides a mechanism for supporting access control security policies, including mandatory access controls. We need to disable this so that Nagios can work fully.
setenforce 0
then modify/etc/selinux/config
and changeenforcing
todisabled
Installing Prerequisites
There are some basic programs that Nagios will need to use.
yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl-devel wget unzip -y
You will also need a user/group for Nagios to use.
useradd nagios
useradd nagcmd
usermod -aG nagcmd nagios
usermod -Ag nagcmd apache
Downloading and Installing Nagios
Run these commands to download and extract the files needed.
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
tar zxf nagios-4.1.1.tar.gz
tar zxf nagios-plugins-2.1.1.tar.gz
Now navigate to nagios-4.1.1
from temp and compile the files with these commands. Each command may take some time.
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
Create Password
In order to use the Nagios Core web GUI we need to create a password for the "nagiosadmin" account we created earlier. Store this password somewhere and do not forget it. The command below will prompt you for a password.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Install Plugins
We downloaded the plugins earlier, but now they need to be install and compiled. Navigate to /tmp/nagios-plugins-2.1.1
.
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make all
make install
Firewall Configuration
Nagios' web page will be hidden behind a firewall, you have to run these commands so that you can access the GUI.
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Starting HTTPD Service
systemctl enable httpd
systemctl start httpd
Starting Nagios Service
Now that everything is configured properly we can start the service and access the page.
- Try
systemctl enable nagios
andsystemctl start nagios
.
If neither of those work, then follow these next steps to create your own service for Nagios.
sudo vi /etc/systemd/system/nagios.service
- Add the following from this page.
sudo systemctl enable /etc/systemd/system/nagios.service
sudo systemctl start nagios
sudo systemctl restart nagios
sudo systemctl enable nagios
Accessing Nagios Web GUI
As long as you followed everything in this guide, you should be able to go to http://`nagios-ip`/nagios/ and see your dashboard.