Open Arcocide opened 1 year ago
Me to. I have problem with script. From all commands working only .\zabbix_vbr_job.ps1 RepoInfo
Help)
Hi, I would like to know if a new version of the script for Veeam B&R 12 will come out ?
When i run this script on my Veeam 12 i don't the job list (it's emply) .\zabbix_vbr_job.ps1 JobsInfo []
I don't remember what I changed, but I was able to apply it to my veeam. PS script
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory = $false)]
[ValidateSet("RepoInfo", "JobsInfo", "TotalJob")]
[System.String]$Operation
)
<#
.SYNOPSIS
Query Veeam job information
This script is intended for use with Zabbix > 6.X
.DESCRIPTION
Query Veeam job information
This script is intended for use with Zabbix > 6.X
It uses SQL queries to the Veeam database to obtain the information
Please change the values of the variables below to match your configuration
You can create the user with SQL Server Management Studio (SSMS) or with sqlcmd.exe.
Using SSMS GUI, create a new SQL user, add it to veeam's database and assign it to db_datareader role.
Alternatively, you can run the following query in either of them to create the user and grant it appropriate rights.
Change password "CHANGEME" with something more secure.
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
.INPUTS
The script takes an unnamed single argument which specifies the information to supply
RepoInfo - Get repository information
JobsInfo - Get job information
TotalJob - The number of Veeam active jobs
.OUTPUTS
System.String. Information requested depending on the parameter given
The output is JSON formated for RepoInfo and JobsInfo parameters.
TotalJob outputs a single string with the number of active jobs.
.EXAMPLE
zabbix_vbr_jobs.ps1 RepoInfo
Description
---------------------------------------
Gets information about Veeam repository
.EXAMPLE
zabbix_vbr_jobs.ps1 JobsInfo
Description
---------------------------------------
Gets information about Veeam jobs
.EXAMPLE
zabbix_vbr_jobs.ps1 TotalJob
Description
---------------------------------------
Sends total number of active Veeam jobs to Zabbix
.NOTES
Created by : Romainsi https://github.com/romainsi
Contributions: aholiveira https://github.com/aholiveira
xtonousou https://github.com/xtonousou
Version : 2.8
.LINK
https://github.com/romainsi/zabbix-VB-R-SQL
#>
########### Adjust the following variables to match your configuration ###########
$veeamserver = '' # Machine name where Veeam is installed
$SQLServer = 'nsmeserver\namesqlinstans' # Database server where Veeam database is located. Change to sqlserver.contoso.local\InstanceName if you are running an SQL named instance
$SQLIntegratedSecurity = $false # Use Windows integrated security?
$SQLuid = '' # SQL Username when using SQL Authentication - ignored if using Integrated security
$SQLpwd = '' # SQL user password
$SQLveeamdb = '' # Name of Veeam database. VeeamBackup is the default
<#
Supported job types.
You can add additional types by extending the variable below
Look into Veeam's database table [BJobs] to find more job types
If using version 2.0 or higher of the companion Zabbix template new types added here are automatically used in Zabbix
If you extend this, please inform the author so that the script can be extended
$typeNames is used in Get-SessionInfo function to send the type name to Zabbix
#>
$typeNames = @{
0 = "Job";
1 = "Replication";
2 = "File";
28 = "Tape";
51 = "Sync";
63 = "Copy";
4030 = "RMAN";
12002 = "Agent backup policy";
12003 = "Agent backup job";
}
# $jobtypes is used in SQL queries. Built automatically from the enumeration above.
$jobTypes = "($(($typeNames.Keys | Sort-Object) -join ", "))"
########### DO NOT MODIFY BELOW ###########
<#
.SYNOPSIS
Build and return a SQL connection string
It uses the variables defined at the top of the script
.INPUTS
None. The function uses the variables defined at the top of the script
.OUTPUTS
System.String. A SQL connection string
#>
function Get-ConnectionString() {
$builder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder
$builder.Add("Data Source", $SQLServer)
$builder.Add("Integrated Security", $SQLIntegratedSecurity)
$builder.Add("Initial Catalog", $SQLveeamdb)
$builder.Add("User Id", $SQLuid)
$builder.Add("Password", $SQLpwd)
Write-Debug "Connection String: $($builder.ConnectionString)"
return $builder.ConnectionString
}
<#
.SYNOPSIS
Opens a connection to the database
Retries if unsucessfull on the first try
.INPUTS
None
.OUTPUTS
System.String. A SQL connection string
#>
function Start-Connection() {
$connectionString = Get-ConnectionString
# Create a connection to MSSQL
Write-Debug "Opening SQL connection"
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()
if ($connection.State -notmatch "Open") {
# Connection open failed. Wait and retry connection
Start-Sleep -Seconds 5
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()
}
Write-Debug "SQL connection state: $($connection.State)"
return $connection
}
<#
.SYNOPSIS
Runs a query against the database given the supplied query string
.PARAMETER Command
Query string to run
.INPUTS
None
.OUTPUTS
System.Data.DataTable. A datatable object on success or $null on failure
#>
function Get-SqlCommand {
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $true)]
[System.String]$Command
)
$Connection = $null
# Use try-catch to avoid exceptions if connection to SQL cannot be opened or data cannot be read
# It either returns the data read or $null on failure
try {
$Connection = Start-Connection
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $Command
$SqlCmd.Connection = $Connection
$SqlCmd.CommandTimeout = 0
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
Write-Debug "Executing SQL query: ##$Command##"
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$retval = $DataSet.Tables[0]
}
catch {
$retval = $null
# We output the error message. This gets sent to Zabbix.
Write-Output $_.Exception.Message
}
finally {
# Make sure the connection is closed
if ($null -ne $Connection) {
$Connection.Close()
}
}
return $retval
}
<#
.SYNOPSIS
Convert to unix timestamp - Seconds elapsed since unix epoch
.PARAMETER date
System.DateTime. The reference date to convert to unix timestamp
.INPUTS
None
.OUTPUTS
System.Int. The converted date to unix timestamp or -1 if date was before the epoch
#>
function ConvertTo-Unixtimestamp {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[System.DateTime]$date
)
# Unix epoch
[System.DateTime]$unixepoch = (get-date -date "01/01/1970 00:00:00Z")
# Handle empty dates
# We make this one second less than $unixepoch.
# This makes the time calculation below return -1 to Zabbix, making the item "unsupported" while the job is running (or before it ran for the first time)
if ($null -eq $date -or $date -lt $unixepoch) {
$date = $unixepoch.AddSeconds(-1);
}
# Return the seconds elapsed between the reference date and the epoch
return [int]((New-TimeSpan -Start $unixepoch -end $date).TotalSeconds)
}
<#
.SYNOPSIS
Builds an object with the information for each job
.PARAMETER BackupSession
System.Object. An object containing job session information
.INPUTS
None
.OUTPUTS
System.Object. An object with the job information with the tags used by the Zabbix template
#>
function Get-SessionInfo {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[System.Object]$BackupSession
)
# Return $null if there is no session data
if (!$BackupSession) {
return $null
}
# Get reason for the job failure/warning
# We get all jobs reasons from both table column and log_xml
$Log = (([Xml]$BackupSession.log_xml).Root.Log | Where-Object { $_.Status -eq 'EFailed' }).Title
$reason = $BackupSession.reason
foreach ($logreason in $Log) {
$reason += "`r`n$logreason"
}
# Build the output object
Write-Debug "Building object for job: $($BackupSession.job_name)"
$Object = [PSCustomObject]@{
JOBID = $BackupSession.job_id
JOBTYPEID = $BackupSession.job_type
JOBTYPENAME = $typeNames[$BackupSession.job_type]
JOBNAME = ([System.Net.WebUtility]::HtmlEncode($BackupSession.job_name))
JOBRESULT = $BackupSession.result
JOBRETRY = $BackupSession.is_retry
JOBREASON = ([System.Net.WebUtility]::HtmlEncode($reason))
JOBPROGRESS = $BackupSession.progress
JOBSTART = (ConvertTo-Unixtimestamp $BackupSession.creation_time.ToUniversalTime())
JOBEND = (ConvertTo-Unixtimestamp $BackupSession.end_time.ToUniversalTime())
}
return $Object
}
<#
.SYNOPSIS
Queries Veeam's database to obtain information about all supported job types.
.INPUTS
None
.OUTPUTS
Job information in JSON format
#>
function Get-JobInfo() {
Write-Debug "Entering Get-JobInfo()"
# Get all active jobs
$BackupJobs = Get-SqlCommand "SELECT id, name, options FROM [BJobs] WHERE [schedule_enabled] = 'true' AND [type] IN $jobTypes ORDER BY [type], [name]"
Write-Debug "Job count: $($BackupJobs.Count)"
$return = @()
# Get information for each active job
foreach ($job in $BackupJobs) {
if (([Xml]$job.options).JobOptionsRoot.RunManually -eq "False") {
Write-Debug "Getting data for job: $($job.name)"
# Get backup jobs session information
$LastJobSessions = Get-SqlCommand "SELECT TOP 2
job_id, job_type, job_name, result, is_retry, progress, creation_time, end_time, log_xml, reason
FROM [Backup.Model.JobSessions]
INNER JOIN [Backup.Model.BackupJobSessions]
ON [Backup.Model.JobSessions].[id] = [Backup.Model.BackupJobSessions].[id]
WHERE job_id='$($job.id)'
ORDER BY creation_time DESC"
$LastJobSession = $LastJobSessions | Sort-Object end_time -Descending | Select-Object -First 1
# Exception BackupSync continuous state
if ($LastJobSession.job_type -like '51' -and $LastJobSession.state -like '9') {
$LastJobSession = $LastJobSessions | Sort-Object end_time -Descending | Select-Object -Last 1
}
$sessionInfo = Get-SessionInfo $LastJobSession
$return += $sessionInfo
}
}
Write-Verbose "Got job information. Number of jobs: $($return.Count)"
# Convert data to JSON
$return = ConvertTo-Json -Compress -InputObject @($return)
Write-Output $return
}
<#
.SYNOPSIS
Queries WIM to obtain Veeam's repository information
.INPUTS
None
.OUTPUTS
Repository information in JSON format
#>
function Get-RepoInfo() {
Write-Debug "Entering Get-RepoInfo()"
Write-Debug "Veeam server: $veeamserver"
# Get data from WIM class
$repoinfo = Get-CimInstance -Class Repository -ComputerName $veeamserver -Namespace ROOT\VeeamBS
$return = @()
# Build the output object
foreach ($item in $repoinfo) {
Write-Debug "Repository $($item.NAME)"
$Object = [PSCustomObject]@{
REPONAME = ([System.Net.WebUtility]::HtmlEncode($item.NAME))
REPOCAPACITY = $item.Capacity
REPOFREE = $item.FreeSpace
REPOOUTOFDATE = $item.OutOfDate
}
$return += $Object
}
Write-Debug "Repository count: $($return.Count)"
# Convert data to JSON
$return = ConvertTo-Json -Compress -InputObject @($return)
Write-Output $return
}
<#
.SYNOPSIS
Gets the number of active jobs from Veeam
.INPUTS
None
.OUTPUTS
The number of active jobs.
In case of an error a message is printed to standard output
#>
function Get-Totaljob() {
$BackupJobs = Get-SqlCommand "SELECT COUNT(jobs.name) as JobCount FROM [VeeamBackup].[dbo].[JobsView] jobs WHERE [Schedule_Enabled] = 'true' AND [type] IN $jobTypes"
Write-Debug $BackupJobs.ToString()
if ($null -ne $BackupJobs) {
Write-Output $BackupJobs.JobCount
}
else {
Write-Output "-- ERROR -- : No data available. Check configuration"
}
}
<#
.SYNOPSIS
Main program
Gets the requested information from Veeam
.INPUTS
None
.OUTPUTS
Requested data in JSON format to be ingested by Zabbix
In case of an error a message is printed to standard output
#>
If ($PSBoundParameters['Debug']) {
$DebugPreference = 'Continue'
}
Write-Debug "Job types: $jobTypes"
Write-Debug "Veeam server: $veeamserver"
Write-Debug "SQL server: $SQLServer"
switch ($Operation) {
"RepoInfo" {
Get-RepoInfo
}
"JobsInfo" {
Get-JobInfo
}
"TotalJob" {
Get-Totaljob
}
default {
Write-Output "-- ERROR -- : Need an option !"
Write-Output "Valid options are: RepoInfo, JobsInfo or TotalJob"
Write-Output "This script is not intended to be run directly but called by Zabbix."
}
}
Template
zabbix_export:
version: '6.2'
date: '2023-07-20T11:44:56Z'
template_groups:
-
uuid: 05241239c2e245959eabc51d0b39de96
name: Veeam
templates:
-
uuid: 6f3da5aef0d44e2692bfb3949628da5e
template: 'Veeam Backup And Replication'
name: 'Veeam Backup And Replication'
description: |
Version: 2.8
Monitor Veeam Backup and Replication job and repository information
It uses SQL queries to the Veeam database to obtain the information
To use the template:
1. Install the Zabbix agent or Zabbix agent 2 on your host.
2. Connect to the veeam sql server, adjust protocols for VEEAMSQL in "Sql Server Configuration Manager" to permit connection using TCP/IP
3. Create User/Pass with reader rights, permit to connect with local user in sql settings and specify the default database, using SQL Server Management Studio.
Alternatively you can use the following sql commands, using sqlcmd.exe:
`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`
4. In script, ajust variables on lines 73-78 to match your configuration
5. Copy `zabbix_vbr_job.ps1` in the directory : `C:\Program Files\Zabbix Agent 2\scripts\` (create folder if not exist)
6. Add `UserParameter=veeam.info[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent 2\scripts\zabbix_vbr_job.ps1" "$1"` in zabbix_agent2.conf
7. Associate the template to the host with Veeam Backup and Replication installed
Created by:
Romainsi https://github.com/romainsi
Contributions:
aholiveira https://github.com/aholiveira
xtonousou https://github.com/xtonousou
groups:
-
name: Veeam
items:
-
uuid: 8980fabd75684014aa4de0bd63d185c5
name: 'Veeam Job Info'
key: 'veeam.info[JobsInfo]'
delay: 1h
trends: '0'
value_type: TEXT
tags:
-
tag: Application
value: 'Master Items'
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Jobs'
triggers:
-
uuid: 938d938bfb064a8bbc9642ab8825e527
expression: 'nodata(/Veeam Backup And Replication/veeam.info[JobsInfo],7200s)=1'
name: 'No data on Jobs'
priority: AVERAGE
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
uuid: b4f0d0f76bfc45dfad2233b693788d10
name: 'Veeam Repository Info'
key: 'veeam.info[RepoInfo]'
delay: 1h
trends: '0'
value_type: TEXT
tags:
-
tag: Application
value: 'Master Items'
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Repository'
triggers:
-
uuid: 671f4be1ba9d41a39aec048031467920
expression: 'nodata(/Veeam Backup And Replication/veeam.info[RepoInfo],7200s)=1'
name: 'No data in RepoInfo'
priority: AVERAGE
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
uuid: 57abe94db85d49009745ab2d163fa59b
name: 'Total number of Veeam jobs'
key: 'veeam.info[TotalJob]'
delay: 1h
trends: '0'
value_type: TEXT
tags:
-
tag: Application
value: 'Master Items'
-
tag: Application
value: 'Veeam Backup and Replication'
discovery_rules:
-
uuid: 72f6223c337e4c2b88a2d7ac703db143
name: 'Veeam Jobs Discovery'
type: DEPENDENT
key: veeam.Discovery.Jobs
delay: '0'
lifetime: 1h
item_prototypes:
-
uuid: 0496e3edd6a94181a4a6a5571a150ab8
name: 'Last job duration {#JOBNAME}'
type: CALCULATED
key: 'veeam.Jobs.Duration[''{#JOBTYPEID}'',''{#JOBID}'']'
delay: 1h
units: s
params: 'last(//veeam.Jobs.LastEnd[''{#JOBTYPEID}'',''{#JOBID}''])-last(//veeam.Jobs.LastStart[''{#JOBTYPEID}'',''{#JOBID}''])'
preprocessing:
-
type: CHECK_NOT_SUPPORTED
parameters:
- ''
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: f9ee55a362db407b89d0d8094dacd381
name: 'Last End Time {#JOBNAME}'
type: DEPENDENT
key: 'veeam.Jobs.LastEnd[''{#JOBTYPEID}'',''{#JOBID}'']'
delay: '0'
units: unixtime
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.JOBID==''{#JOBID}'')].JOBEND.first()'
master_item:
key: 'veeam.info[JobsInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: b7a30412a17b4f5f8618deb8812494a2
name: 'Last run time {#JOBNAME}'
type: DEPENDENT
key: 'veeam.Jobs.LastStart[''{#JOBTYPEID}'',''{#JOBID}'']'
delay: '0'
units: unixtime
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.JOBID==''{#JOBID}'')].JOBSTART.first()'
master_item:
key: 'veeam.info[JobsInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: 0ce7808f0cbd4f28884595ecfc6a534c
name: 'Progress Backup {#JOBTYPENAME}: {#JOBNAME}'
type: DEPENDENT
key: 'veeam.Jobs.Progress[''{#JOBTYPEID}'',''{#JOBID}'']'
delay: '0'
units: '%'
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.JOBID==''{#JOBID}'')].JOBPROGRESS.first()'
master_item:
key: 'veeam.info[JobsInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: d773dc4645ce4f0d94fac0f6f1ac3e5d
name: 'Last Reason {#JOBNAME}'
type: DEPENDENT
key: 'veeam.Jobs.Reason[''{#JOBTYPEID}'',''{#JOBID}'']'
delay: '0'
trends: '0'
value_type: TEXT
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.JOBID==''{#JOBID}'')].JOBREASON.first()'
master_item:
key: 'veeam.info[JobsInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: befe5267925d49f5a82fab79c54af57c
name: 'Result backup {#JOBTYPENAME}: {#JOBNAME}'
type: DEPENDENT
key: 'veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}'']'
delay: '0'
value_type: FLOAT
valuemap:
name: VbrJsonResult
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.JOBID==''{#JOBID}'')].JOBRESULT.first()'
master_item:
key: 'veeam.info[JobsInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: 0742ac00da44467c9924f440186c5e56
name: 'Is Retry {#JOBNAME}'
type: DEPENDENT
key: 'veeam.Jobs.Retry[''{#JOBTYPEID}'',''{#JOBID}'']'
delay: '0'
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.JOBID==''{#JOBID}'')].JOBRETRY.first()'
-
type: BOOL_TO_DECIMAL
parameters:
- ''
master_item:
key: 'veeam.info[JobsInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
trigger_prototypes:
-
uuid: 06ef57742fac4fbdb906a223b75f995b
expression: 'last(/Veeam Backup And Replication/veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}''])=1 and last(/Veeam Backup And Replication/veeam.Jobs.Retry[''{#JOBTYPEID}'',''{#JOBID}''])=0 and length(last(/Veeam Backup And Replication/veeam.Jobs.Reason[''{#JOBTYPEID}'',''{#JOBID}'']))>0'
name: 'Backup {#JOBTYPENAME} {#JOBNAME} ended with Warning'
opdata: '{ITEM.LASTVALUE3}'
priority: AVERAGE
description: '{#JOBREASON}'
dependencies:
-
name: 'Backup {#JOBTYPENAME} {#JOBNAME} ended with Warning (With Retry)'
expression: 'last(/Veeam Backup And Replication/veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}''])=1 and last(/Veeam Backup And Replication/veeam.Jobs.Retry[''{#JOBTYPEID}'',''{#JOBID}''])=1 and length(last(/Veeam Backup And Replication/veeam.Jobs.Reason[''{#JOBTYPEID}'',''{#JOBID}'']))>0'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: 0bd3bd512a9342d6b69ea1099bc35cba
expression: 'last(/Veeam Backup And Replication/veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}''])=1 and last(/Veeam Backup And Replication/veeam.Jobs.Retry[''{#JOBTYPEID}'',''{#JOBID}''])=1 and length(last(/Veeam Backup And Replication/veeam.Jobs.Reason[''{#JOBTYPEID}'',''{#JOBID}'']))>0'
name: 'Backup {#JOBTYPENAME} {#JOBNAME} ended with Warning (With Retry)'
opdata: '{ITEM.LASTVALUE3}'
priority: AVERAGE
description: '{#JOBREASON}'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: 2a3bc3ccbd81458e98447c49e77303c1
expression: 'last(/Veeam Backup And Replication/veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}''])=2 and last(/Veeam Backup And Replication/veeam.Jobs.Retry[''{#JOBTYPEID}'',''{#JOBID}''])=0 and length(last(/Veeam Backup And Replication/veeam.Jobs.Reason[''{#JOBTYPEID}'',''{#JOBID}'']))>0'
name: 'Backup {#JOBTYPENAME} {#JOBNAME} Error'
opdata: '{ITEM.LASTVALUE3}'
priority: HIGH
description: '{#JOBREASON}'
dependencies:
-
name: 'Backup {#JOBTYPENAME} {#JOBNAME} Error (With Retry)'
expression: 'last(/Veeam Backup And Replication/veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}''])=2 and last(/Veeam Backup And Replication/veeam.Jobs.Retry[''{#JOBTYPEID}'',''{#JOBID}''])=1 and length(last(/Veeam Backup And Replication/veeam.Jobs.Reason[''{#JOBTYPEID}'',''{#JOBID}'']))>0'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: c8c1be6d035d441ebc9669c1e38d632b
expression: 'last(/Veeam Backup And Replication/veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}''])=2 and last(/Veeam Backup And Replication/veeam.Jobs.Retry[''{#JOBTYPEID}'',''{#JOBID}''])=1 and length(last(/Veeam Backup And Replication/veeam.Jobs.Reason[''{#JOBTYPEID}'',''{#JOBID}'']))>0'
name: 'Backup {#JOBTYPENAME} {#JOBNAME} Error (With Retry)'
opdata: '{ITEM.LASTVALUE3}'
priority: HIGH
description: '{#JOBREASON}'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
-
uuid: e09b65c222a64def80785e061f38affa
expression: 'last(/Veeam Backup And Replication/veeam.Jobs.Result[''{#JOBTYPEID}'',''{#JOBID}''])<0 and (now()-avg(/Veeam Backup And Replication/veeam.Jobs.LastStart[''{#JOBTYPEID}'',''{#JOBID}''],2m))>{$VEEAM_JOB_HOURS_WARN:"{#JOBNAME}"}*3600'
name: 'Backup {#JOBTYPENAME} {#JOBNAME} in progress > {$VEEAM_JOB_HOURS_WARN:"{#JOBNAME}"}h'
opdata: 'LastStart: {ITEM.LASTVALUE2} Progress: {ITEM.LASTVALUE1}'
priority: HIGH
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: 'Backup Job'
value: '{#JOBNAME}'
-
tag: 'Backup Type'
value: '{#JOBTYPENAME}'
graph_prototypes:
-
uuid: a784c019181e403396bb8ad933739daf
name: 'Job duration: {#JOBNAME}'
graph_items:
-
drawtype: GRADIENT_LINE
color: 199C0D
item:
host: 'Veeam Backup And Replication'
key: 'veeam.Jobs.Duration[''{#JOBTYPEID}'',''{#JOBID}'']'
master_item:
key: 'veeam.info[JobsInfo]'
lld_macro_paths:
-
lld_macro: '{#JOBID}'
path: $.JOBID
-
lld_macro: '{#JOBNAME}'
path: $.JOBNAME
-
lld_macro: '{#JOBREASON}'
path: $.JOBREASON
-
lld_macro: '{#JOBTYPEID}'
path: $.JOBTYPEID
-
lld_macro: '{#JOBTYPENAME}'
path: $.JOBTYPENAME
-
uuid: 9d3543413aeb4bc582b44cf9d03b0787
name: 'Veeam Repository'
type: DEPENDENT
key: Veeam.Discovery.Repo
delay: '0'
lifetime: 7d
item_prototypes:
-
uuid: f7c95c54aadc4a53862a4de689b42cf9
name: 'Total space repository {#REPONAME}'
type: DEPENDENT
key: 'veeam.RepoInfo.Capacity[''{#REPONAME}'']'
delay: '0'
history: 30d
trends: 90d
units: B
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.REPONAME==''{#REPONAME}'')].REPOCAPACITY.first()'
master_item:
key: 'veeam.info[RepoInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Repository'
-
uuid: 288ba9353a394ef3adb0076483b75ea4
name: 'Remaining space repository {#REPONAME}'
type: DEPENDENT
key: 'veeam.RepoInfo.FreeSpace[''{#REPONAME}'']'
delay: '0'
history: 30d
trends: 90d
units: B
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.REPONAME==''{#REPONAME}'')].REPOFREE.first()'
master_item:
key: 'veeam.info[RepoInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Repository'
-
uuid: 6a38e3e0544d4ef083ce36a8cc6a5862
name: 'Out of date {#REPONAME}'
type: DEPENDENT
key: 'veeam.RepoInfo.OutOfDate[''{#REPONAME}'']'
delay: '0'
history: 30d
preprocessing:
-
type: JSONPATH
parameters:
- '$[?(@.REPONAME==''{#REPONAME}'')].REPOOUTOFDATE.first()'
-
type: BOOL_TO_DECIMAL
parameters:
- ''
master_item:
key: 'veeam.info[RepoInfo]'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Repository'
trigger_prototypes:
-
uuid: c45376c7d61f47e4b7c30482568b1d76
expression: 'last(/Veeam Backup And Replication/veeam.RepoInfo.OutOfDate[''{#REPONAME}''])=1'
recovery_mode: RECOVERY_EXPRESSION
recovery_expression: 'last(/Veeam Backup And Replication/veeam.RepoInfo.OutOfDate[''{#REPONAME}''])=0'
name: 'Repository {#REPONAME} information is out of date'
priority: HIGH
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Repository'
-
uuid: 351fcc7e69b1472b8a09a02470082e13
name: 'Percent free space on {#REPONAME}'
type: CALCULATED
key: 'veeam.RepoInfo.PercentFree[''{#REPONAME}'']'
delay: 10m
value_type: FLOAT
units: '%'
params: 'last(//veeam.RepoInfo.FreeSpace[''{#REPONAME}''])/last(//veeam.RepoInfo.Capacity[''{#REPONAME}''])*100'
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Repository'
trigger_prototypes:
-
uuid: 6788ff77c1d34b34b4eeec6805c5d98b
expression: 'last(/Veeam Backup And Replication/veeam.RepoInfo.PercentFree[''{#REPONAME}''])<{$VEEAM_REPO_FREE_WARN:"{#REPONAME}"}'
name: 'Less than {$VEEAM_REPO_FREE_WARN:"{#REPONAME}"}% remaining on the repository {#REPONAME}'
opdata: 'Current value: {ITEM.LASTVALUE1}'
priority: HIGH
tags:
-
tag: Application
value: 'Veeam Backup and Replication'
-
tag: Application
value: 'Veeam Repository'
graph_prototypes:
-
uuid: 36f1adb2dd3c46648799202f4cae3e14
name: 'Percent free repository {#REPONAME}'
graph_items:
-
color: 1A7C11
item:
host: 'Veeam Backup And Replication'
key: 'veeam.RepoInfo.PercentFree[''{#REPONAME}'']'
-
uuid: 30818fc98c734dc18c88d91c0f0c829a
name: 'Remaining repository space {#REPONAME}'
graph_items:
-
sortorder: '1'
color: 1A7C11
item:
host: 'Veeam Backup And Replication'
key: 'veeam.RepoInfo.FreeSpace[''{#REPONAME}'']'
master_item:
key: 'veeam.info[RepoInfo]'
lld_macro_paths:
-
lld_macro: '{#REPONAME}'
path: $.REPONAME
tags:
-
tag: class
value: application
-
tag: target
value: veeam-backup-and-replication
macros:
-
macro: '{$VEEAM_JOB_HOURS_WARN}'
value: '8'
-
macro: '{$VEEAM_REPO_FREE_WARN}'
value: '20'
valuemaps:
-
uuid: cf1d0998a2644d90a948725c37df5fbd
name: VbrJsonResult
mappings:
-
value: '-1'
newvalue: InProgress
-
value: '0'
newvalue: Success
-
value: '1'
newvalue: Warning
-
value: '2'
newvalue: Error
-
uuid: 38e521dc4ad54ac18741ed55765f4f84
name: veeamTypeMap
mappings:
-
value: '0'
newvalue: Job
-
value: '1'
newvalue: Replication
-
value: '2'
newvalue: File
-
value: '28'
newvalue: Tape
-
value: '51'
newvalue: Sync
-
value: '63'
newvalue: Copy
-
value: '4030'
newvalue: RMAN
-
value: '12002'
newvalue: AgentBackupPolicy
-
value: '12003'
newvalue: AgentBackupJob
Did you double check, that your credentials are actually correct? The script eats error messages and just outputs no data, if the crednetials for SQL server access are incorrect. For me the SQL server only had Windows authentication enabled, leading to the script failing. After enabling mixed authentication, eaming Windows Authentication + SQL Server authentication it started working normally. Even with Veeam 12.
Hi, I would like to know if a new version of the script for Veeam B&R 12 will come out ?
When i run this script on my Veeam 12 i don't the job list (it's emply) .\zabbix_vbr_job.ps1 JobsInfo []