central nginx manager

This commit is contained in:
Ned Wright
2025-01-13 12:35:42 +00:00
parent 35b2df729f
commit 6db87fc7fe
45 changed files with 390 additions and 130 deletions

View File

@@ -59,7 +59,14 @@ CefStream::sendLog(const Report &log)
void
CefStream::init() {
updateSettings();
maintainConnection();
mainloop->addOneTimeRoutine(
I_MainLoop::RoutineType::Offline,
[this] ()
{
dbgTrace(D_REPORT) << FIRST_CEF_CONNECT_NAME;
},
FIRST_CEF_CONNECT_NAME
);
auto ceflog_retry_interval = getProfileAgentSettingWithDefault<uint>(
RETRY_CONNECT_INTERVAL,

View File

@@ -26,7 +26,9 @@
#include "logging_comp.h"
static const int RETRY_CONNECT_INTERVAL = 120;
static const std::string FIRST_SYSLOG_CONNECT_NAME = "first connecting to Syslog server";
static const std::string SYSLOG_CONNECT_NAME = "connecting to Syslog server";
static const std::string FIRST_CEF_CONNECT_NAME = "first connecting to CEF server";
static const std::string CEF_CONNECT_NAME = "connecting to CEF server";
static const int NUMBER_OF_LOGS_PER_SEND = 15;
static size_t MAX_LOG_QUEUE = 1000;

View File

@@ -134,6 +134,16 @@ public:
DoAll(SaveArg<1>(&sysog_routine), Return(0))
);
EXPECT_CALL(
mock_mainloop,
addOneTimeRoutine(_, _, "first connecting to Syslog server", _)
).WillRepeatedly(DoAll(SaveArg<1>(&first_connect_syslog_routine), Return(0)));
EXPECT_CALL(
mock_mainloop,
addOneTimeRoutine(_, _, "first connecting to CEF server", _)
).WillRepeatedly(DoAll(SaveArg<1>(&first_connect_cef_routine), Return(0)));
EXPECT_CALL(
mock_mainloop,
addRecurringRoutine(_, _, _, "connecting to Syslog server", _)
@@ -303,6 +313,8 @@ public:
ConfigComponent config;
vector<string> capture_syslog_cef_data;
I_MainLoop::Routine sysog_routine = nullptr;
I_MainLoop::Routine first_connect_syslog_routine = nullptr;
I_MainLoop::Routine first_connect_cef_routine = nullptr;
I_MainLoop::Routine connect_syslog_routine = nullptr;
I_MainLoop::Routine connect_cef_routine = nullptr;
StrictMock<MockShellCmd> mock_shell_cmd;
@@ -1517,6 +1529,8 @@ TEST_F(LogTest, ObfuscationCefSysLogTest)
I_Socket::SocketType protocol = I_Socket::SocketType::TCP;
// for cef
CefStream cef_stream(address, port, protocol);
ASSERT_NE(first_connect_cef_routine, nullptr);
first_connect_cef_routine();
ASSERT_NE(connect_cef_routine, nullptr);
connect_cef_routine();
cef_stream.sendLog(CreateReport(tag1, tag2));
@@ -1525,6 +1539,8 @@ TEST_F(LogTest, ObfuscationCefSysLogTest)
SyslogStream syslog_stream(address, port, protocol);
// connection to socket before send log
ASSERT_NE(first_connect_syslog_routine, nullptr);
first_connect_syslog_routine();
ASSERT_NE(connect_syslog_routine, nullptr);
connect_syslog_routine();
@@ -1554,6 +1570,8 @@ TEST_F(LogTest, SysLogWriteFailTest)
I_Socket::SocketType protocol = I_Socket::SocketType::TCP;
SyslogStream syslog_stream(address, port, protocol);
ASSERT_NE(first_connect_syslog_routine, nullptr);
first_connect_syslog_routine();
ASSERT_NE(connect_syslog_routine, nullptr);
connect_syslog_routine();
@@ -1599,6 +1617,8 @@ TEST_F(LogTest, CefWriteFailTest)
I_Socket::SocketType protocol = I_Socket::SocketType::TCP;
CefStream cef_stream(address, port, protocol);
ASSERT_NE(first_connect_cef_routine, nullptr);
first_connect_cef_routine();
ASSERT_NE(connect_cef_routine, nullptr);
connect_cef_routine();

View File

@@ -71,7 +71,14 @@ SyslogStream::sendLog(const vector<char> &data)
void
SyslogStream::init() {
updateSettings();
maintainConnection();
mainloop->addOneTimeRoutine(
I_MainLoop::RoutineType::Offline,
[this] ()
{
dbgTrace(D_REPORT) << FIRST_SYSLOG_CONNECT_NAME;
},
FIRST_SYSLOG_CONNECT_NAME
);
auto syslog_retry_interval = getProfileAgentSettingWithDefault<uint>(
RETRY_CONNECT_INTERVAL,