Skip to main content

Transform Bacula / Bareos job results into an Icinga2 API passive check result. This is designed to be used with a RunScript after the job has completed on the agent.

Project description

passify-bareos

A script for transforming Bacula / Bareos job results into an Icinga2 API passive check result. This is designed to be used with a RunScript after the job has completed on the agent.

Installation

  1. Clone this repository to your server.
  2. Create a configuration file or run the script interactively for the first time to provide the required information:
    • Icinga Master API URL (submissions are only possible through the currently active master).
    • Verify the fingerprint:
      openssl x509 -in /var/lib/icinga2/certs/<hostname>.crt -noout -fingerprint -sha256
      
    • Username and password for API submission (only basic-auth is currently supported).

Alternatively, deploy a configuration file (config.ini by default) alongside the script:

[DEFAULT]
url = https://localhost:5665/v1/actions/process-check-result
check_source = example.com
user = <api_user>
password = <api_password>

[TLS]
fingerprint = d163f22c2021a498926ff8c30da0288ac20d1b9edaa80d1dbb14c0aebf85245b

Creating an API User for Passive Result Submission

Add the following configuration to /etc/icinga2/features-available/api.conf on the master:

object ApiUser "<api_user>" {
  permissions = [ "actions/process-check-result" ]
  password = "<api_password>"
}

Ensure that the API feature in Icinga2 is activated.

Deployment

Usage

usage: passify-bareos.py [-h] [--config CONFIG] [--timeout TIMEOUT] [--ttl TTL] -s SERVICE_NAME [--prefix-time]
                         {Backup} {Full,Differential,Incremental,VirtualFull} {OK,Error,Fatal Error,Canceled,Differences,Unknown term code} JOB_UID size

Positional Arguments:

  • {Backup}: Bareos job type (currently only Backup is supported).
  • {Full,Differential,Incremental,VirtualFull}: Backup job level.
  • {OK,Error,Fatal Error,Canceled,Differences,Unknown term code}: Backup job result value.
  • JOB_UID: Unique job name (e.g., jobname.date.time...).
  • size: Number of processed bytes for the backup job.

Options:

  • -h, --help: Show help message and exit.
  • --config CONFIG: Path to configuration file (default: config.ini).
  • --timeout TIMEOUT: Optional execution timeout in seconds.
  • --ttl TTL: Time-to-live argument for Icinga API.
  • -s SERVICE_NAME: Specify the service name.
  • --prefix-time: Prefix the service name with the scheduled time.

Integration into Bacula / Bareos

To integrate, create a RunScript directive inside your job definition and add a passive check to your Icinga instance.

Job Definition

Add the following RunScript directive inside your job configuration:

RunScript {
    RunsWhen = After
    RunsOnSuccess = Yes
    RunsOnFailure = Yes
    RunsOnClient = Yes
    FailJobOnError = No
    Command = "/bin/bash -c '/usr/local/bin/passify-bareos/src/passify-bareos/passify-bareos.py --prefix-time -s \"backup check\" \"%t\" \"%l\" \"%e\" \"%j\" \"%b\"'"
}

Modify the Command as needed, but note that the interface is designed to take these parameters in this sequence.

Icinga Passive Check

Add a passive check for the host where the agent/filedaemon runs and should be backed up.

Example Icinga Director configuration:

object Service "23:00 backup check" {
    host_name = "example.com"
    check_command = "passive-crit"
    max_check_attempts = "1"
    check_interval = 1d
    retry_interval = 15s
    enable_active_checks = true
    enable_passive_checks = true
    enable_perfdata = true
    volatile = false
    command_endpoint = host_name
    vars.dummy_state = 2
}

Setting dummy_state = 2 marks a missing passive check as critical, as it likely indicates that a backup was not completed at all. Modify the check interval to the shortest expected backup completion window.

Monitoring Multiple Backup Jobs per Host in 24h

To monitor multiple backup jobs per day:

  • Create one check per backup time window.
  • Prefix the service name with the scheduled backup time (e.g., 23:00).
  • Use the --prefix-time option to dynamically match the expected backup time.

Changelog:

  • reduced time granularity to bareos config format specification granularity

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icinga_passify_bareos-0.1.4.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

icinga_passify_bareos-0.1.4-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file icinga_passify_bareos-0.1.4.tar.gz.

File metadata

  • Download URL: icinga_passify_bareos-0.1.4.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for icinga_passify_bareos-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f16b5c70d6461fab4e62470686811f93b96b51ec69d52976da48061d6183aba5
MD5 891ba6c9b8e1910bf258af7576f48f0d
BLAKE2b-256 7ee7bb8b207f09ca571c75a0fbd2d8e4c35669ac2f51c7a56435b54e22b37293

See more details on using hashes here.

File details

Details for the file icinga_passify_bareos-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for icinga_passify_bareos-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a6316848d34a0b1ce43a5451807dcd21fb6556a09e6583b1d6c4cd6c06c358ee
MD5 ec39293d0f0bfd1022ef010d7d847b62
BLAKE2b-256 85c2ff0eac988bb6244abf1c745236cbca34a707894331c475ba633c648d89a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page