Skip to content

Commit

Permalink
Merge branch 'stretch-monit-systemd-timer' into 'stretch'
Browse files Browse the repository at this point in the history
Run symbiosis-monit from a systemd timer.

See merge request !48
  • Loading branch information
Patrick J Cherry committed Jun 13, 2017
2 parents 11a27d1 + 3b33240 commit 2f56ec4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion monit/debian/control
Expand Up @@ -3,7 +3,7 @@ Section: web
Priority: extra
Maintainer: James Carter <jcarter@bytemark.co.uk>
Uploaders: Patrick J Cherry <patrick@bytemark.co.uk>, Steve Kemp <steve@bytemark.co.uk>
Build-Depends: debhelper (>= 7.0.0), txt2man, gem2deb, ruby
Build-Depends: debhelper (>= 7.0.0), txt2man, gem2deb, ruby, dh-systemd
Standards-Version: 3.9.6
XS-Ruby-Versions: all

Expand Down
2 changes: 1 addition & 1 deletion monit/debian/rules
Expand Up @@ -14,7 +14,7 @@
#export DH_RUBY_GEMSPEC=gem.gemspec

%:
dh $@ --buildsystem=ruby --with ruby
dh $@ --buildsystem=ruby --with ruby,systemd

override_dh_auto_build-indep:
$(MAKE) all
Expand Down
4 changes: 2 additions & 2 deletions monit/debian/symbiosis-monit.install
@@ -1,6 +1,6 @@
sbin/symbiosis-monit usr/sbin/
sbin/* usr/sbin/
monit.d/* usr/share/symbiosis/monit/checks/
templates/* usr/share/symbiosis/monit/
lib/* usr/lib/ruby/vendor_ruby/
test.d/* etc/symbiosis/test.d/

system/* lib/systemd/system/
8 changes: 8 additions & 0 deletions monit/sbin/symbiosis-monit-failure-email
@@ -0,0 +1,8 @@
#!/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
6 changes: 6 additions & 0 deletions monit/system/symbiosis-monit-failure-email.service
@@ -0,0 +1,6 @@
[Unit]
Description=Notify by email about symbiosis-monit failure

[Service]
Type=simple
ExecStart=/usr/sbin/symbiosis-monit-failure-email
8 changes: 8 additions & 0 deletions monit/system/symbiosis-monit.service
@@ -0,0 +1,8 @@
[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
9 changes: 9 additions & 0 deletions monit/system/symbiosis-monit.timer
@@ -0,0 +1,9 @@
[Unit]
Description=Regularly execute symbiosis-monit.service

[Timer]
# run every 2 minutes
OnCalendar=*:0/2

[Install]
WantedBy=timers.target

0 comments on commit 2f56ec4

Please sign in to comment.