icmp/icmpheader.cpp
icmp/icmppacket.cpp
icmp/ipv4header.cpp
- notify/pingstatusnotifier.cpp
+ notify/statusnotifier.cpp
notify/statusnotifiercommand.cpp
ping/boostpinger.cpp
ping/pinganalyzer.cpp
#include "config/configurationreader.h"
#include "config/host.h"
-#include "notify/pingstatusnotifier.h"
+#include "notify/statusnotifier.h"
#include "ping/pingscheduler.h"
using namespace std;
// TODO init_notifier and get_notifier
int limit_hosts_down = config.get_limit_hosts_down();
string status_notifier_cmd = config.get_status_notifier_cmd();
- shared_ptr<PingStatusNotifier> notifier(
- new PingStatusNotifier( limit_hosts_down, status_notifier_cmd )
+ shared_ptr<StatusNotifier> notifier(
+ new StatusNotifier( limit_hosts_down, status_notifier_cmd )
);
// TODO init_pingers()
-#include "notify/pingstatusnotifier.h"
+#include "notify/statusnotifier.h"
#include <iostream>
using namespace std;
//-----------------------------------------------------------------------------
-// PingStatusNotifier
+// StatusNotifier
//-----------------------------------------------------------------------------
-PingStatusNotifier::PingStatusNotifier(
+StatusNotifier::StatusNotifier(
const int limit_hosts_down,
const string &status_notifier_cmd
) :
BOOST_ASSERT( !status_notifier_cmd.empty() );
}
-PingStatusNotifier::~PingStatusNotifier()
+StatusNotifier::~StatusNotifier()
{
}
-void PingStatusNotifier::notify_host_up( const string &host_address )
+void StatusNotifier::notify_host_up( const string &host_address )
{
BOOST_ASSERT( !host_address.empty() );
BOOST_ASSERT( HostsDownList.count( host_address ) == 0 );
}
-void PingStatusNotifier::notify_host_down( const string &host_address )
+void StatusNotifier::notify_host_down( const string &host_address )
{
BOOST_ASSERT( !host_address.empty() );
BOOST_ASSERT( HostsDownList.count( host_address ) == 1 );
}
-void PingStatusNotifier::add_host_up( const string &host_address )
+void StatusNotifier::add_host_up( const string &host_address )
{
if ( HostsDownList.count( host_address ) > 0 )
{
}
}
-void PingStatusNotifier::add_host_down( const string &host_address )
+void StatusNotifier::add_host_down( const string &host_address )
{
HostsDownList.insert( host_address );
}
-bool PingStatusNotifier::exceeded_host_down_count_limit() const
+bool StatusNotifier::exceeded_host_down_count_limit() const
{
int host_down_count = HostsDownList.size();
return ( host_down_count >= LimitHostsDown );
}
-void PingStatusNotifier::notify_system_up()
+void StatusNotifier::notify_system_up()
{
StatusNotifierCmd.set_token_value(
StatusNotifierCommand::StatusToken,
StatusNotifierCmd.execute();
}
-void PingStatusNotifier::notify_system_down()
+void StatusNotifier::notify_system_down()
{
StatusNotifierCmd.set_token_value(
StatusNotifierCommand::StatusToken,
-#ifndef PINGSTATUSNOTIFIER_H
-#define PINGSTATUSNOTIFIER_H
+#ifndef STATUSNOTIFIER_H
+#define STATUSNOTIFIER_H
#include <set>
#include <string>
#include "notify/statusnotifiercommand.h"
//-----------------------------------------------------------------------------
-// PingStatusNotifier
+// StatusNotifier
//-----------------------------------------------------------------------------
/**
* keeping track of the number of hosts down.
* Scope: one object for many hosts.
*/
-class PingStatusNotifier
+class StatusNotifier
{
public:
- PingStatusNotifier(
+ StatusNotifier(
const int limit_hosts_down,
const std::string &status_notifier_cmd
);
- virtual ~PingStatusNotifier();
+ virtual ~StatusNotifier();
void notify_host_up( const std::string &host_address );
void notify_host_down( const std::string &host_address );
};
-#endif /* PINGSTATUSNOTIFIER_H */
+#endif /* STATUSNOTIFIER_H */
#include <boost/assert.hpp>
-#include "notify/pingstatusnotifier.h"
+#include "notify/statusnotifier.h"
using namespace std;
using namespace boost;
PingAnalyzer::PingAnalyzer(
const string &host_address,
const int limit_ping_fail_percentage,
- shared_ptr<PingStatusNotifier> notifier
+ shared_ptr<StatusNotifier> notifier
) :
HostAddress( host_address ),
Notifier( notifier ),
#include <boost/shared_ptr.hpp>
-class PingStatusNotifier;
+class StatusNotifier;
//-----------------------------------------------------------------------------
// PingAnalyzer
public:
PingAnalyzer(
const std::string &host_address,
- const int ping_fail_threshold_percentage,
- boost::shared_ptr<PingStatusNotifier> notifier
+ const int limit_ping_fail_percentage,
+ boost::shared_ptr<StatusNotifier> notifier
);
virtual ~PingAnalyzer();
private:
std::string HostAddress;
- boost::shared_ptr<PingStatusNotifier> Notifier;
+ boost::shared_ptr<StatusNotifier> Notifier;
int LimitPingFailPercentage;
int ResolvedIpCount;
int PingsPerformedCount;
#include <boost/bind.hpp>
#include "dns/dnsresolver.h"
-#include "notify/pingstatusnotifier.h"
+#include "notify/statusnotifier.h"
#include "ping/boostpinger.h"
using namespace std;
PingScheduler::PingScheduler(
boost::asio::io_service &io_service,
const string &ping_address,
- const int ping_interval_in_sec,
+ const long ping_interval_in_sec,
const int limit_ping_fail_percentage,
- shared_ptr<PingStatusNotifier> notifier
+ shared_ptr<StatusNotifier> notifier
) :
IoService( io_service ),
#include "dns/dnsresolver.h"
#include "ping/pinganalyzer.h"
-class PingStatusNotifier;
+class StatusNotifier;
//-----------------------------------------------------------------------------
// PingScheduler
PingScheduler(
boost::asio::io_service &io_service,
const std::string &ping_address,
- const int ping_interval_in_sec,
+ const long ping_interval_in_sec,
const int limit_ping_fail_percentage,
- boost::shared_ptr<PingStatusNotifier> notifier
+ boost::shared_ptr<StatusNotifier> notifier
);
virtual ~PingScheduler();
boost::asio::io_service &IoService;
boost::asio::deadline_timer Timer;
boost::posix_time::ptime TimeSentLastPing;
- const int PingIntervalInSec;
+ const long PingIntervalInSec;
DnsResolver IpList;
PingAnalyzer Analyzer;