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


One-Time maintenance window list

Votes:

0

Your Vote:

Up

Down

Hi, Do you have a way to view all the scheduled Maintenance windows in a list. It would be nice to check they are set etc.

Thanks Mike

list maintenance one-time

Created on Oct 8, 2013 4:44:06 PM by  Mike (0) 1



Best Answer

Accepted Answer

Votes:

5

Your Vote:

Up

Down

This article applies to PRTG Network Monitor 16 or later.

Disclaimer: This script is a proof-of-concept and comes as-is. It comes without support. Using it happens at your own risk.

Introduction

This script will give you a list of configured maintenance windows within PRTG, including the object ID, name, type, start/end of the maintenance and its duration. Here's what it looks like:


All configured maintenance windows in PRTG

Installation

Remarks

The script needs to be run on the PRTG server itself as it reads the configuration file.

Setup
  1. Create a new PowerShell script on the desktop of the PRTG server
  2. Paste the script, save it and start it

Script

## PRTG configuration 
[string] $ConfigurationFilePath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "PRTG Configuration.dat"
   [xml] $configuration = New-Object -TypeName XML;
         $configuration.Load($ConfigurationFilePath)

## PRTGs internal start date
$Start = Get-Date -Date "1899-12-30 23:00:00Z"

## nodes 
$prtgGroups  = $configuration.SelectNodes("//group")
$prtgDevices = $configuration.SelectNodes("//device")
$prtgSensors = $configuration.SelectNodes("//sensor")
#endregion

#region function
<# Function Section
#################################
All functions of the script are defined here. 
############################### #>

