Permalink
Browse files

monit: Email only on exit code which isn't 0 or 75

  • Loading branch information...
andrewladlow committed Aug 7, 2018
1 parent 6273741 commit edfe6bcfc8467a132295314d5e77e667cba353bf
@@ -1,7 +1,6 @@
symbiosis-monit (2018:0802) stable; urgency=medium

* Remove symbiosis-monit-failure-email to email only on test failures
instead of the monit service itself.
* No longer emails on temporary failure of symbiosis-monit service itself.

-- Andrew Ladlow <andrew.ladlow@bytemark.co.uk> Thu, 02 Aug 2018 13:03:11 +0100

@@ -0,0 +1,9 @@
#!/bin/bash

set -e

args="--since=today"
[ -e "/var/tmp/symbiosis-monit.cursor" ] && args="--after-cursor=$(</var/tmp/symbiosis-monit.cursor)"

journalctl -b0 $args -o cat -u "symbiosis-monit.service" | mail -s "Symbiosis monitor detected service failure" root

@@ -0,0 +1,7 @@
[Unit]
Description=Notify by email about symbiosis-monit failure

[Service]
Type=simple
ExecStart=/usr/sbin/symbiosis-monit-failure-email

@@ -1,6 +1,9 @@
[Unit]
Description=Symbiosis monitor
OnFailure=symbiosis-monit-failure-email.service

[Service]
Type=simple
ExecStartPre=/bin/sh -c 'journalctl -o cat -n 0 -u %n --show-cursor | cut -f3 -d" " | sudo -u nobody tee /var/tmp/symbiosis-monit.cursor >/dev/null'
ExecStart=/usr/sbin/symbiosis-monit -t email /etc/symbiosis/monit.d
SuccessExitStatus=75

0 comments on commit edfe6bc

Please sign in to comment.