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

Automatically unpause paused sensors

Votes:

0

Hey,

We were wondering if it is possible (in the future?) to be able to automatically resume all pauzed sensors on a weekly/monthly basis.

We have some employees who forget they paused a sensor permanently instead of for x hours or using the 'until..' option.

We got rid of some of the permanent pause buttons by altering the webpages but couldn't get rid of all of them.

Thank you.

Kind regards, Wim

automatically automation pause resume

Created on Jul 30, 2015 9:17:31 AM



7 Replies

Accepted Answer

Votes:

0

That's easy and can be done with a PowerShell script and a scheduled task:

$prtghost="<enter-your-prtg-host>"
$username="<your-prtg-user>";
$passhash="<the-users-passhash-from-the-account-settings>"
$Sensors = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=sensors&output=json&columns=objid,device,sensor&filter_status=7&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json)


Foreach($Sensor in $Sensors.sensors){
    Write-Host "Resuming $($Sensor.sensor) on $($Sensor.device)..." -NoNewline
    Invoke-WebRequest -Uri "http://$($prtghost)/api/pause.htm?id=$($Sensor.objid)&action=1&username=$($username)&passhash=$($passhash)" | Out-Null
    Write-Host "done." -NoNewline -ForegroundColor Green
    Write-Host "`r"
}

Output will look like this: Output

Simply set the scheduled task to run once a day or hour or minute (so you won't miss any precious metrics).

Created on Jul 30, 2015 11:17:15 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thank you. The script works great!

I tried to extend the script so devices that are paused will also be resumed but I'm having some issues with it. I'm not able to get back a list with paused devices. (using &filter_status=7) Even though I'm sure there is at least one device with this raw status value because I get the following results without the filter.

{"status":"Up","status_raw":3,"device":"VIRUSWALL"}, {"status":"Up","status_raw":3,"device":"BESMVVP"}, {"status":"Up","status_raw":3,"device":"SQLMVVP"}, {"status":"Paused (paused)","status_raw":7,"device":"PH2-TEST"}]}

The URI I'm using is: https://*redacted*/api/table.json?content=devices&output=json&columns=objid,status,device&filter_status=7

Created on Jul 30, 2015 12:39:33 PM



Votes:

0

A bit ugly, but it works:

$Sensors = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=sensors&output=json&columns=objid,device,sensor&filter_status=7&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json)
$Devices = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=devices&output=json&columns=objid,device&filter_status=7&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json)
$Groups = ((Invoke-WebRequest -URI "http://$($prtghost)/api/table.json?content=groups&output=json&columns=objid,device,group&filter_status=7&username=$($username)&passhash=$($passhash)").Content | ConvertFrom-Json)

Write-Host "[Unpausing groups]"
Foreach($Group in $Groups.groups){
    Write-Host "Resuming $($Group.group)..." -NoNewline
    Invoke-WebRequest -Uri "http://$($prtghost)/api/pause.htm?id=$($Group.objid)&action=1&username=$($username)&passhash=$($passhash)" | Out-Null
    Write-Host "done." -NoNewline -ForegroundColor Green
    Write-Host "`r"
}

Write-Host "[Unpausing devices]"
Foreach($Device in $Devices.devices){
    Write-Host "Resuming $($Device.device)..." -NoNewline
    Invoke-WebRequest -Uri "http://$($prtghost)/api/pause.htm?id=$($Device.objid)&action=1&username=$($username)&passhash=$($passhash)" | Out-Null
    Write-Host "done." -NoNewline -ForegroundColor Green
    Write-Host "`r"
}
Write-Host "[Unpausing sensors]"
Foreach($Sensor in $Sensors.sensors){
    Write-Host "Resuming $($Sensor.sensor) on $($Sensor.device)..." -NoNewline
    Invoke-WebRequest -Uri "http://$($prtghost)/api/pause.htm?id=$($Sensor.objid)&action=1&username=$($username)&passhash=$($passhash)" | Out-Null
    Write-Host "done." -NoNewline -ForegroundColor Green
    Write-Host "`r"
}

Outputs something like this:

[Unpausing groups]
Resuming Miscellaneous...done.
Resuming Plants...done.
[Unpausing devices]
Resuming Palm Tree...done.
[Unpausing sensors]
Resuming Status on Palm Tree...done.

I know, could be done in a foreach loop, but I don't have the time to fiddle around with it :)

edit fixed copy pasta

Created on Jul 30, 2015 1:02:46 PM by  Stephan Linke [Paessler Support]

Last change on Jul 30, 2015 1:39:06 PM by  Stephan Linke [Paessler Support]



Votes:

0

Thanks.

Hmm, weird, still no devices that are being resumed. For some reason it just doesn't find them.

Now all the paused sensors are resumed, except the ones that are paused by parent(device) that's paused.

PS C:\Users\Wim\Desktop> .\resumeall.ps1 [Unpausing groups] [Unpausing devices] [Unpausing sensors] Resuming Ping on PH2-TEST (no action necessary)...done. Resuming CPU Load 66 on PH2-TEST (no action necessary)...done. Resuming Memory 71 on PH2-TEST (no action necessary)...done. Resuming Disk Free 69 on PH2-TEST (no action necessary)...done. Resuming vmxnet3 Ethernet Adapter _2 on PH2-TEST (no action necessary)...done.

Created on Jul 30, 2015 1:47:32 PM



Votes:

0

When you paste the device URL into the browser, do you get any results for that? (remember to add the variables, username etc.)

Created on Jul 30, 2015 1:58:55 PM by  Stephan Linke [Paessler Support]

Last change on Jul 30, 2015 1:59:12 PM by  Stephan Linke [Paessler Support]



Votes:

0

I get an empty list in the file I get back if I put the filter in the query. (Via browser) Without the filter I get all our devices it seems.

Created on Aug 6, 2015 9:54:55 AM



Votes:

1

To Start, Resume or CheckNow any object from the command line see also

KB: start or pause sensor from command line

Created on Aug 6, 2015 10:39:56 AM




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.