removed the HostStatus::report_dns_resolution_failure (not used any more)
[pingcheck] / src / host / hoststatus.h
CommitLineData
91fcc471
TJ
1/*
2The software in this package is distributed under the GNU General
3Public License version 2 (with a special exception described below).
4
5A copy of GNU General Public License (GPL) is included in this distribution,
6in the file COPYING.GPL.
7
8As a special exception, if other files instantiate templates or use macros
9or inline functions from this file, or you compile this file and link it
10with other works to produce a work based on this file, this file
11does not by itself cause the resulting work to be covered
12by the GNU General Public License.
13
14However the source code for this file must still be made available
15in accordance with section (3) of the GNU General Public License.
16
17This exception does not invalidate any other reasons why a work based
18on this file might be covered by the GNU General Public License.
19*/
6c14bbee
GMF
20#ifndef HOST_STATUS_H
21#define HOST_STATUS_H
ddf41c89
GMF
22
23#include <string>
24
72e54d1c 25#include "link/linkstatus.h"
ddf41c89
GMF
26
27//-----------------------------------------------------------------------------
6c14bbee 28// HostStatus
ddf41c89
GMF
29//-----------------------------------------------------------------------------
30
c5e4bfa1 31/**
c01a6023
GMF
32 * @brief This class analyze the host status (up or down) based on the pings
33 * responses (success or failure). And notifies its status.
c5e4bfa1
GMF
34 * Scope: one object per host.
35 */
6c14bbee 36class HostStatus
ddf41c89
GMF
37{
38public:
6c14bbee 39 HostStatus(
ddf41c89 40 const std::string &host_address,
cd4048df 41 const int ping_fail_limit_percentage,
c6c54dfb 42 const LinkStatusItem link_analyzer
ddf41c89 43 );
6c14bbee 44 ~HostStatus();
ddf41c89
GMF
45
46 void set_resolved_ip_count( const int resolved_ip_count );
a341119a 47 bool exceeded_ping_failed_limit() const;
ddf41c89
GMF
48 void update_ping_statistics( bool ping_success );
49
50private:
d8a91bd6
GMF
51 bool tried_all_resolved_ip() const;
52 void analyze_ping_statistics();
c1fff16a 53 void reset_ping_counters();
c5e4bfa1
GMF
54 void increase_ping_performed_count();
55 void increase_ping_failed_count();
6827496c 56 void analyze_ping_failed_count();
ddf41c89
GMF
57
58private:
d3e8a9f9 59 /// the DNS address of the host to analyze
c1fff16a 60 std::string HostAddress;
d3e8a9f9 61 /// the object responsible to analyze the link
c6c54dfb 62 const LinkStatusItem LinkAnalyzer;
d3e8a9f9 63 /// the maximum amount of pings that can fail without warning
cd4048df 64 int PingFailLimitPercentage;
d3e8a9f9 65 /// the amount of IPs that are aliases to the host DNS
ddf41c89 66 int ResolvedIpCount;
d3e8a9f9 67 /// the amount of pings sent until now
ddf41c89 68 int PingsPerformedCount;
d3e8a9f9 69 /// the amount of pings sent that failed until now
ddf41c89 70 int PingsFailedCount;
d3e8a9f9
GMF
71 /// boolean flag that indicate if the last set of failed pings exceed the
72 /// limit
a341119a 73 bool ExceededPingFailedLimit;
ddf41c89
GMF
74
75};
76
6c14bbee 77#endif // HOST_STATUS_H