Install Nagios 3 on Ubuntu 8.10

by Mike on November 26, 2008 · 30 comments

in Nagios

Nagios is a free, open-source tool that can be used to monitor network components and services.  When it detects a problem, it can send alert messages by either e-mail or pager.  It can also be configured so that only designated personnel can view status information for particular services or equipment.  This tutorial will show you how to install Nagios 3 on an Ubuntu 8.10 server.

Installation

Nagios3 is in the repository for Ubuntu 8.10.

sudo apt-get install nagios3

You can see that it will install a number of packages to make it all work.
The following extra packages will be installed:
libfreetype6 libgd2-noxpm libjpeg62 libnet-snmp-perl libperl5.10 libpng12-0
libradius1 libsensors3 libsnmp-base libsnmp15 libsysfs2 libtalloc1
libwbclient0 nagios-images nagios-plugins nagios-plugins-basic
nagios-plugins-standard nagios3-common nagios3-doc radiusclient1
samba-common smbclient snmp
Suggested packages:
libfreetype6-dev libgd-tools libcrypt-des-perl libdigest-hmac-perl
libdigest-sha1-perl libio-socket-inet6-perl lm-sensors nagios2 nagios-text
nagios whois nagios-nrpe-plugin smbfs
The following NEW packages will be installed:
libfreetype6 libgd2-noxpm libjpeg62 libnet-snmp-perl libperl5.10 libpng12-0
libradius1 libsensors3 libsnmp-base libsnmp15 libsysfs2 libtalloc1
libwbclient0 nagios-images nagios-plugins nagios-plugins-basic
nagios-plugins-standard nagios3 nagios3-common nagios3-doc radiusclient1
samba-common smbclient snmp
0 upgraded, 24 newly installed, 0 to remove and 0 not upgraded.
Need to get 19.5MB of archives.
After this operation, 54.6MB of additional disk space will be used.

Once it is installed run a pre-flight check to verify it is working correctly.

Pre-Flight Check
sudo nagios3 -v nagios.cfg

Nagios 3.0.2
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 05-19-2008
License: GPL

Reading configuration data…

Running pre-flight check on configuration data…

Checking services…
Checked 7 services.
Checking hosts…
Checked 2 hosts.
Checking host groups…
Checked 5 host groups.
Checking service groups…
Checked 0 service groups.
Checking contacts…
Checked 1 contacts.
Checking contact groups…
Checked 1 contact groups.
Checking service escalations…
Checked 0 service escalations.
Checking service dependencies…
Checked 0 service dependencies.
Checking host escalations…
Checked 0 host escalations.
Checking host dependencies…
Checked 0 host dependencies.
Checking commands…
Checked 142 commands.
Checking time periods…
Checked 4 time periods.
Checking for circular paths between hosts…
Checking for circular host and service dependencies…
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…

Total Warnings: 0
Total Errors:   0

Things look okay – No serious problems were detected during the pre-flight check

By default it should run and you should be able to login to the web interface after you create the nagios user.  Move into the /etc/nagios3 directory and create a user to access the web interface.

htpasswd -c htpasswd.users nagios
New password:
Re-type new password:
Adding password for user nagios

Now login to the web interface with http://ip_address/nagios3

You will not have all of the rights to view everything but for the purposes of making sure it all works you will see it is all running.   Now you need to configure it for your settings.

Basic Configuration
The configuration is where you will get to set  up the services and hosts that you need.

Now, cd to the /etc/nagios3 directory.

cd /etc/nagios3

Here you will see the base file nagios.cfg.  The additional configuration files are located in conf.d.

contacts_nagios2.cfg          generic-service_nagios2.cfg      localhost_nagios2.cfg
extinfo_nagios2.cfg           host-gateway_nagios3.cfg         services_nagios2.cfg
generic-host_nagios2.cfg      hostgroups_nagios2.cfg           timeperiods_nagios2.cfg

Check the “timeperiods_nagios2.cfg” file to define different time periods for when you want certain functions to happen.  Here’s an example:

# Time periods
# All times are valid for all
# checks and notifications

define timeperiod{
timeperiod_name 24×7
alias              24 Hours A Day, 7 Days A Week
sunday          00:00-24:00
monday        00:00-24:00
tuesday         00:00-24:00
wednesday    00:00-24:00
thursday        00:00-24:00
friday            00:00-24:00
saturday        00:00-24:00
}

define timeperiod{
timeperiod_name 8×5
alias                8 Hours A Day, 5 Days A Week
monday          08:00-16:00
tuesday           08:00-16:00
wednesday     08:00-16:00
thursday         08:00-16:00
friday             08:00-16:00
}

Check,  the “contacts_nagios2.cfg” file.  This will define the types of notifications that individuals and groups will receive, and when they will be contacted.

# Contacts–Individuals and Groups

