mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Renamed health services
This commit is contained in:
8
roles/health-btrfs/README.md
Normal file
8
roles/health-btrfs/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# health-btrfs
|
||||
|
||||
Sends a health report
|
||||
|
||||
## see
|
||||
- https://superuser.com/questions/789303/how-to-monitor-btrfs-filesystem-raid-for-errors
|
||||
- https://unix.stackexchange.com/questions/193619/list-all-btrfs-filesystems-and-subvolumes-in-shell
|
||||
- https://www.freedesktop.org/software/systemd/man/systemd.unit.html
|
11
roles/health-btrfs/files/health-btrfs.sh
Normal file
11
roles/health-btrfs/files/health-btrfs.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
exit_code=0
|
||||
for path in $(btrfs filesystem show | awk '/ path /{print $NF}')
|
||||
do
|
||||
echo "Checking health for $path..."
|
||||
result=$(btrfs device stats $path)
|
||||
echo "$result"
|
||||
regex='\.(.*)_errs(\s*)[1-9]'
|
||||
[[ "$result" =~ $regex ]] && echo "Errors found!" && exit_code=1;
|
||||
done
|
||||
exit $exit_code
|
12
roles/health-btrfs/handlers/main.yml
Normal file
12
roles/health-btrfs/handlers/main.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
- name: "reload health-btrfs.service"
|
||||
systemd:
|
||||
name: health-btrfs.service
|
||||
state: reloaded
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
- name: "restart health-btrfs.timer"
|
||||
systemd:
|
||||
name: health-btrfs.timer
|
||||
state: restarted
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
2
roles/health-btrfs/meta/main.yml
Normal file
2
roles/health-btrfs/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- systemd_notifier
|
22
roles/health-btrfs/tasks/main.yml
Normal file
22
roles/health-btrfs/tasks/main.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
- name: "create {{docker_btrfs_health_check_folder}}"
|
||||
file:
|
||||
path: "{{docker_btrfs_health_check_folder}}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: create health-btrfs.sh
|
||||
copy:
|
||||
src: health-btrfs.sh
|
||||
dest: "{{docker_btrfs_health_check_folder}}health-btrfs.sh"
|
||||
|
||||
- name: create health-btrfs.service
|
||||
template:
|
||||
src: health-btrfs.service.j2
|
||||
dest: /etc/systemd/system/health-btrfs.service
|
||||
notify: reload health-btrfs.service
|
||||
|
||||
- name: create health-btrfs.timer
|
||||
template:
|
||||
src: health-btrfs.timer.j2
|
||||
dest: "/etc/systemd/system/health-btrfs.timer"
|
||||
notify: restart health-btrfs.timer
|
7
roles/health-btrfs/templates/health-btrfs.service.j2
Normal file
7
roles/health-btrfs/templates/health-btrfs.service.j2
Normal file
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=Check btrfs status
|
||||
OnFailure=systemd-notifier@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{docker_btrfs_health_check_folder}}health-btrfs.sh
|
10
roles/health-btrfs/templates/health-btrfs.timer.j2
Normal file
10
roles/health-btrfs/templates/health-btrfs.timer.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=starts health-btrfs.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{on_calendar_btrfs_health_check}}
|
||||
RandomizedDelaySec={{randomized_delay_sec}}
|
||||
Persistent=false
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
1
roles/health-btrfs/vars/main.yml
Normal file
1
roles/health-btrfs/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
docker_btrfs_health_check_folder: "{{path_administrator_scripts}}health-btrfs/"
|
Reference in New Issue
Block a user