From 4ba8593ac9312a91ccec48446c02ada49a7eeb82 Mon Sep 17 00:00:00 2001 From: Marco Hofmann Date: Tue, 19 Jan 2016 00:23:13 +0100 Subject: [PATCH 1/2] Added switch "Discovery-Tape" & "Result-Tape" Adding the new Zabbix Template XML tomorrow. --- zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 | 43 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 b/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 index 3eb9933..1856aff 100755 --- a/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 +++ b/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 @@ -1,5 +1,5 @@ # Script: Get-VBRJob -# Author: Jean-Jacques Martr�s (jjmartres |at| gmail |dot| com) +# Author: Jean-Jacques Martrès (jjmartres |at| gmail |dot| com) # Description: Query Veeam job information # License: GPL2 # @@ -18,7 +18,7 @@ # Add to Zabbix Agent # UserParameter=vbr[*],%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -nologo -command "& C:\Zabbix\zabbix_vbr_job.ps1 $1 $2" # -$version = "1.0.4" +$version = "1.0.5" $ITEM = [string]$args[0] $ID = [string]$args[1] @@ -26,7 +26,9 @@ $ID = [string]$args[1] #* Load Veeam snapin Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue -# Query VEEAM for Job. Include only enabled jobs +# Query VEEAM for Job. Include only enabled Disk-Jobs. +# No enabled-check for Tape-Jobs yet. + switch ($ITEM) { "Discovery" { # Open JSON object @@ -49,6 +51,27 @@ switch ($ITEM) { $output = $output + "]}" Write-Host $output } + "Discovery-Tape" { + # Open JSON object + $output = "{`"data`":[" + $query = Get-VBRTapeJob | Select-Object Id,Name, IsScheduleEnabled + $count = $query | Measure-Object + $count = $count.count + foreach ($object in $query) { + $Id = [string]$object.Id + $Name = [string]$object.Name + $Schedule = [string]$object.IsScheduleEnabled + if ($count -eq 1) { + $output = $output + "{`"{#JOBID}`":`"$Id`",`"{#JOBNAME}`":`"$Name`",`"{#JOBSCHEDULED}`":`"$Schedule`"}" + } else { + $output = $output + "{`"{#JOBID}`":`"$Id`",`"{#JOBNAME}`":`"$Name`",`"{#JOBSCHEDULED}`":`"$Schedule`"}," + } + $count-- + } + # Close JSON object + $output = $output + "]}" + Write-Host $output + } "Result" { $query = Get-VBRJob | Where-Object {$_.Id -like "*$ID*" -and $_.IsScheduleEnabled -eq "true"} if ($query) {switch ([string]$query.GetLastResult()) { @@ -66,6 +89,20 @@ switch ($ITEM) { } else {"2"} } + "Result-Tape" { + $query = Get-VBRTapeJob | Where-Object {$_.Id -like "*$ID*"} | select LastResult + switch ([string]$query) { + "Failed" { + return "0" + } + "Warning" { + return "1" + } + default { + return "2" + } + } + } "RunStatus" { $query = Get-VBRJob | Where-Object {$_.Id -like "*$ID*"} if ($query.IsRunning) { return "1" } else { return "0"} From f0c121c94ff63a263cb9be14d6dbe8abaa0b75b6 Mon Sep 17 00:00:00 2001 From: Marco Hofmann Date: Tue, 19 Jan 2016 00:31:05 +0100 Subject: [PATCH 2/2] Typo. --- zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 b/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 index 1856aff..301e673 100755 --- a/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 +++ b/zbx-templates/zbx-veeam/zabbix_vbr_job.ps1 @@ -26,8 +26,7 @@ $ID = [string]$args[1] #* Load Veeam snapin Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue -# Query VEEAM for Job. Include only enabled Disk-Jobs. -# No enabled-check for Tape-Jobs yet. +# Query VEEAM for Job. Include only enabled Disk-Jobs. No enabled-check for Tape-Jobs yet. switch ($ITEM) { "Discovery" {