Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b2749e8
Local make customizations.
bhaveshdell Apr 21, 2025
da9452a
Support for event persistence in redis-db.
bhaveshdell Jan 24, 2024
9b8ba37
Updates
bhaveshdell Jan 26, 2024
fc89042
Updates including fix to eventdb in test enviroment.
bhaveshdell Jan 30, 2024
8d5afbd
Add sonic yang to model event and alarm table.
bhaveshdell Feb 1, 2024
a4316e5
Add event/alarm persistence related testscases
bhaveshdell Feb 21, 2024
c3a70dc
Remove file eventdb_ut.cpp.
bhaveshdell May 16, 2024
127531c
Updates to eventdb testsuite.
bhaveshdell May 17, 2024
a953667
Revert changes to existing eventd UT.
bhaveshdell May 20, 2024
021594e
Commit test related config files.
bhaveshdell May 20, 2024
ccb162c
wRevert "Local make customizations."
bhaveshdell Apr 21, 2025
a1788ae
Separate eventd and eventdb targets in the makefile.
bhaveshdell May 14, 2025
51c2d26
Address review comments.
bhaveshdell Sep 4, 2025
446efe7
Updates.
bhaveshdell Sep 15, 2025
0272ac6
Remove debug statements.
bhaveshdell Sep 16, 2025
f4b5e87
Add script to start eventdb.
bhaveshdell Sep 16, 2025
19ee70f
Handle specific exception while parsing json file.
bhaveshdell Nov 10, 2025
bfb3048
Add the new yangs to setup.py
bhaveshdell Nov 12, 2025
88a9919
Add the sonic-alarm.yang and sonic-event.yang as NON_CONF_YANG_FILES
bhaveshdell Nov 12, 2025
9d053ee
Address review comments.
bhaveshdell Nov 21, 2025
57afe9a
Resolve build errors.
bhaveshdell Apr 16, 2026
56fa563
fix: Fix review comments
bhaveshdell Apr 23, 2026
14a0b48
Add timeout to event receive blocking call.
bhaveshdell Apr 23, 2026
3737b10
Remove loading of eventdb on database start.
bhaveshdell Apr 24, 2026
c361874
Guard creation of EVENTDB with flag include_system_eventdb.
bhaveshdell Apr 24, 2026
0f2eb12
Pass include_system_eventd to runtime jinjanate rendering
bhaveshdell May 11, 2026
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
1 change: 1 addition & 0 deletions dockers/docker-database/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ FROM $BASE
{{ rsync_from_builder_stage() }}

ENV DEBIAN_FRONTEND=noninteractive
ENV INCLUDE_SYSTEM_EVENTD={{ include_system_eventd | default("n") }}
ENTRYPOINT ["/usr/local/bin/docker-database-init.sh"]
8 changes: 8 additions & 0 deletions dockers/docker-database/database_config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@
"separator": "|",
"instance" : "redis_bmp"
}
{% endif %}
{% if include_system_eventd is defined and include_system_eventd == "y" %}
,
"EVENT_DB" : {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some use cases, we just disable eventd.

  1. Will this feature work as expected if eventd disabled?
  2. Did you tested? Do you need adding a testcase?
  3. Do you need a standalone feature enablement/disablement flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This daemon listens to eventd and writes to DB.
In case eventd is shutdown, no events are logged in the DB.

@qiluo-msft qiluo-msft Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens when INCLUDE_EVENTD=n, does the EVENT_DB instance still get provisioned? Does eventdb_wrapper.sh still run?

Could you guard your new section by {% if INCLUDE_EVENTD == "y" %}?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

"id" : 19,
"separator": "|",
"instance" : "redis"
}
{% endif %}
},
"VERSION" : "1.0"
Expand Down
4 changes: 2 additions & 2 deletions dockers/docker-database/docker-database-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ if [ -f /etc/sonic/database_config$NAMESPACE_ID.json ]; then
cp /etc/sonic/database_config$NAMESPACE_ID.json $REDIS_DIR/sonic-db/database_config.json
else
if [ -f /etc/sonic/enable_multidb ]; then
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT jinjanate /usr/share/sonic/templates/multi_database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT include_system_eventd=$INCLUDE_SYSTEM_EVENTD jinjanate /usr/share/sonic/templates/multi_database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
else
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT jinjanate /usr/share/sonic/templates/database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT include_system_eventd=$INCLUDE_SYSTEM_EVENTD jinjanate /usr/share/sonic/templates/database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
fi
fi

