Reapply "Add Veeam job summary item prototype"
This reverts commit 0d44f0ac5b.
This commit is contained in:
@@ -242,6 +242,27 @@ function ConvertTo-ZabbixText {
|
|||||||
return $text
|
return $text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Format-VeeamJobSummary {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Enabled,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$LastRun,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$NextRun,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Result,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$RestorePoints
|
||||||
|
)
|
||||||
|
|
||||||
|
return 'Enabled: {0} | Last: {1} | Next: {2} | Result: {3} | Restore points: {4}' -f $Enabled, $LastRun, $NextRun, $Result, $RestorePoints
|
||||||
|
}
|
||||||
|
|
||||||
function Get-VeeamJobScheduleEnabled {
|
function Get-VeeamJobScheduleEnabled {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
@@ -531,24 +552,33 @@ function Get-VeeamJobMetrics {
|
|||||||
$lastState = Get-VeeamJobLastState -Job $_ -LastSession $lastSession
|
$lastState = Get-VeeamJobLastState -Job $_ -LastSession $lastSession
|
||||||
$restorePoints = $null
|
$restorePoints = $null
|
||||||
$enabledNumeric = if ($scheduleEnabled -eq $false) { 0 } else { 1 }
|
$enabledNumeric = if ($scheduleEnabled -eq $false) { 0 } else { 1 }
|
||||||
|
$enabledText = if ($enabledNumeric -eq 1) { 'yes' } else { 'no' }
|
||||||
|
$lastRunText = ConvertTo-ZabbixText -Value (Get-VeeamJobLastRun -Job $_ -LastSession $lastSession)
|
||||||
|
$nextRunText = ConvertTo-ZabbixText -Value (Get-VeeamJobNextRun -Job $_)
|
||||||
|
$lastResultText = ConvertTo-ZabbixText -Value $lastResult
|
||||||
|
$lastStateText = ConvertTo-ZabbixText -Value $lastState
|
||||||
|
$resultText = ConvertTo-ZabbixText -Value $(if ($null -ne $lastResult) { $lastResult } else { $lastState })
|
||||||
|
|
||||||
if ($restorePointCounts.ContainsKey($jobName)) {
|
if ($restorePointCounts.ContainsKey($jobName)) {
|
||||||
$restorePoints = $restorePointCounts[$jobName]
|
$restorePoints = $restorePointCounts[$jobName]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$restorePointsText = ConvertTo-ZabbixText -Value $restorePoints
|
||||||
|
|
||||||
[ordered]@{
|
[ordered]@{
|
||||||
key = ConvertTo-ZabbixJobKey -Name $jobName
|
key = ConvertTo-ZabbixJobKey -Name $jobName
|
||||||
name = $jobName
|
name = $jobName
|
||||||
enabled = $scheduleEnabled
|
enabled = $scheduleEnabled
|
||||||
enabled_numeric = $enabledNumeric
|
enabled_numeric = $enabledNumeric
|
||||||
enabled_text = if ($enabledNumeric -eq 1) { 'yes' } else { 'no' }
|
enabled_text = $enabledText
|
||||||
last_run = ConvertTo-ZabbixText -Value (Get-VeeamJobLastRun -Job $_ -LastSession $lastSession)
|
last_run = $lastRunText
|
||||||
next_run = ConvertTo-ZabbixText -Value (Get-VeeamJobNextRun -Job $_)
|
next_run = $nextRunText
|
||||||
last_result = ConvertTo-ZabbixText -Value $lastResult
|
last_result = $lastResultText
|
||||||
last_state = ConvertTo-ZabbixText -Value $lastState
|
last_state = $lastStateText
|
||||||
result = ConvertTo-ZabbixText -Value $(if ($null -ne $lastResult) { $lastResult } else { $lastState })
|
result = $resultText
|
||||||
restore_points = $restorePoints
|
restore_points = $restorePoints
|
||||||
restore_points_text = ConvertTo-ZabbixText -Value $restorePoints
|
restore_points_text = $restorePointsText
|
||||||
|
summary = Format-VeeamJobSummary -Enabled $enabledText -LastRun $lastRunText -NextRun $nextRunText -Result $resultText -RestorePoints $restorePointsText
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
$disabledJobs = @($allJobs | Where-Object {
|
$disabledJobs = @($allJobs | Where-Object {
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -43,7 +43,8 @@ This repository contains PowerShell scripts for Veeam Backup & Replication:
|
|||||||
"last_state": "Stopped",
|
"last_state": "Stopped",
|
||||||
"result": "Success",
|
"result": "Success",
|
||||||
"restore_points": 14,
|
"restore_points": 14,
|
||||||
"restore_points_text": "14"
|
"restore_points_text": "14",
|
||||||
|
"summary": "Enabled: yes | Last: 2026-07-16 01:00:00 | Next: 2026-07-17 01:00:00 | Result: Success | Restore points: 14"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -70,6 +71,7 @@ veeam.job.last_run[{#VEEAMJOBKEY}]
|
|||||||
veeam.job.next_run[{#VEEAMJOBKEY}]
|
veeam.job.next_run[{#VEEAMJOBKEY}]
|
||||||
veeam.job.result[{#VEEAMJOBKEY}]
|
veeam.job.result[{#VEEAMJOBKEY}]
|
||||||
veeam.job.restore_points[{#VEEAMJOBKEY}]
|
veeam.job.restore_points[{#VEEAMJOBKEY}]
|
||||||
|
veeam.job.summary[{#VEEAMJOBKEY}]
|
||||||
```
|
```
|
||||||
|
|
||||||
`{#VEEAMJOBNAME}` is stored as a tag named `veeam_job`, so Zabbix views and
|
`{#VEEAMJOBNAME}` is stored as a tag named `veeam_job`, so Zabbix views and
|
||||||
@@ -77,6 +79,18 @@ 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
|
legacy `veeam.jobs.table` item remains available as a quick text overview, but
|
||||||
the discovered items are the preferred way to build a dashboard.
|
the discovered items are the preferred way to build a dashboard.
|
||||||
|
|
||||||
|
For a compact dashboard list, use the discovered summary item:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Veeam job [JOB_NAME]: Summary
|
||||||
|
```
|
||||||
|
|
||||||
|
It displays one line per job:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Enabled: yes | Last: 2026-07-16 01:00:00 | Next: - | Result: Success | Restore points: 14
|
||||||
|
```
|
||||||
|
|
||||||
## Zabbix dashboard idea
|
## Zabbix dashboard idea
|
||||||
|
|
||||||
Create a dashboard named `Veeam Jobs` for hosts linked to the `Veeam Backup Jobs`
|
Create a dashboard named `Veeam Jobs` for hosts linked to the `Veeam Backup Jobs`
|
||||||
@@ -91,7 +105,7 @@ Suggested widgets:
|
|||||||
| Top row | Item value | `veeam.jobs.disabled` |
|
| Top row | Item value | `veeam.jobs.disabled` |
|
||||||
| Top row | Item value | `veeam.jobs.error` |
|
| Top row | Item value | `veeam.jobs.error` |
|
||||||
| Top row | Item value | `veeam.jobs.warning` |
|
| Top row | Item value | `veeam.jobs.warning` |
|
||||||
| Middle | Top hosts or item list | discovered `veeam.job.*` items |
|
| Middle | Item list | discovered `Veeam job [*]: Summary` items |
|
||||||
| Bottom left | Item value or item list | `veeam.jobs.error.names` |
|
| Bottom left | Item value or item list | `veeam.jobs.error.names` |
|
||||||
| Bottom center | Item value or item list | `veeam.jobs.warning.names` |
|
| Bottom center | Item value or item list | `veeam.jobs.warning.names` |
|
||||||
| Bottom right | Item value or item list | `veeam.jobs.disabled.names` |
|
| Bottom right | Item value or item list | `veeam.jobs.disabled.names` |
|
||||||
|
|||||||
@@ -537,6 +537,38 @@
|
|||||||
</tag>
|
</tag>
|
||||||
</tags>
|
</tags>
|
||||||
</item_prototype>
|
</item_prototype>
|
||||||
|
<item_prototype>
|
||||||
|
<uuid>db766a0ea9984a988cb49c5bb6a029b4</uuid>
|
||||||
|
<name>Veeam job [{#VEEAMJOBNAME}]: Summary</name>
|
||||||
|
<type>DEPENDENT</type>
|
||||||
|
<key>veeam.job.summary[{#VEEAMJOBKEY}]</key>
|
||||||
|
<delay>0</delay>
|
||||||
|
<master_item>
|
||||||
|
<key>veeam.scripts.monitor</key>
|
||||||
|
</master_item>
|
||||||
|
<value_type>TEXT</value_type>
|
||||||
|
<description>Single-line summary for Veeam job {#VEEAMJOBNAME}: enabled state, last run, next run, latest result, and restore point count.</description>
|
||||||
|
<preprocessing>
|
||||||
|
<step>
|
||||||
|
<type>JSONPATH</type>
|
||||||
|
<parameters>
|
||||||
|
<parameter>$.jobs[?(@.key=="{#VEEAMJOBKEY}")].summary.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>
|
</item_prototypes>
|
||||||
<preprocessing>
|
<preprocessing>
|
||||||
<step>
|
<step>
|
||||||
|
|||||||
Reference in New Issue
Block a user