The Artima Developer Community
Sponsored Link

Python Buzz Forum
Configuring Nagios 3 on Debian 5.0 (Lenny)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Phillip Pearson

Posts: 1083
Nickname: myelin
Registered: Aug, 2003

Phillip Pearson is a Python hacker from New Zealand
Configuring Nagios 3 on Debian 5.0 (Lenny) Posted: Oct 29, 2008 5:37 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Phillip Pearson.
Original Post: Configuring Nagios 3 on Debian 5.0 (Lenny)
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
Latest Python Buzz Posts
Latest Python Buzz Posts by Phillip Pearson
Latest Posts From Second p0st

Advertisement
I've configured a few Nagios installations now, and just finished helping a friend configure another, so it's about time I wrote down some instructions for getting started from scratch.

The key thing to understand about Nagios is that hosts live in hostgroups, that services run on hosts and are checked by commands, and that services can be associated with hosts or (usually) hostgroups. If a service is associated with a hostgroup, all hosts in the group are checked. If a service is associated with a host, only that host is checked.

I'm running through a basic Nagios 3 installation now on a new Debian Lenny EC2 instance (ami-10d73379). I'm using the mg text editor, because it works like emacs but is quicker to download, but you can use vim, nano, emacs, or whatever you prefer.

apt-get update && apt-get install nagios3 mg less

First I make a user entry for myself:

cd /etc/nagios3; htpasswd -c htpasswd.users nagiosadmin

Now I hit /nagios3 on the public IP address of the EC2 instance in a web browser (http://something.compute-1.amazonaws.com/nagios3/) and log in as nagiosadmin with the password I just supplied.

Let's create some hostgroups - say web and db.

mg conf.d/hostgroups_nagios2.cfg

Replace that file with this:

define hostgroup {
  hostgroup_name all
  alias All servers
  members *
}

define hostgroup {
  hostgroup_name web
  alias Web servers
  members web1, web2
}

define hostgroup {
  hostgroup_name db
  alias Database servers
  members db1
}


Now let's define those hosts:

mg conf.d/hosts.cfg

Add this in there:

define host {
  use generic-host;
  host_name web1;
  address web1.example.com;
}
define host {
  use generic-host;
  host_name web2;
  address web2.example.com;
}
define host {
  use generic-host;
  host_name db1;
  address db1.example.com;
}


Now we can define services that run in the new hostgroups, and disable the ones we aren't using any more:

mg conf.d/services_nagios2.cfg

Change the hostgroup_name in the first service (HTTP) to web, and comment out the next two services. Then add the following:

define service {
  hostgroup_name db
  service_description MySQL
  check_command check_mysql
  use generic-service
  notification_interval 0
}


Finally, we can get rid of some example configuration that we don't need, verify that the configuration is sound, and restart the nagios3 service:

rm conf.d/extinfo_nagios2.cfg conf.d/host-gateway_nagios3.cfg
nagios3 -v nagios.cfg
/etc/init.d/nagios3 restart


If all that went well, you should be able to go back to the Hostgroup Overview page on your Nagios install and see the new hostgroups and hosts. The Service Detail page will show a row for each service configured. You'll probably find that the MySQL check won't work because your Nagios host doesn't have access to the MySQL server. If so, you can pass it a login name and password using the check_mysql_cmdlinecred check like this (inside the MySQL service block in conf.d/services_nagios2.cfg):

check_command check_mysql_cmdlinecred!username!password!

You can also check a particular database like this:

check_command check_mysql_database!username!password!databasename!

Don't forget to run nagios3 -v /etc/nagios3/nagios.cfg to check your configuration, then /etc/init.d/nagios3 restart to restart the daemon, before checking the web interface.

And... you're pretty much done. If you add a new database server, just change the members db1 line in conf.d/hostgroups_nagios2.cfg to members db1, db2, check, and restart. To add a new service to a hostgroup, add a new define service block in conf.d/services_nagios2.cfg. All the default check commands (check_http, check_mysql_database etc) are configured in /etc/nagios/plugins/config/*.cfg, so take a look in there for inspiration on what you can check without needing to write your own check plugin.

Enjoy!

Comment

Read: Configuring Nagios 3 on Debian 5.0 (Lenny)

Topic: Week 3, day 1 Previous Topic   Next Topic Topic: Elisa and Telepathy: experimenting with Elisa users socialization

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use