added option min-time-between-resolves-option and tests for it
[pingcheck] / src / config / configuration.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*/
522c2378
GMF
20#ifndef CONFIGURATION_H
21#define CONFIGURATION_H
ced28dc7 22
aa48371a 23#include <stdint.h>
9c55ecd3 24
ced28dc7 25#include <string>
8739a651 26#include <vector>
ced28dc7 27
5ba17410
GMF
28#include <logfunc.hpp>
29
dbe36b16 30#include <boost/shared_ptr.hpp>
096b06ef 31#include <boost/random/linear_congruential.hpp>
dbe36b16 32
9c55ecd3 33#include "config/host.h"
2c40f493 34#include "host/loglevel.h"
5ba17410 35#include "host/logoutput.h"
ad8eb8ab 36
14d14bd7
GMF
37//-----------------------------------------------------------------------------
38// Configuration
39//-----------------------------------------------------------------------------
ced28dc7 40
096b06ef
CH
41typedef boost::rand48 rand_gen_type;
42
708b0d12
GMF
43/**
44 * @brief This class works like a POD (Plain Old Data) for configuration options.
45 */
ced28dc7
GMF
46class Configuration
47{
48public:
49 Configuration();
50 virtual ~Configuration();
51
8ef29e4a
GMF
52 bool get_daemon() const;
53 void set_daemon( bool daemon );
54
14d14bd7 55 std::string get_config_file_name() const;
703f4d65 56 void set_config_file_name( const std::string &config_file_name );
aa48371a 57
f3c09c5a
GMF
58 I2n::Logger::LogLevel get_log_level() const;
59 void set_log_level( const I2n::Logger::LogLevel &log_level );
2c40f493 60
5ba17410
GMF
61 LogOutput get_log_output() const;
62 void set_log_output( const LogOutput &log_output );
63
fda777ea
CH
64 std::string get_log_file() const;
65 void set_log_file( const std::string &log_file );
66
61e224f8
GMF
67 std::string get_nameserver() const;
68 void set_nameserver( const std::string &nameserver );
69
abb06ac2
GMF
70 std::string get_source_network_interface() const;
71 void set_source_network_interface(
72 const std::string &source_network_interface
73 );
74
a341119a
GMF
75 int get_hosts_down_limit() const;
76 void set_hosts_down_limit( const int hosts_down_limit );
ad8eb8ab 77
a341119a
GMF
78 int get_ping_fail_limit() const;
79 void set_ping_fail_limit( const int ping_fail_limit );
c5e4bfa1 80
d52d036a
GMF
81 std::string get_status_notifier_cmd() const;
82 void set_status_notifier_cmd( const std::string &status_notifier_cmd );
83
4d6ab0f3
GMF
84 int get_link_up_interval_in_min() const;
85 void set_link_up_interval_in_min( const int link_up_interval_in_min );
fb09230d 86
1634f2a1
GMF
87 int get_link_down_interval_in_min() const;
88 void set_link_down_interval_in_min( const int link_down_interval_in_min );
89
079d19ab
CH
90 int get_ping_reply_timeout() const;
91 void set_ping_reply_timeout( const int ping_reply_timeout );
92
93 int get_max_address_resolution_attempts() const;
94 void set_max_address_resolution_attempts(
95 const int max_address_resolution_attempts );
96
97 int get_resolved_ip_ttl_threshold() const;
98 void set_resolved_ip_ttl_threshold(
99 const int resolved_ip_ttl_threshold );
100
f833126b
CH
101 int get_min_time_between_resolves() const;
102 void set_min_time_between_resolves(
103 const int min_time_between_resolves );
104
c5b4902d
CH
105 std::string get_dns_cache_file() const;
106 void set_dns_cache_file(const std::string &dns_cache_file);
107
096b06ef
CH
108 float get_ratio_random_hosts() const;
109 void set_ratio_random_hosts( const float ratio );
110
dbe36b16
GMF
111 HostList get_hosts() const;
112 void set_hosts( const HostList &hosts_list );
ced28dc7 113
096b06ef
CH
114 int get_random_number(const int lowest, const int highest);
115
bfec40a6
CH
116 void set_print_version( const bool do_print );
117 bool get_print_version();
118
079d19ab
CH
119 bool randomize_hosts();
120
ced28dc7 121private:
8ef29e4a 122 bool Daemon;
f3c09c5a 123 I2n::Logger::LogLevel LoggingLevel;
5ba17410 124 LogOutput LoggingOutput;
fda777ea 125 std::string LogFileName;
33f408b1 126 std::string ConfigFileName;
abb06ac2 127 std::string SourceNetworkInterface;
61e224f8 128 std::string NameServer;
a341119a 129 int HostsDownLimit;
dbe36b16
GMF
130 int MinHostsDownLimit;
131 int MaxHostsDownLimit;
a341119a 132 int PingFailLimit;
dbe36b16
GMF
133 int MinPingFailLimit;
134 int MaxPingFailLimit;
d52d036a 135 std::string StatusNotifierCmd;
4d6ab0f3 136 int LinkUpIntervalInMin;
1634f2a1 137 int LinkDownIntervalInMin;
dbe36b16
GMF
138 int MinStableLinkIntervalInMin;
139 int MaxStableLinkIntervalInMin;
079d19ab
CH
140 int PingReplyTimeout;
141 int MaxAddressResolutionAttempts;
142 int ResolvedIpTtlThreshold;
f833126b 143 int MinTimeBetweenResolves;
c5b4902d 144 std::string DnsCacheFile;
dbe36b16 145 HostList Hosts;
079d19ab 146 float RatioRandomHosts;
bfec40a6 147 bool PrintVersion;
096b06ef 148 rand_gen_type RandomNumberGenerator;
ced28dc7
GMF
149};
150
dbe36b16
GMF
151//-----------------------------------------------------------------------------
152// ConfigurationItem
153//-----------------------------------------------------------------------------
154
155typedef boost::shared_ptr<Configuration> ConfigurationItem;
156
708b0d12 157#endif // CONFIGURATION_H