2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
25 #include "host/pingstatus.h"
26 #include "link/linkstatus.h"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
33 * @brief This class analyze the host status (up or down) based on the pings
34 * responses (success or failure). And notifies its status.
35 * Scope: one object per host.
41 const std::string &host_address,
42 const int ping_fail_limit_percentage,
43 const int ping_congestion_limit_percentage,
44 const int ping_duration_congestion_thresh,
45 const int n_parallel_pings,
46 const LinkStatusItem link_analyzer
50 void set_resolved_ip_count( const int resolved_ip_count );
51 bool exceeded_ping_failed_limit() const;
52 bool exceeded_ping_congestion_limit() const;
53 void update_ping_statistics( const PingStatus &ping_success,
54 const long ping_duration_us );
57 void update_fail_stats( const PingStatus &ping_success );
58 void update_congestion_stats( const PingStatus &ping_success,
59 const long ping_duration_us );
60 bool tried_all_resolved_ip() const;
61 void analyze_ping_statistics();
62 void reset_ping_counters();
63 void increase_ping_performed_count();
64 void increase_ping_failed_count();
65 void increase_ping_congestion_count();
66 void analyze_ping_failed_count();
67 void analyze_ping_congestion_count();
69 std::string log_prefix();
72 /// the DNS address of the host to analyze
73 std::string HostAddress;
74 /// the object responsible to analyze the link
75 const LinkStatusItem LinkAnalyzer;
76 /// the maximum amount of pings that can fail without warning
77 int PingFailLimitPercentage;
78 /// the maximum amount of pings that can be congested without warning
79 int PingCongestionLimitPercentage;
80 /// the threshold in micro seconds that ping can take with/out congestion
81 long PingDurationCongestionsThresh;
82 /// the amount of IPs that are aliases to the host DNS
84 /// the amount of pings sent until now
85 int PingsPerformedCount;
86 /// the amount of pings sent that failed until now
88 /// the amount of pings sent that indicate congestion until now
89 int PingCongestionCount;
90 /// boolean flag that indicate if the last set of failed pings exceed the
92 bool ExceededPingFailedLimit;
93 /// boolean flag that indicate if the last set of congested pings exceed the
95 bool ExceededPingCongestionLimit;
96 /// number of pingers that ping the same IP in parallel
101 #endif // HOST_STATUS_H