Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

lucianolingnau commented Jan 25, 2018

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

This comment has been minimized.

Copy link

fredhohenstein commented Jun 27, 2019

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

@mycloudrevolution

This comment has been minimized.

Copy link
Owner Author

mycloudrevolution commented Jun 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.