diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-07-06 03:46:34 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-07-06 03:46:34 -0400 |
commit | d4143e27f906fc4b3c65ce7e90f8d25b120c89ae (patch) | |
tree | 1658549b2eabb40ace30be7847dcae41a780ccb8 /modules/tozt | |
parent | 4e9194920e4dc688accae819e45611b161a5ea14 (diff) | |
download | puppet-tozt-d4143e27f906fc4b3c65ce7e90f8d25b120c89ae.tar.gz puppet-tozt-d4143e27f906fc4b3c65ce7e90f8d25b120c89ae.zip |
add alerts for backups
Diffstat (limited to 'modules/tozt')
-rw-r--r-- | modules/tozt/files/kapacitor/duplicati.tick | 28 | ||||
-rw-r--r-- | modules/tozt/files/kapacitor/tarsnap.tick | 28 | ||||
-rw-r--r-- | modules/tozt/manifests/tick.pp | 4 |
3 files changed, 60 insertions, 0 deletions
diff --git a/modules/tozt/files/kapacitor/duplicati.tick b/modules/tozt/files/kapacitor/duplicati.tick new file mode 100644 index 0000000..5ef1c6b --- /dev/null +++ b/modules/tozt/files/kapacitor/duplicati.tick @@ -0,0 +1,28 @@ +dbrp "telegraf"."autogen" + +var message = ''' +{{- if eq .Level "OK" -}} +backup target {{ index .Tags "name" }} is back to running +{{- else -}} +backup target {{ index .Tags "name" }} hasn't run for a while +{{- end -}} +''' + +var details = ''' +{{- if eq .Level "OK" -}} +backup target {{ index .Tags "name" }} is now {{ index .Fields "days_since_last_run" }} days since its last run +{{- else -}} +backup target {{ index .Tags "name" }} hasn't run for {{ index .Fields "days_since_last_run" }} days +{{- end -}} +''' + +stream +|from() + .measurement('duplicati') + .groupBy('name') +|min('days_since_last_run') + .as('days_since_last_run') +|alert() + .crit(lambda: "days_since_last_run" > 2) + .message(message) + .details(details) diff --git a/modules/tozt/files/kapacitor/tarsnap.tick b/modules/tozt/files/kapacitor/tarsnap.tick new file mode 100644 index 0000000..1239c69 --- /dev/null +++ b/modules/tozt/files/kapacitor/tarsnap.tick @@ -0,0 +1,28 @@ +dbrp "telegraf"."autogen" + +var message = ''' +{{- if eq .Level "OK" -}} +backup target {{ index .Tags "name" }} is back to running +{{- else -}} +backup target {{ index .Tags "name" }} hasn't run for a while +{{- end -}} +''' + +var details = ''' +{{- if eq .Level "OK" -}} +backup target {{ index .Tags "name" }} is now {{ index .Fields "days_since_last_run" }} days since its last run +{{- else -}} +backup target {{ index .Tags "name" }} hasn't run for {{ index .Fields "days_since_last_run" }} days +{{- end -}} +''' + +stream +|from() + .measurement('tarsnap') + .groupBy('name') +|min('days_since_last_run') + .as('days_since_last_run') +|alert() + .crit(lambda: "days_since_last_run" > 2) + .message(message) + .details(details) diff --git a/modules/tozt/manifests/tick.pp b/modules/tozt/manifests/tick.pp index 5071360..f0eb200 100644 --- a/modules/tozt/manifests/tick.pp +++ b/modules/tozt/manifests/tick.pp @@ -14,6 +14,10 @@ class tozt::tick { # source => 'puppet:///modules/tozt/kapacitor/disk.tick'; "certbot": source => 'puppet:///modules/tozt/kapacitor/certbot.tick'; + "tarsnap": + source => 'puppet:///modules/tozt/kapacitor/tarsnap.tick'; + "duplicati": + source => 'puppet:///modules/tozt/kapacitor/duplicati.tick'; } secret { |