summaryrefslogtreecommitdiff
path: root/docs/configuration/service/md-eventhandler.md
diff options
context:
space:
mode:
authorYuriy Andamasov <yuriy@vyos.io>2026-05-06 20:42:32 +0300
committerYuriy Andamasov <yuriy@vyos.io>2026-05-06 20:42:32 +0300
commit5d6fa52b8985f8068314aba26878a1d7d5cb84e5 (patch)
tree99359ff282846e26b5c5fa2b9b176b35b172809f /docs/configuration/service/md-eventhandler.md
parent631e454d674ad5111d2b56a6964ead461894a1f6 (diff)
downloadvyos-documentation-5d6fa52b8985f8068314aba26878a1d7d5cb84e5.tar.gz
vyos-documentation-5d6fa52b8985f8068314aba26878a1d7d5cb84e5.zip
feat: flip swap mechanism — MD as primary, RST as override (Phase 1)
This is the first of three phases inverting the per-page swap mechanism so MD becomes the canonical primary and RST becomes the rare override. Phase 1 — file renames + conf.py exclude_patterns flip only: - Rename docs/**/md-<stem>.md to docs/**/<stem>.md (drop md- prefix) for all 254 stems previously listed in docs/_swap.txt - Rename docs/**/<stem>.rst to docs/**/rst-<stem>.rst (add rst- prefix) for the same 254 stems - Repurpose docs/_swap.txt as docs/_rst_overrides.txt; initially empty comment-only since no pages need the RST fallback right now - conf.py exclude_patterns flipped: rst-*.rst is now excluded by default instead of md-*.md - conf.py runtime-artifact references updated to _rst_override_state.json and _md_exclude.txt (Phase 2 will rewrite swap_sources.py to produce these names; for now no swap script runs because overrides list is empty) Phase 2 (next commit on this branch) will rewrite scripts/swap_sources.py with inverted rename direction, delete scripts/import_myst.py + tests, and update tests/test_swap_sources.py for the new semantics. Phase 3 will be the cleanup pass and ready-for-review flip. Generated by robots https://vyos.io
Diffstat (limited to 'docs/configuration/service/md-eventhandler.md')
-rw-r--r--docs/configuration/service/md-eventhandler.md129
1 files changed, 0 insertions, 129 deletions
diff --git a/docs/configuration/service/md-eventhandler.md b/docs/configuration/service/md-eventhandler.md
deleted file mode 100644
index 6413c24d..00000000
--- a/docs/configuration/service/md-eventhandler.md
+++ /dev/null
@@ -1,129 +0,0 @@
-(event-handler)=
-
-# Event Handler
-
-## Event Handler Technology Overview
-
-Event handler allows you to execute scripts when a string that matches
-a regex or a regex with a service name appears in journald logs. You
-can pass variables, arguments, and a full matching string to the script.
-
-## How to configure Event Handler
-
-> [1. Create an event handler](#create-an-event-handler)
->
-> [2. Add regex to the script](#add-regex-to-the-script)
->
-> [3. Add a full path to the script](#add-a-full-path-to-the-script)
->
-> [4. Add optional parameters](#add-optional-parameters)
-
-## Event Handler Configuration Steps
-
-### 1. Create an event handler
-
-```{cfgcmd} set service event-handler event \<event-handler name\>
-
-This is an optional command because the event handler will be
-automatically created after any of the next commands.
-```
-
-
-### 2. Add regex to the script
-
-```{cfgcmd} set service event-handler event \<event-handler name\> filter pattern \<regex\>
-
-This is a mandatory command. Sets regular expression to match
-against log string message.
-
-:::{note}
-The regular expression matches if and only if the entire
-string matches the pattern.
-:::
-```
-
-
-### 3. Add a full path to the script
-
-```{cfgcmd} set service event-handler event \<event-handler name\> script path \<path to script\>
-
-This is a mandatory command. Sets the full path to the script.
-The script file must be executable.
-```
-
-
-### 4. Add optional parameters
-
-```{cfgcmd} set service event-handler event \<event-handler name\> filter syslog-identifier \<syslogid name\>
-
-This is an optional command. Filters log messages by
-syslog-identifier.
-```
-
-```{cfgcmd} set service event-handler event \<event-handler name\> script environment \<env name\> value \<env value\>
-
-This is an optional command. Adds environment and its value to
-the script. Use separate commands for each environment.
-
-One implicit environment exists.
-
-* ``message``: Full message that has triggered the script.
-```
-
-```{cfgcmd} set service event-handler event \<event-handler name\> script arguments \<arguments\>
-
-This is an optional command. Adds arguments to the script.
-Arguments must be separated by spaces.
-
-:::{note}
-We don't recommend using arguments. Using environment variables is preferable.
-:::
-```
-
-
-## Example
-
-Event handler that monitors the state of interface eth0.
-
-```none
-set service event-handler event INTERFACE_STATE_DOWN filter pattern '.*eth0.*,RUNNING,.*->.*'
-set service event-handler event INTERFACE_STATE_DOWN filter syslog-identifier 'netplugd'
-set service event-handler event INTERFACE_STATE_DOWN script environment interface_action value 'down'
-set service event-handler event INTERFACE_STATE_DOWN script environment interface_name value 'eth0'
-set service event-handler event INTERFACE_STATE_DOWN script path '/config/scripts/eventhandler.py'
-```
-
-Event handler script
-
-```none
-#!/usr/bin/env python3
-#
-# VyOS event-handler script example
-from os import environ
-import subprocess
-from sys import exit
-
-# Perform actions according to requirements
-def process_event() -> None:
- # Get variables
- message_text = environ.get('message')
- interface_name = environ.get('interface_name')
- interface_action = environ.get('interface_action')
- # Print the message that triggered this script
- print(f'Logged message: {message_text}')
- # Prepare a command to run
- command = f'sudo ip link set {interface_name} {interface_action}'.split()
- # Execute a command
- subprocess.run(command)
-
-if __name__ == '__main__':
- try:
- # Run script actions and exit
- process_event()
- exit(0)
- except Exception as err:
- # Exit properly in case if something in the script goes wrong
- print(f'Error running script: {err}')
- exit(1)
-```
-