Skip to content

Commit 937d370

Browse files
committed
T6641: Add vyos-network-event-logger Service
The service parses and logs network events for improved monitoring and diagnostics. Supported event types include: - `RTM_NEWROUTE`, `RTM_DELROUTE` - `RTM_NEWLINK`, `RTM_DELLINK` - `RTM_NEWADDR`, `RTM_DELADDR` - `RTM_NEWNEIGH`, `RTM_DELNEIGH`, `RTM_GETNEIGH` - `RTM_NEWRULE`, `RTM_DELRULE` Added operational mode commands for filtered log retrieval: - `show log network-event <event-type> <interface>`: Retrieve logs filtered by event type and interface. - `show interfaces <type> <name> event-log <event-type>`: Display interface-specific logs filtered by event type.
1 parent 99d0c7a commit 937d370

39 files changed

+2024
-32
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- include start from netlink/log-level.xml.i -->
2+
<leafNode name="log-level">
3+
<properties>
4+
<help>Set log-level</help>
5+
<completionHelp>
6+
<list>info debug</list>
7+
</completionHelp>
8+
<valueHelp>
9+
<format>info</format>
10+
<description>Info log level</description>
11+
</valueHelp>
12+
<valueHelp>
13+
<format>debug</format>
14+
<description>Debug log level</description>
15+
</valueHelp>
16+
<constraint>
17+
<regex>(info|debug)</regex>
18+
</constraint>
19+
</properties>
20+
</leafNode>
21+
<!-- include end -->
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- include start from netlink/queue-size.xml.i -->
2+
<leafNode name="queue-size">
3+
<properties>
4+
<help>Internal message queue size</help>
5+
<valueHelp>
6+
<format>u32:100-2147483647</format>
7+
<description>Queue size</description>
8+
</valueHelp>
9+
<constraint>
10+
<validator name="numeric" argument="--range 1-2147483647"/>
11+
</constraint>
12+
<constraintErrorMessage>Queue size must be between 100 and 2147483647</constraintErrorMessage>
13+
</properties>
14+
</leafNode>
15+
<!-- include end -->
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0"?>
2+
<interfaceDefinition>
3+
<node name="service">
4+
<children>
5+
<node name="monitoring">
6+
<properties>
7+
<help>Monitoring services</help>
8+
</properties>
9+
<children>
10+
<node name="network-event" owner="${vyos_conf_scripts_dir}/service_monitoring_network_event.py">
11+
<properties>
12+
<help>Network event logger</help>
13+
<priority>1280</priority>
14+
</properties>
15+
<children>
16+
<node name="event">
17+
<properties>
18+
<help>Network event type</help>
19+
</properties>
20+
<children>
21+
<leafNode name="route">
22+
<properties>
23+
<help>Log routing table update events</help>
24+
<valueless/>
25+
</properties>
26+
</leafNode>
27+
<leafNode name="link">
28+
<properties>
29+
<help>Log link status change events</help>
30+
<valueless/>
31+
</properties>
32+
</leafNode>
33+
<leafNode name="addr">
34+
<properties>
35+
<help>Log address assignment and removal events</help>
36+
<valueless/>
37+
</properties>
38+
</leafNode>
39+
<leafNode name="neigh">
40+
<properties>
41+
<help>Log neighbor (ARP/ND) table update events</help>
42+
<valueless/>
43+
</properties>
44+
</leafNode>
45+
<leafNode name="rule">
46+
<properties>
47+
<help>Log policy routing rule change events</help>
48+
<valueless/>
49+
</properties>
50+
</leafNode>
51+
</children>
52+
</node>
53+
#include <include/netlink/queue-size.xml.i>
54+
#include <include/netlink/log-level.xml.i>
55+
</children>
56+
</node>
57+
</children>
58+
</node>
59+
</children>
60+
</node>
61+
</interfaceDefinition>

