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

Streaming structured events implementation #10801

Closed
Closed
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
9c2478b
First cut of few events' definitons
renukamanavalan May 10, 2022
4bba076
first cut
renukamanavalan May 18, 2022
ff78343
First run code complete
renukamanavalan May 19, 2022
52a8a14
upon self code read
renukamanavalan May 20, 2022
30c5108
update
renukamanavalan May 26, 2022
b95e5d9
Added severity
renukamanavalan May 26, 2022
e1b6f47
added severity
renukamanavalan May 26, 2022
bb842ad
Sev update
renukamanavalan May 26, 2022
acffaa1
First cut
renukamanavalan Jun 2, 2022
ba48440
first cut
renukamanavalan Jun 4, 2022
99fa2c3
Trying to build
renukamanavalan Jun 6, 2022
bfa0b2c
updates per review
renukamanavalan Jun 7, 2022
c903f02
build in progress
renukamanavalan Jun 7, 2022
091ced5
per comments
renukamanavalan Jun 7, 2022
78e5176
test code written
renukamanavalan Jun 8, 2022
c6dad25
Adding test code
renukamanavalan Jun 9, 2022
b854f07
cap added in pub
renukamanavalan Jun 9, 2022
ef1325a
Added one moe test
renukamanavalan Jun 9, 2022
338766b
test is complete
renukamanavalan Jun 9, 2022
0f64cc8
add UT to make
renukamanavalan Jun 9, 2022
5fe6502
Adding required script & services
renukamanavalan Jun 11, 2022
1fd68a9
Added service file
renukamanavalan Jun 13, 2022
9f9027b
Add eventd as feature
renukamanavalan Jun 13, 2022
d5b9562
service starts fine; tool ready to test send/receive
renukamanavalan Jun 14, 2022
abd6eb5
Add tool to Debian pkg
renukamanavalan Jun 14, 2022
999a175
Add rsyslog plugin and tests
Jun 14, 2022
3082cf8
Add syslog if init fails
Jun 14, 2022
ee28577
Fix onInit logic
Jun 14, 2022
dc691a1
enable unit test run in Makefile
renukamanavalan Jun 14, 2022
f4a0c82
Added graceful restart
renukamanavalan Jun 14, 2022
dbcc4df
added comments
renukamanavalan Jun 14, 2022
f66beac
tool print is updated as not to truncate
renukamanavalan Jun 14, 2022
7cb88d7
Add makefile and resolve PR comments
Jun 15, 2022
b92bb29
Remove redundant headers, etc
Jun 15, 2022
4468e11
Add logic for empty regex expressions
Jun 15, 2022
c57de23
removed restart, as that does not address graceful restart
renukamanavalan Jun 15, 2022
0eec661
Remove redundant syslog messages
Jun 16, 2022
15969a7
name change; test update
renukamanavalan Jun 17, 2022
fcc00ef
Merge remote-tracking branch 'origin/syslog_telemetry_shared' into re…
renukamanavalan Jun 17, 2022
fea1de6
Comments added for i/p file format
renukamanavalan Jun 17, 2022
5916a5a
Resolve PR comments
Jun 20, 2022
ec671c0
No logical chenges; little re-order
renukamanavalan Jun 20, 2022
ae60e1b
per review comments; No logical code change
renukamanavalan Jun 21, 2022
9393101
leafref added per review comments
renukamanavalan Jun 21, 2022
acfd64c
per review comments; No logical code changes
renukamanavalan Jun 21, 2022
1700020
Merge pull request #1 from renukamanavalan/remanava_events
renukamanavalan Jun 22, 2022
b80b884
Merge branch 'zbud-msft' into syslog_telemetry_shared
zbud-msft Jun 27, 2022
8a4c593
Added LIBSWSSCOMMON in DEPENDS
renukamanavalan Jul 5, 2022
3646069
Merge branch 'syslog_telemetry_shared' of https://github.com/renukama…
renukamanavalan Jul 5, 2022
8c03eb5
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Jul 5, 2022
6f9255a
Merge remote-tracking branch 'origin/syslog_telemetry_shared' into re…
renukamanavalan Jul 5, 2022
266c161
removed unused eventd.sh
renukamanavalan Jul 8, 2022
202589f
fix compile errors in rsyslog; adapt to an API change in tools
renukamanavalan Jul 8, 2022
b75607b
first cut: Integrating with BGP container
renukamanavalan Jul 10, 2022
a5f45b8
add docker mountpath
renukamanavalan Jul 11, 2022
9423d0d
minor update per discussion
renukamanavalan Jul 11, 2022
e5be04f
corrected per YANG schema
renukamanavalan Jul 11, 2022
076a6ac
Merge pull request #3 from renukamanavalan/remanava_events
renukamanavalan Jul 12, 2022
13a7f47
Enabled cacheing to kick off right upon startup
renukamanavalan Jul 13, 2022
91d7633
Added comments
renukamanavalan Jul 13, 2022
65f42ed
Merge pull request #4 from renukamanavalan/remanava_events
renukamanavalan Jul 14, 2022
4818259
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Jul 14, 2022
dec3bc5
Yang models are removed as they are being handled separately by Zain
renukamanavalan Jul 14, 2022
2e1d8f9
Updated target; Added plugin dependency to image
renukamanavalan Jul 15, 2022
f10f25b
Merge remote-tracking branch 'origin/syslog_telemetry_shared' into re…
renukamanavalan Jul 15, 2022
b6484c2
tool update
renukamanavalan Jul 15, 2022
33eba65
Merge pull request #5 from renukamanavalan/remanava_events
renukamanavalan Jul 15, 2022
30b9ea1
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Jul 20, 2022
13b8271
Add lua code and formatter for rsyslog plugin
Jul 20, 2022
ae8fb4a
Merge branch 'syslog_telemetry_shared' into lua_support
zbud-msft Jul 20, 2022
540af0f
Remove unneccessary lines
Jul 21, 2022
f114b91
Merge branch 'lua_support' of github.com:renukamanavalan/sonic-buildi…
Jul 21, 2022
8d8103e
Updates per review comments; No logical code changes
renukamanavalan Jul 21, 2022
b8300f3
Add changes from review
Jul 22, 2022
7c4c78d
Remove print statement
Jul 22, 2022
52e1590
Add peer review changes
Jul 22, 2022
3e9a073
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Jul 29, 2022
b8e0b3d
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 2, 2022
f8d066d
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 3, 2022
8f115d3
Merge pull request #6 from renukamanavalan/lua_support
zbud-msft Aug 4, 2022
a679910
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 6, 2022
654a3bd
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 8, 2022
071eb58
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 11, 2022
e8cc328
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 17, 2022
5605b20
stats & options update
renukamanavalan Aug 17, 2022
edfde1e
Add python tool to publish events for testing (#7)
zbud-msft Aug 17, 2022
ce3bcd8
Merge pull request #9 from renukamanavalan/remanava_final
renukamanavalan Aug 18, 2022
4743ca0
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 18, 2022
2059906
Add volume test (#10)
zbud-msft Aug 25, 2022
81485f7
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Aug 25, 2022
b6cf34b
Merge branch 'syslog_telemetry_shared' of https://github.com/renukama…
renukamanavalan Aug 25, 2022
2d09ad4
Fix pr comments (#11)
zbud-msft Aug 25, 2022
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
36 changes: 36 additions & 0 deletions dockers/docker-eventd/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

ARG docker_container_name
ARG image_version
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf

# Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive

# Pass the image_version to container
ENV IMAGE_VERSION=$image_version

# Update apt's cache of available packages
RUN apt-get update

{% if docker_eventd_debs.strip() -%}
# Copy built Debian packages
{{ copy_files("debs/", docker_eventd_debs.split(' '), "/debs/") }}

# Install built Debian packages and implicitly install their dependencies
{{ install_debian_packages(docker_eventd_debs.split(' ')) }}
{%- endif %}

# Clean up
RUN apt-get clean -y && \
apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /debs

COPY ["start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]

ENTRYPOINT ["/usr/local/bin/supervisord"]
1 change: 1 addition & 0 deletions dockers/docker-eventd/critical_processes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
program:eventd
6 changes: 6 additions & 0 deletions dockers/docker-eventd/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

if [ "${RUNTIME_OWNER}" == "" ]; then
RUNTIME_OWNER="kube"
fi

52 changes: 52 additions & 0 deletions dockers/docker-eventd/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[supervisord]
logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:dependent-startup]
command=python3 -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE
buffer_size=1024

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name eventd
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING
autostart=true
autorestart=unexpected
buffer_size=1024

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=unexpected
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:start]
command=/usr/bin/start.sh
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running


[program:eventd]
command=/usr/sbin/eventd
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited

17 changes: 17 additions & 0 deletions files/build_templates/eventd.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=EVENTD container
Requires=updategraph.service
After=updategraph.service
BindsTo=sonic.target
After=sonic.target
StartLimitIntervalSec=1200
StartLimitBurst=3

[Service]
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
RestartSec=30

[Install]
WantedBy=sonic.target
3 changes: 2 additions & 1 deletion files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
("pmon", "enabled", false, "enabled"),
("radv", "enabled", false, "enabled"),
("snmp", "enabled", true, "enabled"),
("eventd", "enabled", true, "enabled"),
("swss", "enabled", false, "enabled"),
("syncd", "enabled", false, "enabled"),
("teamd", "enabled", false, "enabled")] %}
Expand All @@ -58,7 +59,7 @@
"has_per_asic_scope": {% if feature + '@.service' in installer_services.split(' ') %}true{% else %}false{% endif %},
"auto_restart": "{{autorestart}}",
{%- if include_kubernetes == "y" %}
{%- if feature in ["lldp", "pmon", "radv", "snmp", "telemetry"] %}
{%- if feature in ["lldp", "pmon", "radv", "eventd", "snmp", "telemetry"] %}
"set_owner": "kube", {% else %}
"set_owner": "local", {% endif %} {% endif %}
"high_mem_alert": "disabled"
Expand Down
1 change: 1 addition & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ sudo LANG=C cp $SCRIPTS_DIR/bgp.sh $FILESYSTEM_ROOT/usr/local/bin/bgp.sh
sudo LANG=C cp $SCRIPTS_DIR/teamd.sh $FILESYSTEM_ROOT/usr/local/bin/teamd.sh
sudo LANG=C cp $SCRIPTS_DIR/lldp.sh $FILESYSTEM_ROOT/usr/local/bin/lldp.sh
sudo LANG=C cp $SCRIPTS_DIR/radv.sh $FILESYSTEM_ROOT/usr/local/bin/radv.sh
sudo LANG=C cp $SCRIPTS_DIR/eventd.sh $FILESYSTEM_ROOT/usr/local/bin/eventd.sh
sudo LANG=C cp $SCRIPTS_DIR/asic_status.sh $FILESYSTEM_ROOT/usr/local/bin/asic_status.sh
sudo LANG=C cp $SCRIPTS_DIR/asic_status.py $FILESYSTEM_ROOT/usr/local/bin/asic_status.py

