# pengutronix/monitoring-check-dirvish architecture

> Architecture diagram of the GitHub repository pengutronix/monitoring-check-dirvish, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pengutronix/monitoring-check-dirvish
- Repository: https://github.com/pengutronix/monitoring-check-dirvish

## Overview

##### Project type and purpose
- This is a CLI-based monitoring plugin suite for Dirvish backups.
- Its purpose is to check the age and duration of Dirvish vault backups, generate include lists, and emit Nagios-compatible status codes.

##### File structure
- Top-level scripts:
- check_dirvish.py       – main Nagios-style check.
- dirvish_backup_time.py – computes backup age/duration.
- generate_full_backup_includes.py – builds include lists for full backups.
- No subdirectories: all logic lives in these three modules.
- LICENSE.txt and README.md for metadata; no build or deploy scripts.

##### README for additional insights
- Command-line interface with options for warning/critical thresholds, timeouts, base path, etc.
- Outputs Nagios plugin exit codes and performance data.
- BSD zero-clause license.

##### Main components and their interactions
a. check_dirvish.py (CLI driver)
- Parses arguments (vault name, thresholds, base path, timeout).
- Calls into dirvish_backup_time.py to get last backup timestamp and duration.
- Optionally invokes generate_full_backup_includes.py for include-file generation.
- Formats output and exits with OK/WARNING/CRITICAL codes.

b. dirvish_backup_time.py (utility module)
- Scans a vault directory on disk (/srv/backup/<vault>/…)
- Determines age of the latest backup and time taken.
- Returns results in a structured form to the caller.

c. generate_full_backup_includes.py (helper module)
- Reads directory trees to build a file-list for full backups.
- Outputs include patterns for Dirvish configuration.

d. File system (Dirvish vault store)
- Physical directory structure under the “base path.”
- Contains backup snapshots, logs, etc.

e. Monitoring system (e.g., Nagios/Icinga)
- Invokes check_dirvish.py on a schedule (via NRPE or local cron).
- Collects service status and performance data.
- Sends alerts when thresholds are crossed.

##### Architectural patterns and design principles
- Single-responsibility: each script/module focuses on one piece of functionality.
- CLI-driven, composable utilities: small modules invoked by a master script.
- Standard exit codes and perf-data formatting for Nagios integration.
- No external database—relies on the file system as the data source.

##### Final checklist
- [ ] All three modules (check_dirvish, backup_time, include_generator) clearly represented.
- [ ] Vault file system as a data store.
- [ ] Monitoring server invoking the plugin and receiving statuses.
- [ ] Notes on configurable parameters (base path, thresholds, timeout).

This structure ensures you capture every essential piece of the monitoring plugin architecture without overcomplication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Monitoring Server
    Monitoring(("Monitoring Server\n(Nagios/Icinga)")):::external

    %% Core Scripts Group
    subgraph "Core Scripts"
        check["check_dirvish.py\n(parse args: vault, thresholds, base path, timeout)\n(format output)"]:::core
        backup["dirvish_backup_time.py"]:::core
        includes["generate_full_backup_includes.py"]:::core
    end

    %% External Vault File System
    vault[(Vault File System)]:::external

    %% Connections
    Monitoring -->|"invoke via NRPE/cron"| check
    check -->|"exit code + perf data"| Monitoring
    check -->|"get backup age/duration"| backup
    check -->|"generate include list (optional)"| includes
    backup -->|"read backup dirs/logs"| vault
    includes -->|"scan file tree"| vault

    %% Click Events
    click check "https://github.com/pengutronix/monitoring-check-dirvish/blob/master/check_dirvish.py"
    click backup "https://github.com/pengutronix/monitoring-check-dirvish/blob/master/dirvish_backup_time.py"
    click includes "https://github.com/pengutronix/monitoring-check-dirvish/blob/master/generate_full_backup_includes.py"

    %% Styles
    classDef core fill:#e0ffe0,stroke:#2f6627,stroke-width:2px;
    classDef external fill:#e0e0ff,stroke:#1f3f7f,stroke-width:2px;
```
