migrated monitoring to built-in plugin
This commit is contained in:
parent
cd5a24786d
commit
3818707d45
4 changed files with 19 additions and 67 deletions
46
appinfo.yml
46
appinfo.yml
|
|
@ -3,9 +3,27 @@ mainunit: backup-manager
|
||||||
plugins:
|
plugins:
|
||||||
- type: builtin
|
- type: builtin
|
||||||
name: backups_none
|
name: backups_none
|
||||||
|
- type: builtin
|
||||||
|
name: monitoring
|
||||||
|
config:
|
||||||
|
checks:
|
||||||
|
- name: main
|
||||||
|
message: Backup manager activated
|
||||||
|
interval: 3600
|
||||||
|
okvalue: active
|
||||||
|
command: systemctl is-active --user backup-manager.timer
|
||||||
|
- name: lastrun
|
||||||
|
message: Errors last run
|
||||||
|
interval: 3600
|
||||||
|
okvalue: ""
|
||||||
|
command: cat {{ homedir }}/.backupmanager.errors
|
||||||
|
- name: lastrunrecent
|
||||||
|
message: Backup manager did not run recently
|
||||||
|
interval: 3600
|
||||||
|
okvalue: "OK"
|
||||||
|
command: '[ -f {{ homedir }}/.backupmanager.errors ] && [ $(find {{ homedir }}/.backupmanager.errors -mtime -2) ] && echo "OK" || echo "outdated"'
|
||||||
enableunits:
|
enableunits:
|
||||||
- backup-manager.timer
|
- backup-manager.timer
|
||||||
- monitor.socket
|
|
||||||
templatefiles:
|
templatefiles:
|
||||||
- src: backup-manager.timer.j2
|
- src: backup-manager.timer.j2
|
||||||
dest: ~/.config/systemd/user/backup-manager.timer
|
dest: ~/.config/systemd/user/backup-manager.timer
|
||||||
|
|
@ -14,13 +32,6 @@ templatefiles:
|
||||||
- src: backupmanager.j2
|
- src: backupmanager.j2
|
||||||
dest: ~/backupmanager
|
dest: ~/backupmanager
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
- src: monitor@.service.j2
|
|
||||||
dest: ~/.config/systemd/user/monitor@.service
|
|
||||||
- src: monitor.socket.j2
|
|
||||||
dest: ~/.config/systemd/user/monitor.socket
|
|
||||||
- src: monitor.sh.j2
|
|
||||||
dest: ~/monitor.sh
|
|
||||||
mode: "0755"
|
|
||||||
- src: monitor-test.sh.j2
|
- src: monitor-test.sh.j2
|
||||||
dest: ~/monitor-test.sh
|
dest: ~/monitor-test.sh
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
@ -93,22 +104,3 @@ configdefinition:
|
||||||
description: Repositories where the latest backup is older then timeout days will give a warning that there are no recent backups
|
description: Repositories where the latest backup is older then timeout days will give a warning that there are no recent backups
|
||||||
required:
|
required:
|
||||||
- repos
|
- repos
|
||||||
exports:
|
|
||||||
monitoring:
|
|
||||||
checks:
|
|
||||||
- name: main
|
|
||||||
message: Backup manager activated
|
|
||||||
interval: 3600
|
|
||||||
type: string
|
|
||||||
okvalue: active
|
|
||||||
- name: lastrun
|
|
||||||
message: Errors last run
|
|
||||||
interval: 3600
|
|
||||||
type: string
|
|
||||||
okvalue: ""
|
|
||||||
- name: lastrunrecent
|
|
||||||
message: Backup manager did not run recently
|
|
||||||
interval: 3600
|
|
||||||
type: string
|
|
||||||
okvalue: "OK"
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
read -r command
|
|
||||||
case $command in
|
|
||||||
main)
|
|
||||||
systemctl is-active --user backup-manager.timer
|
|
||||||
;;
|
|
||||||
lastrun)
|
|
||||||
cat {{ homedir }}/.backupmanager.errors
|
|
||||||
;;
|
|
||||||
lastrunrecent)
|
|
||||||
[ -f {{ homedir }}/.backupmanager.errors ] && [ $(find {{ homedir }}/.backupmanager.errors -mtime -2) ] && echo "OK" || echo "outdated"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Parameter unknown"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Execute Command Socket
|
|
||||||
PartOf={{ mainunit }}
|
|
||||||
|
|
||||||
[Socket]
|
|
||||||
ListenStream={{ statedir }}/{{ name }}.monitoring
|
|
||||||
Accept=yes
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy={{ mainunit }}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Execute Command Service
|
|
||||||
After=network.target
|
|
||||||
Requires=monitor.socket
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
ExecStart={{ homedir }}/monitor.sh
|
|
||||||
StandardInput=socket
|
|
||||||
StandardOutput=socket
|
|
||||||
TimeoutStopSec=5
|
|
||||||
RuntimeMaxSec=10
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue