Open for Voting
over 2 years ago

Schedule recurring maintenance (unmanage) for nodes and groups

It would be extremely useful to have a function within Orion to schedule recurring maintenance windows for nodes and for groups of nodes.

Examples of use-case scenarios:

  • We have an application that restarts its services for nightly maintenance at 3:00 AM, and should be back up by 3:45 AM.
  • Don't send alerts for non-critical dev/test servers during off business hours (nights and weekends).
  • We have our servers patch on a rotating schedule, with our "Week 1" including non-production servers to be patched on the Sunday following Patch Tuesday. Our production servers are split into 3 groups ("Week {2-4}") that get patched on subsequent Sunday evenings.

As far as I can tell, our only option for achieving this is still (SAM 6.7) to create an SWQL script to unmanage/remanage nodes and run it with Windows Task Scheduler.

  • As a workaround you could also run a script using SWIS to mass unmanage nodes. My server team does it all the time.

    Add-PSSnapin SwisSnapin

    $swis = Connect-Swis -host ORIONSERVERNAME -Trusted

    $targetID = Get-SwisData $swis 'SELECT NodeID FROM Orion.Nodes WHERE Caption = @caption' @{ caption = 'SERVERTOUNMANAGE' } 

    Invoke-SwisVerb $swis 'Orion.Nodes' 'Unmanage' @( "N:$($targetID)", $startDate, $endDate, $false ) | Out-Null 

  • I like what you've done there, but I don't see how to apply it to my environment where I want to unmanage some Cisco ASA firewalls regularly.

    I have seven pollers, and am not managing/unmanaging servers--I'm working on firewall nodes.  Are they required to be listed in your line "$swis = Connect-Swis -host ORIONSERVERNAME -Trusted"?  Or do I list the various firewalls by Node Name in that line, separated by commas?

    The target is to completely unmanage them from 7 a.m. to 10 a.m. every day.  I don't see the way accomplish that in your script, but it's most likely because I don't understand the commands for starting & stopping the unmanage job on recurring dates & times.  I bet it's simple, but I'd be guessing randomly at it.  Any hints for the script to do this task?

  • Try this in your lab environment first !

    First load up the Solarwinds SDK on your machine and then ensure that machine is a managed node in Orion. It can be ICMP Only but make sure its in Orion.

    Get the SDK here and install it.

    -Make a directory on the root of the C drive called SWIS

    -In the SWIS directory create a file with notepad called nodes-to-unmanage.txt. Enter the nodes CAPTION from Oroin for all the nodes you want to unmanage and save it.

    -In the SWIS directory create a file with notepad called UnmanageNodes.ps1 and save it.

    -Right click on the UnmanageNodes.ps1 file in the SWIS directory and click edit. This should open Powershell Editor

    -Paste the code below in:

    #Loads the SDK

    Add-PSSnapin SwisSnapin

    #Connecto to your Orion Server

    #$swis = Connect-Swis -host -Trusted

    $swis = Connect-Swis -host -UserName RSCHROEDER -Password ILOVEFISHING

    #Used to test your connection if needed

    #Get-SwisData $Swis 'SELECT NodeID, Caption FROM Orion.Nodes'

    Unmanages the nodes in the text file

    Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE Caption IN @captions" @{captions=(Get-Content .\nodes-to-unmanage.txt)} | Set-SwisObject $swis -Properties @{UnmanageFrom=[DateTime]::UtcNow;UnmanageUntil=[DateTime]::UtcNow.AddHours(1)}

    -In the code above, you need to enter use the fully qualified name and then enter -UserName RSCHROEDER -Password ILOVEFISHING, create a node management only account and use that one.

    -Save your script and then run it using the Play button or you can click on it in the directory. It should unmanage the nodes you listed in the nodes-to-unmanage.txt file for one hour (UtcNow.AddHours(1)}). You can change that value up if you like.

    -Now if it works fine, you can also run the script as the currently logged in user, and not have a password showing in you script by removing this line:

      $swis = Connect-Swis -host -UserName RSCHROEDER -Password ILOVEFISHING

    and taking the comment # from the beginning of:

    $swis = Connect-Swis -host -Trusted

    -If you want to test just the log in portion to ensure your ID is working uncomment this line temporarily and then comment out the bottom line. This will connect then show a list of all of your nodes.

    its an easier way to test if your connection / orion server /ID is working.

    Once you get the script working you can set it to run in a number of ways. Set it as a Windows Scheduled Task would be the simplest.

    Hope this helps emoticons_happy.png

  • One other comment, I did find that nodes with spaces or $ in their CAPTION failed on this. Once I get that resolved I will post the fix.

  • Impressive!  Somehow it's also more intuitive to read and let me think I understand it.

    Thank you, bobmarley​!

Comment Children