Nagios on ubuntu

Here’s the HTML version of the rewritten content: ```html

In this Scenario

We have two machines: one running Ubuntu Server 10.04, which will be used for Nagios monitoring, and another running Ubuntu 10.10, serving as a remote host to be monitored. Both machines have a minimal installation.

On the Nagios Server

  1. Install Required Packages:
    root@nagios-ubuntu:~# apt-get -y install ssh php5-gd gcc make build-essential libgd2-xpm-dev libssl-dev
  2. Create a User for Nagios:
    root@nagios-ubuntu:~# useradd -m nagios
    root@nagios-ubuntu:~# passwd nagios

    When a new user is created, a group with the same name is typically assigned. However, it's good practice to create a dedicated Nagios group and add the Nagios user to both this group and the www-data (Apache2) group:

    root@nagios-ubuntu:~# groupadd nagios
    root@nagios-ubuntu:~# usermod -G nagios nagios
    root@nagios-ubuntu:~# usermod -a -G nagios www-data
  3. Create a Directory for Nagios Files:
    root@nagios-ubuntu:~# mkdir /garbage
    root@nagios-ubuntu:/garbage# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.3.1.tar.gz http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
  4. Extract the Nagios Core Package:
    root@nagios-ubuntu:/garbage# tar vxzf nagios-3.3.1.tar.gz
    root@nagios-ubuntu:/garbage# cd nagios
  5. Configure and Install Nagios:
    root@nagios-ubuntu:/garbage# ./configure --with-gd-lib=/usr/lib --with-gd-inc=/usr/include --with-command-group=nagcmd

    Use sed to prevent errors during the build process:

    root@nagios-ubuntu:/garbage/nagios# sed -i 's:for file in includes/rss/\*;:for file in includes/rss/\*.\*;:g' ./html/Makefile
    root@nagios-ubuntu:/garbage/nagios# sed -i 's:for file in includes/rss/extlib/\*;:for file in includes/rss/extlib/\*.\*;:g' ./html/Makefile

    Build and install Nagios:

    root@nagios-ubuntu:/garbage/nagios# make all
    root@nagios-ubuntu:/garbage/nagios# make install
    root@nagios-ubuntu:/garbage/nagios# make install-init
    root@nagios-ubuntu:/garbage/nagios# make install-config
    root@nagios-ubuntu:/garbage/nagios# make install-commandmode
    root@nagios-ubuntu:/garbage/nagios# make install-webconf
  6. Check Nagios Configuration:
    root@nagios-ubuntu:/garbage/nagios# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  7. Set Up Login for Nagios Monitoring:
    root@nagios-ubuntu:/garbage/nagios# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  8. Reload Apache Service:
    root@nagios-ubuntu:/garbage/nagios# sudo /etc/init.d/apache2 reload
  9. Ensure Nagios Starts on Reboot:
    root@nagios-ubuntu:/garbage/nagios# ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Installing Nagios Plugins

  1. Extract and Enter the Plugins Directory:
    root@nagios-ubuntu:/garbage/nagios-plugins-1.4.15# ./configure
    root@nagios-ubuntu:/garbage/nagios-plugins-1.4.15# make
    root@nagios-ubuntu:/garbage/nagios-plugins-1.4.15# make install
  2. Verify Nagios Configuration Again:
    root@nagios-ubuntu:/garbage/nagios-plugins-1.4.15# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  3. Access Nagios in Your Browser:

    Point your browser to http://Nagios_Machine's_IP/nagios.

Monitoring Linux Hosts

On the remote Ubuntu machine:

  1. Install Required Packages:
    root@ubuntu:/# apt-get install libssl-dev gcc
  2. Download NRPE Add-on:
    root@ubuntu:/addons# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
  3. Create a Nagios User:
    root@ubuntu:/addons# useradd nagios
    root@ubuntu:/addons# passwd nagios
  4. Extract and Install Nagios Plugins:
    root@ubuntu:/addons# tar vxzf nagios-plugins-1.4.15.tar.gz
    root@ubuntu:/addons# cd nagios-plugins-1.4.15/
    root@ubuntu:/addons/nagios-plugins-1.4.15/# ./configure
    root@ubuntu:/addons/nagios-plugins-1.4.15/# make
    root@ubuntu:/addons/nagios-plugins-1.4.15/# make install
  5. Extract and Install NRPE:
    root@ubuntu:/addons/nrpe-2.13# tar vxzf nrpe-2.13.tar.gz
    root@ubuntu:/addons/nrpe-2.13# cd nrpe-2.13/
    root@ubuntu:/addons/nrpe-2.13# ./configure
    root@ubuntu:/addons/nrpe-2.13# make all
    root@ubuntu:/addons/nrpe-2.13# make install-plugin
    root@ubuntu:/addons/nrpe-2.13# make install-daemon
    root@ubuntu:/addons/nrpe-2.13# make install-daemon-config
  6. Run NRPE as a Service Under xinetd:
    root@ubuntu:/addons/nrpe-2.13# make install-xinetd
  7. Edit the NRPE Configuration:

    Update the /etc/xinetd.d/nrpe file to include the IP address of the monitoring server:

    only_from = 127.0.0.1 192.168.56.102
  8. Add NRPE Entry to /etc/services:
    nrpe 5666/tcp # NRPE
  9. Restart xinetd Service:
    root@ubuntu:/addons/nrpe-2.13# service xinetd restart
            
  10. Check if NRPE is Running:
    root@ubuntu:/addons/nrpe-2.13# netstat -at | grep nrpe
  11. Issue Commands to Verify NRPE:
    /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
    /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load

Installing NRPE on Monitoring Server

  1. Extract and Install NRPE:
    root@ubuntu:/garbage/nrpe-2.13# tar vxzf nrpe-2.13.tar.gz
    root@ubuntu:/garbage/nrpe-2.13# cd nrpe-2.13/
    root@ubuntu:/garbage/nrpe-2.13# ./configure
    root@ubuntu:/garbage/nrpe-2.13# make all
    root@ubuntu:/garbage/nrpe-2.13# make install-plugin
  2. Check Communication with Remote Host:
    root@ubuntu:/garbage/nrpe-2.13# /usr/local/nagios/libexec/check_nrpe -H 192.168.56.103

    If successful, you should see NRPE v2.13.

  3. Configure Nagios for Remote Host Monitoring: Open the main Nagios config file:
    root@ubuntu:/usr/local/nagios/etc/objects# vim /usr/local/nagios/etc/nagios.cfg

    Update the admin_email field and add:

    cfg_file=/usr/local/nagios/etc/objects/ubuntu.cfg
  4. Create Remote Host Configuration File: Create ubuntu.cfg under the same path, copying from localhost.cfg as needed. Change the ownership and update parameters:
    hostgroup_name My remote ubuntu machines
    # Change the IP and hostname accordingly
  5. Reload Nagios: Restart Apache and Nagios services, then access http://your_Nagios_IP/nagios to monitor the added host.

Monitoring a Windows Client

  1. Install NSClient++ on the Windows Machine: Set it to run as a service and start at boot.
  2. Add Windows Object Definition in Nagios: Update nagios.cfg with:
    cfg_file=/usr/local/nagios/etc/objects/winxp.cfg
  3. Create Windows Configuration File: Create winxp.cfg in the specified path, using windows.cfg as a template if needed. Update the IP and hostgroup_name accordingly.

Happy Monitoring!

```

Comments

Popular posts from this blog

Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile] ((null):0)

Using a Self signed Certificate to Run Apache2 under SSL

IPS (Image Packaging system) in Solaris 10