diff --git a/device/molex/x86_64-otn-kvm_x86_64-r0/OLS-V/otn_config.json b/device/molex/x86_64-otn-kvm_x86_64-r0/OLS-V/otn_config.json index 6ee8a112747..9f98ba47352 100644 --- a/device/molex/x86_64-otn-kvm_x86_64-r0/OLS-V/otn_config.json +++ b/device/molex/x86_64-otn-kvm_x86_64-r0/OLS-V/otn_config.json @@ -16,6 +16,8 @@ "target-gain": "4.2", "target-gain-tilt": "0.4", "gain-range": "FIXED_GAIN_RANGE", + "min-gain": "3.00", + "max-gain": "20.00", "amp-mode": "CONSTANT_GAIN", "enabled": "true", "type": "EDFA" @@ -24,6 +26,8 @@ "target-gain": "5.2", "target-gain-tilt": "0.5", "gain-range": "FIXED_GAIN_RANGE", + "min-gain": "4.00", + "max-gain": "22.00", "amp-mode": "CONSTANT_GAIN", "enabled": "true", "type": "EDFA" diff --git a/device/molex/x86_64-otn-kvm_x86_64-r0/default.json b/device/molex/x86_64-otn-kvm_x86_64-r0/default.json new file mode 100644 index 00000000000..c24a1ae00e8 --- /dev/null +++ b/device/molex/x86_64-otn-kvm_x86_64-r0/default.json @@ -0,0 +1,23 @@ +{ + "__README__" : "This is default map of events that eventd uses. Developer can modify this file and send SIGINT to eventd to make it read and use the updated file. Alternatively developer can test the new event by adding it to a custom event profile and use 'event profile ' command to apply that profile without having to send SIGINT to eventd. Developer need to commit default.json file with the new event after testing it out. Supported severities are: CRITICAL, MAJOR, MINOR, WARNING and INFORMATIONAL. Supported enable flag values are: true and false.", + "events":[ + { + "name": "SYSTEM_STATE", + "severity": "INFORMATIONAL", + "enable": "true", + "message" : "" + }, + { + "name": "Invalid Target Gain", + "severity": "MINOR", + "enable": "true", + "message": "OTN Invalid Target Gain" + }, + { + "name": "Out of Gain Range", + "severity": "MINOR", + "enable": "true", + "message": "OTN Out of Gain Range" + } + ] +} diff --git a/dockers/docker-eventd/Dockerfile.j2 b/dockers/docker-eventd/Dockerfile.j2 index dc5eea381ae..141d6852da9 100644 --- a/dockers/docker-eventd/Dockerfile.j2 +++ b/dockers/docker-eventd/Dockerfile.j2 @@ -14,6 +14,11 @@ ENV IMAGE_VERSION=$image_version # Update apt's cache of available packages RUN apt-get update +# Order is important here: COPY must come before installing the Debian packages, +# otherwise the Debian package's eventdb_wrapper.sh will be overwritten. +COPY ["eventdb_wrapper.sh", "/usr/bin"] +RUN chmod +x /usr/bin/eventdb_wrapper.sh + {% if docker_eventd_debs.strip() -%} # Copy built Debian packages {{ copy_files("debs/", docker_eventd_debs.split(' '), "/debs/") }} @@ -36,13 +41,13 @@ COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] 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 RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/dhcp_relay_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/dhcp_relay_events.conf RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/swss_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/swss_events.conf RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/syncd_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/syncd_events.conf +RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/otn_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/otn_events.conf RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 @@ -51,5 +56,6 @@ RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/bgp_events_info.json RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/dhcp_relay_events_info.json RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/swss_events_info.json RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/syncd_events_info.json +RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/otn_events_info.json ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/dockers/docker-eventd/supervisord.conf b/dockers/docker-eventd/supervisord.conf index bd57f978c02..bc12e9c3c3d 100644 --- a/dockers/docker-eventd/supervisord.conf +++ b/dockers/docker-eventd/supervisord.conf @@ -52,7 +52,7 @@ dependent_startup_wait_for=start:exited [program:eventdb] command=/usr/bin/eventdb_wrapper.sh -priority=3 +priority=4 autostart=false autorestart=false startsecs=0 @@ -61,4 +61,4 @@ exitcodes=0 stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true -dependent_startup_wait_for=start:exited \ No newline at end of file +dependent_startup_wait_for=eventd:running \ No newline at end of file diff --git a/platform/otn-kvm/rules.mk b/platform/otn-kvm/rules.mk index e9c48d0183d..719e71a917d 100644 --- a/platform/otn-kvm/rules.mk +++ b/platform/otn-kvm/rules.mk @@ -6,6 +6,7 @@ include $(PLATFORM_PATH)/docker-syncd-otn-kvm.mk include $(PLATFORM_PATH)/platform-modules-otn-kvm.mk include $(PLATFORM_PATH)/sonic-version.mk include $(PLATFORM_PATH)/sonic-yanggen.mk +include $(PLATFORM_PATH)/sonic-eventd-otn-profile.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/onie.mk include $(PLATFORM_PATH)/kvm-image.mk @@ -18,3 +19,6 @@ $(SYNCD)_DEPENDS += $(OTN_KVM_LIBSAI_DEB) $(LIBSAIMETADATA_DEV) # Inject otn-kvm hal dependency library into pmon $(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(OTN_KVM_HALCLIENT_DEB) + +# Inject OTN event profile into docker-eventd (overwrites upstream default.json) +$(DOCKER_EVENTD)_DEPENDS += $(SONIC_EVENTD_OTN_PROFILE) diff --git a/platform/otn-kvm/sonic-eventd-otn-profile.mk b/platform/otn-kvm/sonic-eventd-otn-profile.mk new file mode 100644 index 00000000000..1463fad5411 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile.mk @@ -0,0 +1,7 @@ +SONIC_EVENTD_OTN_PROFILE_VERSION = 1.0.0 +export SONIC_EVENTD_OTN_PROFILE_VERSION + +SONIC_EVENTD_OTN_PROFILE = sonic-eventd-otn-profile_$(SONIC_EVENTD_OTN_PROFILE_VERSION)_all.deb +$(SONIC_EVENTD_OTN_PROFILE)_SRC_PATH = $(PLATFORM_PATH)/sonic-eventd-otn-profile + +SONIC_DPKG_DEBS += $(SONIC_EVENTD_OTN_PROFILE) diff --git a/platform/otn-kvm/sonic-eventd-otn-profile/debian/changelog b/platform/otn-kvm/sonic-eventd-otn-profile/debian/changelog new file mode 100644 index 00000000000..5d3b33440b9 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile/debian/changelog @@ -0,0 +1,6 @@ +sonic-eventd-otn-profile (1.0.0) unstable; urgency=low + + * Initial release + * OTN platform event profile for sonic-eventd + + -- SONiC Team Mon, 16 Mar 2026 00:00:00 +0000 diff --git a/platform/otn-kvm/sonic-eventd-otn-profile/debian/compat b/platform/otn-kvm/sonic-eventd-otn-profile/debian/compat new file mode 100644 index 00000000000..48082f72f08 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile/debian/compat @@ -0,0 +1 @@ +12 diff --git a/platform/otn-kvm/sonic-eventd-otn-profile/debian/control b/platform/otn-kvm/sonic-eventd-otn-profile/debian/control new file mode 100644 index 00000000000..5f0f867ba22 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile/debian/control @@ -0,0 +1,15 @@ +Source: sonic-eventd-otn-profile +Section: net +Priority: optional +Maintainer: SONiC Team +Build-Depends: debhelper (>= 12) +Standards-Version: 4.5.1 +Homepage: https://github.com/sonic-net/sonic-buildimage + +Package: sonic-eventd-otn-profile +Architecture: all +Depends: ${misc:Depends}, sonic-eventd +Description: OTN event profile for sonic-eventd + Provides /etc/evprofile/default.json with OTN alarm type-id entries. + Installed after sonic-eventd in docker-eventd; overwrites the upstream + minimal default to enable OTN alarm recording in EVENT_DB. diff --git a/platform/otn-kvm/sonic-eventd-otn-profile/debian/rules b/platform/otn-kvm/sonic-eventd-otn-profile/debian/rules new file mode 100755 index 00000000000..ac9cc52e299 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile/debian/rules @@ -0,0 +1,17 @@ +#!/usr/bin/make -f + +PACKAGE_NAME := sonic-eventd-otn-profile +DEST_BIN := debian/$(PACKAGE_NAME)/usr/bin +DEST_RSYSLOG := debian/$(PACKAGE_NAME)/etc/rsyslog.d/rsyslog_plugin_conf + +%: + dh $@ + +override_dh_auto_install: + mkdir -p $(DEST_BIN) + install -m 755 eventdb_wrapper.sh $(DEST_BIN)/eventdb_wrapper.sh + mkdir -p $(DEST_RSYSLOG) + install -m 644 otn_events_info.json $(DEST_RSYSLOG)/otn_events_info.json + install -m 644 otn_regex.json $(DEST_RSYSLOG)/otn_regex.json + +override_dh_usrlocal: diff --git a/platform/otn-kvm/sonic-eventd-otn-profile/eventdb_wrapper.sh b/platform/otn-kvm/sonic-eventd-otn-profile/eventdb_wrapper.sh new file mode 100644 index 00000000000..aec3f9d4156 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile/eventdb_wrapper.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +PLATFORM_PROFILE="/usr/share/sonic/platform/default.json" +JSON_FILE="/etc/evprofile/default.json" + +# Copy platform-specific event profile if present +if [ -f "$PLATFORM_PROFILE" ]; then + cp "$PLATFORM_PROFILE" "$JSON_FILE" +fi + +# 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 diff --git a/platform/otn-kvm/sonic-eventd-otn-profile/otn_events_info.json b/platform/otn-kvm/sonic-eventd-otn-profile/otn_events_info.json new file mode 100644 index 00000000000..e8d40d3d710 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile/otn_events_info.json @@ -0,0 +1,9 @@ +{ + "yang_module": "sonic-events-otn", + "proclist": [ + { + "name": "orchagent", + "parse_json": "otn_regex.json" + } + ] +} diff --git a/platform/otn-kvm/sonic-eventd-otn-profile/otn_regex.json b/platform/otn-kvm/sonic-eventd-otn-profile/otn_regex.json new file mode 100644 index 00000000000..7ea9bf16365 --- /dev/null +++ b/platform/otn-kvm/sonic-eventd-otn-profile/otn_regex.json @@ -0,0 +1,12 @@ +[ + { + "tag": "otn-alarm", + "regex": ".*, (CRITICAL|MAJOR|MINOR|WARNING|INFORMATIONAL), (\\S+), ([^,]+), (.+), (RAISE|CLEAR)", + "params": [ "severity", "resource", "type-id", "text", "action" ] + }, + { + "tag": "otn-event", + "regex": ".*, (CRITICAL|MAJOR|MINOR|WARNING|INFORMATIONAL), (\\S+), ([^,]+), (.+)", + "params": [ "severity", "resource", "type-id", "text" ] + } +] diff --git a/platform/otn-kvm/sonic-yanggen/yang_auto_cli.sh b/platform/otn-kvm/sonic-yanggen/yang_auto_cli.sh index 9ab88860f09..acc402cd4cd 100755 --- a/platform/otn-kvm/sonic-yanggen/yang_auto_cli.sh +++ b/platform/otn-kvm/sonic-yanggen/yang_auto_cli.sh @@ -118,6 +118,9 @@ shopt -s nullglob # load sonic default system sonic yang-models sonic-cli-gen generate config sonic-syslog sonic-cli-gen generate show sonic-syslog +# This should be done by system CLI generator. Temporary solution. +sonic-cli-gen generate show sonic-event +# onic-cli-gen generate show sonic-alarm for src_file in "$SOURCE_DIR"/*.yang; do yang_basename="$(basename "$src_file" .yang)" diff --git a/src/sonic-eventd/tests/eventd_ut.cpp b/src/sonic-eventd/tests/eventd_ut.cpp index 6c2ddb11604..c51926e6b19 100644 --- a/src/sonic-eventd/tests/eventd_ut.cpp +++ b/src/sonic-eventd/tests/eventd_ut.cpp @@ -716,7 +716,7 @@ TEST(eventd, service) void wait_for_heartbeat(stats_collector &stats_instance, long unsigned int cnt, - int wait_ms = 3000) + int wait_ms = 10000) { int diff = 0; @@ -785,7 +785,7 @@ TEST(eventd, heartbeat) stats_instance.heartbeat_ctrl(); /* Wait for heartbeat count to change from last count */ - wait_for_heartbeat(stats_instance, cnt, 2000); + wait_for_heartbeat(stats_instance, cnt, 10000); stats_instance.stop(); diff --git a/src/sonic-swss b/src/sonic-swss index 6565935de6a..89aa9383710 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 6565935de6a046ebcb104fed52309193fb824735 +Subproject commit 89aa93837105acec975bd25c6ca39cc814cf2ccc diff --git a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py index 86b27ef174e..78c3d3f5fcf 100644 --- a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py +++ b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py @@ -297,7 +297,7 @@ def test_validate_yang_models(self, sonic_yang_data): # it right now. # event YANG models do not map directly to config_db and are included to NON_CONFIG_YANG_FILES at run time # If any more such helper yang files are added, we need to update here. - EVENT_YANG_FILES = sum(1 for yang_model in syc.yangFiles if 'sonic-events' in yang_model) + EVENT_YANG_FILES = sum(1 for yang_model in syc.yangFiles if 'sonic-event' in yang_model or 'sonic-alarm' in yang_model) NON_CONFIG_YANG_FILES = 3 + EVENT_YANG_FILES # read config jIn = self.readIjsonInput(test_file, 'SAMPLE_CONFIG_DB_JSON') diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index c6f7d92b77d..ec4659fa500 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -210,7 +210,9 @@ def run(self): './yang-models/sonic-xcvrd-log.yang', './yang-models/sonic-grpcclient.yang', './yang-models/sonic-serial-console.yang', - './yang-models/sonic-smart-switch.yang',]), + './yang-models/sonic-smart-switch.yang', + './yang-models/sonic-alarm.yang', + './yang-models/sonic-event.yang',]), ('cvlyang-models', ['./cvlyang-models/sonic-acl.yang', './cvlyang-models/sonic-banner.yang', './cvlyang-models/sonic-bgp-common.yang', diff --git a/src/sonic-yang-models/yang-models/sonic-event.yang b/src/sonic-yang-models/yang-models/sonic-event.yang index a7c4dd23743..faf0381b9bb 100644 --- a/src/sonic-yang-models/yang-models/sonic-event.yang +++ b/src/sonic-yang-models/yang-models/sonic-event.yang @@ -3,6 +3,10 @@ prefix sevents; yang-version 1.1; + import sonic-extension { + prefix sonic-ext; + } + organization "SONiC"; @@ -84,6 +88,7 @@ container sonic-event { container EVENT { + sonic-ext:db-name "EVENT_DB"; list EVENT_LIST { key "id"; @@ -92,7 +97,7 @@ } container EVENT_STATS { - + sonic-ext:db-name "EVENT_DB"; list EVENT_STATS_LIST {