Expand Down
11 changes: 11 additions & 0 deletions rules/docker-eventd.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

DPATH := $($(DOCKER_EVENTD)_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-eventd.mk rules/docker-eventd.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(DPATH))

$(DOCKER_EVENTD)_CACHE_MODE := GIT_CONTENT_SHA
$(DOCKER_EVENTD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(DOCKER_EVENTD)_DEP_FILES := $(DEP_FILES)

$(eval $(call add_dbg_docker,$(DOCKER_EVENTD),$(DOCKER_EVENTD_DBG)))
38 changes: 38 additions & 0 deletions rules/docker-eventd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# docker image for eventd

DOCKER_EVENTD_STEM = docker-eventd
DOCKER_EVENTD = $(DOCKER_EVENTD_STEM).gz
DOCKER_EVENTD_DBG = $(DOCKER_EVENTD_STEM)-$(DBG_IMAGE_MARK).gz

$(DOCKER_EVENTD)_DEPENDS += $(SONIC_EVENTD)

$(DOCKER_EVENTD)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS)
$(DOCKER_EVENTD)_DBG_DEPENDS += $(SONIC_EVENTD_DBG) $(LIBSWSSCOMMON_DBG)

$(DOCKER_EVENTD)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES)

$(DOCKER_EVENTD)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BULLSEYE)

