journal2ntfy: Script to send log messagess via ntfy

The `journal2ntfy.py` script follows the systemd journal by spawning
`journalctl` as a child process and reading from its standard output
stream.  Any command-line arguments passed to `journal2ntfy` are passed
to `journalctl`, which allows the caller to specify message filters.
For any matching journal message, `journal2ntfy` sends a message via
the *ntfy* web service.

For the BURP server, we're going to use `journal2ntfy` to generate
alerts about the RAID array.  When I reconnect the disk that was in the
fireproof safe, the kernel will log a message from the *md* subsystem
indicating that the resynchronization process has begun.  Then, when
the disks are again in sync, it will log another message, which will
let me know it is safe to archive the other disk.
This commit is contained in:
2023-05-17 14:51:21 -05:00
parent 2c002aa7c5
commit a7319c561d
8 changed files with 265 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
[Unit]
Description=Send kernel messages from md via ntfy
Wants=network-online.target
After=network-online.target
[Service]
Type=exec
EnvironmentFile=-/etc/sysconfig/journal2ntfy
ExecStart=/usr/local/bin/journal2ntfy
DevicePolicy=closed
MemoryDenyWriteExecute=yes
PrivateDevices=yes
PrivateTmp=yes
PrivateUsers=yes
ProtectClock=yes
ProtectHome=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectProc=invisible
ProtectSystem=strict
RestrictRealtime=yes
RestrictSUIDSGID=yes
SystemCallFilter=@system-service
SystemCallFilter=~@privileged @resources
UMask=0077
[Install]
WantedBy=multi-user.target