Menu

Installing Nagios 4.1.1 and Nagios Plugin 1.5
Nagios a free and open computer-software application, monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.

Nagios was originally designed to run under Linux, but it also runs well on other Unix variants. It is free software licensed under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
                          
With Nagios you can:
  • Monitor your entire IT infrastructure
  • Spot problems before they occur
  • Know immediately when problems arise
  • Share availability data with stakeholders
  • Detect security breaches
  • Plan and budget for IT upgrades
  • Reduce downtime and business losses
Step 1: Install Required Dependencies
Install Apache, PHP and some libraries like gcc, glibc, glibc-common and GD libraries and its development libraries before installing Nagios 4.1.1 with source. From Yum Library.
yum 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.
[root@hackthesec ]# useradd nagios
[root@hackthesec ]# groupadd nagcmd
Next, add both the nagios user and the apache user to the nagcmd group.

[root@hackthesec ]# usermod -G nagcmd nagios
[root@hackthesec ]# usermod -G nagcmd apache
Step 3: Download Nagios Core 4.1.1 and Nagios Plugin 1.5
Create a directory for your Nagios installation and all its future downloads.

[root@hackthesec ]# mkdir /root/nagios
[root@hackthesec ]# cd /root/nagios
Now download latest Nagios Core 4.1.1 and Nagios plugins 1.5 packages with wget command.

[root@hackthesec nagios~]# wget http://nchc.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.1.1/nagios-4.1.1.tar.gz

[root@hackthesec nagios~]# wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
Step 4: Extract Nagios Core and its Plugins
We need to extract downloaded package with tar command as follows.

[root@hackthesec nagios~]# tar –xvf nagios-4.1.1.tar.gz
[root@hackthesec nagios~]# tar –xvf nagios-plugins-1.5.tar.gz 
When you extract these tarballs with tar command, two new folders will appear in that directory.
[root@hackthesec nagios ~]# ll
total 3712
drwxrwxr-x 18 root root    4099 Feb 24 03:28 nagios-4.1.1
-rw-r--r--  1 root root 1695390 Feb 24 03:32 nagios-4.1.1.tar.gz
drwxr-xr-x 15  200  300    4099 Feb 24 03:40 nagios-plugins-1.5
-rw-r--r--  1 root root 2428259 Feb 24 03:42 nagios-plugins-1.5.tar.gz 
Configure Nagios Core 
We will configure Nagios Core and to do so we need to go to Nagios directory and run configure file and sample output. Please see below.

[root@hackthesec nagios~]# cd nagios-4.1.1
[root@hackthesec nagios-4.1.1]# ./configure --with-command-group=nagcmd
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

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /bin/traceroute

Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.
We need to Compile and install all the binaries with make command and make install command will install all the needed libraries in your machine and sample output bellow

[root@hackthesec nagios-4.1.1 ]# make all
[root@hackthesec nagios-4.1.1 ]# make install
*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs sample config files in /usr/local/nagios/etc
Following command will install the init scripts for Nagios.
[root@hackthesec nagios-4.1.1 ]# make install-init
To make nagios work from command line we need to install command-mode.
[root@hackthesec nagios-4.1.1 ]# make install-commandmode
Next, install sample nagios files, please run following command. and sample output bellow..
[root@hackthesec nagios-4.1.1 ]# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

*** Config files installed ***

Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.
Step 5: Customizing Nagios Configuration
Open the "contacts.cfg" file with your editor and set the email addressassociated with the nagiosadmin contact definition to receiving email alerts.Sample Output Bellow...
# vi /usr/local/nagios/etc/objects/contacts.cfg
###############################################################################
###############################################################################
#
# 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                           hackthesec@hackthesec.co.in     ; *** CHANGE THIS TO YOUR EMAIL ADDRESS ****       }
Step 6: Install and Configure Web Interface for Nagios
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”.
[root@hackthesec nagios-4.1.1 ]# make install-webconf
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.

[root@hackthesec nagios-4.1.1]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
Restart Apache to make the new settings take effect.
[root@hackthesec ]# service httpd start (On RedHat / CentOS)
[root@hackthesec ]# systemctl start httpd.service (On Fedora)
Step 7: Compile and Install Nagios Plugin
We have downloaded nagios plugins in /root/nagios, Go there and configure and install it.
[root@hackthesec nagios]# cd /root/nagios
[root@hackthesec nagios]# cd nagios-plugins-1.5
[root@hackthesec nagios]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@hackthesec nagios]# make
[root@hackthesec nagios]# 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. 
[root@hackthesec nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

*** Nagios/Apache conf file installed ***

 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
...
...
Total Warnings: 0
Total Errors:   0
Step 9: Add Nagios Services to System Startup
We need to add nagios and httpd with chkconfig command.
[root@hackthesec ]# chkconfig --add nagios
[root@hackthesec ]# chkconfig --level 35 nagios on
[root@hackthesec ]# chkconfig --add httpd
[root@hackthesec ]# chkconfig --level 35 httpd on
Restart Nagios to make the new settings take effect.

[root@hackthesec ]# service nagios start (On RedHat / CentOS)
[root@hackthesec ]# systemctl start nagios.service (On Fedora)
Step 10: Login to the Nagios Web Interface
Your nagios is ready to work, please open it in your browser with “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password.



About Author:


I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Next
Newer Post
Previous
Older Post

0 comments:

Post a Comment

 
Top