In this tutorial we will learn about how to install nagios 4.0.2 in Linux using tarball.Nagios is one of the famous and very robust Monitoring Server.The installation has been done in minimal installed CentOS 6.4.Recently Nagios team has released its much awaited 4.x version.The installation steps is applicable to other Nagios version also.
Details of Server:
Operating System : CentOS 6.4
Arch : x86_64
Nagios Version: 4.0.2
My Server IP address: 192.168.1.6
IPtables is stopped
SELINUX is disabled
Follow the given below steps to install Nagios 4.x
Login to your Server by using root user
Step 1 : Install wget package for downloading the Nagios package through command line.
yum install wget
Step 3: Install the dependencies and apache server (httpd)
yum install httpd php gd gd-devel gcc glibc glibc-common openssl perl perl-devel make
Step 4: Now create the user and group for Nagios installation
useradd nagios groupadd nagcmd usermod -a -G nagcmd nagios
Step 5: Now extract the downloaded file. Here I downloaded the file called nagios-4.0.2.tar.gz (see in Step 2)
tar -xvzf nagios-4.0.2.tar.gz
Step 6: After extracting the downloaded nagios package.It will extract out the Nagios directory. Here we downloaded the package nagios-4.0.2.tar.gz, after extraction I got directory called nagios-4.0.2 .
Now change to extracted out Nagios directory . On using
ls -la command you will see many files inside nagios-4.0.2 directory,these all files and directory will be used in installation. So we are going to compile the Nagios package.
cd nagios-4.0.2 ./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode make install-webconf
After running all above commands if you find no error now move to next step.
Now copy the eventhandlers directory into /usr/local/nagios/libexec/ as well as change ownership and group of this copied directory
cp -rvf contrib/eventhandlers/ /usr/local/nagios/libexec/ chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
Step 7: Now we will check nagios.cfg file configuration. Use the given below command for it. It should not show any error otherwise nagios service can not be started. You can use this command whenever you do any configuration change in nagios.cfg file.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Step 8: Now we set the htpasswd apache authentication for user nagiosadmin. This same username and password will be used when you will try to open nagios dashboard.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Step 9: Start the apache and nagios service
/etc/init.d/nagios start /etc/init.d/httpd start
to bydefault service run in runlevel 3,4,5 use below given command
chkconfig nagios on chkconfig httpd on
Step 10: Change the permission of file /usr/local/nagios/var/rw/nagios.cmd .(reference from this troubleshooting post)
chmod 666 /usr/local/nagios/var/rw/nagios.cmd
Install Nagios plugin from source
Now in this section we will install nagios plugin.Later you can also add some more nagios as per your requirement. I downloaded the plugin from this link
Follow the given below steps for nagios plugin installation
cd ~ wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz tar -xvzf nagios-plugins-1.5.tar.gz cd nagios-plugins-1.5 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install
Step 11: Now time to go to Nagios dashboard. Open the web browser in address link type your server ip address appending /nagios.
Now give username nagiosadmin password which you have set in Step 9
My Nagios server ip address is 192.168.1.6 hence replace the ip address with your server ip
After login you will get your Nagios dashboard (See the screenshot)