95 lines
2.5 KiB
Groff
95 lines
2.5 KiB
Groff
|
.\" Automatically generated by Pandoc 2.19.2
|
||
|
.\"
|
||
|
.\" Define V font for inline verbatim, using C font in formats
|
||
|
.\" that render this, and otherwise B font.
|
||
|
.ie "\f[CB]x\f[]"x" \{\
|
||
|
. ftr V B
|
||
|
. ftr VI BI
|
||
|
. ftr VB B
|
||
|
. ftr VBI BI
|
||
|
.\}
|
||
|
.el \{\
|
||
|
. ftr V CR
|
||
|
. ftr VI CI
|
||
|
. ftr VB CB
|
||
|
. ftr VBI CBI
|
||
|
.\}
|
||
|
.TH "systemd_failure_notify" "1" "January 2023" "systemd_failure_notify" ""
|
||
|
.hy
|
||
|
.SH NAME
|
||
|
.PP
|
||
|
systemd_failure_notify - Notifies via mail or gotify when a service has
|
||
|
failed.
|
||
|
Configuration is done in environment files.
|
||
|
.PD 0
|
||
|
.P
|
||
|
.PD
|
||
|
It\[cq]s part of \f[B]system-helpers\f[R].
|
||
|
.SH SYNOPSIS
|
||
|
.PP
|
||
|
\f[B]systemd_failure_notify\f[R] [CONFIG_FILE (absolute path)] [service
|
||
|
name]
|
||
|
.SH DESCRIPTION
|
||
|
.PP
|
||
|
\f[B]systemd_failure_notify\f[R] executes \f[I]mailx\f[R] or
|
||
|
\f[I]gotify\f[R] to send out notifications.
|
||
|
It comes with systemd services.
|
||
|
Use the provided systemd service in the \f[B]OnFailure\f[R] directive
|
||
|
with \f[I]OnFailure=systemd_failure_notify\[at]%n.service\f[R].
|
||
|
.PP
|
||
|
If no \f[I]CONFIG_FILE\f[R] is provided,
|
||
|
\f[B]systemd_failure_notify\f[R] tries to read from
|
||
|
\f[I]$HOME/.systemd_failure_notify.conf\f[R] and
|
||
|
\f[I]/etc/systemd_failure_notify.conf\f[R] for configuration.
|
||
|
It will exit with a non-zero exit code if it cannot find an proper
|
||
|
configuration file.
|
||
|
.PP
|
||
|
The following are at least required for the script to work:
|
||
|
.PD 0
|
||
|
.P
|
||
|
.PD
|
||
|
- \f[B]SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS=\[lq]\[lq]\f[R] which
|
||
|
requires \f[I]mail.rc\f[R] to be configured and `\f[I]mailx\f[R]'
|
||
|
command has be available\[ac]
|
||
|
.PP
|
||
|
By default, \f[B]SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED\f[R] is set to
|
||
|
\f[B]true\f[R].
|
||
|
Set it to \f[B]false\f[R] to use \f[I]gotify\f[R] only.\[ac]
|
||
|
.PP
|
||
|
The following are optional and integrate gotify-cli to send
|
||
|
notifications, it defaults to false: -
|
||
|
SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED=\[lq]true\[rq] // `gotify' command
|
||
|
has be available and needs to be properly configured by having a
|
||
|
cli.json file
|
||
|
.PP
|
||
|
You can copy this script to \f[I]/usr/local/bin\f[R] and use create a
|
||
|
custom \f[B]CONFIG_FILE\f[R] as user.
|
||
|
.SH EXAMPLE
|
||
|
.PP
|
||
|
Create a \f[I]$HOME/.systemd_failure_notify.conf\f[R] and add
|
||
|
\f[I]SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS=\[lq]alias\[at]domain.tld\[rq]\f[R].
|
||
|
Notifications will be delivered to alias\[at]domain.tld.
|
||
|
Examples can be found in
|
||
|
\f[I]/usr/share/doc/systemd_failure_notify\f[R].
|
||
|
.PP
|
||
|
Then, add \f[B]systemd_failure_notify\[at]serviceName\f[R] in a systemd
|
||
|
unit file in the \f[B]OnFailure\f[R] directive:
|
||
|
.PP
|
||
|
[Unit]
|
||
|
.PD 0
|
||
|
.P
|
||
|
.PD
|
||
|
OnFailure=systemd_failure_notify\[at]%n.service
|
||
|
.PD 0
|
||
|
.P
|
||
|
.PD
|
||
|
.SH EXIT VALUES
|
||
|
.TP
|
||
|
\f[B]0\f[R]
|
||
|
Success
|
||
|
.TP
|
||
|
\f[B]1\f[R]
|
||
|
Error
|
||
|
.SH AUTHORS
|
||
|
Alexander Sch\[:a]ferdiek.
|