$(DOCKER_EVENTD)_PATH = $(DOCKERS_PATH)/$(DOCKER_EVENTD_STEM)

$(DOCKER_EVENTD)_INSTALL_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3)
$(DOCKER_EVENTD)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON)

$(DOCKER_EVENTD)_VERSION = 1.0.0
$(DOCKER_EVENTD)_PACKAGE_NAME = eventd

$(DOCKER_DHCP)_SERVICE_REQUIRES = updategraph
$(DOCKER_DHCP)_SERVICE_AFTER = database

SONIC_DOCKER_IMAGES += $(DOCKER_EVENTD)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_EVENTD)

SONIC_DOCKER_DBG_IMAGES += $(DOCKER_EVENTD_DBG)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_EVENTD_DBG)

$(DOCKER_EVENTD)_CONTAINER_NAME = eventd
$(DOCKER_EVENTD)_RUN_OPT += --privileged -t
$(DOCKER_EVENTD)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro

SONIC_BULLSEYE_DOCKERS += $(DOCKER_EVENTD)
SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_EVENTD_DBG)
10 changes: 10 additions & 0 deletions rules/eventd.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

SPATH := $($(SONIC_EVENTD)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/eventd.mk rules/eventd.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files))

$(SONIC_EVENTD)_CACHE_MODE := GIT_CONTENT_SHA
$(SONIC_EVENTD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(SONIC_EVENTD)_DEP_FILES := $(DEP_FILES)

19 changes: 19 additions & 0 deletions rules/eventd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# eventd package

SONIC_EVENTD_VERSION = 1.0.0-0
SONIC_EVENTD_PKG_NAME = eventd

SONIC_EVENTD = sonic-$(SONIC_EVENTD_PKG_NAME)_$(SONIC_EVENTD_VERSION)_$(CONFIGURED_ARCH).deb
$(SONIC_EVENTD)_SRC_PATH = $(SRC_PATH)/sonic-eventd
$(SONIC_EVENTD)_DEPENDS += $(LIBSWSSCOMMON) $(LIBSWSSCOMMON_DEV)

SONIC_DPKG_DEBS += $(SONIC_EVENTD)

SONIC_EVENTD_DBG = sonic-$(SONIC_EVENTD_PKG_NAME)-dbgsym_$(SONIC_EVENTD_VERSION)_$(CONFIGURED_ARCH).deb
$(eval $(call add_derived_package,$(SONIC_EVENTD),$(SONIC_EVENTD_DBG)))

# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list}
# are archived into debug one image to facilitate debugging.
#
DBG_SRC_ARCHIVE += sonic-eventd

83 changes: 83 additions & 0 deletions src/sonic-eventd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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
CP := cp
MKDIR := mkdir
CC := g++
MV := mv
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

CFLAGS += -Wall -std=c++17 -fPIE -I$(PWD)/../sonic-swss-common/common
PWD := $(shell pwd)

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

-include src/subdir.mk
-include tests/subdir.mk
-include tools/subdir.mk
-include rsyslog_plugin/subdir.mk
-include rsyslog_plugin_tests/subdir.mk

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

sonic-eventd: $(OBJS)
@echo 'Building target: $@'
@echo 'Invoking: G++ Linker'
$(CC) $(LDFLAGS) -o $(EVENTD_TARGET) $(OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

eventd-tool: $(TOOL_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: G++ Linker'
$(CC) $(LDFLAGS) -o $(EVENTD_TOOL) $(TOOL_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

rsyslog-plugin: $(RSYSLOG-PLUGIN_OBJS)
@echo 'Buidling Target: $@'
@echo 'Invoking: G++ Linker'
$(CC) $(LDFLAGS) -o $(RSYSLOG-PLUGIN_TARGET) $(RSYSLOG-PLUGIN_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

eventd-tests: $(TEST_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: G++ Linker'
$(CC) $(LDFLAGS) -o $(EVENTD_TEST) $(TEST_OBJS) $(LIBS) $(TEST_LIBS)
@echo 'Finished building target: $@'
$(EVENTD_TEST)
@echo 'Finished running tests'
@echo ' '

rsyslog-plugin-tests: $(RSYSLOG-PLUGIN-TEST_OBJS)
@echo 'BUILDING target: $@'
@echo 'Invoking G++ Linker'
$(CC) $(LDFLAGS) -o $(RSYSLOG-PLUGIN_TEST) $(RSYSLOG-PLUGIN-TEST_OBJS) $(LIBS) $(TEST_LIBS)
@echo 'Finished building target: $@'
$(RSYSLOG-PLUGIN_TEST)
@echo 'Finished running tests'
@echo ' '

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

deinstall:
$(RM) $(DESTDIR)/usr/sbin/$(EVENTD_TARGET)
$(RM) $(DESTDIR)/usr/sbin/$(RSYSLOG-PLUGIN_TARGET)
$(RM) -rf $(DESTDIR)/usr/sbin

clean:
-@echo ' '

.PHONY: all clean dependents
5 changes: 5 additions & 0 deletions src/sonic-eventd/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonic-eventd (1.0.0-0) UNRELEASED; urgency=medium

* Initial release.

-- Renuka Manavalan <remanava@microsoft.com>
1 change: 1 addition & 0 deletions src/sonic-eventd/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
14 changes: 14 additions & 0 deletions src/sonic-eventd/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Source: sonic-eventd
Section: devel
Priority: optional
Maintainer: Renuka Manavalan <remanava@microsoft.com>
Build-Depends: debhelper (>= 12.0.0), libevent-dev, libboost-thread-dev, libboost-system-dev, libswsscommon-dev
Standards-Version: 3.9.3
Homepage: https://github.com/Azure/sonic-buildimage
XS-Go-Import-Path: github.com/Azure/sonic-buildimage

Package: sonic-eventd
Architecture: any
Built-Using: ${misc:Built-Using}
Depends: ${shlibs:Depends}
Description: SONiC event service
6 changes: 6 additions & 0 deletions src/sonic-eventd/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
dh $@ --parallel
57 changes: 57 additions & 0 deletions src/sonic-eventd/rsyslog_plugin/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <iostream>
#include <memory>
#include <unistd.h>
#include "rsyslog_plugin.h"

#define SUCCESS_CODE 0
#define INVALID_REGEX_ERROR_CODE 1
#define EVENT_INIT_PUBLISH_ERROR_CODE 2
#define MISSING_ARGS_ERROR_CODE 3

void showUsage() {
cout << "Usage for rsyslog_plugin: \n" << "options\n"
<< "\t-r,required,type=string\t\tPath to regex file\n"
<< "\t-m,required,type=string\t\tYANG module name of source generating syslog message\n"
<< "\t-h \t\tHelp"
<< endl;
}

int main(int argc, char** argv) {
string regexPath;
string moduleName;
int optionVal;

while((optionVal = getopt(argc, argv, "r:m:h")) != -1) {
switch(optionVal) {
case 'r':
regexPath = optarg;
break;
case 'm':
moduleName = optarg;
break;
case 'h':
case '?':
default:
showUsage();
return 1;
}
}

if(regexPath.empty() || moduleName.empty()) { // Missing required rc path
cerr << "Error: Missing regexPath and moduleName." << endl;
return MISSING_ARGS_ERROR_CODE;
}

unique_ptr<RsyslogPlugin> plugin(new RsyslogPlugin(moduleName, regexPath));
int returnCode = plugin->onInit();
if(returnCode == INVALID_REGEX_ERROR_CODE) {
SWSS_LOG_ERROR("Rsyslog plugin was not able to be initialized due to invalid regex file provided.\n");
return returnCode;
} else if(returnCode == EVENT_INIT_PUBLISH_ERROR_CODE) {
SWSS_LOG_ERROR("Rsyslog plugin was not able to be initialized due to event_init_publish call failing.\n");
return returnCode;
}

plugin->run();
return SUCCESS_CODE;
}
Loading