Shorted monitor-bot- to mon-bot-

This commit is contained in:
2025-07-09 03:22:01 +02:00
parent dd1aab70fb
commit ae5f021b8d
82 changed files with 150 additions and 150 deletions

View 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.

View 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

View File

@@ -0,0 +1,5 @@
- name: "reload mon-bot-journalctl.cymais.service"
systemd:
name: mon-bot-journalctl.cymais.service
enabled: yes
daemon_reload: yes

View 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

View 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

View File

@@ -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

View File

@@ -0,0 +1 @@
health_journalctl_folder: "{{path_administrator_scripts}}mon-bot-journalctl/"