Skip to content

Commit

Permalink
fix compile errors in rsyslog; adapt to an API change in tools
Browse files Browse the repository at this point in the history
  • Loading branch information
renukamanavalan committed Jul 8, 2022
1 parent 266c161 commit 202589f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
2 changes: 2 additions & 0 deletions rules/docker-eventd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ $(DOCKER_EVENTD)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro

SONIC_BULLSEYE_DOCKERS += $(DOCKER_EVENTD)
SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_EVENTD_DBG)

SONIC_COPY_FILES += $((SONIC_EVENTD)_SRC_PATH)/rsyslog_plugin
6 changes: 3 additions & 3 deletions src/sonic-eventd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ RM := rm -rf
EVENTD_TARGET := eventd
EVENTD_TEST := tests/tests
EVENTD_TOOL := tools/events_tool
RSYSLOG-PLUGIN_TARGET := rsyslog_plugin
RSYSLOG-PLUGIN_TEST: rsyslog_plugin_tests/tests
RSYSLOG-PLUGIN_TARGET := rsyslog_plugin/rsyslog_plugin
RSYSLOG-PLUGIN_TEST := rsyslog_plugin_tests/tests
CP := cp
MKDIR := mkdir
CC := g++
Expand All @@ -26,7 +26,7 @@ endif
-include rsyslog_plugin/subdir.mk
-include rsyslog_plugin_tests/subdir.mk

all: sonic-eventd eventd-tests eventd-tool rsyslog-plugin rsyslog-plugin-tests
all: sonic-eventd eventd-tests eventd-tool rsyslog-plugin

sonic-eventd: $(OBJS)
@echo 'Building target: $@'
Expand Down
6 changes: 3 additions & 3 deletions src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <fstream>
#include <regex>
#include "rsyslog_plugin.h"
#include "common/json.hpp"
#include "json.hpp"

using json = nlohmann::json;

Expand All @@ -16,7 +16,7 @@ bool RsyslogPlugin::onMessage(string msg) {
} else {
int returnCode = event_publish(m_eventHandle, tag, &paramDict);
if (returnCode != 0) {
SWSS_LOG_ERROR("rsyslog_plugin was not able to publish event for %s. last thrown event error: %d\n", tag.c_str(), event_last_error());
SWSS_LOG_ERROR("rsyslog_plugin was not able to publish event for %s.\n", tag.c_str());
return false;
}
return true;
Expand Down Expand Up @@ -64,7 +64,7 @@ bool RsyslogPlugin::createRegexList() {
return true;
}

[[noreturn]] void RsyslogPlugin::run() {
void RsyslogPlugin::run() {
while(true) {
string line;
getline(cin, line);
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <string>
#include <memory>
#include "syslog_parser.h"
#include "common/events.h"
#include "common/logger.h"
#include "events.h"
#include "logger.h"

using namespace std;
using namespace swss;
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-eventd/rsyslog_plugin/subdir.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ rsyslog_plugin/%.o: rsyslog_plugin/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
$(CC) -D__FILENAME__="$(subst rsyslog_plugin/,,$<)" $(CFLAGS) -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$(@)" "$<"
@echo 'Finished building: $<
'@echo ' '
@echo 'Finished building: $<'
@echo ' '
2 changes: 1 addition & 1 deletion src/sonic-eventd/rsyslog_plugin/syslog_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <iostream>
#include "syslog_parser.h"
#include "common/logger.h"
#include "logger.h"

/**
* Parses syslog message and returns structured event
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-eventd/rsyslog_plugin/syslog_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <vector>
#include <string>
#include <regex>
#include "common/json.hpp"
#include "common/events.h"
#include "json.hpp"
#include "events.h"

using namespace std;
using json = nlohmann::json;
Expand Down
24 changes: 11 additions & 13 deletions src/sonic-eventd/tools/events_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,22 @@ do_receive(const event_subscribe_sources_t filter, const string outfile, int cnt
ASSERT(h != NULL, "Failed to get subscriber handle");

while(!term_receive) {
string key;
event_params_t params;
map_str_str_t evt;
int missed_cnt=-1;
event_receive_op_t evt;
map_str_str_t evtOp;

int rc = event_receive(h, key, params, missed_cnt);
if (rc != 0) {
ASSERT(rc == EAGAIN, "Failed to receive rc=%d index=%d\n",
rc, index);
evt = event_receive(h);
if (evt.rc != 0) {
ASSERT(evt.rc == EAGAIN, "Failed to receive rc=%d index=%d\n",
evt.rc, index);
continue;
}
ASSERT(!key.empty(), "received EMPTY key");
ASSERT(missed_cnt >= 0, "Missed count uninitialized");
ASSERT(!evt.key.empty(), "received EMPTY key");
ASSERT(evt.missed_cnt >= 0, "Missed count uninitialized");

total_missed += missed_cnt;
total_missed += evt.missed_cnt;

evt[key] = t_map_to_str(params);
(*fp) << t_map_to_str(evt) << "\n";
evtOp[evt.key] = t_map_to_str(evt.params);
(*fp) << t_map_to_str(evtOp) << "\n";
fp->flush();

if ((++index % PRINT_CHUNK_SZ) == 0) {
Expand Down

0 comments on commit 202589f

Please sign in to comment.