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

T6641: Add vyos-network-event-logger Service #4216

Open
wants to merge 1 commit into
base: current
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
91 changes: 91 additions & 0 deletions interface-definitions/service_monitoring_network_event.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0"?>
<interfaceDefinition>
<node name="service">
<children>
<node name="monitoring">
Copy link
Member

Choose a reason for hiding this comment

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

We should probably make a skeleton node for monitoring and include everything else into it, although it's a topic for a different PR.

<properties>
<help>Monitoring services</help>
</properties>
<children>
<node name="network-event" owner="${vyos_conf_scripts_dir}/service_monitoring_network_event.py">
<properties>
<help>Network event logger</help>
<priority>1280</priority>
</properties>
<children>
<node name="event">
<properties>
<help>Network event type</help>
</properties>
<children>
<leafNode name="route">
<properties>
<help>Log routing table update events</help>
<valueless/>
</properties>
</leafNode>
<leafNode name="link">
<properties>
<help>Log link status changes events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Log link status changes events</help>
<help>Log link status change events</help>

<valueless/>
</properties>
</leafNode>
<leafNode name="addr">
<properties>
<help>Log address assignment and removal events</help>
<valueless/>
</properties>
</leafNode>
<leafNode name="neigh">
<properties>
<help>Log neighbor (ARP/ND) table update events</help>
<valueless/>
</properties>
</leafNode>
<leafNode name="rule">
<properties>
<help>Log policy routing rule change events</help>
<valueless/>
</properties>
</leafNode>
</children>
</node>
<leafNode name="queue-size">
Copy link
Member

Choose a reason for hiding this comment

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

I'm always uneasy about such parameters. Why is the upper limit exactly 999999? queue.Queue's maxsize can be any integer, I see no reason to introduce an artificial limit.

<properties>
<help>Internal message queue size</help>
<valueHelp>
<format>u32:100-999999</format>
<description>Queue size</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-999999"/>
</constraint>
<constraintErrorMessage>Queue size must be between 100 and 999999</constraintErrorMessage>
</properties>
</leafNode>
<leafNode name="log-level">
<properties>
<help>Set log-level. Log must be enable</help>
Copy link
Member

Choose a reason for hiding this comment

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

What exactly does "Log must be enable" (sic) mean here?

<completionHelp>
<list>info debug</list>
</completionHelp>
<valueHelp>
<format>info</format>
<description>Info log level</description>
</valueHelp>
<valueHelp>
<format>debug</format>
<description>Debug log level</description>
</valueHelp>
<constraint>
<regex>(info|debug)</regex>
</constraint>
</properties>
</leafNode>
</children>
</node>
</children>
</node>
</children>
</node>
</interfaceDefinition>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- included start from isis-common.xml.i -->
<tagNode name="interface">
<properties>
<help>Show log for specific interface</help>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces</script>
</completionHelp>
</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$4\]" | tr '[:lower:]' '[:upper:]')" | grep "\b$6\b"</command>
</tagNode>
<!-- included end -->
40 changes: 40 additions & 0 deletions op-mode-definitions/include/show-interface-type-event-log.xml.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- included start from show-nht.xml.i -->
<node name="event-log">
<properties>
<help>Show interface network event log</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show interface network event log</help>
<help>Show network interface change event log</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "\b$4\b"</command>
Copy link
Member

Choose a reason for hiding this comment

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

journalctl has a built-in --grep= option that supports PCRE, so I think there is no need to use an external filter here. The built-in will be faster and will preserve coloring, etc.

<children>
<leafNode name="route">
<properties>
<help>Show log for route network events</help>
</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$6\]" | tr '[:lower:]' '[:upper:]')" | grep "\b$4\b"</command>
Copy link
Member

Choose a reason for hiding this comment

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

The journalctl command is duplicated a lot here. Should we make it a script?

I'm also not convinced about the value of the tr call here.

