Skip to content

Instantly share code, notes, and snippets.

@vMarkusK
Created February 29, 2016 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vMarkusK/713b2e4aa767257f84cc to your computer and use it in GitHub Desktop.
Save vMarkusK/713b2e4aa767257f84cc to your computer and use it in GitHub Desktop.
PRTG Advanced Custom Sensor for VEEAM v9
$user = "yourUser"
$password = "yourPassword"
# POST - Authorization
$Auth = @{uri = "http://yourVEM.fqdn:9399/api/sessionMngr/?v=v1_2";
Method = 'POST'; #(or POST, or whatever)
Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($user):$($password)"));
} #end headers hash table
} #end $params hash table
$AuthXML = Invoke-WebRequest @Auth
# GET - Session Statistics
$Sessions = @{uri = "http://yourVEM.fqdn:9399/api/reports/summary/job_statistics";
Method = 'GET';
Headers = @{'X-RestSvcSessionId' = $AuthXML.Headers['X-RestSvcSessionId'];
} #end headers hash table
}
[xml]$SessionsXML = invoke-restmethod @Sessions
$SuccessfulJobRuns = $SessionsXML.JobStatisticsReportFrame.SuccessfulJobRuns
$WarningsJobRuns = $SessionsXML.JobStatisticsReportFrame.WarningsJobRuns
$FailedJobRuns = $SessionsXML.JobStatisticsReportFrame.FailedJobRuns
# GET - VM Statistics
$VMs = @{uri = "http://yourVEM.fqdn:9399/api/reports/summary/vms_overview";
Method = 'GET';
Headers = @{'X-RestSvcSessionId' = $AuthXML.Headers['X-RestSvcSessionId'];
} #end headers hash table
}
[xml]$VMsXML = invoke-restmethod @VMs
$ProtectedVms = $VMsXML.VmsOverviewReportFrame.ProtectedVms
$SourceVmsSize = [Math]::round((($VMsXML.VmsOverviewReportFrame.SourceVmsSize) / 1073741824),0)
# XML Output for PRTG
Write-Host "<prtg>"
Write-Host "<result>"
"<channel>SuccessfulJobRuns</channel>"
"<value>$SuccessfulJobRuns</value>"
"<showChart>1</showChart>"
"<showTable>1</showTable>"
"</result>"
Write-Host "<result>"
"<channel>ProtectedVms</channel>"
"<value>$ProtectedVms</value>"
"<showChart>1</showChart>"
"<showTable>1</showTable>"
"</result>"
Write-Host "<result>"
"<channel>SourceVmsSize</channel>"
"<value>$SourceVmsSize</value>"
"<unit>Custom</unit>"
"<customUnit>GB</customUnit>"
"<showChart>1</showChart>"
"<showTable>1</showTable>"
"</result>"
Write-Host "<result>"
"<channel>WarningsJobRuns</channel>"
"<value>$WarningsJobRuns</value>"
"<showChart>1</showChart>"
"<showTable>1</showTable>"
"<LimitMaxWarning>1</LimitMaxWarning>"
"<LimitMode>1</LimitMode>"
"</result>"
Write-Host "<result>"
"<channel>FailedJobRuns</channel>"
"<value>$FailedJobRuns</value>"
"<showChart>1</showChart>"
"<showTable>1</showTable>"
"<LimitMaxError>1</LimitMaxError>"
"<LimitMode>1</LimitMode>"
"</result>"
Write-Host "</prtg>"
@lucianolingnau
Copy link

Hi there, thank you for sharing your script, it's quite useful. I did however include some changes (variables/parameters for the input like host/port and timeout) and included try/catch when doing the webrequests, otherwise the script doesn't really display any alerts in PRTG when the execution fails. Would you mind updating the code?

Here's the updated version: https://pastebin.com/qxWG6THh

@fredhohenstein
Copy link

Are you still supporting this script? Is it compatible with the current Veeam Version?

@vMarkusK
Copy link
Author

vMarkusK commented Jun 27, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment