2019-07-28 10:31:56 +08:00
|
|
|
|
#include "stdafx.h"
|
2015-04-26 00:11:10 +08:00
|
|
|
|
#include "check_sync.h"
|
|
|
|
|
#include "check_async.h"
|
2015-04-04 15:25:29 +08:00
|
|
|
|
#include "mymonitor.h"
|
|
|
|
|
|
|
|
|
|
mymonitor::mymonitor(acl::connect_manager& manager, const acl::string& proto)
|
|
|
|
|
: connect_monitor(manager)
|
|
|
|
|
, proto_(proto)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mymonitor::~mymonitor(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijһ<C4B3><D2BB><EFBFBD><EFBFBD><EFBFBD>߳̿ռ<CCBF><D5BC><EFBFBD>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
|
|
|
|
|
void mymonitor::sio_check(acl::check_client& checker,
|
|
|
|
|
acl::socket_stream& conn)
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
check_sync check;
|
2015-04-04 15:25:29 +08:00
|
|
|
|
if (proto_ == "http")
|
2015-04-26 00:11:10 +08:00
|
|
|
|
check.sio_check_http(checker, conn);
|
2015-04-04 15:25:29 +08:00
|
|
|
|
else if (proto_ == "pop3")
|
2015-04-26 00:11:10 +08:00
|
|
|
|
check.sio_check_pop3(checker, conn);
|
2015-04-04 15:25:29 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("unknown protocol: %s\r\n", proto_.c_str());
|
|
|
|
|
checker.set_alive(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-26 00:11:10 +08:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳Ŀռ<C4BF><D5BC><EFBFBD>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
|
|
|
|
|
void mymonitor::nio_check(acl::check_client& checker,
|
|
|
|
|
acl::aio_socket_stream& conn)
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><ECB2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
check_async* callback = new check_async(checker);
|
2015-04-04 15:25:29 +08:00
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
conn.add_close_callback(callback);
|
|
|
|
|
conn.add_read_callback(callback);
|
|
|
|
|
conn.add_timeout_callback(callback);
|
2015-04-04 15:25:29 +08:00
|
|
|
|
|
|
|
|
|
int timeout = 10;
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20>첽<EFBFBD><ECB2BD>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ͬʱҪ<CAB1><EFBFBD><F3B2BBB1><EFBFBD> \r\n
|
2015-04-04 15:25:29 +08:00
|
|
|
|
|
|
|
|
|
conn.gets(timeout);
|
|
|
|
|
}
|
2018-06-04 18:00:32 +08:00
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void mymonitor::on_connected(const acl::check_client& checker, double cost)
|
|
|
|
|
{
|
|
|
|
|
printf("addr=%s, connected, cost=%.2f\r\n",
|
|
|
|
|
checker.get_addr(), cost);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mymonitor::on_refuse(const acl::check_client& checker, double cost)
|
|
|
|
|
{
|
|
|
|
|
printf("addr=%s, connection refused, cost=%.2f\r\n",
|
|
|
|
|
checker.get_addr(), cost);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mymonitor::on_timeout(const acl::check_client& checker, double cost)
|
|
|
|
|
{
|
|
|
|
|
printf("addr=%s, connection timeout, cost=%.2f\r\n",
|
|
|
|
|
checker.get_addr(), cost);
|
|
|
|
|
}
|