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

API, filter by tags

Votes:

0

Is there a way using the API to set a number of sensors to resume using their tags?

api sensors tags

Created on Aug 7, 2018 1:51:03 PM



2 Replies

Votes:

0

Dear MEAB_niclas,

yes, but the process is quite complex. Please understand that we have the API documentation with this and this page of special interest for you.

Here is a more detailed outline for your question.

1) Generate a list of sensors by tag:

/api/table.xml?content=sensors&columns=objid,name&count=*&filter_tags=@tag(pingsensor)

2) Iterate over each objid and trigger the resume call for each ID (one API call for each sensor)

/api/pause.htm?id=2123&action=1

Replace the example objid of 2123 with a real objid, extracted by the former API call.

(Yes, the resume call uses /api/pause.htm.)

Created on Aug 7, 2018 8:50:01 PM by  Arne Seifert [Paessler Support]

Last change on Sep 7, 2018 10:32:00 AM by  Sebastian Kniege [Paessler Support]



Votes:

0

Thank you for the quick answer. A quick and easy PS script later and the sensors will be resumed.

Script below for those who are looking for the same thing.

$xmlURL = "https://<URL TO PRTG SERVER>/api/table.xml?content=sensors&columns=objid,name&count=*&filter_tags=<Tag you are looking for>0&username=<USERNAME>&passhash=<PASSHASH>"
(New-Object System.Net.WebClient).DownloadFile($xmlURL,'c:\temp\sensors.xml')
$sensors = [xml](Get-Content 'c:\temp\sensors.xml')

foreach ($sensorID in $sensors.sensors.item.objid) {
    $response = Invoke-WebRequest -Uri "https://<URL TO PRTG SERVER>/api/pause.htm?id=$sensorID &action=1&username=<USERNAME>&passhash=<PASSHASH>"
    write-host "Resumed $sensorID" 
    
}

Created on Aug 8, 2018 7:44:57 AM

Last change on Aug 8, 2018 3:24:44 PM by  Arne Seifert [Paessler Support]




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.