Expand Down
1 change: 1 addition & 0 deletions dockers/docker-eventd/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["critical_processes", "/etc/supervisor"]
COPY ["*.json", "/etc/rsyslog.d/rsyslog_plugin_conf/"]
COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/rsyslog_plugin_conf/"]
COPY ["eventdb_wrapper.sh", "/usr/bin"]

RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/host_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/host_events.conf
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/bgp_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/bgp_events.conf
Expand Down
18 changes: 18 additions & 0 deletions dockers/docker-eventd/eventdb_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

JSON_FILE="/etc/evprofile/default.json"

# Check if file exists and is not empty
if [ -s "$JSON_FILE" ]; then
# Check if "events" is defined and has at least one entry
if jq -e '.events and (.events | length > 0)' "$JSON_FILE" > /dev/null; then
echo "Valid events found. Starting eventdb."
exec /usr/bin/eventdb
else
echo "'events' list is missing or empty. Skipping eventdb start."
exit 0
fi
else
echo "JSON file missing or empty. Skipping eventdb start."
exit 0
fi
13 changes: 13 additions & 0 deletions dockers/docker-eventd/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@ stderr_syslog=true
dependent_startup=true
dependent_startup_wait_for=start:exited

[program:eventdb]
command=/usr/bin/eventdb_wrapper.sh
priority=3
autostart=false
autorestart=false
startsecs=0
startretries=0
exitcodes=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited

34 changes: 29 additions & 5 deletions src/sonic-eventd/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
RM := rm -rf
EVENTD_TARGET := eventd
EVENTD_TEST := tests/tests
EVENTDB_TEST := tests/eventdb
EVENTD_TOOL := tools/events_tool
EVENTD_PUBLISH_TOOL := tools/events_publish_tool.py
RSYSLOG-PLUGIN_TARGET := rsyslog_plugin/rsyslog_plugin
RSYSLOG-PLUGIN_TEST := rsyslog_plugin_tests/tests
EVENTD_MONIT := tools/events_monit_test.py
EVENTD_MONIT_CONF := tools/monit_events
EVENTDB_TARGET := eventdb
EVENTDB_DEFAULT_PROFILE := var/evprofile/default.json
EVENTDB_PROF := etc/eventd.json

CP := cp
MKDIR := mkdir
CC := g++
LIBS := -lhiredis -lswsscommon -lzmq -lboost_serialization -llua5.1
TEST_LIBS := -L/usr/src/gtest -lgtest -lgtest_main -lgmock -lgmock_main
TEST_LIBS := -lgtest -lgtest_main -lgmock -lgmock_main

CFLAGS += -Wall -std=c++17 -fPIE
PWD := $(shell pwd)

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS) $(OBJS)
-include $(C_DEPS) $(OBJS) $(EVENTDB_OBJS)
endif
endif

Expand All @@ -29,9 +33,9 @@ endif
-include rsyslog_plugin/subdir.mk
-include rsyslog_plugin_tests/subdir.mk

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

test: eventd-tests rsyslog-plugin-tests
test: eventd-tests rsyslog-plugin-tests eventdb-tests

sonic-eventd: $(OBJS)
@echo 'Building target: $@'
Expand All @@ -40,6 +44,13 @@ sonic-eventd: $(OBJS)
@echo 'Finished building target: $@'
@echo ' '

