This is a small program to forward systemd failure notifications to PagerDuty.
PAGERDUTY_ROUTING_KEY
is a required variable and must be set to PagerDuty Event API v2 Routing Key.
HTTP_PROXY
is an optional variable and should be set to the HTTP Proxy URL.
Install systemd-failure-pagerduty to /bin or your preferred directory.
Create a systemd unit /etc/systemd/system/[email protected]
for this program.
[Unit]
Description=notify systemd failure to PagerDuty
After=network.target
[Service]
Type=simple
ExecStart=/bin/systemd-failure-pagerduty %i
EnvironmentFile=/etc/default/systemd-failure-pagerduty
Write the necessary environment variables in /etc/default/systemd-failure-pagerduty
.
PAGERDUTY_ROUTING_KEY=...
HTTP_PROXY=...
SUMMARY_TEMPLATE="[{{.HostName}}] systemd failed {{.UnitName}}"
Set systemd-failure-pagerduty@%n
to the OnFailure hook of the service for which you want to be notified of failures.