Nagios is an awesome Open Source monitoring tool, its provides you more comprehensive monitoring environment to always keep an eye on your all machines / networks whether you are in a your data center or just your small labs.
Installing Nagios 4.3.4 and Nagios Plugin 2.2.1
If you follow these instructions correctly, you will end up with following information.
- Nagios and its plugins will be installed under /usr/local/nagios directory.
- Nagios will be configured to monitor few services of your local machine (Disk Usage, CPU Load, Current Users, Total Processes, etc.)
- Nagios web interface will be available at http://orissawebhosting.in/nagios
yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp
Step 2: Create Nagios User and Group
Create a new nagios user and nagcmd group account and set a password.
useradd nagios groupadd nagcmd
Next, add both the nagios user and the apache user to the nagcmd group.
usermod -G nagcmd nagios usermod -G nagcmd apache
Step 3: Download Nagios Core 4.3.4 and Nagios Plugin 2.2.1
Create a directory for your Nagios installation and all its future downloads.
mkdir /root/nagios cd /root/nagios
Now download latest Nagios Core 4.3.4 and Nagios plugins 2.2.1 packages with wget command.
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
Step 4: Extract Nagios Core and its Plugins
We need to extract downloaded package with tar command as follows.
tar -xvf nagios-4.3.4.tar.gz tar -xvf nagios-plugins-2.2.1.tar.gz
Configure Nagios Core
Now, first we will configure Nagios Core and to do so we need to go to Nagios directory and run configure file and if everything goes fine, it will show the output in the end as sample output. Please see below.
cd nagios-4.3.4/ ./configure --with-command-group=nagcmd
After configuring, we need to compile and install all the binaries with make all and make install command, it will install all the needed libraries in your machine and we can proceed further.
make all make install
Following command will install the init scripts for Nagios.
To make nagios work from command line we need to install command-mode.
Next, install sample nagios files, please run following command.
Step 5: Customizing Nagios Configuration
Open the “contacts.cfg” file with your choice of editor and set the email address associated with the nagiosadmin contact definition to receiving email alerts.
Step 6: Install and Configure Web Interface for Nagios
We are done with all configuration in the backend, now we will configure Web Interface For Nagios with following command. The below command will Configure Web interface for Nagios and a web admin user will be created “nagiosadmin”.
In this step, we will be creating a password for “nagiosadmin”. After executing this command, please provide a password twice and keep it remember because this password will be used when you login in the Nagios Web interface.
htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin
Step 7: Compile and Install Nagios Plugin
We have downloaded nagios plugins in /root/nagios, Go there and configure and install it as directed below.
cd /root/nagios cd nagios-plugins-2.2.1/ ./configure --with-nagios-user=nagios --with-nagios-group=nagios make all make install
Step 8: Verify Nagios Configuration Files
Now we are all done with Nagios configuration and its time to verify it and to do so please insert following command. If everything goes smooth it will show up similar to below output.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Restart Apache to make the new settings take effect.
systemctl start httpd.service
Step 10: Login to the Nagios Web Interface
Your nagios is ready to work, please open it in your browser with “http://YourIP-address/nagios” or http://orissawebhosting.in/nagios and Provide the username “nagiosadmin” and password.
You’ve successfully installed and configured Nagios and its Plugins. You’ve just begin your journey into monitoring.