added congestion analysis to HostStatus
[pingcheck] / src / host / hoststatus.h
index 3dba06c..1bb5a08 100644 (file)
@@ -40,6 +40,8 @@ public:
     HostStatus(
             const std::string &host_address,
             const int ping_fail_limit_percentage,
+            const int ping_congestion_limit_percentage,
+            const int ping_duration_congestion_thresh,
             const int n_parallel_pings,
             const LinkStatusItem link_analyzer
     );
@@ -47,16 +49,24 @@ public:
 
     void set_resolved_ip_count( const int resolved_ip_count );
     bool exceeded_ping_failed_limit() const;
+    bool exceeded_ping_congestion_limit() const;
     void update_ping_statistics( const PingStatus &ping_success,
                                  const long ping_duration_us );
 
 private:
+    void update_fail_stats( const PingStatus &ping_success );
+    void update_congestion_stats( const PingStatus &ping_success,
+                                  const long ping_duration_us );
     bool tried_all_resolved_ip() const;
     void analyze_ping_statistics();
     void reset_ping_counters();
     void increase_ping_performed_count();
     void increase_ping_failed_count();
+    void increase_ping_congestion_count();
     void analyze_ping_failed_count();
+    void analyze_ping_congestion_count();
+
+    std::string log_prefix();
 
 private:
     /// the DNS address of the host to analyze
@@ -65,15 +75,24 @@ private:
     const LinkStatusItem LinkAnalyzer;
     /// the maximum amount of pings that can fail without warning
     int PingFailLimitPercentage;
+    /// the maximum amount of pings that can be congested without warning
+    int PingCongestionLimitPercentage;
+    /// the threshold in micro seconds that ping can take with/out congestion
+    long PingDurationCongestionsThresh;
     /// the amount of IPs that are aliases to the host DNS
     int ResolvedIpCount;
     /// the amount of pings sent until now
     int PingsPerformedCount;
     /// the amount of pings sent that failed until now
     int PingsFailedCount;
+    /// the amount of pings sent that indicate congestion until now
+    int PingCongestionCount;
     /// boolean flag that indicate if the last set of failed pings exceed the
     /// limit
     bool ExceededPingFailedLimit;
+    /// boolean flag that indicate if the last set of congested pings exceed the
+    /// limit
+    bool ExceededPingCongestionLimit;
     /// number of pingers that ping the same IP in parallel
     int NParallelPingers;