No description
Find a file
2025-09-16 14:39:20 +00:00
app first commit 2025-09-16 14:39:20 +00:00
execution first commit 2025-09-16 11:13:27 +00:00
locale Initial commit of the installer 2025-09-15 14:03:49 +00:00
messaging first commit 2025-09-16 11:13:27 +00:00
.env Initial commit of the installer 2025-09-15 14:03:49 +00:00
main_config.json Initial commit of the installer 2025-09-15 14:03:49 +00:00
monitored_targets.json Initial commit of the installer 2025-09-15 14:03:49 +00:00
README.md Initial commit of the installer 2025-09-15 14:03:49 +00:00
requirements.txt Initial commit of the installer 2025-09-15 14:03:49 +00:00
state.db Initial commit of the installer 2025-09-15 14:03:49 +00:00
watchdog_monitor.py first commit 2025-09-16 14:39:20 +00:00

Watchdog Core

An autonomous monitoring and automation system designed to ensure the maximum availability and stability of IT infrastructure. The core of the system is responsible for orchestrating checks, detecting state changes, and executing actions through modular extensions.

Key Features

  • Fully Modular Architecture: All specific logic (notifications, actions, checks) is implemented in separate, independent modules managed as standalone Git repositories.
  • Automatic Module Management: The core automatically handles downloading (git clone) of missing modules and installing their dependencies (requirements.txt).
  • Configuration-Driven: The system's behavior is fully controlled by .json and .env files, with no need to modify the code.
  • Full Internationalization (i18n) Support: All output is translated into the language defined in the configuration. The system also automatically and intelligently compiles translation files (.po to .mo) on startup.
  • Automatic Restart: The application restarts itself after a module is added or removed to ensure proper loading and consistency.

Project Structure

The project expects the following directory structure for proper operation:


/watchdog\_project/
|
|-- .venv/                    \# Python virtual environment
|
|-- watchdog\_core/            \# This repository
|   |-- .env                  \# File for sensitive data (API tokens, passwords)
|   |-- main\_config.json      \# Main configuration for the core and modules
|   |-- monitored\_targets.json\# List of monitored targets
|   |-- watchdog\_monitor.py   \# Main execution script
|   ` -- ...                   # Other core files |  `-- [module-name]/            \# A cloned module as a sibling of the core
\`-- ...

Installation and Setup

  1. Prerequisites: Ensure you have Python 3.8+, git, and gettext installed.

    # For Debian/Ubuntu
    sudo apt update && sudo apt install git gettext
    
  2. Create Structure and Clone:

    mkdir watchdog_project
    cd watchdog_project
    git clone [URL_TO_REPOSITORY] watchdog_core
    
  3. Create and Activate Virtual Environment:

    cd watchdog_core
    python3 -m venv ../.venv
    source ../.venv/bin/activate
    
  4. Create Configuration Files: In the watchdog_core folder, create the files main_config.json, monitored_targets.json, and .env. In the future, this step will be handled by an interactive installer.

Configuration

main_config.json

The main configuration file for the core's behavior and module management.

Key (general) Type Description
language string Language code for the output (cs, en).
git_module_base_url string The base URL for the module Git repositories.
check_interval_seconds integer The main loop interval in seconds.
auto_uninstall_modules boolean If true, deletes folders of modules that are not enabled.

monitored_targets.json

A list of targets for the system to monitor.

Key Type Description
name string A unique name for the target.
ip string IP address or hostname.
check_methods array A list of checks to perform (e.g., ["ping", "port_check"]).
action_on_failure array A list of actions to execute on failure (e.g., ["notify:telegram"]).
action_on_recovery array A list of actions to execute on recovery.

.env

A file for sensitive data. It is not part of the Git repository and must be created manually or by a future installer. It contains variables required by various modules.

# Example for watchdog-telegram-notifier
TELEGRAM_BOT_TOKEN="<YOUR_TOKEN_FROM_BOTFATHER>"
TELEGRAM_CHAT_ID="<YOUR_CHAT_ID>"

Usage

The application is run from the core's root directory:

# Make sure your virtual environment is activated
python3 watchdog_monitor.py

On first run, Watchdog will automatically download and install all modules defined in main_config.json.

License

This project is licensed under the MIT License.


Watchdog Core (Česká verze)

Autonomní monitorovací a automatizační systém navržený pro zajištění maximální dostupnosti a stability IT infrastruktury. Jádro systému je zodpovědné za orchestraci kontrol, detekci změn stavu a spouštění akcí prostřednictvím modulárních rozšíření.

Klíčové Vlastnosti

  • Plně Modulární Architektura: Veškerá specifická logika (notifikace, akce, kontroly) je implementována v samostatných, oddělených modulech, které jsou spravovány jako samostatné Git repozitáře.
  • Automatická Správa Modulů: Jádro se samo stará o stahování (git clone) chybějících modulů a instalaci jejich závislostí (requirements.txt).
  • Řízení Pomocí Konfigurace: Chování systému je plně řízeno pomocí .json a .env souborů, bez nutnosti zasahovat do kódu.
  • Plná Podpora Překladů (i18n): Veškerý výstup je přeložen do jazyka definovaného v konfiguraci. Systém navíc automaticky a inteligentně kompiluje překladové soubory (.po na .mo) při startu.
  • Automatický Restart: Aplikace se sama restartuje po přidání nebo odebrání modulu, aby se zajistilo správné načtení a konzistence.

Struktura Projektu

Projekt očekává následující adresářovou strukturu pro správné fungování:

/watchdog_project/
|
|-- .venv/                    # Virtuální prostředí Pythonu
|
|-- watchdog_core/            # Tento repozitář
|   |-- .env                  # Soubor s citlivými údaji (API tokeny, hesla)
|   |-- main_config.json      # Hlavní konfigurace jádra a modulů
|   |-- monitored_targets.json# Seznam monitorovaných cílů
|   |-- watchdog_monitor.py   # Hlavní spouštěcí skript
|   `-- ...                   # Ostatní soubory jádra
|
`-- [nazev-modulu]/         # Naklonovaný modul jako sourozenec jádra
    `-- ...

