mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Shorted monitor-bot- to mon-bot-
This commit is contained in:
13
roles/mon-bot-journalctl/README.md
Normal file
13
roles/mon-bot-journalctl/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# mon-bot-journalctl
|
||||
|
||||
## Description
|
||||
Scans `journalctl` over the last day for “error” entries and alerts if any are found.
|
||||
|
||||
## Features
|
||||
- Runs `journalctl --since '1 day ago' | grep -i error`.
|
||||
- Exits non-zero on matches.
|
||||
- Scheduled via systemd timer.
|
||||
- Alerts via `alert-compose` on detection.
|
||||
|
||||
## Usage
|
||||
Include the role; set `on_calendar_health_journalctl` for your preferred schedule.
|
10
roles/mon-bot-journalctl/files/mon-bot-journalctl.sh
Normal file
10
roles/mon-bot-journalctl/files/mon-bot-journalctl.sh
Normal file
@@ -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
|
5
roles/mon-bot-journalctl/handlers/main.yml
Normal file
5
roles/mon-bot-journalctl/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
- name: "reload mon-bot-journalctl.cymais.service"
|
||||
systemd:
|
||||
name: mon-bot-journalctl.cymais.service
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
24
roles/mon-bot-journalctl/meta/main.yml
Normal file
24
roles/mon-bot-journalctl/meta/main.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: "Searches the systemd journal for errors over the past day and alerts if any are found."
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
license: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Archlinux
|
||||
versions: ["rolling"]
|
||||
galaxy_tags:
|
||||
- monitor
|
||||
- journalctl
|
||||
- logs
|
||||
- health
|
||||
- systemd
|
||||
repository: "https://s.veen.world/cymais"
|
||||
documentation: "https://s.veen.world/cymais"
|
||||
dependencies:
|
||||
- alert-compose
|
36
roles/mon-bot-journalctl/tasks/main.yml
Normal file
36
roles/mon-bot-journalctl/tasks/main.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
- name: "create {{health_journalctl_folder}}"
|
||||
file:
|
||||
path: "{{health_journalctl_folder}}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
when: run_once_health_journalctl is not defined
|
||||
|
||||
- name: create mon-bot-journalctl.sh
|
||||
copy:
|
||||
src: mon-bot-journalctl.sh
|
||||
dest: "{{health_journalctl_folder}}mon-bot-journalctl.sh"
|
||||
when: run_once_health_journalctl is not defined
|
||||
|
||||
- name: create mon-bot-journalctl.cymais.service
|
||||
template:
|
||||
src: mon-bot-journalctl.service.j2
|
||||
dest: /etc/systemd/system/mon-bot-journalctl.cymais.service
|
||||
notify: reload mon-bot-journalctl.cymais.service
|
||||
when: run_once_health_journalctl is not defined
|
||||
|
||||
- name: set service_name to the name of the current role
|
||||
set_fact:
|
||||
service_name: "{{ role_name }}"
|
||||
when: run_once_health_journalctl is not defined
|
||||
|
||||
- name: "include role for generic-timer for {{service_name}}"
|
||||
include_role:
|
||||
name: generic-timer
|
||||
vars:
|
||||
on_calendar: "{{on_calendar_health_journalctl}}"
|
||||
when: run_once_health_journalctl is not defined
|
||||
|
||||
- name: run the health_journalctl tasks once
|
||||
set_fact:
|
||||
run_once_health_journalctl: true
|
||||
when: run_once_health_journalctl is not defined
|
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=checking journalctl health
|
||||
OnFailure=alert-compose.cymais@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{health_journalctl_folder}}mon-bot-journalctl.sh
|
1
roles/mon-bot-journalctl/vars/main.yml
Normal file
1
roles/mon-bot-journalctl/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
health_journalctl_folder: "{{path_administrator_scripts}}mon-bot-journalctl/"
|
Reference in New Issue
Block a user