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 0then modify/etc/selinux/configand changeenforcingtodisabled
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 nagiosuseradd nagcmdusermod -aG nagcmd nagiosusermod -Ag nagcmd apache
Downloading and Installing Nagios
Run these commands to download and extract the files needed.
cd /tmpwget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gzwget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gztar zxf nagios-4.1.1.tar.gztar 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=nagcmdmake allmake installmake install-initmake install-configmake install-commandmodemake 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-opensslmake allmake 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 --permanentfirewall-cmd --reload
Starting HTTPD Service
systemctl enable httpdsystemctl start httpd
Starting Nagios Service
Now that everything is configured properly we can start the service and access the page.
- Try
systemctl enable nagiosandsystemctl 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.servicesudo systemctl start nagiossudo systemctl restart nagiossudo 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.