<# Function Name: This-GetXMLValue
#################################
Used For: Retrieving XML values. Returns inherited if the trim fails (i.e. if there's nothing to trim
#################################
Parameters: 
# [xml]    object - the object that should have it's node extracted
# [string] node   - the node you want retrieved
################################# #>
function This-GetXMLValue($object,[string]$node){

    try   { $value = $object.data.$node.trim(); }
    catch { $value = "Inherited" }

    return $value;

}
#endregion

$MaintenanceList = @(); 

foreach($prtgGroup in $prtgGroups){

    if((($prtgGroup.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtggroup.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtggroup.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
    $Group = [pscustomobject]@{
            ID   = $prtgGroup.ID
            Name = $prtgGroup.data.name.Trim()
            Type = "Group"
            "Maintenance Start" = $maintenanceStart
            "Maintenance End"   = $maintenanceEnd
            Duration            = $duration
           
           }
     $MaintenanceList += $Group 
    }
}

foreach($prtgDevice in $prtgDevices){

    if((($prtgDevice.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgDevice.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgDevice.data.maintend)
      

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
        $Device = [pscustomobject]@{
                ID   = $prtgDevice.ID
                Name = $prtgDevice.data.name.Trim()
                Type = "Device"
            
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                Duration            = $duration
           
        }
        $MaintenanceList += $Device;
    }
}

foreach($prtgSensor in $prtgSensors){

    if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgSensor.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgSensor.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
   
        $Sensor = [pscustomobject]@{
                ID   = $prtgSensor.ID
                Name = $prtgSensor.data.name.Trim()
                Type = "Sensor"
                "Has Maintenance Configured" = $maintenanceEnabled
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                 Duration            = $duration
               }
         $MaintenanceList += $Sensor; 
        }
}

$MaintenanceList | Out-GridView -Title "Maintenance List"

Created on Apr 21, 2017 7:27:37 AM by  Stephan Linke [Paessler Support]

Last change on Mar 13, 2018 11:30:02 AM by  Torsten Lindner [Paessler Support]



8 Replies

Votes:

0

Your Vote:

Up

Down

I'm afraid such a function is not yet available, but I have added it to the wish list for future consideration. Please bear with us.

Created on Oct 9, 2013 12:32:19 PM by  Patrick Hutter [Paessler Support] (7,114) 3 3



Votes:

0

Your Vote:

Up

Down

thank you.

Created on Oct 9, 2013 12:34:47 PM by  Mike (0) 1



Votes:

0

Your Vote:

Up

Down

Question about this: Has this been implemented yet? Because I can't find this functionality (running version 17.1.29.1427)

Reason: One of our providers announced Maintenance on one of our connections. So I added a One time maintenance to a list of devices. However, the provider just notified us they changed the date of the maintenance. So now I want to remove the previously added One time maintenance, so the devices won't be paused for nothing.

Created on Apr 20, 2017 2:29:39 PM by  Corné van den Bosch (30) 1



Accepted Answer

Votes:

5

Your Vote:

Up

Down

This article applies to PRTG Network Monitor 16 or later.

Disclaimer: This script is a proof-of-concept and comes as-is. It comes without support. Using it happens at your own risk.

Introduction

This script will give you a list of configured maintenance windows within PRTG, including the object ID, name, type, start/end of the maintenance and its duration. Here's what it looks like:


All configured maintenance windows in PRTG

Installation

Remarks

The script needs to be run on the PRTG server itself as it reads the configuration file.

Setup
  1. Create a new PowerShell script on the desktop of the PRTG server
  2. Paste the script, save it and start it

Script

## PRTG configuration 
[string] $ConfigurationFilePath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "PRTG Configuration.dat"
   [xml] $configuration = New-Object -TypeName XML;
         $configuration.Load($ConfigurationFilePath)

## PRTGs internal start date
$Start = Get-Date -Date "1899-12-30 23:00:00Z"

## nodes 
$prtgGroups  = $configuration.SelectNodes("//group")
$prtgDevices = $configuration.SelectNodes("//device")
$prtgSensors = $configuration.SelectNodes("//sensor")
#endregion

#region function
<# Function Section
#################################
All functions of the script are defined here. 
############################### #>

<# Function Name: This-GetXMLValue
#################################
Used For: Retrieving XML values. Returns inherited if the trim fails (i.e. if there's nothing to trim
#################################
Parameters: 
# [xml]    object - the object that should have it's node extracted
# [string] node   - the node you want retrieved
################################# #>
function This-GetXMLValue($object,[string]$node){

    try   { $value = $object.data.$node.trim(); }
    catch { $value = "Inherited" }

    return $value;

}
#endregion

$MaintenanceList = @(); 

foreach($prtgGroup in $prtgGroups){

    if((($prtgGroup.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtggroup.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtggroup.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
    $Group = [pscustomobject]@{
            ID   = $prtgGroup.ID
            Name = $prtgGroup.data.name.Trim()
            Type = "Group"
            "Maintenance Start" = $maintenanceStart
            "Maintenance End"   = $maintenanceEnd
            Duration            = $duration
           
           }
     $MaintenanceList += $Group 
    }
}

foreach($prtgDevice in $prtgDevices){

    if((($prtgDevice.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgDevice.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgDevice.data.maintend)
      

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
        $Device = [pscustomobject]@{
                ID   = $prtgDevice.ID
                Name = $prtgDevice.data.name.Trim()
                Type = "Device"
            
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                Duration            = $duration
           
        }
        $MaintenanceList += $Device;
    }
}

foreach($prtgSensor in $prtgSensors){

    if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgSensor.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgSensor.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
   
        $Sensor = [pscustomobject]@{
                ID   = $prtgSensor.ID
                Name = $prtgSensor.data.name.Trim()
                Type = "Sensor"
                "Has Maintenance Configured" = $maintenanceEnabled
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                 Duration            = $duration
               }
         $MaintenanceList += $Sensor; 
        }
}

$MaintenanceList | Out-GridView -Title "Maintenance List"

Created on Apr 21, 2017 7:27:37 AM by  Stephan Linke [Paessler Support]

Last change on Mar 13, 2018 11:30:02 AM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Regarding my post of April 20th: Now I run this script (it throws some errors, but it still gives me the list; I'll have to find time to get rid of the errors) and it displays the list of future and past One Time Maintenance windows.

Together with the solution of https://kb.paessler.com/en/topic/75783-cancel-one-time-maintenance-windows I am now able to remove the One Time Maintenance for the sensors if needed.

Created on Oct 12, 2017 2:14:38 PM by  Corné van den Bosch (30) 1



Votes:

0

Your Vote:

Up

Down

Thanks for your feedback, Corné. Glad it's saving you some time :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Oct 13, 2017 7:38:49 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I get the following errors when running this as an administrator on main Probe Server.

You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Created on Mar 10, 2018 4:18:58 PM by  Shock (0)

Last change on Mar 13, 2018 6:24:13 AM by  Luciano Lingnau [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Shock, did you run the script on the actual host machine of the PRTG core server? Or on your client work station?

Created on Mar 13, 2018 11:30:44 AM by  Torsten Lindner [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.