parent/child pains

Holger Weiss holger at CIS.FU-Berlin.DE
Sun Oct 23 02:50:49 CEST 2005


* Rossz Vamos-Wentworth <rossz at vamos-wentworth.org> [2005-10-21 11:56]:
> I definately need to get this mess done right because in a week I start 
> a new job and one of the things I will be taking care of is setting up a 
> Nagios system for a large number of hosts and services.  Doing it wrong 
> will multiple this morning's alert problems by a thousand fold! :(

FWIW, I set "parents" simply by tracerouting to the hosts specified in
the Nagios configuration via "address" and then using (the first part
of) the name of the last hop prior to the host:

  #!/usr/bin/perl -w
  #
  # $ cp hosts.cfg hosts.cfg.bak
  # $ setparents.pl < hosts.cfg.bak > hosts.cfg
  #
  sub traceroute ($) {
  	my $host = shift;
  	my @hops = `/usr/bin/traceroute -I $host 2>/dev/null`;
  	die "traceroute -I $host failed" if $? >> 8 != 0;
  	return undef unless @hops > 1; # ignore local hosts
  	die "parse error" unless $hops[-2] =~ /\s+\d+\s+([\w-]+)/;
  	$1;
  }
  for (<>) {
  	print unless /^\s*parents/;
  	if (/^\s*address\s+([\w\.-]+)/) {
  		if (defined (my $parent = traceroute($1))) {
  			print "\tparents $parent\n";
  		}
  	}
  }

Whether this works and whether it makes sense depends on the network
layout, of course.

Holger

-- 
PGP fingerprint:  F1F0 9071 8084 A426 DD59  9839 59D3 F3A1 B8B5 D3DE


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list