New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


PRTG Management via shell / bash / ps

Votes:

0

Your Vote:

Up

Down

Hello,

I would like to help my devops to create devices / sensors automatically:

  • Every time I create a VM in VCenter (Hyper-V, whatever), a script should get executed
  • This script connects to PRTG-Server, Clones existing (paused) device into a new Name / IP-Device
  • Unpauses this device and
  • Get the Object-ID of this new device into a field in VCenter / Hyper-V / whatever...

Is this possible - on which way? If not, is there basically a way to sent http-api-calls via powershell?

Thanks!
Ruediger

api devop powershell skript vcenter

Created on Sep 13, 2019 1:31:13 PM by  Ruediger Grimm (0) 1

Last change on Sep 13, 2019 6:06:59 PM by  Sven Roggenhofer [Paessler Technical Support]



1 Reply

Votes:

1

Your Vote:

Up

Down

I'm not sure whether vCenter and Hyper-V have the ability to perform custom actions on specific events, however I would recommend setting up a Scheduled Task to periodically run on some server (such as the PRTG Core); this will connect to both PRTG and vCenter, figure out which devices are missing from PRTG and then create those devices for you.

You can control vCenter and PRTG using PowerShell via the VMware PowerCLI and PrtgAPI

Connect-VIServer vcenter-1

if(!(Get-PrtgClient)
{
    Connect-PrtgServer prtg.example.com (New-Credential username password)
}

$cloneSource = Get-Device -Id 1234

$vms = Get-VM
$devices = Get-Device | select -expand Name

$missingVMs = $vms | where { $_.Name -notin $devices }

foreach($vm in $missingVMs)
{
    Write-Host "Creating device for VM '$($vm.Name)'"
    $newDevice = $cloneSource | Clone-Object -DestinationId $cloneSource.ParentId $vm.Name
    $newDevice | Resume-Object
    $vm | Set-VM $vm -Notes "PRTG Device $($newDevice.Id)"
}

You would likely want to customize this a bit so that VMs that are stored in certain groups/have certain names etc are cloned from specific PRTG devices and then stored in custom groups, rather than storing all of your created devices under the parent of the clone source. Depending on your setup you may instead want to store your PRTG notes on the VM in a custom attribute / annotation, etc

Regards,

lordmilko

Created on Sep 14, 2019 12:02:43 AM by  lordmilko (1,592) 2 1



Please log in or register to enter your reply.


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.