The Nagios Core is a free version of Nagios – Infrastructure monitoring solution. In our last post we have explained its uses and features which can help you to decide why and how you want to use it. So its recommended to read Nagios – IT Infrastructure Monitoring Solution before you go forward with this post, otherwise you might get lost in the content 😉 .
Nagios Core can only be installed on a linux machine and requires you to be known of linux commands, if not an expert. But I hope most of us can easily google out things and make it work, so no worries. Let’s continue then with a traditional approach:
- Machine with linux, maybe RHEL, CentOS etc, or Ubuntu.
- Root Permissions (Login as Root user or use sudo -i and become one)
So if you have root access, then now let’s download Nagios Core packages and other required plugins.
cd /tmp wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.4.tar.gz wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
Now you have downloaded the packages in /tmp folder and now can add the required dependencies into your system.
For RHEL/CentOS users:
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp
For Ubuntu users:
sudo apt-get install wget build-essential apache2 php5-gd libgd2-xpm libgd2-xpm-dev libapache2-modphp5
Here we added the required packages into our linux system which are mandatory for Nagios Core to work. Like httpd and php provides service through which Nagios Core gives its web interface to the user. Gcc, glibc, etc provides packages to build our Nagios downloaded files and install it on the system.
Now we will add user and group for Nagios Core to work. I hope you are aware of the users, groups, permissions. If not please google it out and learn, before getting your hands dirty with next steps. Moreover you can read our posts Useful Linux Commands and Unix And Linux File Permissions.
useradd nagios groupadd nagcmd usermod -a -G nagcmd nagios
Here we added a user called nagios and a group called nagcmd into our system, also we added nagios user to nagcmd group.
Nagios Core Installation:
- Unzip the files from the downloaded packages
tar zxvf nagios-4.0.4.tar.gz tar zxvf nagios-plugins-2.0.tar.gz
- Go inside the unzipped package to Nagios Core directory
- Configuring package before compiling and installing it.
For RHEL/CentOS users:
For Ubuntu users:
./configure --with-nagios-group=nagios --with-command-group=nagcmd -–with-mail=/usr/bin/sendmail
- Then make the package
make all make install make install-init make install-config make install-commandmode make install-webconf
- Copy the few files from downloaded folders to installation folders and change ownership of those folders to nagios user.
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
- Pre-launch configuration check of Nagios and then starting it. You have to this step all the time when you update nagios configuration file and restart it.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg /etc/init.d/nagios start
- Check if httpd service is up or not and if not, start it(For RHEL/CentOS users:)
- Now we will create a web user to access our Nagios web portal and password protect it.
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
nagiosadmin is the user name and it will ask you to provide password. Let’s say we added [email protected] as password
Nagios Plugins Installation:
Install Nagios plugins, these are the key component which monitors and report the status of monitored element to Nagios platform. Go to its directory where we unzipped it, configure it and do a make install.
cd /tmp/nagios-plugins-2.0 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install
Nagios Service startup:
We will add Nagios daemon to system startup file and it will start the daemon on system startup.
chkconfig --add nagios chkconfig --level 35 nagios on chkconfig --add httpd chkconfig --level 35 httpd on
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Now you can access the Nagios web portal which is running on this system using its ip.
And login into it using username: nagiosadmin and password [email protected]
And you will end up with the following screen. Now just roam around and try to understand what it indicates you 😉 .
We will bring you more about Nagios, just stay tuned and keep visiting us. Also don’t forget to comment below for any queries. 🙂