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

Add Structured Events w/ YANG Models #12270

Merged
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
017b9b5
Test covers from event_publish to event_receive
renukamanavalan Sep 6, 2022
8fa7cc7
Build a rsyslog debian pkg
renukamanavalan Sep 6, 2022
3011a32
Added monit code to be invoked by monit periodically
renukamanavalan Sep 8, 2022
703e96f
Merge branch 'sonic-net:master' into syslog_telemetry_shared
zbud-msft Sep 8, 2022
666e0ae
Merge remote-tracking branch 'origin/syslog_telemetry_shared' into re…
renukamanavalan Sep 8, 2022
ce83a9a
Merge pull request #15 from renukamanavalan/remanava_final
renukamanavalan Sep 8, 2022
423446e
Add plugin bgp host (#16)
zbud-msft Sep 9, 2022
bcc5421
fixed a bug in monit conf file (#19)
renukamanavalan Sep 12, 2022
171a1f9
Added event for container_checker (#20)
renukamanavalan Sep 12, 2022
42d718c
Add Structured events yang models (#21)
zbud-msft Sep 12, 2022
bd051e5
Add conf to host, move plugin to sbin (#18)
zbud-msft Sep 13, 2022
b74b2a1
Schema update (#22)
renukamanavalan Sep 13, 2022
90a640e
Revert "Schema update (#22)" (#23)
zbud-msft Sep 13, 2022
f782f42
Revert "Add Structured events yang models (#21)" (#24)
zbud-msft Sep 13, 2022
ca7c0bb
Merge branch 'sonic-net:master' into syslog_telemetry_shared
zbud-msft Sep 13, 2022
d65e511
Change log level (#25)
zbud-msft Sep 14, 2022
2cd2385
Move event_publish_tool to sbin (#26)
zbud-msft Sep 16, 2022
78ac446
Add events to host (#27)
zbud-msft Sep 16, 2022
e773a0e
Fix LGTM (#28)
zbud-msft Sep 16, 2022
2b30fc4
Add systemd event (#29)
zbud-msft Sep 16, 2022
e4c97be
Add events to host (#30)
zbud-msft Sep 16, 2022
929fa81
Add events to host (#31)
zbud-msft Sep 17, 2022
2ba5c9a
Add systemd regex file to rsyslog.d dir
zbud-msft Sep 19, 2022
1527ad2
Merge branch 'sonic-net:master' into syslog_telemetry_shared
zbud-msft Oct 4, 2022
617559c
Proposed yang model changes (#35)
zbud-msft Oct 4, 2022
d389d89
Add remaining events (#33)
zbud-msft Oct 4, 2022
3183e88
Remove event yang models from test count (#36)
zbud-msft Oct 5, 2022
d7630d8
Merge branch 'sonic-net:master' into syslog_telemetry_shared
zbud-msft Oct 5, 2022
5923461
Revert "Remove event yang models from test count (#36)" (#37)
zbud-msft Oct 6, 2022
5bd7d95
Revert "Proposed yang model changes (#35)" (#38)
zbud-msft Oct 6, 2022
0b8c223
Merge branch 'sonic-net:master' into syslog_telemetry_shared
zbud-msft Oct 6, 2022
7ce2875
Merge branch 'sonic-net:master' into syslog_telemetry_shared
zbud-msft Oct 6, 2022
ee59b08
Merge branch 'sonic-net:master' into syslog_telemetry_shared
zbud-msft Oct 7, 2022
1c4e1fc
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Oct 7, 2022
0faa95a
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
renukamanavalan Oct 7, 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
10 changes: 10 additions & 0 deletions dockers/docker-fpm-frr/bgp_regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
"tag": "bgp-state",
"regex": "Peer .default\\|([0-9a-f:.]*[0-9a-f]*). admin state is set to .(up|down).",
"params": [ "ip", "status" ]
},
{
"tag": "zebra-no-buff",
"regex": "No buffer space available",
"params": []
},
{
"tag": "notification",
"regex": "NOTIFICATION: (received|sent) (?:to|from) neighbor ([0-9a-f:.]*[0-9a-f+]*)\\s*.* (\\d*)\/(\\d*)",
"params": [ "is-sent", "ip", "major-code", "minor-code" ]
}
]

7 changes: 7 additions & 0 deletions files/build_templates/dhcp_relay_regex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"tag": "dhcp-relay-discard",
"regex": "Discarding packet received on ([a-zA-Z0-9-_]*) interface that has no IPv4 address assigned.",
"params": [ "ifname" ]
}
]
7 changes: 7 additions & 0 deletions files/build_templates/dockerd_regex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"tag": "invalid-freelist",
"regex": "invalid freelist",
"params": []
}
]
26 changes: 25 additions & 1 deletion files/build_templates/events_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"proclist": [
{
"name": "monit",
"parse_json": "monit_regex.json"
"parse_json": "monit_regex.json"
},
{
"name": "sshd",
Expand All @@ -12,6 +12,30 @@
{
"name": "systemd",
"parse_json": "systemd_regex.json"
},
{
"name": "dhcp_relay",
"parse_json": "dhcp_relay_regex.json"
},
{
"name": "syncd",
"parse_json": "syncd_regex.json"
},
{
"name": "kernel",
"parse_json": "kernel_regex.json"
},
{
"name": "dockerd",
"parse_json": "dockerd_regex.json"
},
{
"name": "arista",
"parse_json": "seu_regex.json"
},
{
"name": "python3",
"parse_json": "seu_regex.json"
}
]
}
7 changes: 7 additions & 0 deletions files/build_templates/kernel_regex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"tag": "event-kernel",
"regex": "(write failed|Write protected|Remounting filesystem read-only|zlib decompression failed, data probably corrupt)",
"params": [ "fail_type:ret=(arg==\"write failed\")and\"write_failed\"or((arg==\"Write protected\")and\"write_protected\"or((arg==\"Remounting filesystem read-only\")and\"remount_read_only\"or((arg==\"zlib decompression failed, data probably corrupt\")and\"zlib_decompress\"or\"\")))" ]
}
]
7 changes: 7 additions & 0 deletions files/build_templates/seu_regex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"tag": "event-seu",
"regex": "SEU error was detected",
"params": []
}
]
5 changes: 5 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ j2 -f json $BUILD_TEMPLATES/rsyslog_plugin.conf.j2 $BUILD_TEMPLATES/events_info.
sudo cp $BUILD_TEMPLATES/monit_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/sshd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/systemd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/dhcp_relay_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/syncd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/kernel_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/dockerd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
sudo cp $BUILD_TEMPLATES/seu_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/

# Install custom-built monit package and SONiC configuration files
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/monit_*.deb || \
Expand Down
7 changes: 7 additions & 0 deletions files/build_templates/syncd_regex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"tag": "syncd-failure",
"regex": "(MMU ERR Type|L3 route add failed with error|Assertion failed|Received switch event|SER Parity Check Error)",
"params": [ "fail_type:ret=(arg==\"Received switch event\")and\"switch_event\"or((arg==\"Assertion Failed\")and\"assert\"or((arg==\"SER Parity Check Error\")and\"parity_check\"or((arg==\"MMU ERR Type\")and\"mmu_err\"or((arg==\"route add failed\")and\"route_add_failed\"or\"\"))))" ]
}
]
7 changes: 6 additions & 1 deletion files/build_templates/systemd_regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
{
"tag": "event-stopped-ctr",
"regex": "Stopped ([a-zA-Z-_\\s]*) container",
"params": [ "ctr-name" ]
"params": [ "ctr_name" ]
},
{
"tag": "watchdog-timeout",
"regex": "(?:watchdog|Watchdog) timeout .limit.([0-9])min.",
"params": [ "limit" ]
}
]
2 changes: 1 addition & 1 deletion files/image_config/monit/container_checker
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def publish_events(lst):
params = swsscommon.FieldValueMap()

for ctr in lst:
params["name"] = ctr;
params["ctr_name"] = ctr;
swsscommon.event_publish(events_handle, EVENTS_PUBLISHER_TAG, params)

swsscommon.events_deinit_publisher(events_handle)
Expand Down
17 changes: 16 additions & 1 deletion src/dhcpmon/src/dhcp_mon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "dhcp_mon.h"
#include "dhcp_devman.h"
#include "events.h"

/** DHCP device/interface state */
typedef struct
Expand All @@ -40,6 +41,8 @@ static struct event *ev_sigterm;
/** libevent SIGUSR1 signal event struct */
static struct event *ev_sigusr1;

event_handle_t g_events_handle;

/** DHCP monitor state data for aggregate device for mgmt device */
static dhcp_mon_state_t state_data[] = {
[0] = {
Expand Down Expand Up @@ -95,7 +98,15 @@ static void check_dhcp_relay_health(dhcp_mon_state_t *state_data)
{
case DHCP_MON_STATUS_UNHEALTHY:
if (++state_data->count > dhcp_unhealthy_max_count) {
syslog(LOG_ALERT, state_data->msg, state_data->count * window_interval_sec, context->intf);
auto duration = state_data->count * window_interval_sec;
std::string vlan(context->intf);
Copy link
Collaborator

Choose a reason for hiding this comment

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

   [](http://example.com/codeflow?start=0&length=5)

Mixing tabs and spaces indentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

We will take it in the next PR.

syslog(LOG_ALERT, state_data->msg, duration, vlan);
if (state_data->check_type == DHCP_MON_CHECK_POSITIVE) {
event_params_t params = {
{ "vlan", vlan },
{ "duration", std::to_string(duration) }};
event_publish(g_events_handle, "dhcp-relay-disparity", &params);
}
dhcp_devman_print_status(context, DHCP_COUNTERS_SNAPSHOT);
dhcp_devman_print_status(context, DHCP_COUNTERS_CURRENT);
}
Expand Down Expand Up @@ -179,6 +190,8 @@ int dhcp_mon_init(int window_sec, int max_count)
break;
}

g_events_handle = events_init_publisher("sonic-events-dhcp-relay");

rv = 0;
} while (0);

Expand All @@ -203,6 +216,8 @@ void dhcp_mon_shutdown()
event_free(ev_sigusr1);

event_base_free(base);

events_deinit_publisher(g_events_handle);
}

/**
Expand Down
12 changes: 12 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def run(self):
'./yang-models/sonic-device_neighbor.yang',
'./yang-models/sonic-device_neighbor_metadata.yang',
'./yang-models/sonic-dhcpv6-relay.yang',
'./yang-models/sonic-events-bgp.yang',
'./yang-models/sonic-events-common.yang',
'./yang-models/sonic-events-dhcp-relay.yang',
'./yang-models/sonic-events-host.yang',
'./yang-models/sonic-events-swss.yang',
'./yang-models/sonic-events-syncd.yang',
'./yang-models/sonic-extension.yang',
'./yang-models/sonic-flex_counter.yang',
'./yang-models/sonic-feature.yang',
Expand Down Expand Up @@ -174,6 +180,12 @@ def run(self):
'./cvlyang-models/sonic-crm.yang',
'./cvlyang-models/sonic-device_metadata.yang',
'./cvlyang-models/sonic-device_neighbor.yang',
'./cvlyang-models/sonic-events-bgp.yang',
'./cvlyang-models/sonic-events-common.yang',
'./cvlyang-models/sonic-events-dhcp-relay.yang',
'./cvlyang-models/sonic-events-host.yang',
'./cvlyang-models/sonic-events-swss.yang',
'./cvlyang-models/sonic-events-syncd.yang',
'./cvlyang-models/sonic-device_neighbor_metadata.yang',
'./cvlyang-models/sonic-extension.yang',
'./cvlyang-models/sonic-flex_counter.yang',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"SONIC_EVENTS_BGP_BGP_STATE_INCORRECT_IP": {
"desc": "BGP_STATE_EVENT_INCORRECT_IP failure.",
"eStrKey": "InvalidValue"
},
"SONIC_EVENTS_BGP_BGP_STATE_INCORRECT_STATUS": {
"desc": "BGP_STATE_EVENT_INCORRECT_STATUS failure.",
"eStrKey": "InvalidValue"
},
"SONIC_EVENTS_BGP_BGP_STATE_INCORRECT_TIMESTAMP": {
"desc": "BGP_STATE_EVENT_INCORRECT_TIMESTAMP failure.",
"eStrKey": "Pattern"
},
"SONIC_EVENTS_BGP_BGP_STATE_VALID": {
"desc": "VALID BGP STATE EVENT."
},
"SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_MAJOR_CODE": {
"desc": "BGP_NOTIFICATION_INCORRECT_MAJOR_CODE failure.",
"eStrKey": "InvalidValue"
},
"SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_MINOR_CODE": {
"desc": "BGP_NOTIFICATION_INCORRECT_MINOR_CODE failure.",
"eStrKey": "InvalidValue"
},
"SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_IP": {
"desc": "BGP_NOTIFICATION_INCORRECT_IP failure.",
"eStrKey": "InvalidValue"
},
"SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_IS-SENT": {
"desc": "BGP_NOTIFICATION_INCORRECT_IS-SENT failure.",
"eStrKey": "InvalidValue"
},
"SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_TIMESTAMP": {
"desc": "BGP_NOTIFICATION_INCORRECT_TIMESTAMP failure.",
"eStrKey": "Pattern"
},
"SONIC_EVENTS_BGP_NOTIFICATION_VALID": {
"desc": "VALID BGP NOTIFICATION."
},
"SONIC_EVENTS_BGP_ZEBRA_NO_BUFF_INCORRECT_TIMESTAMP": {
"desc": "ZEBRA_NO_BUFF_EVENT_INCORRECT_TIMESTAMP.",
"eStrKey": "Pattern"
},
"SONIC_EVENTS_BGP_ZEBRA_NO_BUFF_VALID": {
"desc": "VALID ZEBRA_NO_BUFF EVENT."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_INCORRECT_IFNAME": {
"desc": "DHCP_RELAY_DISCARD_EVENT_INCORRECT_IFNAME failure.",
"eStrKey": "Pattern"
},
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_INCORRECT_TIMESTAMP": {
"desc": "DHCP_RELAY_DISCARD_EVENT_INCORRECT_TIMESTAMP failure.",
"eStrKey": "Pattern"
},
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISCARD_VALID": {
"desc": "VALID DHCP_RELAY_DISCARD EVENT."
},
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISPARITY_INCORRECT_VLAN": {
"desc": "DHCP_RELAY_DISPARITY_EVENT_INCORRECT_VLAN failure.",
"eStrKey": "Pattern"
},
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISPARITY_INCORRECT_DURATION": {
"desc": "DHCP_RELAY_DISPARITY_EVENT_INCORRECT_DURATION failure.",
"eStrKey": "InvalidValue"
},
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISPARITY_INCORRECT_TIMESTAMP": {
"desc": "DHCP_RELAY_DISPARITY_EVENT_INCORRECT_TIMESTAMP failure.",
"eStrKey": "Pattern"
},
"SONIC_EVENTS_DHCP_RELAY_DHCP_RELAY_DISPARITY_VALID": {
"desc": "VALID DHCP_RELAY_DISPARITY EVENT."
}
}
Loading