Emmabuntus, Ubuntu, Derivate, Linux, Open Source BackTrack, Linux, distributions, Ubuntu, derivate, securuty, forensic VirtualBox, Linux, Ubuntu, Raring Ringtail synaptic, Ubuntu, Linux, software packages jwplayer, multimedia, Linux, Ubuntu, flash Meshlab, graphic, software, Ubuntu, open source, Linux Synapse, Linux, Ubuntu, raring, Quantal Gimp, Ubuntu, Linux FreeMind, Linux, open source Linux, infographic, history

Monitor Services with Nagios on Ubuntu 10.04 Lucid Lynx.

Nagios is a flexible monitoring system framework that makes it possible to maintain consistent monitoring of a broad range of infrastructural components.

Many users use Nagios to monitor a broad range of network services over protocols that include SMTP and POP3 (email), HTTP (web), ICMP (ping), and SSH.

In addition to simple uptime monitoring, Nagios also contains features for advanced notification and graphing as well as an extensible plugin architecture that allows users to develop simple plugins for accessing unique monitoring information and providing customized reports.


Before beginning this document, we assume that you have followed our getting started guide and LAMP Guide to achieve a fully functional LAMP stack on your Linode. If you're new to Linux system administration, you may also want to consider the administration basics article in our using linux series.


These instructions work with the Linode platform. If you don't have a Linode yet, sign up for a Linux VPS and get started today.


Prepare for Nagios Installation.

Ensure that your system's package repository and installed packages are up to date by issuing the following commands:

apt-get update apt-get upgrade

Install Dependencies.

Before we can begin installing Nagios, we must first install several prerequisites. Issue the following command:


apt-get install build-essential php5-gd wget libgd2-xpm libgd2-xpm-dev


Create Users and Groups.

Create a new system user account to run Nagios under. Issue the following commands:


adduser --system --no-create-home --disabled-login --group nagios groupadd nagcmd usermod -G nagcmd nagios usermod -a -G nagcmd www-data

Now we're ready to continue with the installation of Nagios itself.


Install Nagios.


Download Nagios Software.

Begin by downloading the latest version of the Nagios Core. At the time of writing the latest version of Nagios is 3.2.1, but be sure that you are downloading the latest version by checking the Nagios download page. Issue the following command:



Next, download the official plugin package for Nagios. At the time of writing this is version 1.4.14, but check the Nagios plugin download page to ensure that this remains the latest version. Issue the following commands:



Image:Nagios-PNP-Screenshot.gif

Build and Install Nagios Core.


Issue the following command to extract, compile and install the Nagios Core software:

tar -xzvf /opt/nagios-3.2.1.tar.gz cd /opt/nagios-3.2.1 ./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode


Configure Nagios Core.

Begin by editing the /usr/local/nagios/etc/objects/contacts.cfg file's email field, according to the example below:
File excerpt: /usr/local/nagios/etc/objects/contacts.cfg
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias John Doe ; Full name of user

email nagiosuser@ducklington.org ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } Issue the following commands to configure the web interface for Nagios:

cd /opt/nagios-3.2.1 make install-webconf

Now issue the following command to create a password for the nagiosadmin user.

To learn more about HTTP Authentication consider our documentation. You will use this password to log into the Nagios administration panel when it is configured.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


Now reload the configuration of the web server by issuing the following command:
/etc/init.d/apache2 reload


Before we continue with the web configuration of Nagios we need to install the default plugins for Nagios.


Build and install Nagios Plugins.

To install and configure the Nagios plugins, issue the following commands to extract, build, and install them:

cd /opt/ tar xzf /opt/nagios-plugins-1.4.14.tar.gz cd /opt/nagios-plugins-1.4.14
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

We're now ready to run Nagios for the first time and continue with the configuration process!

Running Nagios.
Issue the following command to ensure that Nagios will be restarted following a system boot.

chmod +x /etc/init.d/nagios /usr/sbin/update-rc.d -f nagios defaults

Run the following command to check your Nagios configuration file for errors:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


Any errors will be shown in red. If everything is okay, you may issue the following command to start Nagios for the first time:

/etc/init.d/nagios start


Now you can access the web based administration and reporting tools by visiting http://ducklington.org/nagios/, where ducklington.org refers to your Linode's default virtual host. You may also access this interface by visiting http://12.34.56.78/nagios/ where 12.34.56.78 is the IP address of your Linode. You will need to authenticate with the nagiosadmin user you created earlier.


Configure Nagios Alerts.

