What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Custom MapObject to fetch more than one channel from a sensor

Votes:

0

I would like to create a MapObject, where I could display the data of all channels from a sensor and not just the primary. Just like the gauge object but without the gauges or the graph object but of cause without the graph.

For Example I have a custom Powershell Sensor which lists all VMs with snapshots on it with the help of PowerCLI. On my map/dashboard I have an area for vm related monitoring where I want to display a list of vm-Names with VMs which have a current snapshot. Here my Custom PS Sensor:

______________________________________
Connect-VIServer -Server *** -User ***

$VMList = Get-VM | Get-Snapshot | Select-Object VM, Name, Created
$CurrentDate = Get-Date
$SnapshotCount = $VMList.COUNT

$output = @"
<?xml version=`"1.0`" encoding=`"UTF-8`" ?>
<prtg>
<result>
    <channel>Snapshot Count</channel>
    <value>$SnapshotCount</value>
    <CustomUnit>snps</CustomUnit>
    <showChart>0</showChart>
    <showTable>0</showTable>
</result>

"@
foreach ($VM in $VMList) {
    $VMName = $VM.VM
    $SnapshotDate = [datetime]$VM.Created
    $timebetween = New-TimeSpan -Start $SnapshotDate -End $CurrentDate
    $daysbetween = $timebetween.Days
    $tobeappended = @"
<result>
    <channel>$VMName</channel>
    <value>$daysbetween</value>
    <CustomUnit>Days</CustomUnit>
    <showChart>1</showChart>
    <showTable>1</showTable>
</result>

"@
$output = $output + $tobeappended

}
$endofoutput = @"
</prtg>
"@

$output = $output + $endofoutput
[Console]::WriteLine($output);
_____________________________________

Don't judge the naming of my variables^^

This script will create for all of the VMs with an active snapshot a separate channel with the value of "days since last snapshot".

Thanks for your help :)

channel custom custom-sensor map-objects powercli powershell snapshot vmware

Created on Jan 6, 2020 2:48:49 PM

Last change on Jan 7, 2020 5:10:53 AM by  Sven Roggenhofer [Paessler Technical Support]



Replies

Nobody has replied yet


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.