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


Desable all schedule and enable it after maintenance

Votes:

0

Your Vote:

Up

Down

Hello, I'd like to desable all schedules by script in order to check if we will have sensors down after our maintenance. And once all is good, we'd like to enable all schedules again.

Regards Jeff

api script shedule

Created on Apr 25, 2018 2:39:51 PM by  jeff83 (0) 1



4 Replies

Votes:

0

Your Vote:

Up

Down

Hi Jeff,

I am afraid this is not possible.


Kind regards
Andreas Günther, Technical Support

Created on Apr 26, 2018 1:42:26 PM by  Andreas Günther [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hello Andreas, What about antoher way ?

Export in CSV or XML all sensors with schedule, by script modify their sensors to delete schedule.

After our maintenance, restore all schedules on every sensor.

Regards.

Created on Apr 26, 2018 2:02:28 PM by  jeff83 (0) 1



Votes:

0

Your Vote:

Up

Down

Hi Jeff,

Actually there is no dedicated API call to disable schedules. In addition to that you would loose the connection between sensor and the specific schedule.

I am afraid I'm not able to provide you with a workaround for your plans.


Kind regards
Andreas Günther, Technical Support

Created on Apr 27, 2018 10:55:35 AM by  Andreas Günther [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Jeff,

This can be achieved with PrtgAPI. Whiile manipulation of schedule properties is not fully supported, this can still be achieved by combining a bit of PowerShell with the library's underlying C# API

As you've indicated, by enabling inheritance of schedule settings from the parent object, you will have effectively "disabled" the schedule for that object. The schedules can (theoretically) be re-added by disabling schedule inheritance again. The major challenge however (as Andreas alludes to) is that when you enable inheritance of schedule settings the original schedule will actually have been deleted!

The solution to this, therefore, is to perform the following

1. Save the original schedule of the object (if applicable)

2. Enable schedule inheritance (removing the schedule)

3. Disable schedule inheritance, re-adding the previously saved schedule

The following gives an example of how to do this to a single sensor (ID 7816)

$sensor = Get-Sensor -Id 7816

$schedule = ($sensor | Get-ObjectProperty).Schedule

$sensor | Set-ObjectProperty -RawProperty scheduledependency -RawValue 1

$p1 = New-Object PrtgAPI.Parameters.CustomParameter -ArgumentList @("schedule_", $schedule)
$p2 = New-Object PrtgAPI.Parameters.CustomParameter -ArgumentList @("scheduledependency", 0)

$ps = $p1,$p2

(Get-PrtgClient).SetObjectPropertyRaw($sensor.Id, $ps)

In your scenario, I would recommend building up a Dictionary mapping objects to schedules. Abstract the code out into two functions: one that gets rid of a schedule and one that restores it. When you are ready to re-enable your schedules again, you can simply iterate over the Dictionary, re-adding the specific schedule that belonged to each object.

Regards,

lordmilko

Created on Apr 27, 2018 11:24:01 AM by  lordmilko (1,182) 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.