Skip to content

romainsi/zabbix-VB-R-SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VEEAM-B&R-SQL

Contents


Description

This template uses SQL queries to retrieve Veeam Backup & Replication job and repository data and sends it to Zabbix using a PowerShell script.

The script supports both:

  • Microsoft SQL Server (native .NET provider)
  • PostgreSQL (via ODBC)

The script outputs JSON for discovery and dependent items.


Features

  • Supports Veeam Backup & Replication v11 → v13
  • Supports Zabbix 7.x
  • Multi-database support:
    • SQL Server (integrated or SQL authentication)
    • PostgreSQL (ODBC driver required)
  • Automatic Low-Level Discovery (LLD):
    • Jobs
    • Repositories
  • Secure credential handling via external config file
  • No hardcoded credentials in script

Requirements

  • Zabbix Agent or Zabbix Agent 2
  • PowerShell 5.1+
  • Network access to Veeam database

For SQL Server

  • TCP/IP enabled
  • SQL authentication (optional)

For PostgreSQL


Setup

1. Database Access

SQL Server

USE [VeeamBackup]
CREATE LOGIN [zabbixveeam] WITH PASSWORD = N'CHANGEME', CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF;
CREATE USER [zabbixveeam] FOR LOGIN [zabbixveeam];
EXEC sp_addrolemember 'db_datareader', 'zabbixveeam';
GO

PostgreSQL

CREATE USER zabbixveeam WITH PASSWORD 'CHANGEME';
GRANT CONNECT ON DATABASE "VeeamBackup" TO zabbixveeam;
GRANT USAGE ON SCHEMA public TO zabbixveeam;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO zabbixveeam;

2. Script Deployment

Copy script:

zabbix_vbr_jobs.ps1

to:

C:\Program Files\Zabbix Agent\scripts\

3. Create Configuration File

Create file:

zabbix_vbr.conf

Place it in the same directory as the script.


Configuration File

SQL Server Example

SQLServer=SQLSERVER\INSTANCE
SQLDatabase=VeeamBackup
SQLIntegratedSecurity=false
SQLUsername=zabbixveeam
SQLPassword=CHANGEME
VeeamServer=VEEAM01
DBProvider=SqlServer

PostgreSQL Example

SQLServer=localhost
SQLPort=5432
SQLDatabase=VeeamBackup
SQLIntegratedSecurity=false
SQLUsername=postgres
SQLPassword=CHANGEME
VeeamServer=VEEAM01
DBProvider=Postgres

Secure the file

$path = "zabbix_vbr.conf"
$acl = Get-Acl $path
$acl.SetAccessRuleProtection($true,$false)
$acl.SetAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("NT SERVICE\ZabbixAgent","Read","Allow")))
$acl.SetAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM","FullControl","Allow")))
$acl.SetAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Administrators","FullControl","Allow")))
Set-Acl $path $acl

Zabbix Configuration

Add to agent config:

UserParameter=veeam.info[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\scripts\zabbix_vbr_jobs.ps1" -Config "C:\Program Files\Zabbix Agent\scripts\zabbix_vbr.conf" -Operation "$1"

Supported keys

  • veeam.info[RepoInfo]
  • veeam.info[JobsInfo]
  • veeam.info[TotalJob]

Import Template

  • Import Template_Veeam_Backup_And_Replication.yaml
  • Link template to host

Timeout tuning

(Measure-Command { & "C:\Program Files\Zabbix Agent\scripts\zabbix_vbr_jobs.ps1" -Operation "JobsInfo" }).TotalSeconds

Items

Master Items

  • Veeam Job Info (JSON)
  • Veeam Repository Info (JSON)
  • Total number of jobs

Discovery

Jobs Discovery

Automatically discovers:

  • Backup jobs
  • Replication jobs
  • Tape jobs
  • Backup Copy jobs
  • Backup Sync jobs
  • Agent jobs
  • RMAN jobs

Job Item Prototypes

  • Result
  • Progress
  • Start / End time
  • Duration
  • Retry status
  • Failure reason
  • Size metrics
  • Speed

Repository Discovery

  • Total space
  • Free space
  • Used space
  • Percent free
  • Out-of-date status

Triggers

Global

  • No data in RepoInfo
  • No data in JobsInfo

Jobs

  • Job failed
  • Job failed (with retry)
  • Job warning
  • Job warning (with retry)
  • Job running too long

Repository

  • Low free space (default < 20%)
  • Repository out-of-date

Notes

  • PostgreSQL support is implemented but not fully tested due to lack of a Veeam environment using PostgreSQL. Feedback and validation are welcome.
  • Script supports both SQL Server and PostgreSQL transparently
  • PostgreSQL requires ODBC driver
  • Config file is mandatory (no inline credentials)
  • JSON output is consumed by dependent items

Credits

  • Original author: romainsi

  • Contributors:

  • Acknowledgements:

    • PostgreSQL support was added by adapting the existing SQL Server logic and using community PostgreSQL-related scripts from aaeMotoko and smolkik-code as reference material. Final implementation (ODBC) was AI-assisted.

Version

3.2

About

Monitore VB&R with SQL query

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors