Renamed health services

This commit is contained in:
2023-11-16 15:32:29 +01:00
parent 04f69aefde
commit d9d6c8060a
47 changed files with 162 additions and 162 deletions

View 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

View 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

View 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

View File

@@ -0,0 +1,2 @@
dependencies:
- systemd_notifier

View 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

View 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

View 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

View File

@@ -0,0 +1 @@
docker_btrfs_health_check_folder: "{{path_administrator_scripts}}health-btrfs/"