</leafNode>
<leafNode name="link">
<properties>
<help>Show log for link network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for link network events</help>
<help>Show log for network link events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$6\]" | tr '[:lower:]' '[:upper:]')" | grep "\b$4\b"</command>
</leafNode>
<leafNode name="addr">
<properties>
<help>Show log for addr network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for addr network events</help>
<help>Show log for network address events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$6\]" | tr '[:lower:]' '[:upper:]')" | grep "\b$4\b"</command>
</leafNode>
<leafNode name="neigh">
<properties>
<help>Show log for neigh network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for neigh network events</help>
<help>Show log for neighbor table events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$6\]" | tr '[:lower:]' '[:upper:]')" | grep "\b$4\b"</command>
</leafNode>
<leafNode name="rule">
<properties>
<help>Show log for rule network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for rule network events</help>
<help>Show log for PBR rule change events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$6\]" | tr '[:lower:]' '[:upper:]')" | grep "\b$4\b"</command>
</leafNode>
</children>
</node>
<!-- included end -->
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-bonding.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
</leafNode>
</children>
</tagNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="bonding">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-bridge.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=bridge</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="bridge">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-dummy.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=dummy</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="dummy">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-ethernet.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
</leafNode>
</children>
</tagNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="ethernet">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-geneve.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=geneve</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="geneve">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-input.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=input</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="input">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-l2tpv3.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=l2tpv3</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="l2tpv3">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-loopback.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=loopback</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="loopback">
Expand Down
3 changes: 3 additions & 0 deletions op-mode-definitions/show-interfaces-macsec.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
</completionHelp>
</properties>
<command>ip macsec show $4</command>
<children>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
</children>
</node>
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-pppoe.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</properties>
<command>if [ -d "/sys/class/net/$4" ]; then /usr/sbin/pppstats "$4"; fi</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="pppoe">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=pseudo-ethernet</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="pseudo-ethernet">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-sstpc.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</properties>
<command>if [ -d "/sys/class/net/$4" ]; then /usr/sbin/pppstats "$4"; fi</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="sstpc">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-tunnel.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=tunnel</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="tunnel">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=virtual-ethernet</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="virtual-ethernet">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-vti.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=vti</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="vti">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-vxlan.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>
<command>${vyos_op_scripts_dir}/interfaces.py show_summary --intf-name="$4" --intf-type=vxlan</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="vxlan">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-wireguard.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
</properties>
<command>sudo ${vyos_op_scripts_dir}/interfaces_wireguard.py show_summary --intf-name="$4"</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="wireguard">
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-wireless.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
</leafNode>
</children>
</tagNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
</children>
Expand Down
1 change: 1 addition & 0 deletions op-mode-definitions/show-interfaces-wwan.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
</properties>
<command>echo not implemented</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
</tagNode>
<node name="wwan">
Expand Down
62 changes: 62 additions & 0 deletions op-mode-definitions/show-log.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,68 @@
</properties>
<command>journalctl --no-hostname --boot --unit squid.service</command>
</leafNode>
<node name="network-event">
<properties>
<help>Show log for network events</help>
</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service</command>
<children>
<tagNode name="interface">
<properties>
<help>Show log for specific interface</help>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces</script>
</completionHelp>
</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep $5</command>
</tagNode>
<node name="route">
<properties>
<help>Show log for route network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for route network events</help>
<help>Show log for route events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$4\]" | tr '[:lower:]' '[:upper:]')" </command>
<children>
#include <include/log/network-event-type-interface.xml.i>
</children>
</node>
<node name="link">
<properties>
<help>Show log for link network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for link network events</help>
<help>Show log for network link events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$4\]" | tr '[:lower:]' '[:upper:]')" </command>
<children>
#include <include/log/network-event-type-interface.xml.i>
</children>
</node>
<node name="addr">
<properties>
<help>Show log for addr network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for addr network events</help>
<help>Show log for network address events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$4\]" | tr '[:lower:]' '[:upper:]')" </command>
<children>
#include <include/log/network-event-type-interface.xml.i>
</children>
</node>
<node name="neigh">
<properties>
<help>Show log for neigh network events</help>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<help>Show log for neigh network events</help>
<help>Show log for neighbor table events</help>

</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$4\]" | tr '[:lower:]' '[:upper:]')" </command>
<children>
#include <include/log/network-event-type-interface.xml.i>
</children>
</node>
<node name="rule">
<properties>
<help>Show log for rule network events</help>
</properties>
<command>journalctl --no-hostname --boot --unit vyos-network-event-logger.service | grep "$(echo "\[$4\]" | tr '[:lower:]' '[:upper:]')" </command>
<children>
#include <include/log/network-event-type-interface.xml.i>
</children>
</node>
</children>
</node>
</children>
</node>
</children>
Expand Down
Loading
Loading