From: Christian Herdtweck Date: Wed, 20 May 2015 15:22:47 +0000 (+0200) Subject: add some debugging output at NOTICE level to HostStatus so can debug on production... X-Git-Url: http://developer.intra2net.com/git/?p=pingcheck;a=commitdiff_plain;h=3f7c921f38b291e37ee4e3fc98a2b9cdced9988d add some debugging output at NOTICE level to HostStatus so can debug on production machine --- diff --git a/src/host/hoststatus.cpp b/src/host/hoststatus.cpp index 41cab9e..e35f668 100644 --- a/src/host/hoststatus.cpp +++ b/src/host/hoststatus.cpp @@ -20,10 +20,12 @@ on this file might be covered by the GNU General Public License. #include "host/hoststatus.h" #include +#include #include "boost_assert_handler.h" using namespace std; +using I2n::Logger::GlobalLogger; //----------------------------------------------------------------------------- // HostStatus @@ -64,6 +66,10 @@ void HostStatus::set_resolved_ip_count( const int resolved_ip_count ) BOOST_ASSERT( 1 <= resolved_ip_count ); ResolvedIpCount = resolved_ip_count; + + GlobalLogger.notice() << "Stat(" << HostAddress << "): " + << PingsFailedCount << " fail/" << PingsPerformedCount << " pings/" + << ResolvedIpCount << " IPs: #IPs set"; } /** @@ -81,6 +87,10 @@ bool HostStatus::exceeded_ping_failed_limit() const */ void HostStatus::update_ping_statistics( bool ping_success ) { + GlobalLogger.notice() << "Stat(" << HostAddress << "): " + << PingsFailedCount << " fail/" << PingsPerformedCount << " pings/" + << ResolvedIpCount << " IPs: add ping with success=" << ping_success; + BOOST_ASSERT( 1 <= ResolvedIpCount ); BOOST_ASSERT( 0 <= PingsPerformedCount ); BOOST_ASSERT( PingsFailedCount <= PingsPerformedCount ); @@ -122,10 +132,16 @@ void HostStatus::analyze_ping_statistics() // notify if the amount of pings that failed exceed the limit if ( exceeded_ping_failed_limit() ) { + GlobalLogger.notice() << "Stat(" << HostAddress << "): " + << PingsFailedCount << " fail/" << PingsPerformedCount << " pings/" + << ResolvedIpCount << " IPs: notify down"; LinkAnalyzer->notify_host_down( HostAddress ); } else { + GlobalLogger.notice() << "Stat(" << HostAddress << "): " + << PingsFailedCount << " fail/" << PingsPerformedCount << " pings/" + << ResolvedIpCount << " IPs: notify up"; LinkAnalyzer->notify_host_up( HostAddress ); } } //lint !e1762 @@ -140,7 +156,7 @@ void HostStatus::increase_ping_performed_count() { ++PingsPerformedCount; - BOOST_ASSERT( ( 0 <= PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) ); + BOOST_ASSERT( ( 0 < PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) ); } void HostStatus::increase_ping_failed_count() @@ -161,9 +177,17 @@ void HostStatus::analyze_ping_failed_count() if ( PingsFailedCount > ping_fail_limit_count ) { ExceededPingFailedLimit = true; + + GlobalLogger.notice() << "Stat(" << HostAddress << "): " + << PingsFailedCount << " fail/" << PingsPerformedCount << " pings/" + << ResolvedIpCount << " IPs: exceed limit=" << ping_fail_limit_count; } else { ExceededPingFailedLimit = false; + + GlobalLogger.notice() << "Stat(" << HostAddress << "): " + << PingsFailedCount << " fail/" << PingsPerformedCount << " pings/" + << ResolvedIpCount << " IPs: below limit=" << ping_fail_limit_count; } }