interface-definitions/system_conntrack.xml.in

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -263,38 +263,8 @@
263263
<valueless/>
264264
</properties>
265265
</leafNode>
266-
<leafNode name="queue-size">
267-
<properties>
268-
<help>Internal message queue size</help>
269-
<valueHelp>
270-
<format>u32:100-999999</format>
271-
<description>Queue size</description>
272-
</valueHelp>
273-
<constraint>
274-
<validator name="numeric" argument="--range 1-999999"/>
275-
</constraint>
276-
<constraintErrorMessage>Queue size must be between 100 and 999999</constraintErrorMessage>
277-
</properties>
278-
</leafNode>
279-
<leafNode name="log-level">
280-
<properties>
281-
<help>Set log-level. Log must be enable.</help>
282-
<completionHelp>
283-
<list>info debug</list>
284-
</completionHelp>
285-
<valueHelp>
286-
<format>info</format>
287-
<description>Info log level</description>
288-
</valueHelp>
289-
<valueHelp>
290-
<format>debug</format>
291-
<description>Debug log level</description>
292-
</valueHelp>
293-
<constraint>
294-
<regex>(info|debug)</regex>
295-
</constraint>
296-
</properties>
297-
</leafNode>
266+
#include <include/netlink/queue-size.xml.i>
267+
#include <include/netlink/log-level.xml.i>
298268
</children>
299269
</node>
300270
<node name="modules">
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- included start from network-event-type-interface.xml.i -->
2+
<tagNode name="interface">
3+
<properties>
4+
<help>Show log for specific interface</help>
5+
<completionHelp>
6+
<script>${vyos_completion_dir}/list_interfaces</script>
7+
</completionHelp>
8+
</properties>
9+
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$4\]" | tr '[:lower:]' '[:upper:]')" | grep "\b$6\b"</command>
10+
</tagNode>
11+
<!-- included end -->
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!-- included start from show-interface-type-event-log.xml.i -->
2+
<node name="event-log">
3+
<properties>
4+
<help>Show network interface change event log</help>
5+
</properties>
6+
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service --grep "\b$4\b"</command>
7+
<children>
8+
<leafNode name="route">
9+
<properties>
10+
<help>Show log for route events</help>
11+
</properties>
12+
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service --grep "\b$4\b" | grep -i "\[$6\]"</command>
13+
</leafNode>
14+
<leafNode name="link">
15+
<properties>
16+
<help>Show log for network link events</help>
17+
</properties>
18+
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service --grep "\b$4\b" | grep -i "\[$6\]"</command>
19+
</leafNode>
20+
<leafNode name="addr">
21+
<properties>
22+
<help>Show log for network address events</help>
23+
</properties>
24+
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service --grep "\b$4\b" | grep -i "\[$6\]"</command>
25+
</leafNode>
26+
<leafNode name="neigh">
27+
<properties>
28+
<help>Show log for neighbor table events</help>
29+
</properties>
30+
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service --grep "\b$4\b" | grep -i "\[$6\]"</command>
31+
</leafNode>
32+
<leafNode name="rule">
33+
<properties>
34+
<help>Show log for PBR rule change events</help>
35+
</properties>
36+
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service --grep "\b$4\b" | grep -i "\[$6\]"</command>
37+
</leafNode>
38+
</children>
39+
</node>
40+
<!-- included end -->

op-mode-definitions/show-interfaces-bonding.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
</leafNode>
6868
</children>
6969
</tagNode>
70+
#include <include/show-interface-type-event-log.xml.i>
7071
</children>
7172
</tagNode>
7273
<node name="bonding">

op-mode-definitions/show-interfaces-bridge.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=bridge</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="bridge">

op-mode-definitions/show-interfaces-dummy.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=dummy</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="dummy">

op-mode-definitions/show-interfaces-ethernet.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
</leafNode>
6969
</children>
7070
</tagNode>
71+
#include <include/show-interface-type-event-log.xml.i>
7172
</children>
7273
</tagNode>
7374
<node name="ethernet">

op-mode-definitions/show-interfaces-geneve.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=geneve</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="geneve">

op-mode-definitions/show-interfaces-input.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=input</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="input">

op-mode-definitions/show-interfaces-l2tpv3.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=l2tpv3</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="l2tpv3">

op-mode-definitions/show-interfaces-loopback.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=loopback</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="loopback">

op-mode-definitions/show-interfaces-macsec.xml.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
</completionHelp>
3030
</properties>
3131
<command>ip macsec show $4</command>
32+
<children>
33+
#include <include/show-interface-type-event-log.xml.i>
34+
</children>
3235
</tagNode>
3336
</children>
3437
</node>

op-mode-definitions/show-interfaces-pppoe.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</properties>
2929
<command>if [ -d "/sys/class/net/$4" ]; then /usr/sbin/pppstats "$4"; fi</command>
3030
</leafNode>
31+
#include <include/show-interface-type-event-log.xml.i>
3132
</children>
3233
</tagNode>
3334
<node name="pppoe">

op-mode-definitions/show-interfaces-pseudo-ethernet.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=pseudo-ethernet</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="pseudo-ethernet">

op-mode-definitions/show-interfaces-sstpc.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</properties>
2929
<command>if [ -d "/sys/class/net/$4" ]; then /usr/sbin/pppstats "$4"; fi</command>
3030
</leafNode>
31+
#include <include/show-interface-type-event-log.xml.i>
3132
</children>
3233
</tagNode>
3334
<node name="sstpc">

op-mode-definitions/show-interfaces-tunnel.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=tunnel</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="tunnel">

op-mode-definitions/show-interfaces-virtual-ethernet.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=virtual-ethernet</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="virtual-ethernet">

op-mode-definitions/show-interfaces-vti.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=vti</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="vti">

op-mode-definitions/show-interfaces-vxlan.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
</properties>
2020
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=vxlan</command>
2121
</leafNode>
22+
#include <include/show-interface-type-event-log.xml.i>
2223
</children>
2324
</tagNode>
2425
<node name="vxlan">

op-mode-definitions/show-interfaces-wireguard.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
</properties>
4444
<command>sudo ${vyos_op_scripts_dir}/interfaces_wireguard.py show_summary --intf-name="$4"</command>
4545
</leafNode>
46+
#include <include/show-interface-type-event-log.xml.i>
4647
</children>
4748
</tagNode>
4849
<node name="wireguard">

op-mode-definitions/show-interfaces-wireless.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
</leafNode>
7474
</children>
7575
</tagNode>
76+
#include <include/show-interface-type-event-log.xml.i>
7677
</children>
7778
</tagNode>
7879
</children>

op-mode-definitions/show-interfaces-wwan.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
</properties>
8181
<command>echo not implemented</command>
8282
</leafNode>
83+
#include <include/show-interface-type-event-log.xml.i>
8384
</children>
8485
</tagNode>
8586
<node name="wwan">

0 commit comments

Comments
 (0)