define contact{
contact_name                                fred
alias                                              Nagios Admin
service_notification_period          24×7
host_notification_period               24×7
service_notification_options        w,u,c,r
host_notification_options              d,r
service_notification_commands    notify-by-email
host_notification_commands         host-notify-by-email
email                                              fred.smith@some_mail.net
}

The email account that you add for the Nagios Admin should be your main email account as this will be used to send you information.

# contact groups
# Nagios only talks to contact groups, not individuals
# Members must be Nagios users, alias and contact_group
# are whatever you want

define contactgroup{
contactgroup_name               admins
alias                                       Nagios Administrators
members                                 fred
}

In this file, each person who is to be a contact must have his own “define contact” section.  Each person must also be a member of a “contactgroup”.  Also, each person who is to be a contact must have a system account on the Nagios server, have a Nagios password, and be a member of the “nagios” group.  (This group will be created automatically when you install Nagios.)

useradd -m -G nagios fred
passwd fred

If you haven’t yet created the Nagios password database, you’ll use the “htpasswd” command with the -c option to create the new file.

htpasswd -c /etc/nagios/htpasswd.users nagios

If the database has already been created, and you just want to add a new user to it, then omit the -c option:

Now you should be able to see the host that you set up for an example and see that it is monitoring.  You are ready to begin the next phase of setting up a loto of hosts and services to monitor.  If you are interested in learning more about Nagios CLICK HERE for live classes.

{ 16 comments }

Lee November 27, 2008 at 1:14 am

Nice article, I’ve recently been setting up Nagios 3 on my CentOS server install. Last time I tried it was version 2 and either I’ve gotten more intelligent or Nagios 3 is a big improvement as I’ve found it a lot easier then version 2.

One thing I’d like to get into now is setting up host groups as adding each host manually is quite involved.

Thanks

Lee

Zac November 27, 2008 at 6:00 am

Good article. Wow, learn something new everyday. Slowly taking my head out of the sand. :) I shall give it try. Thanks.

Doug November 27, 2008 at 12:20 pm

I installed Nagios on my Ibex last week at work and have been completely satisfied with it. It was easy to install (from source in my case) and configure. A day later I did it at home and am using it there to monitor my Tivos, print server, wireless router and my chumby.

hardawayd November 28, 2008 at 11:37 am

I followed the instructions but when i access my site nagios does not appear. A couple of issues: 1. i use lightpd and when the nagios3 directory is in /etc there is no way for my root for lightpd to access it /var/www/ is my root. I copied nagios3 and its contents to /var/www/ which is not a good practice i believe but there is no index.html file in nagios3 so no web page appears. Please help.

mike November 29, 2008 at 3:04 am

A better way to make adjustments is to look at the config files and change locations of the root for the web server. See the article on file locations as that is the best way to adjust.

johnny December 31, 2008 at 3:05 am

c6Wsz6 Thanks for good post

St January 3, 2009 at 12:07 pm

is all ok :) )
tnk

As400 Mike February 27, 2009 at 5:15 am

Always searching for articles that can help me. Thank you

Jack June 4, 2009 at 4:56 am

Hi,

Thanks for the article.

When I go through the above steps, I get to the pre flight checks (sudo nagios3 -v nagios.cfg) and get the following error:

Reading configuration data…

Error: Cannot open main configuration file ‘/etc/nagios.cfg’ for reading!

Any ideas?

Thanks

Jack June 4, 2009 at 4:59 am

Cancel that forgot to move into the /etc/nagios3 directory.

Mike July 28, 2009 at 3:59 am

hi!!

I have a problem. I’m just new to this nagios and linux setup. But i already setup one centos 5.3 with nagios 3. Ok, i can see the web interface and it’s hosts that being monitored. But the problem is it’s not sending me a notifications.

Thanks in advance!!

mike August 2, 2009 at 4:02 am

A common problem with Nagios is not that is not sending the messages out, but rather that most mail servers will not receive the email from an IP address because they will think it is spam. Try pointing you email to a gmail account for testing, note that it may be listed as spam. If you need more help move the question to the forum and I will be happy to help you there. http://beginlinux.com/forum

Andy January 6, 2010 at 10:03 pm

How do you get full view to the nagios gui? I’ve followed the tutorial and can log in with the user nagios but as the tutorial stated I don’t have full access to see/do anything. How can I change this so I have full access?

mike January 8, 2010 at 2:56 am

By default only nagiosadmin has access to the whole GUI initially. You must use htpasswd to create a password for nagisoadmin so you can log in. You can add other users to the same rights as nagiosadmin.

agitdd99 March 26, 2010 at 2:51 am

I try it on lucid server, and i took time to realize what make the free-flight was not OK, until i run
sudo nagios3 -v /etc/nagios3/nagios.cfg

not “sudo nagios3 -v nagios.cfg”

Tim Moor May 24, 2010 at 9:17 am

Thanks Jack, Jack June 4, 2009 at 4:59 am

Solved my problem.

Cheers!

{ 14 trackbacks }

Previous post:

Next post: