parent/child pains
Andreas Ericsson
ae at op5.se
Sun Oct 23 11:08:52 CEST 2005
Holger Weiss wrote:
> * 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:
>
This won't work if you're monitoring layer 2 switches, since they don't
appear in a traceroute.
It's a nice script though.
> #!/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
>
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
-------------------------------------------------------
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