Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes #5

Merged
merged 3 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion files/build_templates/eventd.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ ExecStop=/usr/bin/{{docker_container_name}}.sh stop
RestartSec=30

[Install]
WantedBy=sonic.target
WantedBy=multi-user.target
1 change: 0 additions & 1 deletion rules/docker-config-engine-bullseye.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ $(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY3)
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_LOAD_DOCKERS += $(DOCKER_BASE_BULLSEYE)
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $(SWSS_VARS_TEMPLATE)
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $(RSYSLOG_PLUGIN_CONF_J2)
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $($(DOCKER_EVENTD)_PLUGIN)
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $($(SONIC_CTRMGRD)_CONTAINER_SCRIPT)

$(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS = $($(DOCKER_BASE_BULLSEYE)_DBG_DEPENDS) \
Expand Down
1 change: 1 addition & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_YANG_MODELS_PY3)) \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CTRMGRD)) \
$(addprefix $(FILES_PATH)/,$($(SONIC_CTRMGRD)_FILES)) \
$(addprefix $(FILES_PATH)/,$($(DOCKER_EVENTD)_PLUGIN)) \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_YANG_MGMT_PY3)) \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SYSTEM_HEALTH)) \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_HOST_SERVICES_PY3))
Expand Down
6 changes: 3 additions & 3 deletions src/sonic-eventd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RSYSLOG-PLUGIN_TEST := rsyslog_plugin_tests/tests
CP := cp
MKDIR := mkdir
CC := g++
MV := mv
CP := cp
LIBS := -levent -lhiredis -lswsscommon -lpthread -lboost_thread -lboost_system -lzmq -lboost_serialization -luuid
TEST_LIBS := -L/usr/src/gtest -lgtest -lgtest_main -lgmock -lgmock_main

Expand Down Expand Up @@ -69,8 +69,8 @@ rsyslog-plugin-tests: $(RSYSLOG-PLUGIN-TEST_OBJS)

install:
$(MKDIR) -p $(DESTDIR)/usr/sbin
$(MV) $(EVENTD_TARGET) $(DESTDIR)/usr/sbin
$(MV) $(EVENTD_TOOL) $(DESTDIR)/usr/sbin
$(CP) $(EVENTD_TARGET) $(DESTDIR)/usr/sbin
$(CP) $(EVENTD_TOOL) $(DESTDIR)/usr/sbin

deinstall:
$(RM) $(DESTDIR)/usr/sbin/$(EVENTD_TARGET)
Expand Down
7 changes: 7 additions & 0 deletions src/sonic-eventd/src/eventd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ capture_service::do_capture()

switch(cap_state) {
case CAP_STATE_INIT:
/*
* In this state check against cache, if duplicate
* When duplicate or new one seen, remove the entry from pre-exist map
* Stay in this state, until the pre-exist cache is empty or as many
* messages as in cache are seen, as in worst case even if you see
* duplicate of each, it will end with first m_events.size()
*/
{
bool add = true;
init_cnt--;
Expand Down
22 changes: 13 additions & 9 deletions src/sonic-eventd/tools/events_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Note:\n\
]\n\
Default: <some test message>\n\
\n\
-c - Use offline cache in receive mode\n\
-o - O/p file to write received events\n\
Default: STDOUT\n";

Expand All @@ -86,7 +87,7 @@ t_map_to_str(const Map &m)
}

void
do_receive(const event_subscribe_sources_t filter, const string outfile, int cnt=0, int pause=0)
do_receive(const event_subscribe_sources_t filter, const string outfile, int cnt, int pause, bool use_cache)
{
int index=0, total_missed = 0;
ostream* fp = &cout;
Expand All @@ -99,7 +100,9 @@ do_receive(const event_subscribe_sources_t filter, const string outfile, int cnt
printf("outfile=%s set\n", outfile.c_str());
}
}
event_handle_t h = events_init_subscriber(false, 100, filter.empty() ? NULL : &filter);
event_handle_t h = events_init_subscriber(use_cache, 2000, filter.empty() ? NULL : &filter);
printf("Subscribed with use_cache=%d timeout=2000 filter %s\n",
use_cache, filter.empty() ? "empty" : "non-empty");
ASSERT(h != NULL, "Failed to get subscriber handle");

while(!term_receive) {
Expand Down Expand Up @@ -130,10 +133,6 @@ do_receive(const event_subscribe_sources_t filter, const string outfile, int cnt
break;
}
}
if (pause) {
/* Pause between two sends */
this_thread::sleep_for(chrono::milliseconds(pause));
}
}

events_deinit_subscriber(h);
Expand Down Expand Up @@ -277,15 +276,20 @@ void usage()

int main(int argc, char **argv)
{
bool use_cache = false;
int op = OP_INIT;
int cnt=0, pause=0;
string json_str_msg, outfile("STDOUT"), infile;
event_subscribe_sources_t filter;

for(;;)
{
switch(getopt(argc, argv, "srn:p:i:o:f:")) // note the colon (:) to indicate that 'b' has a parameter and is not a switch
switch(getopt(argc, argv, "srn:p:i:o:f:c")) // note the colon (:) to indicate that 'b' has a parameter and is not a switch
{
case 'c':
use_cache = true;
continue;

case 's':
op |= OP_SEND;
continue;
Expand Down Expand Up @@ -339,14 +343,14 @@ int main(int argc, char **argv)
op, cnt, pause, infile.c_str(), outfile.c_str());

if (op == OP_SEND_RECV) {
thread thr(&do_receive, filter, outfile, 0, 0);
thread thr(&do_receive, filter, outfile, 0, 0, use_cache);
do_send(infile, cnt, pause);
}
else if (op == OP_SEND) {
do_send(infile, cnt, pause);
}
else if (op == OP_RECV) {
do_receive(filter, outfile, cnt, pause);
do_receive(filter, outfile, cnt, pause, use_cache);
}
else {
ASSERT(false, "Elect -s for send or -r receive or both; Bailing out with no action\n");
Expand Down