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
Votes:
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
Votes:
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.
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
The script needs to be run on the PRTG server itself as it reads the configuration file.
## 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]
12 Replies
Votes:
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.
Votes:
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.
Votes:
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.
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
The script needs to be run on the PRTG server itself as it reads the configuration file.
## 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:
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.
Votes:
Thanks for your feedback, Corné. Glad it's saving you some time :)
Kind regards,
Stephan Linke, Tech Support Team
Votes:
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
Last change on Mar 13, 2018 6:24:13 AM by
Luciano Lingnau [Paessler]
Votes:
Shock, did you run the script on the actual host machine of the PRTG core server? Or on your client work station?
Votes:
I have the same error that Shock has listed above. I am running the script on our PRTG core server.
Votes:
Also, the times reported are incorrect in the maintenance list. I have a window set to begin at 2019-04-26 19:00 but the script is reporting that it begins 4/27/19 17:00
Votes:
It's working perfectly fine for, still. Does the Windows Server have a different timezone than your PRTG? Could you provide some screenshots of the defined maintenance window and the output of the script?
PRTGapi |
Feature Requests |
WMI Issues |
SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Votes:
Hello,
I've noticed on "Probe Health" sensor (in "Probe Device" device), the "maintenable" object does not exist, generating an error at line number 94 in the script.
Even if this point is not script blocking, if you want, you can just add a conditional test for the block 94-116 :
if($prtgSensor.data.maintenable){ ... }
©2024 Paessler AG Terms & Conditions Privacy Policy Legal Notice Download & Install
Add comment