$SPONGSLEEP = $SPONGSLEEP{'spong-network'} || $SPONGSLEEP{'DEFAULT'} ||
$SPONGSLEEP || 300;
+&munge_services(); # Convert service list in %HOSTS to a form that we like
+
%PLUGINS = {};
&config_funcs();
&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);
}
$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
}
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: $@"); }