From e1ce19009d12d5bffc9a0c8e8f678d313980240c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Sun, 29 Mar 2009 15:59:54 +1300 Subject: [PATCH] Move the TCP timeout configuration for check_simple to the config file. --- config/spong.conf-sample | 7 +++++++ src/spong-network.pl | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config/spong.conf-sample b/config/spong.conf-sample index f9c2436..6e847c3 100755 --- a/config/spong.conf-sample +++ b/config/spong.conf-sample @@ -121,6 +121,13 @@ $RECHECKSLEEP = 15; # Sleep time in seconds for down services recheck # greater then 1 +$TCP_SIMPLE_TIMEOUT{"DEFAULT"}=[3,5,12] ; # default timeout for the tcp test ( like pop3,smtp ) + # for all plugins that use &check_simple + +$TCP_SIMPLE_TIMEOUT{"smtp"}=[12,24] ; # default timeout for the tcp test + # for the plugin who use &check_simple with service equal "smtp" + + # --------------------------------------------------------------------------- # Thresholds, season to taste. These can be overridden on a host by host # case in a spong.conf. file. diff --git a/src/spong-network.pl b/src/spong-network.pl index c52e393..723676f 100755 --- a/src/spong-network.pl +++ b/src/spong-network.pl @@ -323,14 +323,14 @@ sub check_simple { my( $color, $summary ) = ( "red", "" ); my( $attempt, $start, $message, $diff, $errcd ); - for $timeout ( 3, 5, 12 ) { + for $timeout (@{( $TCP_SIMPLE_TIMEOUT{$service} || $TCP_SIMPLE_TIMEOUT{'DEFAULT'} || [3,5] )}) { $start = $hires ? main::time() : time(); ($errcd,$message) = &check_tcp( $host, $port, $send, $timeout ); $diff = ($hires ? main::time() : time()) - $start; $attempt++; if( $message =~ /$check/ ) { $color = "green"; last; } - &debug("check_simple: $service - $host - attempt $attempt failed"); + &debug("check_simple: $service - $host - timeout $timeout - attempt $attempt failed"); } $diff = sprintf("%.3f",$diff); -- 2.30.2