Contact Us

How To Install Nagios 4.x Server/Client – Part 1
Nagios is an open-source tool for monitoring servers. when there is a good number of the server then health checks and server monitoring is a headache and Nagios is a good solution for such environment. It’s a lovely Open Source monitoring tool and always keep you updated about server health.
If you are using Nagios you can monitor server hosts on a single platform on your web browser. whenever there is a warning occurring (your setup limit), it shows the warning and sends it to you through mail/SMS accordingly. It helps us to reduce downtime and business losses.
This post will help and instruct you to install Nagios4.0.1 from source (tarball) on RHEL 7.x/6.x/5.x, CentOS 7.x/6.x/5.x and Fedora 24-19 distributions. And it is really easy to set up and 100% effective and time-saving.
Scenario:
Installation Directory: /usr/local/Nagios
Nagios will be accessible at http://IP/nagios or http://localhost/nagios
By default, Nagios Will monitor Your local machine (Disk Usage, CPU Load, Current Users, Total Processes, etc.)
Step 1: Install Required Packages For compilation
-------------- ON RHEL 7.x/6.x/5.x, CentOS 7.x/6.x/5.x -------------------- [[email protected]]# yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp -------------- Fedora 24-19 distributions -------------- [[email protected]]# dnf install -y httpd 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.
[[email protected]]# groupadd nagcmd [[email protected]]# useradd -G nagcmd nagios [[email protected]]# echo "Your Password" | passwd --stdin nagios [[email protected]]# usermod -G nagcmd apache
Step 3: Download Nagios Core 4.4.3 and Nagios Plugin 2.2.1
[[email protected]]# mkdir /root/nagios; cd /root/nagios [[email protected]]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.3.tar.gz [[email protected]]# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
Step 4: Extract Nagios Core and its Plugins
[[email protected]]# tar -xvzf nagios-4.4.3.tar.gz;tar -xvzf nagios-plugins-2.2.1.tar.gz
After Successful Extraction, remove These files if you want to
[[email protected]]# rm -rf nagios-4.4.3.tar.gz nagios-plugins-2.2.1.tar.gz
And Your Directory Will look Like this
[[email protected] nagios]# ll total 1952 drwxrwxr-x. 18 root root 4096 Aug 20 2015 nagios-4.0.1 drwxr-xr-x. 15 root root 4096 Aug 1 21:58 nagios-plugins-2.1.2
Step 5: Configure Nagios Core
[[email protected] nagios] cd nagios-4.4.3 [[email protected] nagios-4.4.3] ./configure --with-command-group=nagcmd
Sample Output
Creating sample config files in sample-config/ ... *** Configuration summary for nagios 4.0.1 017-04-2017 ***: General Options: ------------------------- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Event Broker: yes Install ${prefix}: /usr/local/nagios Install ${includedir}: /usr/local/nagios/include/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/rc.d/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu IOBroker Method: epoll Web Interface Options: ------------------------ HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /usr/bin/traceroute Review the options above for accuracy. If they look okay, type 'make all' to compile the main program and CGIs.
Now Make Final Hit to make it small (do not forget I am putting semicolon)
[[email protected] nagios-4.4.3 ]# make all;make install;make install-init;make install-commandmode; make install-config;make install-webconf
Step 6: Customizing Nagios Configuration
[[email protected] nagios-4.4.3 ]# vim /usr/local/nagios/etc/objects/contacts.cfg Sample ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # Just one contact defined by default - the Nagios admin (that's you) # This contact definition inherits a lot of default values from the 'generic-contact' # template which is defined elsewhere. define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email [email protected],[email protected] ; *** CHANGE THIS TO YOUR EMAIL ADDRESS **** }
Step 7: Install and Configure Web Interface for Nagios
We have already installed Web Interface (make install-webconf
) so need to run this but the following are needed
[[email protected] nagios-4.4.3 ]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password:
Adding password for user nagiosadmin
and restart Nagios and Apache
[[email protected] ]# service httpd start
Step 8: Compile and Install Nagios Plugin
[[email protected]]# cd /root/nagios/nagios-plugins-2.2.1 [[email protected]]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios [[email protected]]# make;make install
Step 8: Checking Configuration and Adding service at startup
For CentOS 6:
[[email protected]]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg [[email protected]]# chkconfig --add nagios [[email protected]]# chkconfig --level 35 nagios on [[email protected]]# chkconfig --add httpd [[email protected]]# chkconfig --level 35 httpd on [[email protected]]# service nagios start
For CentOS 7:
[[email protected] nagios-plugins-2.2.1]# systemctl enable nagios Created symlink from /etc/systemd/system/multi-user.target.wants/nagios.service to /usr/lib/systemd/system/nagios.service. [[email protected] nagios-plugins-2.2.1]# systemctl start nagios [[email protected] nagios-plugins-2.2.1]# systemctl start httpd [[email protected] nagios-plugins-2.2.1]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Step 9: Checking Configuration and Adding service at startup
Login Using http://localhot/nagios or http://IP/nagios and provide the username nagiosadmin
& your password
Here You Can see The Host
See Services which are Being Monitored