Skip to content

Commit

Permalink
Merge pull request jjmartres#82 from Rikbruggink/master
Browse files Browse the repository at this point in the history
Discover and check only enabled jobs
  • Loading branch information
jjmartres committed May 31, 2015
2 parents f8032df + 3b38385 commit be94219
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 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,20 +18,20 @@
# 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.3"
$version = "1.0.4"

$ITEM = [string]$args[0]
$ID = [string]$args[1]

#* Load Veeam snapin
Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

# Query VEEAM for Job
# Query VEEAM for Job. Include only enabled jobs
switch ($ITEM) {
"Discovery" {
# Open JSON object
$output = "{`"data`":["
$query = Get-VBRJob | Select-Object Id,Name, IsScheduleEnabled
$query = Get-VBRJob | Where-Object {$_.IsScheduleEnabled -eq "true"} | Select-Object Id,Name, IsScheduleEnabled
$count = $query | Measure-Object
$count = $count.count
foreach ($object in $query) {
Expand All @@ -50,8 +50,8 @@ switch ($ITEM) {
Write-Host $output
}
"Result" {
$query = Get-VBRJob | Where-Object {$_.Id -like "*$ID*"}
switch ([string]$query.GetLastResult()) {
$query = Get-VBRJob | Where-Object {$_.Id -like "*$ID*" -and $_.IsScheduleEnabled -eq "true"}
if ($query) {switch ([string]$query.GetLastResult()) {
"Failed" {
return "0"
}
Expand All @@ -61,7 +61,10 @@ switch ($ITEM) {
default {
return "2"
}

}
}
else {"2"}
}
"RunStatus" {
$query = Get-VBRJob | Where-Object {$_.Id -like "*$ID*"}
Expand Down

0 comments on commit be94219

Please sign in to comment.