Nagios in a large production network

Brian Wilson wilson at ncsu.edu
Thu Nov 21 06:34:15 CET 2002


On Wed, 20 Nov 2002, Rafael F Suguiura wrote:

> Hi Brian,
>
> How did you generate config files from a mySQL database?
> I know the question is a little silly, but...
>

It's done with a perl script that I wrote for this project.  Basically,
there's enough information in the mysql database for me to figure out
which service checks to run on a host.  For instance, if an email address
exists exists in the email_notify field for a host, then generate a
contact for that user:

#contact entry for wilson_ncstate_net (wilson at ncstate.net)
define contact{
        contact_name                    wilson_ncstate_net
        alias                           wilson_ncstate_net
....

I then create a contact group for that email (I wish you could associate
contacts with services instead of having to do groups):

# Contact group definition for wilson_ncstate_net-group (really just for
wilson_ncstate_net)
define contactgroup{
        contactgroup_name       wilson_ncstate_net-group
        alias                   Group for wilson_ncstate_net
        members                 wilson_ncstate_net
        }

Then I associate this user with a service for a host.

All hosts that arent associated with an email address get a generic event
handler applied to them.  This event handler logs to mysql the down count
notifications, etc, and a script is run from cron to check for hosts that
have a positive down count.  This way, you can run a cronjob every 15
minutes, and you get all the notifications for the past 15 mins, instead
of getting a notification for every host.  There are also fields in the db
to keep track of notifications that have been sent, scheduled downtime,
etc.

Basically, the script controls these files:
$hostg_file="$conf_dir/hostgroups.cfg";
$hosts_file="$conf_dir/hosts.cfg";
$services_file="$conf_dir/services.cfg";
$contacts_file="$conf_dir/contacts.cfg";
$contactg_file="$conf_dir/contactgroups.cfg";

It backs them up, rebuilds them, checks to make sure everything is valid,
then reloads nagios.  If the validity check fails, then the backups are
restored.  It also does the job of associating a host with a particular
host group (it does this by comparing the IP address with a range of
addresses in a DB which is associated to a Vlan name).

If I get some free time I'll try and get together a database schema and a
cleaned up script that I can share, but for now thats the basic way we're
doing things.

Brian

--
Brian Wilson  <wilson at ncsu.edu>      Network Analyst
Communication Technologies, ATD      W: 919.513.3472
North Carolina State University      www.ncstate.net



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf




More information about the Users mailing list