From 5908a9ca1fb627954af2990627ea7dce61c6e8e4 Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Tue, 18 Apr 2000 18:12:30 +0000 Subject: [PATCH] added support for noping in $services field of %HOSTS --- src/spong-network.pl | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/spong-network.pl b/src/spong-network.pl index a529411..819e98c 100755 --- a/src/spong-network.pl +++ b/src/spong-network.pl @@ -66,6 +66,8 @@ Spong::Daemon::Daemonize() # Daemonize if not signalling or a one-shot $SPONGSLEEP = $SPONGSLEEP{'spong-network'} || $SPONGSLEEP{'DEFAULT'} || $SPONGSLEEP || 300; +&munge_services(); # Convert service list in %HOSTS to a form that we like + %PLUGINS = {}; &config_funcs(); @@ -76,7 +78,7 @@ while( 1 ) { &debug( "checking network services on $host" ); my $check; - foreach $check (('ping',split(/\s+/,$HOSTS{$host}->{'services'}))) { + foreach $check ( split(/\s+/,$HOSTS{$host}->{'services'}) ) { $0 = "spong-network (checking $host/$check)"; &do_check($host,$check); } @@ -419,6 +421,26 @@ sub pipe_handler { $SIG{$_[0]} = \&pipe_handler; } +# This routine munges the services list in %HOSTS to a form that spong-network likes +# it and converts/removed any meta-service names +sub munge_services { + + my ( $service, $services, $host, $ping ); + foreach $host ( @HOSTS_LIST ) { + $ping = 1; $services = ""; + + foreach $service ( split(/\s+/,$HOSTS{$host}->{'services'}) ) { + # noping is a meta-service that say to skip ping test for this host + if ( $service eq "noping" ) { $ping = 0; next; } + $service = " $service" if ( $services ); + $services .= $service; + } + + $services = "ping $services" if ( $ping ); + $HOSTS{$host}->{'services'} = $services; + } +} + # Load all of the checks specified in all of the 'services' attribute # in %HOSTS @@ -434,7 +456,7 @@ sub config_funcs { } my $plugin; - foreach $plugin ( ('ping',keys(%checks)) ) { + foreach $plugin ( keys(%checks) ) { &debug("Loading $plugin plugin"); eval "require 'Spong/Network/plugins/check_$plugin';"; if ( $@ ) { &error("Could not load $plugin plugin: $@"); } -- 2.30.2