From: Guilherme Maciel Ferreira Date: Fri, 25 Mar 2011 15:58:20 +0000 (+0100) Subject: Renamed PingAnalyzer to HostStatusAnalyzer X-Git-Tag: v1.0~109 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=c01a60230960db5609e61286b97474cd75f2298a;p=pingcheck Renamed PingAnalyzer to HostStatusAnalyzer - this describes better what the class is suppode to do, analyze the status of the host, using the pings. --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d63f58f..fa0d756 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,7 @@ set(SOURCES notify/statusnotifier.cpp notify/statusnotifiercommand.cpp ping/boostpinger.cpp - ping/pinganalyzer.cpp + ping/hoststatusanalyzer.cpp ping/pingscheduler.cpp main.cpp ) diff --git a/src/ping/pinganalyzer.cpp b/src/ping/hoststatusanalyzer.cpp similarity index 70% rename from src/ping/pinganalyzer.cpp rename to src/ping/hoststatusanalyzer.cpp index b72d4c1..47118ea 100644 --- a/src/ping/pinganalyzer.cpp +++ b/src/ping/hoststatusanalyzer.cpp @@ -1,4 +1,4 @@ -#include "ping/pinganalyzer.h" +#include "ping/hoststatusanalyzer.h" #include @@ -10,10 +10,16 @@ using namespace std; using namespace boost; //----------------------------------------------------------------------------- -// PingAnalyzer +// HostStatusAnalyzer //----------------------------------------------------------------------------- -PingAnalyzer::PingAnalyzer( +/** + * @param host_address the address of the host it has to analyze. + * @param ping_fail_percentage_limit the percentage threshold of pings that can + * fail. + * @param notifier the object used to notify the status of the host. + */ +HostStatusAnalyzer::HostStatusAnalyzer( const string &host_address, const int ping_fail_percentage_limit, shared_ptr notifier @@ -30,23 +36,34 @@ PingAnalyzer::PingAnalyzer( BOOST_ASSERT( ( 0 <= PingFailPercentageLimit ) && ( PingFailPercentageLimit <= 100 ) ); } -PingAnalyzer::~PingAnalyzer() +HostStatusAnalyzer::~HostStatusAnalyzer() { } -void PingAnalyzer::set_resolved_ip_count( const int resolved_ip_count ) +/** + * @param resolved_ip_count the number of IPs resolved for the host. + */ +void HostStatusAnalyzer::set_resolved_ip_count( const int resolved_ip_count ) { BOOST_ASSERT( 1 <= resolved_ip_count ); ResolvedIpCount = resolved_ip_count; } -bool PingAnalyzer::exceeded_ping_failed_limit() const +/** + * @return true if the amount of failed pings given to the host exceeded the + * limit. + */ +bool HostStatusAnalyzer::exceeded_ping_failed_limit() const { return ExceededPingFailedLimit; } -void PingAnalyzer::update_ping_statistics( bool ping_success ) +/** + * Adds a ping status (success or failure). + * @param ping_success + */ +void HostStatusAnalyzer::update_ping_statistics( bool ping_success ) { BOOST_ASSERT( 1 <= ResolvedIpCount ); BOOST_ASSERT( 0 <= PingsPerformedCount ); @@ -71,14 +88,14 @@ void PingAnalyzer::update_ping_statistics( bool ping_success ) BOOST_ASSERT( PingsFailedCount <= PingsPerformedCount ); } -bool PingAnalyzer::tried_all_resolved_ip() const +bool HostStatusAnalyzer::tried_all_resolved_ip() const { BOOST_ASSERT( ( 0 <= PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) ); return ( PingsPerformedCount == ResolvedIpCount ); } -void PingAnalyzer::analyze_ping_statistics() +void HostStatusAnalyzer::analyze_ping_statistics() { BOOST_ASSERT( !HostAddress.empty() ); BOOST_ASSERT( PingsPerformedCount == ResolvedIpCount ); @@ -95,20 +112,20 @@ void PingAnalyzer::analyze_ping_statistics() } -void PingAnalyzer::reset_ping_counters() +void HostStatusAnalyzer::reset_ping_counters() { PingsPerformedCount = 0; PingsFailedCount = 0; } -void PingAnalyzer::increase_ping_performed_count() +void HostStatusAnalyzer::increase_ping_performed_count() { ++PingsPerformedCount; BOOST_ASSERT( ( 0 <= PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) ); } -void PingAnalyzer::increase_ping_failed_count() +void HostStatusAnalyzer::increase_ping_failed_count() { ++PingsFailedCount; @@ -117,7 +134,7 @@ void PingAnalyzer::increase_ping_failed_count() BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) ); } -void PingAnalyzer::analyze_ping_failed_count() +void HostStatusAnalyzer::analyze_ping_failed_count() { BOOST_ASSERT( ( 0 <= PingFailPercentageLimit ) && ( PingFailPercentageLimit <= 100 ) ); BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) ); diff --git a/src/ping/pinganalyzer.h b/src/ping/hoststatusanalyzer.h similarity index 76% rename from src/ping/pinganalyzer.h rename to src/ping/hoststatusanalyzer.h index 6f89620..c46cea6 100644 --- a/src/ping/pinganalyzer.h +++ b/src/ping/hoststatusanalyzer.h @@ -1,5 +1,5 @@ -#ifndef PINGANALYZER_H -#define PINGANALYZER_H +#ifndef HOSTSTATUSANALYZER_H +#define HOSTSTATUSANALYZER_H #include @@ -8,23 +8,23 @@ class StatusNotifier; //----------------------------------------------------------------------------- -// PingAnalyzer +// HostStatusAnalyzer //----------------------------------------------------------------------------- /** - * @brief This class analyze the ping status (success or failure) and decides - * what to do. + * @brief This class analyze the host status (up or down) based on the pings + * responses (success or failure). And notifies its status. * Scope: one object per host. */ -class PingAnalyzer +class HostStatusAnalyzer { public: - PingAnalyzer( + HostStatusAnalyzer( const std::string &host_address, const int ping_fail_percentage_limit, boost::shared_ptr notifier ); - virtual ~PingAnalyzer(); + virtual ~HostStatusAnalyzer(); void set_resolved_ip_count( const int resolved_ip_count ); bool exceeded_ping_failed_limit() const; @@ -49,4 +49,4 @@ private: }; -#endif /* PINGANALYZER_H */ +#endif /* HOSTSTATUSANALYZER_H */ diff --git a/src/ping/pingscheduler.h b/src/ping/pingscheduler.h index a5b6683..bc0caed 100644 --- a/src/ping/pingscheduler.h +++ b/src/ping/pingscheduler.h @@ -7,7 +7,7 @@ #include #include "dns/dnsresolver.h" -#include "ping/pinganalyzer.h" +#include "ping/hoststatusanalyzer.h" #include "ping/pinginterval.h" class StatusNotifier; @@ -51,7 +51,7 @@ private: boost::posix_time::ptime TimeSentLastPing; PingInterval PingIntervalInSec; DnsResolver IpList; - PingAnalyzer Analyzer; + HostStatusAnalyzer Analyzer; };