fix recallhis in pingtest
This commit is contained in:
@@ -217,6 +217,8 @@ std::string g_strOTLConnect = "postgres/bmdev@123@pgsql"; //OTL
|
||||
//lnk2024-8-14<31><34><EFBFBD>ӽ<EFBFBD><D3BD>ͽ<EFBFBD><CDBD>߱<EFBFBD>־,0<><30><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD>ν<EFBFBD><CEBD>ߣ<EFBFBD>1<EFBFBD><31><EFBFBD>ڽ<EFBFBD><DABD>ν<EFBFBD><CEBD><EFBFBD>
|
||||
int isdelta_flag = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool g_stopTelnetTest = false;
|
||||
|
||||
//////CZY 2023-09-06 config
|
||||
//<2F><>ǰ<EFBFBD><C7B0>flag:1Ϊ<31><CEAA><EFBFBD><EFBFBD>,0Ϊ<30>ر<EFBFBD>
|
||||
@@ -352,6 +354,7 @@ std::string WEB_FILEDOWNLOAD = "";
|
||||
extern pthread_mutex_t mtx;
|
||||
|
||||
/*lnk 2024-10-21 */
|
||||
std::string intToString(int number);
|
||||
int OTL_Select_DecideRecall_web(char* time, char* id);//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
void OTL_Select_recall_web(char* time, char* id); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
bool CheckPG_To_Recall_web(long long start, long long end, char* Monitorid);
|
||||
@@ -1166,70 +1169,76 @@ bool ping_ip(const std::string& ip) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void pingPrint(QTcpSocket* clientSocket, const std::string &msg) {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
std::cout << msg << std::endl;
|
||||
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD>
|
||||
add_comm_log(const_cast<char*>(msg.c_str()));
|
||||
// <20><><EFBFBD><EFBFBD> clientSocket <20><>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD> shell
|
||||
if (clientSocket != nullptr) {
|
||||
clientSocket->write((msg + "\r\n").c_str());
|
||||
clientSocket->flush();
|
||||
}
|
||||
}
|
||||
int init_ping_telnet(QTcpSocket* clientSocket, int& ip_count, int& telnet_count) {
|
||||
pingPrint(clientSocket, "start test ping telnet");
|
||||
ied_t* ied = NULL;
|
||||
int iedno;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸
|
||||
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ֹ
|
||||
if (g_stopTelnetTest) {
|
||||
pingPrint(clientSocket, "Telnet test stopped by user.");
|
||||
break;
|
||||
}
|
||||
ied = g_node->clients[iedno];
|
||||
if (ied) {
|
||||
if (g_onlyIP[0] != 0 && (strcmp(g_onlyIP, ied->channel[0].addr_str) != 0)) {
|
||||
continue;
|
||||
}
|
||||
bool pingResult = ping_ip(ied->channel[0].addr_str);
|
||||
bool telnetResult = telnet_port_socket(ied->channel[0].addr_str, ied->channel[0].port);
|
||||
|
||||
int init_ping_telnet(int& ip_count, int& telnet_count) {
|
||||
cout << "start test ping telnet" << endl;
|
||||
ied_t* ied = NULL;
|
||||
int iedno;
|
||||
LD_info_t* LD_info = NULL;
|
||||
int count = 0;
|
||||
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
|
||||
ied = g_node->clients[iedno];
|
||||
if (ied) {
|
||||
//ied->channel[0].addr_str[LONGNAME - 1] = 0;//DEV_IP
|
||||
if (g_onlyIP[0] != 0 && (strcmp(g_onlyIP, ied->channel[0].addr_str) != 0)) {
|
||||
continue;
|
||||
}
|
||||
ied->channel[0].addr_str;//DEV_IP
|
||||
ied->channel[0].port;//DEV_PortID
|
||||
bool pingResult = ping_ip(ied->channel[0].addr_str);
|
||||
//bool pingResult = test_ping(ied->channel[0].addr_str);
|
||||
std::string logMsg;
|
||||
logMsg.append("Ping to IP ");
|
||||
logMsg.append(ied->channel[0].addr_str);
|
||||
if (pingResult) {
|
||||
ip_count++;
|
||||
logMsg.append(" is successful.");
|
||||
} else {
|
||||
logMsg.append(" is unsuccessful.");
|
||||
}
|
||||
pingPrint(clientSocket, logMsg);
|
||||
add_comm_log(const_cast<char*>(logMsg.c_str()));
|
||||
|
||||
//bool telnetResult = telnetIPPort(ied->channel[0].addr_str, ied->channel[0].port);
|
||||
bool telnetResult = telnet_port_socket(ied->channel[0].addr_str, ied->channel[0].port);
|
||||
std::string strlog = "";
|
||||
strlog.append("Ping to IP ");
|
||||
strlog.append(ied->channel[0].addr_str);
|
||||
logMsg = "";
|
||||
logMsg.append("Telnet port ");
|
||||
logMsg.append(QString::number(ied->channel[0].port).toStdString());
|
||||
if (telnetResult) {
|
||||
telnet_count++;
|
||||
logMsg.append(" is open on IP ");
|
||||
} else {
|
||||
logMsg.append(" is closed on IP ");
|
||||
}
|
||||
logMsg.append(ied->channel[0].addr_str);
|
||||
add_comm_log(const_cast<char*>(logMsg.c_str()));
|
||||
pingPrint(clientSocket, logMsg);
|
||||
|
||||
if (pingResult) {
|
||||
ip_count++;
|
||||
std::cout << "Ping to IP " << ied->channel[0].addr_str << " is successful." << std::endl;
|
||||
strlog.append(" is successful.");
|
||||
}
|
||||
else {
|
||||
std::cout << "Ping to IP " << ied->channel[0].addr_str << " is unsuccessful." << std::endl;
|
||||
strlog.append(" is unsuccessful.");
|
||||
std::string countMsg = "iedno:" + intToString(iedno) +
|
||||
" ip_count:" + intToString(ip_count) +
|
||||
" telnet_count:" + intToString(telnet_count);
|
||||
pingPrint(clientSocket, countMsg);
|
||||
|
||||
}
|
||||
add_comm_log(const_cast<char*>(strlog.c_str()));
|
||||
strlog = "";
|
||||
std::string str = QString::number(ied->channel[0].port).toStdString();
|
||||
strlog.append("Telnet port ");
|
||||
strlog.append(str);
|
||||
if (telnetResult) {
|
||||
telnet_count++;
|
||||
std::cout << "Telnet port " << ied->channel[0].port << " is open on IP " << ied->channel[0].addr_str << std::endl;
|
||||
strlog.append(" is open on IP ");
|
||||
}
|
||||
else {
|
||||
std::cout << "Telnet port " << ied->channel[0].port << " is closed on IP " << ied->channel[0].addr_str << std::endl;
|
||||
strlog.append(" is closed on IP ");
|
||||
|
||||
}
|
||||
strlog.append(ied->channel[0].addr_str);
|
||||
add_comm_log(const_cast<char*>(strlog.c_str()));
|
||||
|
||||
cout << "iedno:" << iedno << " ip_count:" << ip_count << " telnet_count:" << telnet_count << endl;
|
||||
QString MyKafkaIniFilename = QString("../etc/") + QString("testping.ini"); //+QString::fromAscii(subdir)
|
||||
QSettings settings(MyKafkaIniFilename, QSettings::IniFormat);
|
||||
settings.setValue("test/IpCount", ip_count);
|
||||
settings.setValue("test/TelnetCount", telnet_count);
|
||||
settings.setValue("test/IedCount", iedno);
|
||||
}
|
||||
}
|
||||
cout << "end test ping telnet" << endl;
|
||||
|
||||
return 1;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
QString MyKafkaIniFilename = QString("../etc/") + QString("testping.ini");
|
||||
QSettings settings(MyKafkaIniFilename, QSettings::IniFormat);
|
||||
settings.setValue("test/IpCount", ip_count);
|
||||
settings.setValue("test/TelnetCount", telnet_count);
|
||||
settings.setValue("test/IedCount", iedno);
|
||||
}
|
||||
}
|
||||
pingPrint(clientSocket, "end test ping telnet");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//CZY 2023-08-30 read device account from web api
|
||||
@@ -11892,10 +11901,10 @@ void Worker::handleViewLogCommand(const QString& command, QTcpSocket* clientSock
|
||||
clientSocket->flush();
|
||||
|
||||
while (!stopViewLog) {
|
||||
// **1. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> `q` <20>˳<EFBFBD>**
|
||||
// **1. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> ``` <20>˳<EFBFBD>**
|
||||
if (clientSocket->waitForReadyRead(500)) { // ? <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
QByteArray input = clientSocket->readAll().trimmed();
|
||||
if (input == "`") { // ? <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> `q`<60><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>־ģʽ
|
||||
if (input == "`") { // ? <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> ```<60><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>־ģʽ
|
||||
std::cout << "Received '`' from shell socket! Exiting viewlog...\n";
|
||||
stopViewLog = true;
|
||||
showinshellflag = false;
|
||||
@@ -13134,7 +13143,7 @@ void OnTimerThread::run()
|
||||
<< localTime.tm_hour << ":" << localTime.tm_min << ":" << localTime.tm_sec
|
||||
<< endl;
|
||||
|
||||
//web<65>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>еĽ<D0B5><C4BD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* //web<65>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>еĽ<D0B5><C4BD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int ip_count = 0;
|
||||
int telnet_count = 0;
|
||||
if (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) {
|
||||
@@ -13144,7 +13153,7 @@ void OnTimerThread::run()
|
||||
Cout_account_information();
|
||||
pthread_mutex_unlock(&mtx); std::cout << "testping free lock !!!!!!!!!!!" << std::endl;
|
||||
}
|
||||
|
||||
*///<2F><><EFBFBD><EFBFBD>testsheell
|
||||
//<2F><><EFBFBD><EFBFBD>ģʽ
|
||||
if (g_onlyIP[0] != 0)
|
||||
{
|
||||
@@ -15636,5 +15645,15 @@ void echo_msg_debugexy(const char *file_name, int line_no, const char *fmt, ...)
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void telnetetst(QTcpSocket* clientSocket) {
|
||||
int ip_count = 0;
|
||||
int telnet_count = 0;
|
||||
g_stopTelnetTest = false;
|
||||
//<2F>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>̨<EFBFBD>˼<EFBFBD><CBBC><EFBFBD>lnk20250114
|
||||
pthread_mutex_lock(&mtx); std::cout << "testping hold lock !!!!!!!!!!!" << std::endl;
|
||||
init_ping_telnet(clientSocket,ip_count, telnet_count);
|
||||
Cout_account_information();
|
||||
pthread_mutex_unlock(&mtx); std::cout << "testping free lock !!!!!!!!!!!" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,12 @@ extern int G_TEST_NUM;
|
||||
extern void ledger(const char* terminal_id = NULL,QIODevice* outputDevice = NULL);
|
||||
extern void value_print(const char *variableName, QTcpSocket *clientSocket);
|
||||
extern int TEST_PORT;
|
||||
extern void telnetetst(QTcpSocket* clientSocket);
|
||||
|
||||
extern void redirectErrorOutput(bool enable);
|
||||
extern void redirectWarnOutput(bool enable);
|
||||
extern void redirectNormalOutput(bool enable);
|
||||
extern void redirectDebugOutput(bool enable);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -150,6 +155,7 @@ public:
|
||||
timer(NULL),
|
||||
historyIndex(-1),
|
||||
stopViewLog(false),
|
||||
g_stopTelnetTest(false),
|
||||
activeClient(NULL)
|
||||
{
|
||||
}
|
||||
@@ -231,6 +237,13 @@ public slots:
|
||||
TEST_NUM = num;
|
||||
}
|
||||
|
||||
void setTestlog(bool flag) {
|
||||
redirectErrorOutput(flag);
|
||||
redirectWarnOutput(flag);
|
||||
redirectNormalOutput(flag);
|
||||
redirectDebugOutput(flag);
|
||||
}
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
@@ -309,11 +322,12 @@ private slots:
|
||||
continue;
|
||||
}
|
||||
|
||||
// 1) <20><><EFBFBD><EFBFBD> '`' <20>˳<EFBFBD> viewlog
|
||||
// 1) <20><><EFBFBD><EFBFBD> '`' <20>˳<EFBFBD> viewlog <20><>ping
|
||||
if (c == '`') {
|
||||
std::cout << "Received '`' from shell socket! Exiting viewlog...\n";
|
||||
if (activeClient == clientSocket) {
|
||||
stopViewLog = true;
|
||||
g_stopTelnetTest = true;
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("\r\nLog view stopped. Returning to shell.\r\n");
|
||||
printPrompt(clientSocket);
|
||||
@@ -417,6 +431,8 @@ private:
|
||||
if (cmd == "help") {
|
||||
QString helpText = "Available commands:\r\n";
|
||||
helpText += "TEST_NUM=<num> - Set the TEST_NUM\r\n";
|
||||
helpText += "LOG=<bool> - Set the LOG\r\n";
|
||||
helpText += "telnettest - Set the telnettest\r\n";
|
||||
helpText += "rc - Execute rocketmq_test_rc\r\n";
|
||||
helpText += "rt - Execute rocketmq_test_rt\r\n";
|
||||
helpText += "ud - Execute rocketmq_test_ud\r\n";
|
||||
@@ -450,6 +466,23 @@ private:
|
||||
clientSocket->write("Invalid number\r\n");
|
||||
}
|
||||
}
|
||||
else if (cmd.startsWith("LOG=")) {
|
||||
bool ok;
|
||||
bool flag = cmd.mid(4).toInt(&ok);
|
||||
if (ok) {
|
||||
setTestlog(flag);
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("TEST_NUM updated\r\n");
|
||||
} else {
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("Invalid number\r\n");
|
||||
}
|
||||
}
|
||||
else if (cmd.startsWith("telnettest")) {
|
||||
telnetetst(clientSocket);
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("Executed telnettest warning!!! it woont stop until finish!!!\r\n");
|
||||
}
|
||||
else if (cmd.startsWith("rc")) {
|
||||
rocketmq_test_rc();
|
||||
clientSocket->write("\r\x1B[K");
|
||||
@@ -586,7 +619,9 @@ private:
|
||||
QString currentCommand; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// viewlog <20><><EFBFBD><EFBFBD>
|
||||
bool stopViewLog;
|
||||
bool stopViewLog;
|
||||
//ping<6E><67><EFBFBD><EFBFBD>
|
||||
bool g_stopTelnetTest;
|
||||
QTcpSocket* activeClient;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user