| app | ||
| execution | ||
| locale | ||
| messaging | ||
| .env | ||
| main_config.json | ||
| monitored_targets.json | ||
| README.md | ||
| requirements.txt | ||
| state.db | ||
| watchdog_monitor.py | ||
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
.jsonand.envfiles, 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 (
.poto.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
-
Prerequisites: Ensure you have
Python 3.8+,git, andgettextinstalled.# For Debian/Ubuntu sudo apt update && sudo apt install git gettext -
Create Structure and Clone:
mkdir watchdog_project cd watchdog_project git clone [URL_TO_REPOSITORY] watchdog_core -
Create and Activate Virtual Environment:
cd watchdog_core python3 -m venv ../.venv source ../.venv/bin/activate -
Create Configuration Files: In the
watchdog_corefolder, create the filesmain_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í
.jsona.envsouborů, 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 (
.pona.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í
-
Předpoklady: Ujistěte se, že máte nainstalovaný
Python 3.8+,gitagettext.# Pro Debian/Ubuntu sudo apt update && sudo apt install git gettext -
Vytvořte strukturu a naklonujte repozitář:
mkdir watchdog_project cd watchdog_project git clone [URL_K_REPOZITARI] watchdog_core -
Vytvořte a aktivujte virtuální prostředí:
cd watchdog_core python3 -m venv ../.venv source ../.venv/bin/activate -
Vytvořte konfigurační soubory: Ve složce
watchdog_corevytvořte souborymain_config.json,monitored_targets.jsona.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.