Instalace a Nastavení

  1. Předpoklady: Ujistěte se, že máte nainstalovaný Python 3.8+, git a gettext.

    # Pro Debian/Ubuntu
    sudo apt update && sudo apt install git gettext
    
  2. Vytvořte strukturu a naklonujte repozitář:

    mkdir watchdog_project
    cd watchdog_project
    git clone [URL_K_REPOZITARI] watchdog_core
    
  3. Vytvořte a aktivujte virtuální prostředí:

    cd watchdog_core
    python3 -m venv ../.venv
    source ../.venv/bin/activate
    
  4. Vytvořte konfigurační soubory: Ve složce watchdog_core vytvořte soubory main_config.json, monitored_targets.json a .env. V budoucnu bude tento krok zajišťovat interaktivní instalátor.

Konfigurace

main_config.json

Hlavní konfigurační soubor pro chování jádra a správu modulů.

Klíč (general) Typ Popis
language string Kód jazyka pro výstup (cs, en).
git_module_base_url string Základní URL k Git repozitářům modulů.
check_interval_seconds integer Interval hlavní smyčky v sekundách.
auto_uninstall_modules boolean Pokud true, smaže složky modulů, které nejsou povolené.

monitored_targets.json

Seznam cílů, které má systém monitorovat.

Klíč Typ Popis
name string Unikátní název cíle.
ip string IP adresa nebo hostname.
check_methods array Seznam kontrol, které se mají provést (např. ["ping", "port_check"]).
action_on_failure array Seznam akcí při výpadku (např. ["notify:telegram"]).
action_on_recovery array Seznam akcí při obnově.

.env

Soubor pro citlivé údaje. Není součástí Git repozitáře a musí být vytvořen manuálně nebo pomocí budoucího instalátoru. Obsahuje proměnné vyžadované jednotlivými moduly.

# Příklad pro watchdog-telegram-notifier
TELEGRAM_BOT_TOKEN="<TOKEN_OD_BOTFATHER>"
TELEGRAM_CHAT_ID="<ID_VASEHO_CHATU>"

Použití

Aplikace se spouští z kořenové složky jádra:

# Ujistěte se, že máte aktivované virtuální prostředí
python3 watchdog_monitor.py

Při prvním spuštění si Watchdog sám stáhne a nainstaluje všechny moduly definované v main_config.json.

Licence

Tento projekt je licencován pod licencí MIT.