added variable for threshold for switching from "all congested" --> "connection failed"
[pingcheck] / src / host / hoststatus.cpp
index 401051c..e9410c0 100644 (file)
@@ -46,6 +46,7 @@ HostStatus::HostStatus(
         const string &host_address,
         const int ping_fail_limit_percentage,
         const int ping_congestion_limit_percentage,
+        const int congest_caused_by_fail_limit_percentage,
         const int ping_duration_congestion_thresh,
         const int n_parallel_pings,
         const LinkStatusItem link_analyzer
@@ -54,6 +55,7 @@ HostStatus::HostStatus(
     LinkAnalyzer( link_analyzer ),
     PingFailLimitPercentage( ping_fail_limit_percentage ),
     PingCongestionLimitPercentage( ping_congestion_limit_percentage ),
+    CongestCausedByFailLimitPercentage(congest_caused_by_fail_limit_percentage),
     PingDurationCongestionsThresh( ping_duration_congestion_thresh*1000000 ),
     ResolvedIpCount( 0 ),
     PingsPerformedCount( 0 ),
@@ -224,12 +226,16 @@ void HostStatus::analyze_ping_statistics()
     BOOST_ASSERT( PingsPerformedCount >= ResolvedIpCount*NParallelPingers );
 
     // timeouts are not counted towards failures, only count as congestions
-    // However, if all pings timed out even in burst mode, then we still declare
-    // the line down
-    if (InBurstMode && PingCongestionCount >= PingsPerformedCount)
+    // However, if many pings timed out even in burst mode, then we still
+    // declare the line down
+    float limit = static_cast<float>( PingsPerformedCount
+                                    * CongestCausedByFailLimitPercentage)/100.f;
+    if (InBurstMode && PingCongestionCount > limit)
     {
-        GlobalLogger.notice() << log_prefix() << "All pings timed out despite "
-            << "using more pings per IP --> assume connection is really down";
+        GlobalLogger.info() << log_prefix()
+            << "Assume congestion is actually caused by compromised connection "
+            << "to host because " << PingCongestionCount << " of "
+            << PingsPerformedCount << " burst pings timed out";
         PingsFailedCount += PingCongestionCount;
         PingCongestionCount = 0;
         ExceededPingFailedLimit = true;