Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added switch "Discovery-Tape" & "Result-Tape" #102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions zbx-templates/zbx-veeam/zabbix_vbr_job.ps1
Original file line number Diff line number Diff line change
@@ -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
#
Expand All @@ -18,15 +18,16 @@
# 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]

#* 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
Expand All @@ -49,6 +50,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()) {
Expand All @@ -66,6 +88,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"}
Expand Down