A great deal of the power of Nagios is its ability to send notifications and alerts of the status of the components of your network on a very granular level. While most of this fine grained configuration is beyond the scope of this document, we have outlined some basic notification systems below.


Installing Prerequsites to send Mail Alerts.

Before Nagios can send Alerts by way of email, basic mail services need to be installed. Issue the following command:

apt-get install mailutils postfix

When the installation process prompts you to define the type of mail setup you're running, select "Internet Site." You will also want to specify the machine specific hostname for this server during the installation process. Next, we'll need to update the path to the mail binary in the Nagios command file. Change both references from /bin/mail to /usr/bin/mail. The relevant section of this file should look like this:
File: /usr/local/nagios/etc/objects/commands.cfg
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Issue the following command to restart Nagios and put the changes into effect:
/etc/init.d/nagios restart
You will now be able to successfully configure and send email alerts using Nagios.
Configuring Basic IRC Notifications
You can also configure Nagios to send notifications to an IRC channel. Issue the following commands to download, extract, and build the IRC bot:

cd /opt/ wget http://www.vanheusden.com/nagircbot/nagircbot-0.0.29b.tgz tar -zxvf /opt/nagircbot-0.0.29b.tgz cd /opt/nagircbot-0.0.29b make make install

You are now ready to run the bot, however you will need to specify some parameters such as the IRC network and channel. For a list of parameters, issue the following command:

nagircbot -h

Now to start the Nagios IRC bot issue the nagircbot command. See the following example as a starting point. Replace irc.ducklington.net with the domain of your IRC network, and #bucknell with the name of the IRC channel to which you would like to send notifications. Replace nagircbot with the desired nickname for your bot, and ident and realname with the ident and real name strings for the IRC bot.
nagircbot -f /usr/local/nagios/var/status.dat -s irc.duckligton.net:6667 -c \#bucknell -C -n nagircbot -u ident -U realname -I 900


In the above example, "-f /usr/local/nagios/var/status.dat" tells the bot where to get status updates. The "-C" flag will allow the bot to send colored messages to the channel depending on the status of the service. When services are down, red status messages are displayed, and these messages turn green when the service has recovered. Warnings are displayed in yellow, but do not typically represent a critical status. The "-I 900" parameter tells the bot to send a status message to the channel every 900 seconds (or 15 minutes). For example, the bot may send something like "Critical: 0, warning: 1, ok: 6, up: 2, down: 0, unreachable: 0, pending: 0", which indicates that there are no critical messages and 1 warning.


These two examples only scratch the surface of the kinds of monitoring and notifications that are possible with Nagios. Explore the resources listed below and the administrative interface for more information regarding the setup and configuration of Nagios. Congratulations on your new Nagios monitoring and notification system.


Default Nagios Interface.

The screenshots below are from the default interface that gets installed with Nagios Core.

Main Splash Screen Tactical Overview Service Detail Host Detail
Hostgroup Overview Hostgroup Summary Hostgroup Grid Service Problems
Circular Status Map Balloon Status Map Tree Status Map Comments
Scheduled Downtime Scheduling Host Downtime Scheduling Service Downtime Nagios Process Info
Performance Info Scheduled Event Queue Alert History Notification History
Event Log Configuration View Alert Summary Menu Trends Menu
Host State Trends Service State Trends Hostgroup Availibility Report Service Availibility Report
Service Alert Histogram Host Alert Histogram PNP Addon Graphs WAP Interface


This guide is licensed under a Creative Commons Attribution-No Derivative Works 3.0 United States License. Please feel free to redistribute unmodified copies of it as long as attribution is provided, preferably via a link to this page.


Adserver          610x250

If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:

rss_trappola

Do you consider this article interesting? Share it on your network of Twitter contacts, on your Facebook wall or simply press "+1" to suggest this result in searches in Google, Linkedin, Instagram or Pinterest. Spreading content that you find relevant helps this blog to grow. Thank you!
Share on Google Plus

About Hugo

Ubuntu is a Linux distribution that offers an operating system predominantly focused on desktop computers but also provides support for servers. Based on Debian GNU / Linux, Ubuntu focuses on ease of use, freedom in usage restriction, regular releases (every 6 months) and ease of installation.
    Blogger Comment
    Facebook Comment

1 comments:

  1. When I first visited this commentary I determined Ubuntuland & The Dream Valley's readers should review this: http://hubpages.com/hub/rent-a-laptop-rentals . I can't fathom renting a notebook at all! The expense for renting a portable computer for even a week or two is going to set you back as much as basically buying the thing!

    ReplyDelete