Non-virtual destructors for classes that are unlikely to be base classes
[pingcheck] / Readme
CommitLineData
f9c5fff0
GMF
1 Table of Contents
2=======================================
31. Introduction
42. Code Conventions
53. Source Code
64. Configuration File
75. References
8
9
10
c08bc448
GMF
111. Introduction
12=======================================
13This application provides means to check the availability of remote hosts
14through pings to them.
15
16
171.1. Rationale
18---------------------------------------
19The application uses ICMP echo requests messages to verify if a given host
20is available or not.
21
22The host's address can be an IP or a DNS.
23
24
251.2. How to use
26---------------------------------------
27There are many ways to invoke the application, the simplest is just type:
28 ./libpingcheck
29which uses the configuration values from the configuration file (describled in
f9c5fff0 30the Configuration File section).
c08bc448 31
703f4d65 32
c08bc448
GMF
331.3. Resources
34---------------------------------------
f9c5fff0
GMF
35Further information about the problem domain can be found in the References
36section.
37
38
391.4. Legal Issues
40---------------------------------------
41All rights reserved to Intra2net AG.
c08bc448
GMF
42
43
44
452. Code Conventions
703f4d65
GMF
46=======================================
47This section describes the code conventions that must be followed when maintain
48this code.
49
50
c08bc448
GMF
512.1. Data Types
52---------------------------------------
53This section is a guideline about the type you MUST use when declaring
54variables and constants. These types were chose to provide portability and
55improve code reradability.
56
57- Use the std::string to represent array of characters.
58
59- Use int32_t, int16_t and int8_t (or their unsigned couter parts) - instead of
60 int, short and char, respectively - when the variable or constant MUST have a
61 specific size (e.g. like in the protocol headers). This documents that the
62 variable has the given number of bits. This states clear the intent of the
63 original programmer and avoids improper modifications.
64
fc444c5a
GMF
65- Use only int for regular integer numbers that do not require any specific
66 size. And document that a variable is non-negative using assertions. Do not
67 use unsigned types to say a number will never be negative.
c08bc448
GMF
68
69- Use std::size_t for integers that represent sizes of vectors, objects or
70 buffers. Thus leaving the size difinition to the platform.
71
72
732.2. Coding Style
703f4d65 74---------------------------------------
c08bc448
GMF
75The coding style used in this program is in accordance with the Intra2net,
76which can be found in the following source:
77
78- http://intranet/support_wiki/doku.php?id=entwicklung:codingstyle
79
80
812.3. Versioning
82---------------------------------------
83Version is built as follows:
84 major.minor[-[a|b|rc]]
85where:
86- major represents big changes in application functionality.
87- minor means small changes of bug fixes.
88- a, b and rc stand for Alpha, Beta and Release Candidate respectivelly. Though
89 they are optional and not required in public release.
90
91
09de3c4b
GMF
922.4. Error Handling
93---------------------------------------
94There are two basic kinds of errors that shall happen in the program, errors
95that the program can recover (expected) and errors that the progam can not or
96should not recover from (exceptional errors). Bellow the description and the
97method adopted to deal with each one:
98- Expected: these errors can occur and must be handled by boolean return values.
99 (i.e. if a host is down, if the address was not resolved). This errors can
100 happen, but THE PROGRAM MUST CONTINUE TO OPERATE EVEN IF THEY HAPPEN.
101- Exceptional: these are the kinds of errors that should not occur. They must be
102 handled by exceptions and THE PROGRAM MUST HALT IF THEY HAPPEN.
103Thus, to keep things as simple as possible, this program adopts just two kinds
104of error detection and handling:
105- Return Boolean Value for expected errors and
106- Handle Exceptions for exceptional errors.
107
108
c5e4bfa1
GMF
1092.5. Assertions
110---------------------------------------
111Also, it is good to use ASSERTS to document assumptions about:
112- method's argument values. If you expect that a parameter have certain values,
113 assert it (preconditions)
114- and if you expect the method deliver a certain value, assert in the end of
115 the method (postcondition).
116This is known by programming by contract.
117
118
703f4d65 119
c08bc448
GMF
1203. Source Code
121=======================================
122In this section is presented an overview of the source code and key design
123decisions.
124
125
1263.1. Main directories
127---------------------------------------
128The sources are spread over these distincts directories:
129- src: contains the main application.
130- test: where is located the unit tests.
131- conf: keeps default and example configuration files.
132
133
f9c5fff0
GMF
1343.2. Main concept of application operation
135---------------------------------------
136This application makes extensive use of asynchronous timers-handlers from
137Boost ASIO. So this section describes briefly how ASIO works. More information
138can be found in the References section.
139
140The basic idea is to have a handler which will be called when a timer expires.
141After the timer expires, you have to schedule the timer again to call your
142handler once more. Given the declaration of the timer:
143
144 boost::asio::deadline_timer my_timer( my_io_service );
145
146you must specify when it will expire:
147
148 my_timer.expires_at( some_time_in_seconds + seconds( interval_in_seconds ) );
149
150and which method will handle when the timer expires.
151
152 my_timer.async_wait( boost::bind( &MyClass::my_handle_method, this ) );
153
154Then, the my_io_service service can be called to perform a loop:
155
156 my_io_service.run();
157
158
c08bc448
GMF
159
1604. Configuration file
161=======================================
f9c5fff0 162In this section are describled the configuration items, along with they
7a073300
GMF
163possible values and meanings. This section is organized in each major
164configuration block.
165
166
1674.1. General
168---------------------------------------
169This configurations are shared among and affect all the hosts.
a341119a 170- hosts-down-limit: an absolute number, which ranges from 0 to the number of
c5e4bfa1
GMF
171 hosts available. This value represents the minimum number of hosts that have
172 to fail (i.e. do not reply to the ping) in order to alert any external system.
a341119a 173- ping-fail-limit: percentage of pings to a host that can fail. If the
c5e4bfa1
GMF
174 percentage of failed pings to a host exceed this number, then the host is
175 considered down.
d52d036a 176- status-notifier-cmd: the command line that is called when a host is down, or
c1d76f1b
GMF
177 up. Accepted variables are:
178 ${status} - down or up
f75a2748 179- link-up-interval: how long (in minutes) the pings don't have to fail
fb09230d 180 in order to consider the link up, or stable.
703f4d65 181
703f4d65 182
7a073300
GMF
1834.2. Host
184---------------------------------------
d52d036a 185- name: the DNS or IP of the host to ping. Take in consideration that, if a
7a073300
GMF
186 DNS is given, the application pings all IPs in the look up table, however, if
187 IP is provide, it is the only which will be pinged.
d52d036a 188- interval: the host will be pinged every "interval" seconds.
7a073300
GMF
189
190
f9c5fff0
GMF
191
1925. References
193=======================================
194[1] http://tools.ietf.org/html/rfc792
195[2] http://en.wikipedia.org/wiki/Ping
196[3] http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol
197[4] http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio.html
198[5] http://www.boost.org/doc/libs/1_45_0/doc/html/program_options.html