System Monitoring (with systemd)
Prerequisites: Email (msmtp).
We can set up systemd to notify us by email if a service fails. Systemd actually does this by starting another service.
We can create the notification service at
[Unit] Description=Send email [Service] Type=oneshot ExecStart=/usr/bin/sh -c 'printf "Subject: [systemd] %i Failed" | /usr/bin/msmtp default'
This can easily be tested with
systemctl start [email protected].
This notification method can be used by our other systemd services by adding the line:
[Unit] OnFailure[email protected]%N
We add the files to our backup script:
/etc/systemd/system/[email protected] \