sonic-eventdb: $(EVENTDB_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: G++ Linker'
$(CC) $(LDFLAGS) -o $(EVENTDB_TARGET) $(EVENTDB_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

eventd-tool: $(TOOL_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: G++ Linker'
Expand All @@ -63,6 +74,15 @@ eventd-tests: $(TEST_OBJS)
@echo 'Finished running tests'
@echo ' '

eventdb-tests: $(EVENTDB_TEST_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: G++ Linker'
$(CC) $(LDFLAGS) -o $(EVENTDB_TEST) $(EVENTDB_TEST_OBJS) $(LIBS) $(TEST_LIBS)
@echo 'Finished building target: $@'
$(EVENTDB_TEST)
@echo 'Finished running tests'
@echo ' '

rsyslog-plugin-tests: $(RSYSLOG-PLUGIN-TEST_OBJS)
@echo 'BUILDING target: $@'
@echo 'Invoking G++ Linker'
Expand All @@ -75,19 +95,23 @@ rsyslog-plugin-tests: $(RSYSLOG-PLUGIN-TEST_OBJS)
install:
$(MKDIR) -p $(DESTDIR)/usr/bin
$(MKDIR) -p $(DESTDIR)/etc/monit/conf.d
$(MKDIR) -p $(DESTDIR)/etc/evprofile
$(CP) $(EVENTD_TARGET) $(DESTDIR)/usr/bin
$(CP) $(EVENTD_TOOL) $(DESTDIR)/usr/bin
$(CP) $(EVENTD_PUBLISH_TOOL) $(DESTDIR)/usr/bin
$(CP) $(RSYSLOG-PLUGIN_TARGET) $(DESTDIR)/usr/bin
$(CP) $(EVENTD_MONIT) $(DESTDIR)/usr/bin
$(CP) $(EVENTD_MONIT_CONF) $(DESTDIR)/etc/monit/conf.d
$(CP) $(EVENTDB_TARGET) $(DESTDIR)/usr/bin
$(CP) $(EVENTDB_PROF) $(DESTDIR)/etc/eventd.json
$(CP) $(EVENTDB_DEFAULT_PROFILE) $(DESTDIR)/etc/evprofile/default.json

deinstall:
$(RM) -rf $(DESTDIR)/usr
$(RM) -rf $(DESTDIR)/etc

clean:
-$(RM) $(EVENTD_TARGET) $(OBJS) $(EVENTD_TOOL) $(TOOL_OBJS) $(RSYSLOG-PLUGIN_TARGET) $(RSYSLOG-PLUGIN_OBJS) $(EVENTD_TEST) $(TEST_OBJS) $(RSYSLOG-PLUGIN_TEST) $(RSYSLOG-PLUGIN-TEST_OBJS) $(C_DEPS)
-$(RM) $(EVENTD_TARGET) $(OBJS) $(EVENTD_TOOL) $(TOOL_OBJS) $(RSYSLOG-PLUGIN_TARGET) $(RSYSLOG-PLUGIN_OBJS) $(EVENTD_TEST) $(TEST_OBJS) $(EVENTDB_TEST) $(EVENTDB_TEST_OBJS) $(RSYSLOG-PLUGIN_TEST) $(RSYSLOG-PLUGIN-TEST_OBJS) $(C_DEPS)
-@echo ' '

.PHONY: all clean dependents
2 changes: 1 addition & 1 deletion src/sonic-eventd/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: sonic-eventd
Section: devel
Priority: optional
Maintainer: Renuka Manavalan <remanava@microsoft.com>
Build-Depends: debhelper (>= 12.0.0), libswsscommon-dev, liblua5.1-0, libzmq3-dev, libboost-serialization1.83-dev
Build-Depends: debhelper (>= 12.0.0), libswsscommon-dev, liblua5.1-0, libzmq3-dev, libboost-serialization1.83-dev, libgtest-dev, libgmock-dev
Standards-Version: 3.9.3
Homepage: https://github.com/Azure/sonic-buildimage
XS-Go-Import-Path: github.com/Azure/sonic-buildimage
Expand Down
3 changes: 3 additions & 0 deletions src/sonic-eventd/debian/sonic-eventd.install
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
usr/bin/eventd
usr/bin/eventdb
usr/bin/events_tool
usr/bin/events_publish_tool.py
etc/evprofile/default.json
etc/eventd.json
5 changes: 5 additions & 0 deletions src/sonic-eventd/etc/eventd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"__README__": "Specify size of event history table. Whichever limit is hit first, eventd wraps event history table around and deletes older records.",
"max-records": 40000,
"max-days": 30
}
Loading
Loading