[ref]同步
This commit is contained in:
parent
9bf9491684
commit
41b52470df
@ -8,7 +8,7 @@ SUBDIRS += \
|
|||||||
net_msg_bus_relay \
|
net_msg_bus_relay \
|
||||||
net_msg_bus_ping \
|
net_msg_bus_ping \
|
||||||
net_msg_bus_mng \
|
net_msg_bus_mng \
|
||||||
net_msg_bus_test \
|
# net_msg_bus_test \
|
||||||
net_msg_bus_mng_ping_gui \
|
net_msg_bus_mng_ping_gui \
|
||||||
net_snmp_agent \
|
net_snmp_agent \
|
||||||
net_keepalived
|
net_keepalived
|
||||||
|
|||||||
@ -129,7 +129,13 @@ int CCheckDatabaseThread::getMaxSyncId()
|
|||||||
if ( m_pDb->open() )
|
if ( m_pDb->open() )
|
||||||
{
|
{
|
||||||
if ( m_eDBType == EDBType_KINGBASE )
|
if ( m_eDBType == EDBType_KINGBASE )
|
||||||
m_pDb->exec( "SET search_path TO iscs6000;" );
|
{
|
||||||
|
/* 为以后搜索方便,保留此注释
|
||||||
|
* QString sSql = QString("SET search_path TO %1;").arg(EMS_DEFAULT_DATABASE) ;
|
||||||
|
*/
|
||||||
|
QString sSql = QString("SET search_path TO %1;").arg(m_pDb->databaseName()) ;
|
||||||
|
m_pDb->exec( sSql);
|
||||||
|
}
|
||||||
QSqlQuery objQuery = m_pDb->exec( "select max(id) from dbop_list" );
|
QSqlQuery objQuery = m_pDb->exec( "select max(id) from dbop_list" );
|
||||||
if ( objQuery.isActive() )
|
if ( objQuery.isActive() )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
|
||||||
static const char *pszSystemdCfgFile = "/lib/systemd/system/net_keepalived.service";
|
static const char *pszSystemdCfgFile = "/usr/lib/systemd/system/net_keepalived.service";
|
||||||
|
|
||||||
//< 注册系统服务,并设置自启动
|
//< 注册系统服务,并设置自启动
|
||||||
bool regSysService(QString &strErr)
|
bool regSysService(QString &strErr)
|
||||||
|
|||||||
@ -51,7 +51,7 @@ static bool regSysService( QString &strErr )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SERVICE_DESCRIPTIONA stSrvDesc;
|
SERVICE_DESCRIPTIONA stSrvDesc;
|
||||||
char szDesc[] = "Virtual IP service of KBD.";
|
char szDesc[] = "Virtual IP service";
|
||||||
stSrvDesc.lpDescription = szDesc;
|
stSrvDesc.lpDescription = szDesc;
|
||||||
if (::ChangeServiceConfig2A(hService, SERVICE_CONFIG_DESCRIPTION, &stSrvDesc))
|
if (::ChangeServiceConfig2A(hService, SERVICE_CONFIG_DESCRIPTION, &stSrvDesc))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -121,6 +121,7 @@ CLocalMng::SLocalMng* CLocalMng::SLocalMng::newLocalMng(zsock_t *pActorPipe)
|
|||||||
|
|
||||||
int nTimerID = zloop_timer(self->m_pLoop, 1000, 0, handleProcTimeOutTimer, self);
|
int nTimerID = zloop_timer(self->m_pLoop, 1000, 0, handleProcTimeOutTimer, self);
|
||||||
assert(nTimerID >= 0); //< zloop的TimerID从0开始
|
assert(nTimerID >= 0); //< zloop的TimerID从0开始
|
||||||
|
boost::ignore_unused_variable_warning(nTimerID);
|
||||||
|
|
||||||
bRc = setSocketHandle(self, self->m_pSockMng, handleSockMng);
|
bRc = setSocketHandle(self, self->m_pSockMng, handleSockMng);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
|||||||
@ -11,8 +11,20 @@
|
|||||||
|
|
||||||
#include "boost/typeof/typeof.hpp"
|
#include "boost/typeof/typeof.hpp"
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
//< 屏蔽xml_parser编译告警
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "boost/property_tree/xml_parser.hpp"
|
#include "boost/property_tree/xml_parser.hpp"
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "czmq.h"
|
#include "czmq.h"
|
||||||
|
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
|
|||||||
@ -8,14 +8,11 @@
|
|||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
|
|
||||||
#include "boost/format.hpp"
|
#include "boost/format.hpp"
|
||||||
|
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
|
|
||||||
#include "../net_msg_bus_base_api/CommonDef.h"
|
#include "../net_msg_bus_base_api/CommonDef.h"
|
||||||
|
|
||||||
#include "CMbServer.h"
|
#include "CMbServer.h"
|
||||||
|
|
||||||
#include "CRemoteHost.h"
|
#include "CRemoteHost.h"
|
||||||
|
#include "boost/concept_check.hpp"
|
||||||
|
|
||||||
namespace iot_net
|
namespace iot_net
|
||||||
{
|
{
|
||||||
@ -285,6 +282,7 @@ CRemoteHost::SRemoteHost* CRemoteHost::SRemoteHost::newRemoteHost(zsock_t *pActo
|
|||||||
|
|
||||||
int nPendingMsgTimerID = zloop_timer(self->m_pLoop, 1000, 0, handlePendingMsgTimer, self);
|
int nPendingMsgTimerID = zloop_timer(self->m_pLoop, 1000, 0, handlePendingMsgTimer, self);
|
||||||
assert(nPendingMsgTimerID >= 0);
|
assert(nPendingMsgTimerID >= 0);
|
||||||
|
boost::ignore_unused_variable_warning(nPendingMsgTimerID);
|
||||||
|
|
||||||
//< 系统信号打断不退出
|
//< 系统信号打断不退出
|
||||||
zloop_set_nonstop(self->m_pLoop, true);
|
zloop_set_nonstop(self->m_pLoop, true);
|
||||||
@ -454,6 +452,7 @@ int CRemoteHost::SRemoteHost::delaySockDataIn(zloop_t *, int timer_id, void *arg
|
|||||||
//< 恢复接收m_pSockDataIn的消息
|
//< 恢复接收m_pSockDataIn的消息
|
||||||
bool bRc = setSocketHandle(self, self->m_pSockDataIn, handleSockDataIn);
|
bool bRc = setSocketHandle(self, self->m_pSockDataIn, handleSockDataIn);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//< 取消本定时器
|
//< 取消本定时器
|
||||||
@ -465,6 +464,7 @@ int CRemoteHost::SRemoteHost::delaySockDataIn(zloop_t *, int timer_id, void *arg
|
|||||||
//< 取消接收m_pSockDataIn的消息
|
//< 取消接收m_pSockDataIn的消息
|
||||||
bool bRc = setSocketHandle(self, self->m_pSockDataIn, NULL);
|
bool bRc = setSocketHandle(self, self->m_pSockDataIn, NULL);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
|
|
||||||
//< 设置定时器,到时恢复,单位ms
|
//< 设置定时器,到时恢复,单位ms
|
||||||
self->m_nDelaySockDataInTimerID = zloop_timer(self->m_pLoop, 100, 1, delaySockDataIn, self);
|
self->m_nDelaySockDataInTimerID = zloop_timer(self->m_pLoop, 100, 1, delaySockDataIn, self);
|
||||||
@ -701,6 +701,8 @@ int CRemoteHost::SRemoteHost::handleActorPipe(zloop_t *, zsock_t *reader, void *
|
|||||||
|
|
||||||
int CRemoteHost::SRemoteHost::handleSockDataIn(zloop_t *, zsock_t *reader, void *arg)
|
int CRemoteHost::SRemoteHost::handleSockDataIn(zloop_t *, zsock_t *reader, void *arg)
|
||||||
{
|
{
|
||||||
|
boost::ignore_unused_variable_warning(reader);
|
||||||
|
|
||||||
SRemoteHost *self = (SRemoteHost *)arg;
|
SRemoteHost *self = (SRemoteHost *)arg;
|
||||||
|
|
||||||
assert(reader == self->m_pSockDataIn);
|
assert(reader == self->m_pSockDataIn);
|
||||||
@ -1021,11 +1023,15 @@ int CRemoteHost::SRemoteHost::handleSockNetAllMon(zloop_t *, zsock_t *reader, vo
|
|||||||
|
|
||||||
int CRemoteHost::SRemoteHost::handleSockNetAll(zloop_t *, zsock_t *reader, void *arg)
|
int CRemoteHost::SRemoteHost::handleSockNetAll(zloop_t *, zsock_t *reader, void *arg)
|
||||||
{
|
{
|
||||||
|
boost::ignore_unused_variable_warning(reader);
|
||||||
|
|
||||||
SRemoteHost *self = (SRemoteHost *)arg;
|
SRemoteHost *self = (SRemoteHost *)arg;
|
||||||
|
|
||||||
assert(reader == self->m_pSockNetA
|
assert(reader == self->m_pSockNetA
|
||||||
|| reader == self->m_pSockNetB);
|
|| reader == self->m_pSockNetB);
|
||||||
|
|
||||||
|
boost::ignore_unused_variable_warning(self);
|
||||||
|
|
||||||
//< 当前,不应该收到任何消息
|
//< 当前,不应该收到任何消息
|
||||||
//< 将收到的消息释放,避免占用内存
|
//< 将收到的消息释放,避免占用内存
|
||||||
|
|
||||||
|
|||||||
@ -159,6 +159,7 @@ CRemoteMng::SRemoteMng* CRemoteMng::SRemoteMng::newRemoteMng(zsock_t *pActorPipe
|
|||||||
//< 10s发一次
|
//< 10s发一次
|
||||||
int nSubChgCntTimerID = zloop_timer(self->m_pLoop, 10000, 0, handleSubChgCntTimer, self);
|
int nSubChgCntTimerID = zloop_timer(self->m_pLoop, 10000, 0, handleSubChgCntTimer, self);
|
||||||
assert(nSubChgCntTimerID >= 0);
|
assert(nSubChgCntTimerID >= 0);
|
||||||
|
boost::ignore_unused_variable_warning(nSubChgCntTimerID);
|
||||||
|
|
||||||
bRc = setSocketHandle(self, self->m_pSockMng, handleSockMng);
|
bRc = setSocketHandle(self, self->m_pSockMng, handleSockMng);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
|||||||
@ -10,16 +10,12 @@
|
|||||||
#include "boost/typeof/typeof.hpp"
|
#include "boost/typeof/typeof.hpp"
|
||||||
#include "boost/asio/ip/host_name.hpp"
|
#include "boost/asio/ip/host_name.hpp"
|
||||||
#include "boost/interprocess/detail/os_thread_functions.hpp"
|
#include "boost/interprocess/detail/os_thread_functions.hpp"
|
||||||
|
#include "boost/concept_check.hpp"
|
||||||
#include "lz4.h"
|
#include "lz4.h"
|
||||||
|
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
|
|
||||||
#include "../net_msg_bus_base_api/kmbp_cnt.h"
|
#include "../net_msg_bus_base_api/kmbp_cnt.h"
|
||||||
|
|
||||||
#include "../net_msg_bus_base_api/CMbSubEngine.h"
|
#include "../net_msg_bus_base_api/CMbSubEngine.h"
|
||||||
#include "../net_msg_bus_base_api/CommonDef.h"
|
#include "../net_msg_bus_base_api/CommonDef.h"
|
||||||
|
|
||||||
#include "CInProcBroker.h"
|
#include "CInProcBroker.h"
|
||||||
|
|
||||||
namespace iot_net
|
namespace iot_net
|
||||||
@ -100,6 +96,7 @@ CInProcBroker::SActWorker* CInProcBroker::SActWorker::newActWorker(zsock_t *pAct
|
|||||||
|
|
||||||
int nRc = zsock_bind(self->m_pSockInData, MB_P2C_DATA_ENDPOINT);
|
int nRc = zsock_bind(self->m_pSockInData, MB_P2C_DATA_ENDPOINT);
|
||||||
assert(0 == nRc);
|
assert(0 == nRc);
|
||||||
|
boost::ignore_unused_variable_warning(nRc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//< 初始化m_pSockOut
|
//< 初始化m_pSockOut
|
||||||
@ -186,6 +183,7 @@ CInProcBroker::SActWorker* CInProcBroker::SActWorker::newActWorker(zsock_t *pAct
|
|||||||
bRc = setSocketHandle(self, self->m_pSockOut, handleSockOut);
|
bRc = setSocketHandle(self, self->m_pSockOut, handleSockOut);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
|
||||||
|
boost::ignore_unused_variable_warning(nRc);
|
||||||
//< 系统信号打断不退出
|
//< 系统信号打断不退出
|
||||||
zloop_set_nonstop(self->m_pLoop, true);
|
zloop_set_nonstop(self->m_pLoop, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,8 @@ CMbCommunicatorImp::CMbCommunicatorImp(const char *pchName, const int *pAutoZipS
|
|||||||
zsock_set_identity(m_pSockCmd, pchName);
|
zsock_set_identity(m_pSockCmd, pchName);
|
||||||
if (0 != zsock_connect(m_pSockCmd, MB_P2C_CMD_ENDPOINT))
|
if (0 != zsock_connect(m_pSockCmd, MB_P2C_CMD_ENDPOINT))
|
||||||
{
|
{
|
||||||
LOGERROR("CMbCommunicatorImp(): 0 != zsock_connect() !");
|
const char *errMsg=zmq_strerror(zmq_errno());
|
||||||
|
LOGERROR("CMbCommunicatorImp(): 0 != zsock_connect() errno(%d)_error(%s) !",zmq_errno(),errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//< 初始化m_pSockData
|
//< 初始化m_pSockData
|
||||||
@ -79,7 +80,8 @@ CMbCommunicatorImp::CMbCommunicatorImp(const char *pchName, const int *pAutoZipS
|
|||||||
zsock_set_identity(m_pSockData, pchName);
|
zsock_set_identity(m_pSockData, pchName);
|
||||||
if (0 != zsock_connect(m_pSockData, MB_P2C_DATA_ENDPOINT))
|
if (0 != zsock_connect(m_pSockData, MB_P2C_DATA_ENDPOINT))
|
||||||
{
|
{
|
||||||
LOGERROR("CMbCommunicatorImp(): 0 != zsock_connect() !");
|
const char *errMsg=zmq_strerror(zmq_errno());
|
||||||
|
LOGERROR("CMbCommunicatorImp(): 0 != zsock_connect() errno(%d)_error(%s) !",zmq_errno(),errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//< 初始化m_pPollerData
|
//< 初始化m_pPollerData
|
||||||
@ -444,8 +446,8 @@ bool CMbCommunicatorImp::sendMsgToDomain(kmbp_t **ppKmbpSend, const int nDomainI
|
|||||||
|
|
||||||
//< 释放本端引用
|
//< 释放本端引用
|
||||||
kmbp_cnt_dec(&pKmbpCnt);
|
kmbp_cnt_dec(&pKmbpCnt);
|
||||||
|
const char *errMsg=zmq_strerror(zmq_errno());
|
||||||
LOGWARN("sendMsgToDomain(): 0 != zsock_send() , return false !");
|
LOGWARN("sendMsgToDomain(): 0 != zsock_send() , return false ! errno(%d)_error(%s)",zmq_errno(),errMsg);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,19 @@
|
|||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
|
|
||||||
#include "boost/typeof/typeof.hpp"
|
#include "boost/typeof/typeof.hpp"
|
||||||
|
|
||||||
|
//< 屏蔽xml_parser编译告警
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "boost/property_tree/xml_parser.hpp"
|
#include "boost/property_tree/xml_parser.hpp"
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
#include "pub_utility_api/FileUtil.h"
|
#include "pub_utility_api/FileUtil.h"
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ namespace iot_net
|
|||||||
//#define MB_H2P_PORT_INT ((int)6020)
|
//#define MB_H2P_PORT_INT ((int)6020)
|
||||||
//#define MB_H2P_PORT_STR "6020"
|
//#define MB_H2P_PORT_STR "6020"
|
||||||
#if defined (__UTYPE_LINUX)
|
#if defined (__UTYPE_LINUX)
|
||||||
#define MB_H2P_ENDPOINT "ipc://@/kbd_msg_bus_h2p_ipc"
|
#define MB_H2P_ENDPOINT "ipc://@/iot_msg_bus_h2p_ipc"
|
||||||
#else
|
#else
|
||||||
#define MB_H2P_ENDPOINT "tcp://127.0.0.1:6020"
|
#define MB_H2P_ENDPOINT "tcp://127.0.0.1:6020"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
The following ABNF grammar defines the 宏茂技术消息总线管理协议(KBD Message Bus Management Protocol):
|
The following ABNF grammar defines the 远信储能消息总线管理协议(KBD Message Bus Management Protocol):
|
||||||
|
|
||||||
kmbmp = *( MEMORY-ALIGNMENT | COMMON-RETURN-TRUE | COMMON-RETURN-FALSE | M2H-LOCAL-INFO-REQ | H2M-LOCAL-INFO | M2H-REMOTE-INFO-REQ | H2M-REMOTE-INFO )
|
kmbmp = *( MEMORY-ALIGNMENT | COMMON-RETURN-TRUE | COMMON-RETURN-FALSE | M2H-LOCAL-INFO-REQ | H2M-LOCAL-INFO | M2H-REMOTE-INFO-REQ | H2M-REMOTE-INFO )
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
kmbmp - 宏茂技术消息总线管理协议(KBD Message Bus Management Protocol)
|
kmbmp - 远信储能消息总线管理协议(KBD Message Bus Management Protocol)
|
||||||
|
|
||||||
Codec class for kmbmp.
|
Codec class for kmbmp.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@header
|
@header
|
||||||
kmbmp - 宏茂技术消息总线管理协议(KBD Message Bus Management Protocol)
|
kmbmp - 远信储能消息总线管理协议(KBD Message Bus Management Protocol)
|
||||||
@discuss
|
@discuss
|
||||||
@end
|
@end
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
kmbmp - 宏茂技术消息总线管理协议(KBD Message Bus Management Protocol)
|
kmbmp - 远信储能消息总线管理协议(KBD Message Bus Management Protocol)
|
||||||
|
|
||||||
Codec header for kmbmp.
|
Codec header for kmbmp.
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
******************************************************************************** -->
|
******************************************************************************** -->
|
||||||
|
|
||||||
<!-- signature用于协议版本校验,本协议起始值6000,当修改本协议,与之前版本不兼容时,需将signature加1 -->
|
<!-- signature用于协议版本校验,本协议起始值6000,当修改本协议,与之前版本不兼容时,需将signature加1 -->
|
||||||
<class name="kmbmp" signature="6000" title="宏茂技术消息总线管理协议(KBD Message Bus Management Protocol)"
|
<class name="kmbmp" signature="6000" title="远信储能消息总线管理协议(KBD Message Bus Management Protocol)"
|
||||||
script="./my_zproto_codec_c.gsl" package_dir="." source_dir="."
|
script="./my_zproto_codec_c.gsl" package_dir="." source_dir="."
|
||||||
export_header="mb_base_api_exp.h" export_macro="MSGBUS_BASE_API">
|
export_header="mb_base_api_exp.h" export_macro="MSGBUS_BASE_API">
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
The following ABNF grammar defines the 宏茂技术消息总线协议(KBD Message Bus Protocol):
|
The following ABNF grammar defines the 远信储能消息总线协议(KBD Message Bus Protocol):
|
||||||
|
|
||||||
kmbp = *( MEMORY-ALIGNMENT | COMMON-RETURN-TRUE | COMMON-RETURN-FALSE | C2H-DATA-PEER | C2H-DATA-HOST | C2H-DATA-DOMAIN | H2P-DATA | P2C-DATA | H2H-SUB-ALL | H2H-SUB-ALL-REQ | H2H-SUB-CHGCNT | H2H-SUB-CHGCNT-REQ | H2H-SUB-ADD | H2H-SUB-DEL | P2H-HEARTBEAT | P2H-SUB-ALL | H2P-SUB-ALL-REQ | P2H-SUB-ADD | P2H-SUB-DEL | C2P-REG | C2P-UNREG | C2P-SUB-ADD | C2P-SUB-DEL | C2P-SUB-ALL-REQ | P2C-SUB-ALL )
|
kmbp = *( MEMORY-ALIGNMENT | COMMON-RETURN-TRUE | COMMON-RETURN-FALSE | C2H-DATA-PEER | C2H-DATA-HOST | C2H-DATA-DOMAIN | H2P-DATA | P2C-DATA | H2H-SUB-ALL | H2H-SUB-ALL-REQ | H2H-SUB-CHGCNT | H2H-SUB-CHGCNT-REQ | H2H-SUB-ADD | H2H-SUB-DEL | P2H-HEARTBEAT | P2H-SUB-ALL | H2P-SUB-ALL-REQ | P2H-SUB-ADD | P2H-SUB-DEL | C2P-REG | C2P-UNREG | C2P-SUB-ADD | C2P-SUB-DEL | C2P-SUB-ALL-REQ | P2C-SUB-ALL )
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
kmbp - 宏茂技术消息总线协议(KBD Message Bus Protocol)
|
kmbp - 远信储能消息总线协议(KBD Message Bus Protocol)
|
||||||
|
|
||||||
Codec class for kmbp.
|
Codec class for kmbp.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@header
|
@header
|
||||||
kmbp - 宏茂技术消息总线协议(KBD Message Bus Protocol)
|
kmbp - 远信储能消息总线协议(KBD Message Bus Protocol)
|
||||||
@discuss
|
@discuss
|
||||||
@end
|
@end
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
kmbp - 宏茂技术消息总线协议(KBD Message Bus Protocol)
|
kmbp - 远信储能消息总线协议(KBD Message Bus Protocol)
|
||||||
|
|
||||||
Codec header for kmbp.
|
Codec header for kmbp.
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
******************************************************************************** -->
|
******************************************************************************** -->
|
||||||
|
|
||||||
<!-- signature用于协议版本校验,本协议起始值0755,当修改本协议,与之前版本不兼容时,需将signature加1 -->
|
<!-- signature用于协议版本校验,本协议起始值0755,当修改本协议,与之前版本不兼容时,需将signature加1 -->
|
||||||
<class name="kmbp" signature="0756" title="宏茂技术消息总线协议(KBD Message Bus Protocol)"
|
<class name="kmbp" signature="0756" title="远信储能消息总线协议(KBD Message Bus Protocol)"
|
||||||
script="./my_zproto_codec_c.gsl" package_dir="." source_dir="."
|
script="./my_zproto_codec_c.gsl" package_dir="." source_dir="."
|
||||||
export_header="mb_base_api_exp.h" export_macro="MSGBUS_BASE_API">
|
export_header="mb_base_api_exp.h" export_macro="MSGBUS_BASE_API">
|
||||||
|
|
||||||
|
|||||||
@ -21,10 +21,14 @@ static bool isIpFormatRight(const char *ipAddress)
|
|||||||
}
|
}
|
||||||
|
|
||||||
addNodeDialog::addNodeDialog(QWidget *parent) :
|
addNodeDialog::addNodeDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
CustomUiDialog(parent),
|
||||||
ui(new Ui::addNodeDialog)
|
ui(new Ui::addNodeDialog)
|
||||||
{
|
{
|
||||||
|
setWindowTitle(tr("添加节点"));
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
setAutoLayout(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
addNodeDialog::~addNodeDialog()
|
addNodeDialog::~addNodeDialog()
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
#ifndef ADDNODEDIALOG_H
|
#ifndef ADDNODEDIALOG_H
|
||||||
#define ADDNODEDIALOG_H
|
#define ADDNODEDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include"pub_widget/CustomDialog.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class addNodeDialog;
|
class addNodeDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class addNodeDialog : public QDialog
|
class addNodeDialog : public CustomUiDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@ -13,54 +13,54 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="geometry">
|
<item>
|
||||||
<rect>
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<x>120</x>
|
<property name="leftMargin">
|
||||||
<y>90</y>
|
<number>5</number>
|
||||||
<width>221</width>
|
</property>
|
||||||
<height>41</height>
|
<property name="topMargin">
|
||||||
</rect>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="rightMargin">
|
||||||
<enum>Qt::Horizontal</enum>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="bottomMargin">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<item row="0" column="0">
|
||||||
<widget class="QWidget" name="">
|
<widget class="QLabel" name="label">
|
||||||
<property name="geometry">
|
<property name="text">
|
||||||
<rect>
|
<string>结点名称</string>
|
||||||
<x>20</x>
|
</property>
|
||||||
<y>10</y>
|
</widget>
|
||||||
<width>321</width>
|
</item>
|
||||||
<height>81</height>
|
<item row="0" column="1">
|
||||||
</rect>
|
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||||
</property>
|
</item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<item row="1" column="0">
|
||||||
<item row="0" column="0">
|
<widget class="QLabel" name="label_2">
|
||||||
<widget class="QLabel" name="label">
|
<property name="text">
|
||||||
<property name="text">
|
<string>结点ip地址</string>
|
||||||
<string>结点名称</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
<item row="1" column="1">
|
||||||
<item row="0" column="1">
|
<widget class="QLineEdit" name="lineEdit_address"/>
|
||||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
</item>
|
||||||
</item>
|
</layout>
|
||||||
<item row="1" column="0">
|
</item>
|
||||||
<widget class="QLabel" name="label_2">
|
<item>
|
||||||
<property name="text">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<string>结点ip地址</string>
|
<property name="orientation">
|
||||||
</property>
|
<enum>Qt::Horizontal</enum>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<property name="standardButtons">
|
||||||
<item row="1" column="1">
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
<widget class="QLineEdit" name="lineEdit_address"/>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
</layout>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
@ -1,12 +1,40 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "czmq.h"
|
#include "czmq.h"
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "net_msg_bus_api/MsgBusApi.h"
|
#include "net_msg_bus_api/MsgBusApi.h"
|
||||||
|
#include "pub_utility_api/FileStyle.h"
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
void loadStyle()
|
||||||
|
{
|
||||||
|
QString qss = QString();
|
||||||
|
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss","zh","light");
|
||||||
|
|
||||||
|
QFile qssfile1(QString::fromStdString(strFullPath));
|
||||||
|
qssfile1.open(QFile::ReadOnly);
|
||||||
|
if (qssfile1.isOpen())
|
||||||
|
{
|
||||||
|
qss += QLatin1String(qssfile1.readAll());
|
||||||
|
qssfile1.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("net_msg_bus_mng_ping_gui.qss","zh","light");
|
||||||
|
QFile qssfile2(QString::fromStdString(strFullPath));
|
||||||
|
qssfile2.open(QFile::ReadOnly);
|
||||||
|
if (qssfile2.isOpen())
|
||||||
|
{
|
||||||
|
qss += QLatin1String(qssfile2.readAll());
|
||||||
|
qssfile2.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!qss.isEmpty())
|
||||||
|
{
|
||||||
|
qApp->setStyleSheet(qss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -22,6 +50,8 @@ int main(int argc, char *argv[])
|
|||||||
iot_public::StartLogSystem("default", "net_msg_bus_mng_ping_gui");
|
iot_public::StartLogSystem("default", "net_msg_bus_mng_ping_gui");
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
loadStyle();
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
|||||||
@ -34,10 +34,8 @@
|
|||||||
#define treeWidgetIpType 3
|
#define treeWidgetIpType 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
CustomUiMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
m_browser(new QtTreePropertyBrowser(this)),
|
m_browser(new QtTreePropertyBrowser(this)),
|
||||||
m_strPropMngLocalHost(new QtStringPropertyManager(this)),
|
m_strPropMngLocalHost(new QtStringPropertyManager(this)),
|
||||||
@ -46,16 +44,19 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
m_propMngremoteHostInfosGroup(new QtGroupPropertyManager(this)),
|
m_propMngremoteHostInfosGroup(new QtGroupPropertyManager(this)),
|
||||||
m_timerAutoPing(new QTimer(this))
|
m_timerAutoPing(new QTimer(this))
|
||||||
{
|
{
|
||||||
|
setAutoLayout(true);
|
||||||
|
setWindowTitle(tr("消息总线管理工具"));
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// tabWidet填充整个mainwindow
|
// tabWidet填充整个mainwindow
|
||||||
this->setCentralWidget(ui->tabWidget);
|
this->setCentralWidget(ui->tabWidget);
|
||||||
|
|
||||||
// 分为两个tab,每个tab的宽度为主窗口的一半
|
// 分为两个tab,每个tab的宽度为主窗口的一半
|
||||||
auto tabWidth = this->width()/2;
|
// auto tabWidth = this->width()/2;
|
||||||
ui->tabWidget->setStyleSheet( ui->tabWidget->styleSheet() +
|
// ui->tabWidget->setStyleSheet( ui->tabWidget->styleSheet() +
|
||||||
"QTabBar::tab {"
|
// "QTabBar::tab {"
|
||||||
"width: " + QString::number(tabWidth) + "px; }" );
|
// "width: " + QString::number(tabWidth) + "px; }" );
|
||||||
|
|
||||||
loadTreeHosts();
|
loadTreeHosts();
|
||||||
loadCustomHosts();
|
loadCustomHosts();
|
||||||
@ -118,6 +119,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
// ping查询结果返回到textbrowser上
|
// ping查询结果返回到textbrowser上
|
||||||
connect(this,&MainWindow::signalPingQuery,this,&MainWindow::slotSendPingQuery);
|
connect(this,&MainWindow::signalPingQuery,this,&MainWindow::slotSendPingQuery);
|
||||||
|
|
||||||
|
setContentsMargins(5,5,5,5);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -144,12 +147,14 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|||||||
{
|
{
|
||||||
// 重新绘制tab的宽度
|
// 重新绘制tab的宽度
|
||||||
// 分为两个tab,每个tab的宽度为主窗口的一半
|
// 分为两个tab,每个tab的宽度为主窗口的一半
|
||||||
auto tabWidth = this->width()/2;
|
// auto tabWidth = (this->width()-100)/2;
|
||||||
ui->tabWidget->setStyleSheet( ui->tabWidget->styleSheet() +
|
// ui->tabWidget->setStyleSheet( ui->tabWidget->styleSheet() +
|
||||||
"QTabBar::tab {"
|
// "QTabBar::tab {"
|
||||||
"width: " + QString::number(tabWidth) + "px; }" );
|
// "width: " + QString::number(tabWidth) + "px; }" );
|
||||||
|
|
||||||
Q_UNUSED(event);
|
// Q_UNUSED(event);
|
||||||
|
|
||||||
|
CustomUiMainWindow::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadTreeHosts()
|
void MainWindow::loadTreeHosts()
|
||||||
|
|||||||
@ -15,12 +15,13 @@
|
|||||||
#include "qteditorfactory.h"
|
#include "qteditorfactory.h"
|
||||||
#include "qttreepropertybrowser.h"
|
#include "qttreepropertybrowser.h"
|
||||||
#include "cmbping.h"
|
#include "cmbping.h"
|
||||||
|
#include "pub_widget/CustomMainWindow.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public CustomUiMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -15,6 +15,9 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -28,7 +31,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_mng">
|
<widget class="QWidget" name="tab_mng">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>mng</string>
|
<string>节点管理</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
@ -107,7 +110,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_ping">
|
<widget class="QWidget" name="tab_ping">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>ping</string>
|
<string>PING</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_10">
|
<layout class="QGridLayout" name="gridLayout_10">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
@ -514,7 +517,7 @@
|
|||||||
请选择功能,然后输入参数,然后点击go按钮
|
请选择功能,然后输入参数,然后点击go按钮
|
||||||
|
|
||||||
输入参数参考
|
输入参数参考
|
||||||
主机名:kbd-rd-gyh (通过hostname命令得到)
|
主机名:db01 (通过hostname命令得到)
|
||||||
进程名:rdb_server
|
进程名:rdb_server
|
||||||
实例:rdb_server -a COMAPP
|
实例:rdb_server -a COMAPP
|
||||||
进程号(pid):55558
|
进程号(pid):55558
|
||||||
|
|||||||
@ -12,7 +12,8 @@ TARGET = net_msg_bus_mng_ping_gui
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
LIBS += -lboost_system -lboost_program_options -lzmq -lczmq -llog4cplus \
|
LIBS += -lboost_system -lboost_program_options -lzmq -lczmq -llog4cplus \
|
||||||
-lpub_logger_api -lnet_msg_bus_base_api -lnet_msg_bus_api -lpub_sysinfo_api
|
-lpub_logger_api -lnet_msg_bus_base_api -lnet_msg_bus_api -lpub_sysinfo_api \
|
||||||
|
-lpub_widget -lpub_utility_api
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,19 @@
|
|||||||
|
|
||||||
#include "boost/typeof/typeof.hpp"
|
#include "boost/typeof/typeof.hpp"
|
||||||
#include "boost/lexical_cast.hpp"
|
#include "boost/lexical_cast.hpp"
|
||||||
|
|
||||||
|
//< 屏蔽xml_parser编译告警
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "boost/property_tree/xml_parser.hpp"
|
#include "boost/property_tree/xml_parser.hpp"
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
|
|
||||||
#include "pub_utility_api/FileUtil.h"
|
#include "pub_utility_api/FileUtil.h"
|
||||||
|
|||||||
@ -8,12 +8,10 @@
|
|||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
|
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
|
|
||||||
#include "../net_msg_bus_base_api/CommonDef.h"
|
#include "../net_msg_bus_base_api/CommonDef.h"
|
||||||
|
|
||||||
#include "CDomainMng.h"
|
#include "CDomainMng.h"
|
||||||
|
|
||||||
#include "CDomainThread.h"
|
#include "CDomainThread.h"
|
||||||
|
#include "boost/concept_check.hpp"
|
||||||
|
|
||||||
namespace iot_net
|
namespace iot_net
|
||||||
{
|
{
|
||||||
@ -76,6 +74,7 @@ CDomainThread::CActWorker* CDomainThread::CActWorker::newCActWorker(zsock_t *pAc
|
|||||||
//< 设置m_pLoop事件驱动,优先级与书写顺序有关
|
//< 设置m_pLoop事件驱动,优先级与书写顺序有关
|
||||||
bool bRc = self->setSocketHandle(self->m_pActorPipe, handleActorPipe);
|
bool bRc = self->setSocketHandle(self->m_pActorPipe, handleActorPipe);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
|
|
||||||
//< 此处不添加m_pSockDataIn的接收处理
|
//< 此处不添加m_pSockDataIn的接收处理
|
||||||
//bRc = setSocketHandle(self, self->m_pSockDataIn, handleSockDataIn);
|
//bRc = setSocketHandle(self, self->m_pSockDataIn, handleSockDataIn);
|
||||||
@ -83,6 +82,7 @@ CDomainThread::CActWorker* CDomainThread::CActWorker::newCActWorker(zsock_t *pAc
|
|||||||
|
|
||||||
int nPendingMsgTimerID = zloop_timer(self->m_pLoop, 1000, 0, handlePendingMsgTimer, self);
|
int nPendingMsgTimerID = zloop_timer(self->m_pLoop, 1000, 0, handlePendingMsgTimer, self);
|
||||||
assert(nPendingMsgTimerID >= 0);
|
assert(nPendingMsgTimerID >= 0);
|
||||||
|
boost::ignore_unused_variable_warning(nPendingMsgTimerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//< m_vecRemoteConn
|
//< m_vecRemoteConn
|
||||||
@ -386,6 +386,8 @@ int CDomainThread::CActWorker::handleActorPipe(zloop_t *, zsock_t *reader, void
|
|||||||
|
|
||||||
int CDomainThread::CActWorker::handleSockDataIn(zloop_t *, zsock_t *reader, void *arg)
|
int CDomainThread::CActWorker::handleSockDataIn(zloop_t *, zsock_t *reader, void *arg)
|
||||||
{
|
{
|
||||||
|
boost::ignore_unused_variable_warning(reader);
|
||||||
|
|
||||||
CActWorker *self = (CActWorker *)arg;
|
CActWorker *self = (CActWorker *)arg;
|
||||||
|
|
||||||
assert(reader == self->m_pSockDataIn);
|
assert(reader == self->m_pSockDataIn);
|
||||||
@ -427,6 +429,7 @@ int CDomainThread::CActWorker::delaySockDataIn(zloop_t *, int timer_id, void *ar
|
|||||||
//< 恢复接收 m_pSockDataIn 的消息
|
//< 恢复接收 m_pSockDataIn 的消息
|
||||||
bool bRc = self->setSocketHandle(self->m_pSockDataIn, handleSockDataIn);
|
bool bRc = self->setSocketHandle(self->m_pSockDataIn, handleSockDataIn);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//< 取消本定时器
|
//< 取消本定时器
|
||||||
@ -438,6 +441,7 @@ int CDomainThread::CActWorker::delaySockDataIn(zloop_t *, int timer_id, void *ar
|
|||||||
//< 取消接收 m_pSockDataIn 的消息
|
//< 取消接收 m_pSockDataIn 的消息
|
||||||
bool bRc = self->setSocketHandle(self->m_pSockDataIn, NULL);
|
bool bRc = self->setSocketHandle(self->m_pSockDataIn, NULL);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
|
|
||||||
//< 设置定时器,到时恢复,单位ms
|
//< 设置定时器,到时恢复,单位ms
|
||||||
self->m_nDelaySockDataInTimerID = zloop_timer(self->m_pLoop, 100, 1, delaySockDataIn, self);
|
self->m_nDelaySockDataInTimerID = zloop_timer(self->m_pLoop, 100, 1, delaySockDataIn, self);
|
||||||
|
|||||||
@ -9,13 +9,10 @@
|
|||||||
|
|
||||||
#include "boost/typeof/typeof.hpp"
|
#include "boost/typeof/typeof.hpp"
|
||||||
#include "boost/format.hpp"
|
#include "boost/format.hpp"
|
||||||
|
#include "boost/concept_check.hpp"
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
|
|
||||||
#include "../net_msg_bus_base_api/CommonDef.h"
|
#include "../net_msg_bus_base_api/CommonDef.h"
|
||||||
|
|
||||||
#include "CDomainMng.h"
|
#include "CDomainMng.h"
|
||||||
|
|
||||||
#include "CMainThread.h"
|
#include "CMainThread.h"
|
||||||
|
|
||||||
namespace iot_net
|
namespace iot_net
|
||||||
@ -284,6 +281,7 @@ int CMainThread::CActWorker::handleActorPipe(zloop_t *, zsock_t *reader, void *a
|
|||||||
CActWorker *self = (CActWorker *)arg;
|
CActWorker *self = (CActWorker *)arg;
|
||||||
|
|
||||||
assert(reader == self->m_pActorPipe);
|
assert(reader == self->m_pActorPipe);
|
||||||
|
boost::ignore_unused_variable_warning(self);
|
||||||
|
|
||||||
bool bTerm = false;
|
bool bTerm = false;
|
||||||
|
|
||||||
@ -348,6 +346,7 @@ int CMainThread::CActWorker::delaySockRemote(zloop_t *, int timer_id, void *arg)
|
|||||||
//< 恢复接收m_pSockRemote的消息
|
//< 恢复接收m_pSockRemote的消息
|
||||||
bool bRc = self->setSocketHandle(self->m_pSockRemote, handleSockRemote);
|
bool bRc = self->setSocketHandle(self->m_pSockRemote, handleSockRemote);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//< 取消本定时器
|
//< 取消本定时器
|
||||||
@ -359,6 +358,7 @@ int CMainThread::CActWorker::delaySockRemote(zloop_t *, int timer_id, void *arg)
|
|||||||
//< 取消接收m_pSockRemote的消息
|
//< 取消接收m_pSockRemote的消息
|
||||||
bool bRc = self->setSocketHandle(self->m_pSockRemote, NULL);
|
bool bRc = self->setSocketHandle(self->m_pSockRemote, NULL);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
|
|
||||||
//< 设置定时器,到时恢复,单位ms
|
//< 设置定时器,到时恢复,单位ms
|
||||||
self->m_nDelaySockRemoteTimerID = zloop_timer(self->m_pLoop, 100, 1, delaySockRemote, self);
|
self->m_nDelaySockRemoteTimerID = zloop_timer(self->m_pLoop, 100, 1, delaySockRemote, self);
|
||||||
@ -624,6 +624,7 @@ int CMainThread::CActWorker::handleSockLocalMon(zloop_t *, zsock_t *reader, void
|
|||||||
//< 取消接收 m_pSockRemote 的消息
|
//< 取消接收 m_pSockRemote 的消息
|
||||||
bool bRc = self->setSocketHandle(self->m_pSockRemote, NULL);
|
bool bRc = self->setSocketHandle(self->m_pSockRemote, NULL);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ZMQ_EVENT_CONNECTED:
|
case ZMQ_EVENT_CONNECTED:
|
||||||
@ -639,6 +640,8 @@ int CMainThread::CActWorker::handleSockLocalMon(zloop_t *, zsock_t *reader, void
|
|||||||
//< 设置接收 m_pSockRemote 的消息
|
//< 设置接收 m_pSockRemote 的消息
|
||||||
bool bRc = self->setSocketHandle(self->m_pSockRemote, handleSockRemote);
|
bool bRc = self->setSocketHandle(self->m_pSockRemote, handleSockRemote);
|
||||||
assert(bRc);
|
assert(bRc);
|
||||||
|
boost::ignore_unused_variable_warning(bRc);
|
||||||
|
|
||||||
if (self->m_nDelaySockRemoteTimerID >= 0)
|
if (self->m_nDelaySockRemoteTimerID >= 0)
|
||||||
{
|
{
|
||||||
//< 如果有延迟接收定时器,取消它,避免重复添加reader,zloop的说明如下:
|
//< 如果有延迟接收定时器,取消它,避免重复添加reader,zloop的说明如下:
|
||||||
|
|||||||
@ -8,12 +8,10 @@
|
|||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
|
|
||||||
#include "pub_logger_api/logger.h"
|
#include "pub_logger_api/logger.h"
|
||||||
|
|
||||||
#include "../net_msg_bus_base_api/CommonDef.h"
|
#include "../net_msg_bus_base_api/CommonDef.h"
|
||||||
|
|
||||||
#include "CDomainMng.h"
|
#include "CDomainMng.h"
|
||||||
|
|
||||||
#include "CRemoteConn.h"
|
#include "CRemoteConn.h"
|
||||||
|
#include "boost/concept_check.hpp"
|
||||||
|
|
||||||
namespace iot_net
|
namespace iot_net
|
||||||
{
|
{
|
||||||
@ -258,6 +256,7 @@ int CRemoteConn::handleSockConn(zloop_t *, zsock_t *reader, void *arg)
|
|||||||
CRemoteConn *self = (CRemoteConn *)arg;
|
CRemoteConn *self = (CRemoteConn *)arg;
|
||||||
|
|
||||||
assert(reader == self->m_pSockConn);
|
assert(reader == self->m_pSockConn);
|
||||||
|
boost::ignore_unused_variable_warning(self);
|
||||||
|
|
||||||
//< 当前,不应该收到任何消息
|
//< 当前,不应该收到任何消息
|
||||||
//< 将收到的消息释放,避免占用内存
|
//< 将收到的消息释放,避免占用内存
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
QT -= gui core
|
||||||
|
CONFIG -= qt
|
||||||
|
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
TARGET = net_msg_bus_test_client_dealer
|
||||||
|
|
||||||
|
LIBS += -lboost_system -lboost_thread -llog4cplus -lpub_logger_api -lzmq -lczmq
|
||||||
|
|
||||||
|
win32{
|
||||||
|
LIBS += -lboost_date_time
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
LIBS += -lpthread
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#HEADERS +=
|
||||||
|
|
||||||
|
SOURCES += main.cpp
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
COMMON_PRI=$$PWD/../../../common.pri
|
||||||
|
exists($$COMMON_PRI) {
|
||||||
|
include($$COMMON_PRI)
|
||||||
|
}else {
|
||||||
|
error("FATAL error: can not find common.pri")
|
||||||
|
}
|
||||||
|
|
||||||
83
platform/src/net/net_msg_bus_test/client_dealer/main.cpp
Normal file
83
platform/src/net/net_msg_bus_test/client_dealer/main.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
/******************************************************************************//**
|
||||||
|
* @file
|
||||||
|
* @brief
|
||||||
|
* @author yikenan
|
||||||
|
* @version 1.0
|
||||||
|
* @date
|
||||||
|
**********************************************************************************/
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "boost/thread.hpp"
|
||||||
|
|
||||||
|
#include "pub_logger_api/logger.h"
|
||||||
|
#include "czmq.h"
|
||||||
|
|
||||||
|
static volatile bool g_bNeedExit = false;
|
||||||
|
#define WORKER_READY "hello caodingfa" // Signals worker is ready
|
||||||
|
|
||||||
|
static void signalCallback(int /*sig*/)
|
||||||
|
{
|
||||||
|
std::cout << "signalCallback()" << std::endl;
|
||||||
|
|
||||||
|
g_bNeedExit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int /*argc*/, char ** /*argv[]*/)
|
||||||
|
{
|
||||||
|
signal(SIGTERM, signalCallback);
|
||||||
|
signal(SIGINT, signalCallback);
|
||||||
|
#ifdef WIN32
|
||||||
|
signal(SIGBREAK, signalCallback);
|
||||||
|
#else
|
||||||
|
signal(SIGQUIT, signalCallback);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//< 启动日志
|
||||||
|
iot_public::StartLogSystem("default", "net_msg_bus_test_client_dealer");
|
||||||
|
|
||||||
|
LOGINFO("Log system OK !");
|
||||||
|
|
||||||
|
zsock_t *client = zsock_new(ZMQ_DEALER);
|
||||||
|
zsock_set_sndhwm(client,2);
|
||||||
|
zsock_set_sndtimeo(client,10);
|
||||||
|
zsock_set_identity(client,"fes");
|
||||||
|
// zframe_t *frame = zframe_new(WORKER_READY, strlen(WORKER_READY));
|
||||||
|
// zsock_set_hello_msg(client,frame);
|
||||||
|
// zsock_set_heartbeat_ivl(client,10*1000);
|
||||||
|
|
||||||
|
printf("begin connect\n");
|
||||||
|
zsock_connect(client,"tcp://localhost:8888");
|
||||||
|
printf("end connect\n");
|
||||||
|
|
||||||
|
zpoller_t *poller = zpoller_new (client, NULL);
|
||||||
|
zpoller_set_nonstop (poller, true);
|
||||||
|
|
||||||
|
int request_nbr = 0;
|
||||||
|
|
||||||
|
while (!g_bNeedExit)
|
||||||
|
{
|
||||||
|
int ret = zstr_sendf (client, "request #%d", ++request_nbr);
|
||||||
|
printf("ret=%d request #%d\n", ret,request_nbr);
|
||||||
|
|
||||||
|
zsock_t *pReader = (zsock_t *)zpoller_wait(poller,2000);
|
||||||
|
if(pReader == NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// zmq_sleep(1);
|
||||||
|
zmsg_t *msg = zmsg_recv (client);
|
||||||
|
zframe_print (zmsg_last (msg), "recv:");
|
||||||
|
zmsg_destroy(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//< 停止日志系统
|
||||||
|
iot_public::StopLogSystem();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@ -6,4 +6,6 @@ SUBDIRS += receiver \
|
|||||||
sender \
|
sender \
|
||||||
client \
|
client \
|
||||||
server \
|
server \
|
||||||
|
client_dealer \
|
||||||
|
server_router
|
||||||
|
|
||||||
|
|||||||
@ -122,7 +122,7 @@ int main(int argc, char *argv[])
|
|||||||
objMsgToSend.setPara1(nLoop);
|
objMsgToSend.setPara1(nLoop);
|
||||||
bSendRc = pMbComm->sendMsgToDomain(objMsgToSend);
|
bSendRc = pMbComm->sendMsgToDomain(objMsgToSend);
|
||||||
//bSendRc = g_pComm->sendMsgToHost(objMsgToSend);
|
//bSendRc = g_pComm->sendMsgToHost(objMsgToSend);
|
||||||
//bSendRc = g_pComm->sendMsgToPeer(objMsgToSend, "Comm1", "Proc2", "Inst1", -1, "kbd-rd-ykn");
|
//bSendRc = g_pComm->sendMsgToPeer(objMsgToSend, "Comm1", "Proc2", "Inst1", -1, "host1");
|
||||||
|
|
||||||
if (!bSendRc)
|
if (!bSendRc)
|
||||||
{
|
{
|
||||||
|
|||||||
106
platform/src/net/net_msg_bus_test/server_router/main.cpp
Normal file
106
platform/src/net/net_msg_bus_test/server_router/main.cpp
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
|
||||||
|
/******************************************************************************//**
|
||||||
|
* @file
|
||||||
|
* @brief
|
||||||
|
* @author yikenan
|
||||||
|
* @version 1.0
|
||||||
|
* @date
|
||||||
|
**********************************************************************************/
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "boost/thread.hpp"
|
||||||
|
|
||||||
|
#include "pub_logger_api/logger.h"
|
||||||
|
|
||||||
|
#include "net_msg_bus_api/MsgBusApi.h"
|
||||||
|
#include "czmq.h"
|
||||||
|
#include <boost/icl/interval_set.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
static volatile bool g_bNeedExit = false;
|
||||||
|
#define WORKER_READY "hello caodingfa" // Signals worker is ready
|
||||||
|
|
||||||
|
|
||||||
|
static void signalCallback(int /*sig*/)
|
||||||
|
{
|
||||||
|
std::cout << "signalCallback()" << std::endl;
|
||||||
|
|
||||||
|
g_bNeedExit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int /*argc*/, char ** /*argv[]*/)
|
||||||
|
{
|
||||||
|
typedef boost::icl::interval_set<unsigned int> set_t;
|
||||||
|
typedef set_t::interval_type ival;
|
||||||
|
set_t outages;
|
||||||
|
|
||||||
|
outages.insert(ival::closed(1,9));
|
||||||
|
outages.insert(ival::open(7,10));
|
||||||
|
outages.insert(ival::open(8,11));
|
||||||
|
outages.insert(ival::open(90,120));
|
||||||
|
|
||||||
|
for(set_t::iterator it = outages.begin(); it != outages.end(); it++){
|
||||||
|
std::cout << it->lower() << ", " << it->upper() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
signal(SIGTERM, signalCallback);
|
||||||
|
signal(SIGINT, signalCallback);
|
||||||
|
#ifdef WIN32
|
||||||
|
signal(SIGBREAK, signalCallback);
|
||||||
|
#else
|
||||||
|
signal(SIGQUIT, signalCallback);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//< 启动日志
|
||||||
|
iot_public::StartLogSystem("default", "net_msg_bus_test_server");
|
||||||
|
|
||||||
|
LOGINFO("Log system OK !");
|
||||||
|
|
||||||
|
zsock_t *server = zsock_new(ZMQ_ROUTER);
|
||||||
|
zframe_t *frame = zframe_new(WORKER_READY, strlen(WORKER_READY));
|
||||||
|
zsock_set_hello_msg(server,frame);
|
||||||
|
|
||||||
|
zsock_bind(server,"tcp://*:5570");
|
||||||
|
zpoller_t *poller = zpoller_new (server, NULL);
|
||||||
|
zpoller_set_nonstop (poller, true);
|
||||||
|
|
||||||
|
int request_nbr = 0;
|
||||||
|
|
||||||
|
while (!g_bNeedExit)
|
||||||
|
{
|
||||||
|
zsock_t *pReader = (zsock_t *)zpoller_wait(poller,2000);
|
||||||
|
if(pReader == NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
zmsg_t *msg = zmsg_recv (server);
|
||||||
|
printf("recv msg size=%d\n",(int)zmsg_size(msg));
|
||||||
|
zframe_print (zmsg_last (msg), "recv:");
|
||||||
|
zframe_print (zmsg_first(msg), "recv2:");
|
||||||
|
printf("\n");
|
||||||
|
zmsg_destroy(&msg);
|
||||||
|
|
||||||
|
zmsg_t *sendMsg = zmsg_new ();
|
||||||
|
zmsg_addstr(sendMsg,"fes");
|
||||||
|
zmsg_addstrf(sendMsg,"request #%d",--request_nbr);
|
||||||
|
int ret = zmsg_send(&sendMsg,server);
|
||||||
|
zmsg_destroy(&sendMsg);
|
||||||
|
|
||||||
|
//int ret = zstr_sendf (pReader, "request #%d", --request_nbr);
|
||||||
|
printf("ret=%d request #%d\n", ret,request_nbr);
|
||||||
|
// zmq_sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//< 停止日志系统
|
||||||
|
iot_public::StopLogSystem();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
QT -= gui core
|
||||||
|
CONFIG -= qt
|
||||||
|
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
TARGET = net_msg_bus_test_server_router
|
||||||
|
|
||||||
|
LIBS += -lboost_system -lboost_thread -llog4cplus -lpub_logger_api -lzmq -lczmq
|
||||||
|
|
||||||
|
win32{
|
||||||
|
LIBS += -lboost_date_time
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
LIBS += -lpthread
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#HEADERS +=
|
||||||
|
|
||||||
|
SOURCES += main.cpp
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
COMMON_PRI=$$PWD/../../../common.pri
|
||||||
|
exists($$COMMON_PRI) {
|
||||||
|
include($$COMMON_PRI)
|
||||||
|
}else {
|
||||||
|
error("FATAL error: can not find common.pri")
|
||||||
|
}
|
||||||
|
|
||||||
@ -35,8 +35,19 @@
|
|||||||
//< 纯头文件,不会引入动态库依赖,不影响单程序发布
|
//< 纯头文件,不会引入动态库依赖,不影响单程序发布
|
||||||
#include "boost/typeof/typeof.hpp"
|
#include "boost/typeof/typeof.hpp"
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
//< 屏蔽xml_parser编译告警
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "boost/property_tree/xml_parser.hpp"
|
#include "boost/property_tree/xml_parser.hpp"
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "AgentCommon.h"
|
#include "AgentCommon.h"
|
||||||
|
|
||||||
namespace iot_net
|
namespace iot_net
|
||||||
@ -50,7 +61,7 @@ bool g_bNeedExit = false;
|
|||||||
sigar_t *g_pSigar = nullptr;
|
sigar_t *g_pSigar = nullptr;
|
||||||
|
|
||||||
//< 模块名,调用日志时使用
|
//< 模块名,调用日志时使用
|
||||||
const char *cn_szModuleName = "kbd";
|
const char *cn_szModuleName = "agent";
|
||||||
|
|
||||||
//< 进程名最大长度
|
//< 进程名最大长度
|
||||||
//< 比如Linux系统限制进程名最大长度为15个字符(即加上最后的\0是16Byte),超过则截断
|
//< 比如Linux系统限制进程名最大长度为15个字符(即加上最后的\0是16Byte),超过则截断
|
||||||
|
|||||||
@ -179,8 +179,8 @@ bool CAgentServer::initialize()
|
|||||||
std::string strLogFile("/net_snmp_agent.log");
|
std::string strLogFile("/net_snmp_agent.log");
|
||||||
int nLogErrFlt = 15, nLogWarFlt = 4, nLogEvtFlt = 0, nLogInfFlt = 0, nLogDbgFlt = 0, nLogUsrFlt = ULL_EVENT;
|
int nLogErrFlt = 15, nLogWarFlt = 4, nLogEvtFlt = 0, nLogInfFlt = 0, nLogDbgFlt = 0, nLogUsrFlt = ULL_EVENT;
|
||||||
std::string strCommunity("public");
|
std::string strCommunity("public");
|
||||||
std::string strAdminAuth("kbdct");
|
std::string strAdminAuth("admin");
|
||||||
std::string strAdminPriv("kbdct@0755");
|
std::string strAdminPriv(EMS_DEFAULT_PASSWD);
|
||||||
std::set<std::string> setProcWhiteList;
|
std::set<std::string> setProcWhiteList;
|
||||||
|
|
||||||
const std::string &&strCurModuleDir = iot_net::getCurModuleDir();
|
const std::string &&strCurModuleDir = iot_net::getCurModuleDir();
|
||||||
@ -298,7 +298,7 @@ bool CAgentServer::initialize()
|
|||||||
//< 业务相关
|
//< 业务相关
|
||||||
{
|
{
|
||||||
//< add() 后由MIB接管,无需我们来释放内存
|
//< add() 后由MIB接管,无需我们来释放内存
|
||||||
pMib->add(new sysGroup("Agent of KBDCT", CN_OID_KBD_ROOT, 10));
|
pMib->add(new sysGroup("Snmp Agent", CN_OID_KBD_ROOT, 10));
|
||||||
pMib->add(new snmpGroup());
|
pMib->add(new snmpGroup());
|
||||||
//mib->add(new snmp_target_mib());
|
//mib->add(new snmp_target_mib());
|
||||||
//mib->add(new snmp_notification_mib());
|
//mib->add(new snmp_notification_mib());
|
||||||
@ -326,14 +326,17 @@ bool CAgentServer::initialize()
|
|||||||
|
|
||||||
void CAgentServer::release()
|
void CAgentServer::release()
|
||||||
{
|
{
|
||||||
//< 如果有尚未处理完的请求,析构Mib时会“死等”,分析其源码,是Agent++的Bug
|
if( pMib )
|
||||||
while (!pMib->get_thread_pool()->is_idle())
|
|
||||||
{
|
{
|
||||||
Thread::sleep(100);
|
//< 如果有尚未处理完的请求,析构Mib时会“死等”,分析其源码,是Agent++的Bug
|
||||||
}
|
while (!pMib->get_thread_pool()->is_idle())
|
||||||
|
{
|
||||||
|
Thread::sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
delete pMib;
|
delete pMib;
|
||||||
pMib = nullptr;
|
pMib = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
delete pReqList;
|
delete pReqList;
|
||||||
pReqList = nullptr;
|
pReqList = nullptr;
|
||||||
@ -354,8 +357,11 @@ void CAgentServer::release()
|
|||||||
pCpuGroup = nullptr;
|
pCpuGroup = nullptr;
|
||||||
pProcessGroup = nullptr;
|
pProcessGroup = nullptr;
|
||||||
|
|
||||||
sigar_close(g_pSigar);
|
if( g_pSigar )
|
||||||
g_pSigar = nullptr;
|
{
|
||||||
|
sigar_close(g_pSigar);
|
||||||
|
g_pSigar = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Snmp::socket_cleanup();
|
Snmp::socket_cleanup();
|
||||||
|
|
||||||
|
|||||||
@ -29,15 +29,15 @@ static void handleSigno(int nSigno)
|
|||||||
iot_net::g_bNeedExit = true;
|
iot_net::g_bNeedExit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *szSystemdCfgFile = "/lib/systemd/system/kbd_snmp_agent.service";
|
static const char *szSystemdCfgFile = "/usr/lib/systemd/system/byd_snmp_agent.service";
|
||||||
|
|
||||||
//< 注册系统服务,并设置自启动
|
//< 注册系统服务,并设置自启动
|
||||||
static bool regSysService()
|
static bool regSysService()
|
||||||
{
|
{
|
||||||
//< 判断服务是否已注册,普通用户权限可执行
|
//< 判断服务是否已注册,普通用户权限可执行
|
||||||
if (0 == std::system("systemctl is-enabled kbd_snmp_agent.service"))
|
if (0 == std::system("systemctl is-enabled byd_snmp_agent.service"))
|
||||||
{
|
{
|
||||||
printf("\nSystem service kbd_snmp_agent already enabled, exit.\n");
|
printf("\nSystem service byd_snmp_agent already enabled, exit.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ static bool regSysService()
|
|||||||
// fclose(pFile);
|
// fclose(pFile);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const std::string strExec = iot_net::getCurModuleDir() + "/net_snmp_agent -s";
|
const std::string strExec = iot_net::getCurModuleDir() + "net_snmp_agent -s";
|
||||||
|
|
||||||
//< 生成或修改systemd服务配置文件
|
//< 生成或修改systemd服务配置文件
|
||||||
try
|
try
|
||||||
@ -60,7 +60,7 @@ static bool regSysService()
|
|||||||
using namespace boost::property_tree;
|
using namespace boost::property_tree;
|
||||||
ptree objPtree;
|
ptree objPtree;
|
||||||
|
|
||||||
objPtree.put<const char *>("Unit.Description", "kbd_snmp_agent");
|
objPtree.put<const char *>("Unit.Description", "byd_snmp_agent");
|
||||||
objPtree.put<const char *>("Unit.After", "network.target");
|
objPtree.put<const char *>("Unit.After", "network.target");
|
||||||
|
|
||||||
objPtree.put<const char *>("Service.Type", "simple");
|
objPtree.put<const char *>("Service.Type", "simple");
|
||||||
@ -87,13 +87,13 @@ static bool regSysService()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//< 设置服务开机自启动
|
//< 设置服务开机自启动
|
||||||
if (0 != std::system("systemctl enable kbd_snmp_agent.service"))
|
if (0 != std::system("systemctl enable byd_snmp_agent.service"))
|
||||||
{
|
{
|
||||||
printf("\nEnable service failed, exit.\n");
|
printf("\nEnable service failed, exit.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nSuccessfully registered system service kbd_snmp_agent.\n");
|
printf("\nSuccessfully registered system service byd_snmp_agent.\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ static bool unregSysService()
|
|||||||
//< 重新加载一次,确保systemd配置与文件一致,需需管理员权限
|
//< 重新加载一次,确保systemd配置与文件一致,需需管理员权限
|
||||||
nRc = std::system("systemctl daemon-reload");
|
nRc = std::system("systemctl daemon-reload");
|
||||||
|
|
||||||
printf("\nSystem service kbd_snmp_agent has not been registered.\n");
|
printf("\nSystem service byd_snmp_agent has not been registered.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -120,10 +120,10 @@ static bool unregSysService()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//< 停止服务
|
//< 停止服务
|
||||||
nRc = std::system("systemctl stop kbd_snmp_agent.service");
|
nRc = std::system("systemctl stop byd_snmp_agent.service");
|
||||||
|
|
||||||
//< 取消服务开机自启动
|
//< 取消服务开机自启动
|
||||||
nRc = std::system("systemctl disable kbd_snmp_agent.service");
|
nRc = std::system("systemctl disable byd_snmp_agent.service");
|
||||||
|
|
||||||
//< 删除服务配置文件
|
//< 删除服务配置文件
|
||||||
remove(szSystemdCfgFile);
|
remove(szSystemdCfgFile);
|
||||||
@ -131,7 +131,7 @@ static bool unregSysService()
|
|||||||
//< systemd重新加载配置文件
|
//< systemd重新加载配置文件
|
||||||
nRc = std::system("systemctl daemon-reload");
|
nRc = std::system("systemctl daemon-reload");
|
||||||
|
|
||||||
printf("\nSuccessfully unregistered system service kbd_snmp_agent.\n");
|
printf("\nSuccessfully unregistered system service byd_snmp_agent.\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ static void handleSigno(int nSigno)
|
|||||||
iot_net::g_bNeedExit = true;
|
iot_net::g_bNeedExit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CN_SERVICE_NAME "kbd_snmp_agent"
|
#define CN_SERVICE_NAME "byd_snmp_agent"
|
||||||
static const char *szServiceName = CN_SERVICE_NAME;
|
static const char *szServiceName = CN_SERVICE_NAME;
|
||||||
static SERVICE_STATUS_HANDLE g_hServiceStatus = NULL;
|
static SERVICE_STATUS_HANDLE g_hServiceStatus = NULL;
|
||||||
static LPSERVICE_STATUS g_pStatus = NULL;
|
static LPSERVICE_STATUS g_pStatus = NULL;
|
||||||
@ -52,7 +52,7 @@ static bool regSysService()
|
|||||||
SC_HANDLE hService = ::OpenServiceA(hSCM, szServiceName, SERVICE_QUERY_CONFIG);
|
SC_HANDLE hService = ::OpenServiceA(hSCM, szServiceName, SERVICE_QUERY_CONFIG);
|
||||||
if (NULL == hService)
|
if (NULL == hService)
|
||||||
{
|
{
|
||||||
const std::string strExec = iot_net::getCurModuleDir() + "/net_snmp_agent.exe -s";
|
const std::string strExec = iot_net::getCurModuleDir() + "net_snmp_agent.exe -s";
|
||||||
|
|
||||||
//< 创建服务
|
//< 创建服务
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ static bool regSysService()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SERVICE_DESCRIPTIONA stSrvDesc;
|
SERVICE_DESCRIPTIONA stSrvDesc;
|
||||||
char szDesc[] = "The SNMP agent of KBD.";
|
char szDesc[] = "The SNMP agent";
|
||||||
stSrvDesc.lpDescription = szDesc;
|
stSrvDesc.lpDescription = szDesc;
|
||||||
if (::ChangeServiceConfig2A(hService, SERVICE_CONFIG_DESCRIPTION, &stSrvDesc))
|
if (::ChangeServiceConfig2A(hService, SERVICE_CONFIG_DESCRIPTION, &stSrvDesc))
|
||||||
{
|
{
|
||||||
@ -84,7 +84,7 @@ static bool regSysService()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("System service kbd_snmp_agent already exists.\n");
|
printf("System service byd_snmp_agent already exists.\n");
|
||||||
::CloseServiceHandle(hService);
|
::CloseServiceHandle(hService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ static bool regSysService()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(bRet)
|
if(bRet)
|
||||||
printf("\nSuccessfully registered system service kbd_snmp_agent.\n");
|
printf("\nSuccessfully registered system service byd_snmp_agent.\n");
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ static bool unregSysService()
|
|||||||
if (NULL == hService)
|
if (NULL == hService)
|
||||||
{
|
{
|
||||||
//< 服务不存在
|
//< 服务不存在
|
||||||
printf("System service kbd_snmp_agent not exists.\n");
|
printf("System service byd_snmp_agent not exists.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -171,7 +171,7 @@ static bool unregSysService()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(bRet)
|
if(bRet)
|
||||||
printf("\nSuccessfully unregistered system service kbd_snmp_agent.\n");
|
printf("\nSuccessfully unregistered system service byd_snmp_agent.\n");
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -201,9 +201,12 @@ void CProcessGroup::CTabByCrc32::updateOfMine(unsigned long &nTotal, unsigned lo
|
|||||||
++nRunning;
|
++nRunning;
|
||||||
break;
|
break;
|
||||||
case SIGAR_PROC_STATE_SLEEP:
|
case SIGAR_PROC_STATE_SLEEP:
|
||||||
|
case SIGAR_PROC_STATE_DISK_SLEEP: // added by yikenan
|
||||||
++nSleeping;
|
++nSleeping;
|
||||||
break;
|
break;
|
||||||
case SIGAR_PROC_STATE_STOP:
|
case SIGAR_PROC_STATE_STOP:
|
||||||
|
case SIGAR_PROC_STATE_TRACE: // added by yikenan
|
||||||
|
case SIGAR_PROC_STATE_DEAD: // added by yikenan,是否合理待商榷
|
||||||
++nStopped;
|
++nStopped;
|
||||||
break;
|
break;
|
||||||
case SIGAR_PROC_STATE_ZOMBIE:
|
case SIGAR_PROC_STATE_ZOMBIE:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
#snmpbulkwalk -v 3 -u admin -l authPriv -a sha -A kbdct@0755 -x des -X kbdct@0755 192.168.77.79:4700 ".1.3"
|
#snmpbulkwalk -v 3 -u admin -l authPriv -a sha -A ems@byd23 -x des -X ems@byd23 192.168.77.79:4700 ".1.3"
|
||||||
snmpbulkwalk -v 3 -u admin -l authPriv -a sha -A kbdct@0755 -x des -X kbdct@0755 127.0.0.1:4700 ".1.3"
|
snmpbulkwalk -v 3 -u admin -l authPriv -a sha -A ems@byd23 -x des -X ems@byd23 127.0.0.1:4700 ".1.3"
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user