Revert "Discover Veeam jobs as individual Zabbix items"
This reverts commit 5c06c90abb.
This commit is contained in:
@@ -213,35 +213,6 @@ function ConvertTo-ZabbixDateTime {
|
||||
return $text
|
||||
}
|
||||
|
||||
function ConvertTo-ZabbixJobKey {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name
|
||||
)
|
||||
|
||||
$bytes = [System.Text.Encoding]::UTF8.GetBytes($Name)
|
||||
|
||||
return [Convert]::ToBase64String($bytes).TrimEnd('=') -replace '\+', '-' -replace '/', '_'
|
||||
}
|
||||
|
||||
function ConvertTo-ZabbixText {
|
||||
param(
|
||||
[object]$Value
|
||||
)
|
||||
|
||||
if ($null -eq $Value) {
|
||||
return '-'
|
||||
}
|
||||
|
||||
$text = [string]$Value
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($text)) {
|
||||
return '-'
|
||||
}
|
||||
|
||||
return $text
|
||||
}
|
||||
|
||||
function Get-VeeamJobScheduleEnabled {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
@@ -530,25 +501,19 @@ function Get-VeeamJobMetrics {
|
||||
$lastResult = Get-VeeamJobLastResult -Job $_ -LastSession $lastSession
|
||||
$lastState = Get-VeeamJobLastState -Job $_ -LastSession $lastSession
|
||||
$restorePoints = $null
|
||||
$enabledNumeric = if ($scheduleEnabled -eq $false) { 0 } else { 1 }
|
||||
|
||||
if ($restorePointCounts.ContainsKey($jobName)) {
|
||||
$restorePoints = $restorePointCounts[$jobName]
|
||||
}
|
||||
|
||||
[ordered]@{
|
||||
key = ConvertTo-ZabbixJobKey -Name $jobName
|
||||
name = $jobName
|
||||
enabled = $scheduleEnabled
|
||||
enabled_numeric = $enabledNumeric
|
||||
enabled_text = if ($enabledNumeric -eq 1) { 'yes' } else { 'no' }
|
||||
last_run = ConvertTo-ZabbixText -Value (Get-VeeamJobLastRun -Job $_ -LastSession $lastSession)
|
||||
next_run = ConvertTo-ZabbixText -Value (Get-VeeamJobNextRun -Job $_)
|
||||
last_result = ConvertTo-ZabbixText -Value $lastResult
|
||||
last_state = ConvertTo-ZabbixText -Value $lastState
|
||||
result = ConvertTo-ZabbixText -Value $(if ($null -ne $lastResult) { $lastResult } else { $lastState })
|
||||
restore_points = $restorePoints
|
||||
restore_points_text = ConvertTo-ZabbixText -Value $restorePoints
|
||||
name = $jobName
|
||||
enabled = $scheduleEnabled
|
||||
last_run = Get-VeeamJobLastRun -Job $_ -LastSession $lastSession
|
||||
next_run = Get-VeeamJobNextRun -Job $_
|
||||
last_result = if ($null -eq $lastResult) { $null } else { [string]$lastResult }
|
||||
last_state = if ($null -eq $lastState) { $null } else { [string]$lastState }
|
||||
restore_points = $restorePoints
|
||||
}
|
||||
})
|
||||
$disabledJobs = @($allJobs | Where-Object {
|
||||
@@ -573,12 +538,6 @@ function Get-VeeamJobMetrics {
|
||||
$successfulJobs = @($jobDetails | Where-Object {
|
||||
$_.last_result -in @('Success', 'Succeeded') -or $_.last_state -in @('Success', 'Succeeded')
|
||||
})
|
||||
$jobsLld = @($jobDetails | Sort-Object -Property name | ForEach-Object {
|
||||
[ordered]@{
|
||||
'{#VEEAMJOBKEY}' = $_.key
|
||||
'{#VEEAMJOBNAME}' = $_.name
|
||||
}
|
||||
})
|
||||
|
||||
$disabledCount = $disabledJobs.Count
|
||||
$disabledExcludedJobs = @()
|
||||
@@ -614,9 +573,6 @@ function Get-VeeamJobMetrics {
|
||||
error_names = Format-ZabbixTextValue -Values @($errorJobs | ForEach-Object { Get-VeeamJobName -Job $_ })
|
||||
warning_names = Format-ZabbixTextValue -Values @($warningJobs | ForEach-Object { Get-VeeamJobName -Job $_ })
|
||||
jobs_table = Format-VeeamJobDetailsTable -JobDetails $jobDetails
|
||||
jobs_lld = [ordered]@{
|
||||
data = $jobsLld
|
||||
}
|
||||
jobs = $jobDetails
|
||||
}
|
||||
}
|
||||
|
||||
46
README.md
46
README.md
@@ -22,28 +22,15 @@ This repository contains PowerShell scripts for Veeam Backup & Replication:
|
||||
"error_names": "Failed job",
|
||||
"warning_names": "Warning job",
|
||||
"jobs_table": "Name | Enabled | Last run | Next run | Result | Restore points\n...",
|
||||
"jobs_lld": {
|
||||
"data": [
|
||||
{
|
||||
"{#VEEAMJOBKEY}": "RGFpbHkgYmFja3Vw",
|
||||
"{#VEEAMJOBNAME}": "Daily backup"
|
||||
}
|
||||
]
|
||||
},
|
||||
"jobs": [
|
||||
{
|
||||
"key": "RGFpbHkgYmFja3Vw",
|
||||
"name": "Daily backup",
|
||||
"enabled": true,
|
||||
"enabled_numeric": 1,
|
||||
"enabled_text": "yes",
|
||||
"last_run": "2026-07-16 01:00:00",
|
||||
"next_run": "2026-07-17 01:00:00",
|
||||
"last_result": "Success",
|
||||
"last_state": "Stopped",
|
||||
"result": "Success",
|
||||
"restore_points": 14,
|
||||
"restore_points_text": "14"
|
||||
"restore_points": 14
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -54,29 +41,6 @@ Restore point counting is best effort. The script uses `Get-VBRBackup` and
|
||||
to backups in the current environment, the job remains visible and its restore
|
||||
point count is shown as `-`.
|
||||
|
||||
## Discovered per-job items
|
||||
|
||||
The template uses a dependent low-level discovery rule:
|
||||
|
||||
```text
|
||||
veeam.jobs.discovery
|
||||
```
|
||||
|
||||
It creates one set of discovered items per Veeam job:
|
||||
|
||||
```text
|
||||
veeam.job.enabled[{#VEEAMJOBKEY}]
|
||||
veeam.job.last_run[{#VEEAMJOBKEY}]
|
||||
veeam.job.next_run[{#VEEAMJOBKEY}]
|
||||
veeam.job.result[{#VEEAMJOBKEY}]
|
||||
veeam.job.restore_points[{#VEEAMJOBKEY}]
|
||||
```
|
||||
|
||||
`{#VEEAMJOBNAME}` is stored as a tag named `veeam_job`, so Zabbix views and
|
||||
dashboard widgets can group or filter the discovered items by job name. The
|
||||
legacy `veeam.jobs.table` item remains available as a quick text overview, but
|
||||
the discovered items are the preferred way to build a dashboard.
|
||||
|
||||
## Zabbix dashboard idea
|
||||
|
||||
Create a dashboard named `Veeam Jobs` for hosts linked to the `Veeam Backup Jobs`
|
||||
@@ -91,10 +55,10 @@ Suggested widgets:
|
||||
| Top row | Item value | `veeam.jobs.disabled` |
|
||||
| Top row | Item value | `veeam.jobs.error` |
|
||||
| Top row | Item value | `veeam.jobs.warning` |
|
||||
| Middle | Top hosts or item list | discovered `veeam.job.*` items |
|
||||
| Bottom left | Item value or item list | `veeam.jobs.error.names` |
|
||||
| Bottom center | Item value or item list | `veeam.jobs.warning.names` |
|
||||
| Bottom right | Item value or item list | `veeam.jobs.disabled.names` |
|
||||
| Middle | Plain text | `veeam.jobs.table` |
|
||||
| Bottom left | Plain text | `veeam.jobs.error.names` |
|
||||
| Bottom center | Plain text | `veeam.jobs.warning.names` |
|
||||
| Bottom right | Plain text | `veeam.jobs.disabled.names` |
|
||||
|
||||
Use a red threshold for `veeam.jobs.error`, yellow for `veeam.jobs.warning`, and
|
||||
keep `veeam.jobs.disabled` aligned with the existing exclusion policy. The
|
||||
|
||||
@@ -365,191 +365,6 @@
|
||||
</tags>
|
||||
</item>
|
||||
</items>
|
||||
<discovery_rules>
|
||||
<discovery_rule>
|
||||
<uuid>781c7b57c4934bb4af113614ef8959bd</uuid>
|
||||
<name>Veeam: Job discovery</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>veeam.jobs.discovery</key>
|
||||
<delay>0</delay>
|
||||
<master_item>
|
||||
<key>veeam.scripts.monitor</key>
|
||||
</master_item>
|
||||
<description>Discovers Veeam jobs from the JSON returned by Monitor-VeeamJobs.ps1.</description>
|
||||
<item_prototypes>
|
||||
<item_prototype>
|
||||
<uuid>07f8608d3a6c40e6bed412afe6c9a410</uuid>
|
||||
<name>Veeam job [{#VEEAMJOBNAME}]: Enabled</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>veeam.job.enabled[{#VEEAMJOBKEY}]</key>
|
||||
<delay>0</delay>
|
||||
<master_item>
|
||||
<key>veeam.scripts.monitor</key>
|
||||
</master_item>
|
||||
<value_type>UNSIGNED</value_type>
|
||||
<description>Schedule enabled state for Veeam job {#VEEAMJOBNAME}: 1 enabled, 0 disabled.</description>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<parameters>
|
||||
<parameter>$.jobs[?(@.key=="{#VEEAMJOBKEY}")].enabled_numeric.first()</parameter>
|
||||
</parameters>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<history>90d</history>
|
||||
<trends>365d</trends>
|
||||
<tags>
|
||||
<tag>
|
||||
<tag>component</tag>
|
||||
<value>backup</value>
|
||||
</tag>
|
||||
<tag>
|
||||
<tag>veeam_job</tag>
|
||||
<value>{#VEEAMJOBNAME}</value>
|
||||
</tag>
|
||||
</tags>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<uuid>75e8646b8db84b6f942a5af414c14305</uuid>
|
||||
<name>Veeam job [{#VEEAMJOBNAME}]: Last run</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>veeam.job.last_run[{#VEEAMJOBKEY}]</key>
|
||||
<delay>0</delay>
|
||||
<master_item>
|
||||
<key>veeam.scripts.monitor</key>
|
||||
</master_item>
|
||||
<value_type>TEXT</value_type>
|
||||
<description>Latest run time for Veeam job {#VEEAMJOBNAME}.</description>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<parameters>
|
||||
<parameter>$.jobs[?(@.key=="{#VEEAMJOBKEY}")].last_run.first()</parameter>
|
||||
</parameters>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<history>90d</history>
|
||||
<trends>0</trends>
|
||||
<tags>
|
||||
<tag>
|
||||
<tag>component</tag>
|
||||
<value>backup</value>
|
||||
</tag>
|
||||
<tag>
|
||||
<tag>veeam_job</tag>
|
||||
<value>{#VEEAMJOBNAME}</value>
|
||||
</tag>
|
||||
</tags>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<uuid>fdacc145952c4fd592e3a038c7b71888</uuid>
|
||||
<name>Veeam job [{#VEEAMJOBNAME}]: Next run</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>veeam.job.next_run[{#VEEAMJOBKEY}]</key>
|
||||
<delay>0</delay>
|
||||
<master_item>
|
||||
<key>veeam.scripts.monitor</key>
|
||||
</master_item>
|
||||
<value_type>TEXT</value_type>
|
||||
<description>Next scheduled run time for Veeam job {#VEEAMJOBNAME}.</description>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<parameters>
|
||||
<parameter>$.jobs[?(@.key=="{#VEEAMJOBKEY}")].next_run.first()</parameter>
|
||||
</parameters>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<history>90d</history>
|
||||
<trends>0</trends>
|
||||
<tags>
|
||||
<tag>
|
||||
<tag>component</tag>
|
||||
<value>backup</value>
|
||||
</tag>
|
||||
<tag>
|
||||
<tag>veeam_job</tag>
|
||||
<value>{#VEEAMJOBNAME}</value>
|
||||
</tag>
|
||||
</tags>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<uuid>2f3d12d455f249e98bb973d0b3be628a</uuid>
|
||||
<name>Veeam job [{#VEEAMJOBNAME}]: Result</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>veeam.job.result[{#VEEAMJOBKEY}]</key>
|
||||
<delay>0</delay>
|
||||
<master_item>
|
||||
<key>veeam.scripts.monitor</key>
|
||||
</master_item>
|
||||
<value_type>TEXT</value_type>
|
||||
<description>Latest result for Veeam job {#VEEAMJOBNAME}.</description>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<parameters>
|
||||
<parameter>$.jobs[?(@.key=="{#VEEAMJOBKEY}")].result.first()</parameter>
|
||||
</parameters>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<history>90d</history>
|
||||
<trends>0</trends>
|
||||
<tags>
|
||||
<tag>
|
||||
<tag>component</tag>
|
||||
<value>backup</value>
|
||||
</tag>
|
||||
<tag>
|
||||
<tag>veeam_job</tag>
|
||||
<value>{#VEEAMJOBNAME}</value>
|
||||
</tag>
|
||||
</tags>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<uuid>7bdca2a712cc460382d3412b391c1c93</uuid>
|
||||
<name>Veeam job [{#VEEAMJOBNAME}]: Restore points</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>veeam.job.restore_points[{#VEEAMJOBKEY}]</key>
|
||||
<delay>0</delay>
|
||||
<master_item>
|
||||
<key>veeam.scripts.monitor</key>
|
||||
</master_item>
|
||||
<value_type>TEXT</value_type>
|
||||
<description>Restore point count for Veeam job {#VEEAMJOBNAME}; '-' means the count is unavailable.</description>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<parameters>
|
||||
<parameter>$.jobs[?(@.key=="{#VEEAMJOBKEY}")].restore_points_text.first()</parameter>
|
||||
</parameters>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<history>90d</history>
|
||||
<trends>0</trends>
|
||||
<tags>
|
||||
<tag>
|
||||
<tag>component</tag>
|
||||
<value>backup</value>
|
||||
</tag>
|
||||
<tag>
|
||||
<tag>veeam_job</tag>
|
||||
<value>{#VEEAMJOBNAME}</value>
|
||||
</tag>
|
||||
</tags>
|
||||
</item_prototype>
|
||||
</item_prototypes>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<parameters>
|
||||
<parameter>$.jobs_lld</parameter>
|
||||
</parameters>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<lifetime>30d</lifetime>
|
||||
<enabled_lifetime>0</enabled_lifetime>
|
||||
</discovery_rule>
|
||||
</discovery_rules>
|
||||
</template>
|
||||
</templates>
|
||||
</zabbix_export>
|
||||
|
||||
Reference in New Issue
Block a user