New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.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


Use API to assign Schedules to sensors

Votes:

0

Your Vote:

Up

Down

We have about 2k sensors and I would like to start automating some tasks around the management of them. Our maintenance schedules for server downtime is in another database and i want to be able to update schedule in PRTG via the web API if possible.

Can anyone tell me if this would be possible? I was hoping to create the schedule too, but being able to assign a sensor to a pre-defined schedule would be fine too.

Thanks!

api automation prtg

Created on Sep 2, 2015 1:13:32 PM by  jankar (0) 1



4 Replies

Votes:

0

Your Vote:

Up

Down

Dear jankar

The short answer is: That is not possible.

The long answer is: It is possible in principle, however we don't provide technical support for this. Only some parts of PRTG management can be accessed through the API. Of that, only a part is documented.

If you manually change the schedule for an object and analyse the HTTP POST generated by the webinterface, you could try to create your own API call derived from that POST.

Another option would be to stop the PRTG core service and change the "PRTG Configuration.dat" (which is an XML file) directly. However, this method is not recommended as it is very easy to unintentionally damage the configuration.


There is a way to pause objects via the API. That would be the alternative: Write a script which pauses / resumes objects instead of changing the schedule attached.

To pause an object for x minutes:

/api/pauseobjectfor.htm?id=objectid&pausemsg=yourmessage&duration=x 

To pause it until it is resumed:

/api/pause.htm?id=objectid&pausemsg=yourmessage&action=0 

To resume it:

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

Created on Sep 3, 2015 11:42:51 AM by  Arne Seifert [Paessler Support]



Votes:

0

Your Vote:

Up

Down

any news regarding this feature?

I would like to automate the notification schedule on both groups and single sensors via the API, is that still not possible?

Created on May 29, 2018 7:08:19 AM by  Olav Langeland (0)



Votes:

0

Your Vote:

Up

Down

Hello Olav,

Nothing new so far. Arne posted some workaround for some automatition, though if your aim is to indeed tinker with the schedules only for notification, this won't be ideal. It also collides with how notifications are organized, since schedules can be set directly in a notification, telling it when to be active and when not, indepedently of whether the sensor is running or not. Now since notifications are sort of organized centrally, you cannot have the same notification behave differently for one sensor than on another sensor where the same notification is in place. This would only be feasible by having differently configured notifications, each one with configured schedules if necessary.

Kind regards,

Erhard

Created on May 29, 2018 11:23:00 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Your Vote:

Up

Down

You can do this with the PRTGAPI powershell module. Here's a Cmdlet to use. *WARNING* This modifies raw properties and may have unexpected side effects. Works pretty stable for us but use at your own risk.

#requires -module prtgapi
<#
.EXAMPLE
$schedule = Get-PRTGSchedule "Sundays*" | select -first 1
Get-Device mytestdevice | Set-PRTGSchedule -Schedule $schedule
#>
function Set-PRTGSchedule {
    [CmdletBinding(SupportsShouldProcess)]
    param (
        [Parameter(Mandatory,ValueFromPipeline)][prtgapi.deviceorgrouporprobe]$Object,
        [Parameter(Mandatory)][prtgapi.schedule]$Schedule
    )

    begin {
        if (-not (Get-PrtgClient)) {Connect-PrtgServer}
    }

    process {
        if (-not $Object.id) {
            write-error "Could not find valid ID on schedule object $schedule"
            continue
        }

        [string]$scheduleValue = ($Schedule.id,$schedule.name -join '|') + '|'
        if ($PSCmdlet.ShouldProcess($Object.name,"Set Schedule to $($Schedule.name)")) {
            Set-ObjectProperty -Force -Object $Object -RawParameters @{
                scheduledependency = 0
                schedule_ = $scheduleValue
            }
        }
    }
}

Created on Apr 17, 2019 4:56:41 PM by  jgrote (70)

Last change on Apr 18, 2019 6:26:56 AM by  Erhard Mikulik [Paessler Support]



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.