merged PingRotate into PingScheduler; fixed save/load of cache to/from file; started...
[pingcheck] / src / host / pingscheduler.h
index 250bf85..e61b0b0 100644 (file)
@@ -33,7 +33,7 @@ on this file might be covered by the GNU General Public License.
 #include "host/pinger.h"
 #include "host/pinginterval.h"
 #include "host/pingprotocol.h"
-#include "host/pingrotate.h"
+#include "dns/resolverbase.h"
 
 //-----------------------------------------------------------------------------
 // PingScheduler
@@ -56,7 +56,6 @@ public:
             const long ping_interval_in_sec,
             const int ping_fail_percentage_limit,
             const int ping_reply_timeout,
-            const int resolved_ip_ttl_threshold,
             LinkStatusItem link_analyzer,
             const int first_delay
     );
@@ -70,9 +69,7 @@ private:
     // Methods
     //
 
-    void resolve_and_ping(const boost::system::error_code &error);
-
-    void ping();
+    void ping(const boost::system::error_code &error);
     void ping_done_handler(const bool ping_success);
     void update_ping_interval();
     void update_ping_elapsed_time();
@@ -86,45 +83,47 @@ private:
 
     void try_to_ping();
     void dns_resolve_callback(const bool was_success, const int cname_count);
+    void start_resolving_ping_address();
+
+    void update_log_prefix();
 
     //
     // Attributes
     //
 
-    /// Timer to trigger the next ping
-    boost::asio::deadline_timer NextPingTimer;
-    /// Timer to trigger the next attempt to resolve addresses
-    boost::asio::deadline_timer NextAddressTimer;
-    /// Keeps track of the time when the last ping was send
-    boost::posix_time::ptime TimeSentLastPing;
-    /// Interval between each ping to the same host
-    PingInterval PingIntervalInSec;
-    /// Interval between attempts to resolve host address
-    PingInterval AddressResolveIntervalInSec;
-    /// Object responsible to evaluate the status of the host
-    HostStatus HostAnalyzer;
-    /// delay for very first ping to avoid lots of simultaneous pings
-    int FirstDelay;
     /// The IO service object, which has the loop event
     IoServiceItem IoService;
     /// The network interface name
     std::string NetworkInterfaceName;
-    /// The Dns resolver
-    ResolverItem Resolver;
     /// The address to ping
     std::string DestinationAddress;
-    /// The port to ping at destination host (same port to all protocols in the list)
+    /// The port to ping at destination host (same for all protocols)
     uint16_t DestinationPort;
-    /// time threshold for address resolution
-    int ResolvedIpTtlThreshold;
-    /// timeout for ping reply
+    /// The list of protocols to ping and iterator over them
+    PingProtocolList Protocols;
+    PingProtocolList::const_iterator ProtocolIter;
+    /// Interval between each ping to the same host
+    PingInterval PingIntervalInSec;
+    /// delay for very first ping to avoid lots of simultaneous pings at startup
+    int FirstDelay;
+    /// Timer to trigger the next ping
+    boost::asio::deadline_timer NextPingTimer;
+    /// Keeps track of the time when the last ping was send
+    boost::posix_time::ptime TimeSentLastPing;
+    /// time threshold for ping
     const int PingReplyTimeout;
-    /// The list of protocols to ping
-    CircularProtocolList ProtocolRotate;
-    /// Internal boost pinger object
+    /// Object responsible to evaluate the status of the host
+    HostStatus HostAnalyzer;
+    /// The Dns resolver
+    ResolverItem Resolver;
+    /// The actual pinger
     PingerItem Ping;
     /// a flag whether we should ping as soon as dns is ready
     bool WantToPing;
+    /// Prefix to log messages for quicker analysis/debugging
+    std::string LogPrefix;
+    /// Flag whether DNS resolution has failed so we have to run on outdated IPs
+    bool ContinueOnOutdatedIps;
 };
 
 //-----------------------------------------------------------------------------