mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-29 16:01:04 +01:00
Implemented systemctl error checker
This commit is contained in:
parent
cf66f07c4e
commit
d456905577
2
roles/native-journalctl-health-check/README.md
Normal file
2
roles/native-journalctl-health-check/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# journalctl-health-check
|
||||
Checks journalctl for error messages
|
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
echo "Checking journalctl for error messages..."
|
||||
journalctl_errors="$(journalctl --since '1 day ago' --no-pager | grep -i 'error')"
|
||||
if [ ! -z "$journalctl_errors" ]
|
||||
then
|
||||
echo "Some errors where found: $journalctl_errors"
|
||||
exit 1
|
||||
fi
|
||||
echo "All docker containers are healthy."
|
||||
exit 0
|
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=starts journalctl-health-check.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar=00:00
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
6
roles/native-journalctl-health-check/handlers/main.yml
Normal file
6
roles/native-journalctl-health-check/handlers/main.yml
Normal file
@ -0,0 +1,6 @@
|
||||
- name: "restart journalctl-health-check.timer"
|
||||
systemd:
|
||||
name: journalctl-health-check.timer
|
||||
state: restarted
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
2
roles/native-journalctl-health-check/meta/main.yml
Normal file
2
roles/native-journalctl-health-check/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- native-systemd-email
|
19
roles/native-journalctl-health-check/tasks/main.yml
Normal file
19
roles/native-journalctl-health-check/tasks/main.yml
Normal file
@ -0,0 +1,19 @@
|
||||
- name: "create {{journalctl_health_check_folder}}"
|
||||
file:
|
||||
path: "{{journalctl_health_check_folder}}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: create journalctl-health-check.sh
|
||||
copy:
|
||||
src: journalctl-health-check.sh
|
||||
dest: "{{journalctl_health_check_folder}}journalctl-health-check.sh"
|
||||
|
||||
- name: create journalctl-health-check.service
|
||||
template: src=journalctl-health-check.service.j2 dest=/etc/systemd/system/journalctl-health-check.service
|
||||
|
||||
- name: create journalctl-health-check.timer
|
||||
copy:
|
||||
src: journalctl-health-check.timer
|
||||
dest: "/etc/systemd/system/journalctl-health-check.timer"
|
||||
notify: restart journalctl-health-check.timer
|
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=checking journalctl health
|
||||
OnFailure=systemd-email@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{journalctl_health_check_folder}}journalctl-health-check.sh
|
1
roles/native-journalctl-health-check/vars/main.yml
Normal file
1
roles/native-journalctl-health-check/vars/main.yml
Normal file
@ -0,0 +1 @@
|
||||
journalctl_health_check_folder: "/home/administrator/scripts/journalctl-health-check/"
|
@ -3,5 +3,5 @@
|
||||
# live monitoring
|
||||
|
||||
```bash
|
||||
watch -n 0.5 'journalctl -n 20 --no-pager'
|
||||
'journalctl -f'
|
||||
```
|
2
roles/native-journalctl/meta/main.yml
Normal file
2
roles/native-journalctl/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- native-journalctl-health-check
|
Loading…
Reference in New Issue
Block a user