#include "host/hoststatus.h"
#include <iostream>
+#include <iomanip>
#include <logfunc.hpp>
#include "boost_assert_handler.h"
NParallelPingers = n_parallel_pings;
reset_ping_counters();
}
- GlobalLogger.debug() << log_prefix() << "#pingers set";
+
+ log_status_count();
+}
+
+void HostStatus::log_status_count()
+{
+ std::stringstream temp;
+ temp << "Stat(" << HostAddress << "): " << ResolvedIpCount << " IPs"
+ << "*" << NParallelPingers << " (burst=" << InBurstMode << "); "
+ << PingsPerformedCount << " pings; ";
+ temp << std::fixed << std::setprecision(2);
+ float limit = static_cast<float>( PingsPerformedCount
+ * PingFailLimitPercentage) / 100.f;
+ temp << PingsFailedCount << " fail (limit " << limit << "), ";
+ limit = static_cast<float>( PingsPerformedCount
+ * PingCongestionLimitPercentage) / 100.f;
+ float limitC = static_cast<float>( PingsPerformedCount
+ * CongestCausedByFailLimitPercentage)/100.f;
+ temp << PingCongestionCount << " congest (limits " << limit << ","
+ << limitC << ")";
+ GlobalLogger.info() << temp.str();
}
std::string HostStatus::log_prefix()
{
std::stringstream temp;
- temp << "Stat(" << HostAddress << "): "
+ temp << "Stat(" << HostAddress;
+ if (InBurstMode)
+ temp << "!";
+ temp << "): "
<< PingsFailedCount << " fail," << PingCongestionCount << " cong/"
<< PingsPerformedCount << " pings/" << NParallelPingers << "*"
<< ResolvedIpCount << " IPs: ";
}
ResolvedIpCount = resolved_ip_count;
- GlobalLogger.debug() << log_prefix() << "#IPs set";
+ log_status_count();
}
/**
{
float ping_duration_ms = static_cast<float>(ping_duration_us) / 1000.0f;
- GlobalLogger.debug() << log_prefix() << "add ping with result "
- << to_string(result) << " which took " << ping_duration_ms << " ms";
-
BOOST_ASSERT( 0 <= ResolvedIpCount );
BOOST_ASSERT( 0 <= PingsPerformedCount );
BOOST_ASSERT( PingsFailedCount <= PingsPerformedCount );
ping_duration_us );
update_fail_stats( result, failed_because_congested );
+ log_status_count();
+
// after we tried all IPs resolved for this host, we can analyze how many
// failed
if ( tried_all_resolved_ip() )
else if (exceeded_ping_congestion_limit() && !InBurstMode)
// only notify up if will not try burst mode next
// otherwise will continuously notify up and down if get timeouts
- GlobalLogger.notice() << log_prefix() << "will not notify up because "
+ GlobalLogger.debug() << log_prefix() << "will not notify up because "
<< " will go into burst mode next";
else
{
BOOST_ASSERT( ( 0 <= PingFailLimitPercentage ) && ( PingFailLimitPercentage <= 100 ) );
BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) );
- int limit = ( PingsPerformedCount * PingFailLimitPercentage) / 100;
+ float limit = static_cast<float>( PingsPerformedCount
+ * PingFailLimitPercentage) / 100.f;
// keep a boolean variable because the PingsFailedCount can be reseted
if ( PingsFailedCount > limit )
- {
ExceededPingFailedLimit = true;
-
- GlobalLogger.debug() << log_prefix() << "exceed fail limit=" << limit;
- }
else
- {
ExceededPingFailedLimit = false;
-
- GlobalLogger.debug() << log_prefix() << "below fail limit=" << limit;
- }
}
void HostStatus::analyze_ping_congestion_count()
BOOST_ASSERT( ( 0 <= PingCongestionCount )
&& ( PingCongestionCount <= PingsPerformedCount ) );
- int limit = ( PingsPerformedCount * PingCongestionLimitPercentage) / 100;
+ float limit = static_cast<float>( PingsPerformedCount
+ * PingCongestionLimitPercentage) / 100.f;
// keep a boolean variable because the PingCongestionCount can be reseted
if ( PingCongestionCount > limit )
- {
ExceededPingCongestionLimit = true;
-
- GlobalLogger.debug() << log_prefix() << "exceed congestion limit="
- << limit;
- }
else
- {
- ExceededPingCongestionLimit = false;
-
- GlobalLogger.debug() << log_prefix() << "below congestion limit="
- << limit;
- }
}