This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

How can I deploy Application monitors using Powershell and the Orion SDK?

FormerMember
FormerMember

I've been told by that Orion SDK v1.5 support the deployment of application monitors in SAM 5.2 (awesome!), but I don't see any documentation for that.  Can anyone provide an example of this or point me to some updated documentation?

Thanks!

Parents
  • Hello,


    We are creating sample script for demonstrate this functionality right now. Here is the simple script to demonstrate the creating the application, executing "Poll Now" and deleting the application:

    # This sample script demonstrates the use of verbs provided for manipulating

    # with applications and templates. The verbs are defined by "Orion.APM.Application"

    # entity type.

    #

    # The script progresses in several steps, it:

    # 1. Creating a new application by assigning a template to a node.

    # 2. Executing "Poll Now" on an application

    # 3. Deleting an application

    #

    # Please update the hostname and credential setup to match your configuration.

    if (! (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {

        Add-PSSnapin "SwisSnapin"

    }


    # Connect to SWIS

    $hostname = "localhost"

    $username = "admin"

    $password = New-Object System.Security.SecureString

    $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

    $swis = Connect-Swis -host $hostname -cred $cred


    #

    # ASSIGNING TEMPLATE TO A NODE

    #

    # Select the node, application template and credential set and create the application by assigning template to node

    # with selected credential set.

    #


    # Select the node

    $ip = '10.140.127.221'

    $nodeId = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE IP_Address=@ip" @{ip=$ip}

    if (!$nodeId) {

      Write-Host "Can't find node with IP '$ip'."

      exit 1

    }


    # Select the template

    $template = 'Windows Server 2003-2008 Services and Counters'

    $applicationTemplateId = Get-SwisData $swis "SELECT ApplicationTemplateID FROM Orion.APM.ApplicationTemplate WHERE Name=@template" @{template=$template}

    if (!$applicationTemplateId) {

      Write-Host "Can't find template with name '$template'."

      exit 1

    }


    # Select the credential

    $credential = 'MyCredential'

    $credentialId = Get-SwisData $swis "SELECT ID FROM Orion.Credential WHERE CredentialOwner='APM' AND Name=@credential" @{credential=$credential}

    if (!$credentialId) {

      Write-Host "Can't find credential with name '$credential'."

      exit 1

    }


    Write-Host "Creating application on node '$nodeId' using template '$applicationTemplateId' and credential '$credentialId'."


    # Assign application template to node to create the application

    $applicationId = (Invoke-SwisVerb $swis "Orion.APM.Application" "CreateApplication" @(

        # Node ID

        $nodeId,

        # Application Template ID

        $applicationTemplateId,

        # Credential Set ID

        $credentialId,

        # Skip if duplicate (in lowercase)

        "true"

      )).InnerText


    # Check if application was created

    if ($applicationId -eq -1) {

      Write-Host "Application wasn't created. Likely the template is already assigned to node and the skipping of duplications are set to 'true'."

      exit 1

    }

    else {

      Write-Host "Application created with ID '$applicationId'."

    }


    #

    # EXECUTING "POLL NOW"

    #

    # Execute "Poll Now" on created application.

    #

    Write-Host "Executing Poll Now for application '$applicationId'."

    Invoke-SwisVerb $swis "Orion.APM.Application" "PollNow" @($applicationId) | Out-Null

    Write-Host "Poll Now for application '$applicationId' was executed."


     

    #

    # DELETING APPLICATION

    #

    # Delete the created application.

    #

    Write-Host "Deleting application '$applicationId'."

    Invoke-SwisVerb $swis "Orion.APM.Application" "DeleteApplication" @($applicationId) | Out-Null

    Write-Host "Application '$applicationId' was deleted."

  • FormerMember
    0 FormerMember in reply to lukas.belza

    I've upgraded to SAM 5.2 and this is working great!  I would like to be able to modify the name and script arguments of the application monitor via the SDK once it is deployed.  Any ideas?

  • That's not supported through the SDK at this time. I'll make the product manager aware of your request.

  • FormerMember
    0 FormerMember in reply to tdanner

    Cool, thanks!  A related question -- is there a verb for Orion.APM.Application that I can invoke that will allow me to unmanage an application or a component?

  • Orion.APM.Application has Unmanage/Remanage verbs. The arguments take the same for as the arguments to Orion.Nodes.Unmanage/Remanage. Net object IDs for applications look like "AA:8".

    The product does not support unmanaging individual components. Is that something you are interested in?

  • FormerMember
    0 FormerMember in reply to tdanner

    That rocks!  I think I can get by with unmanaging the entire application at this point, but the ability to unmanage/disable components would be a great thing to have the toolbox.  Thanks for the help!

  • FormerMember
    0 FormerMember in reply to tdanner

    I am having some trouble using that Swis verb:

    -begin script except-

    $AppID = $monitors.ApplicationID

    $now = Get-Date

    $later = $now.AddDays(1)

    Invoke-SwisVerb $swis "Orion.APM.Application" "Unmanage" @("AA:1922", $now, $later, "false")

    - end script except -

    Script Output:

    Invoke-SwisVerb : Could not load type 'SolarWinds.InformationService.Addons.IServiceHost' from assembly 'SolarWinds.InformationService.Addons, Version=2012.1.0.310, Culture=neutral, PublicKeyToken=null'.

    At line:30 char:16

    + Invoke-SwisVerb <<<<  $swis "Orion.APM.Application" "Unmanage" @("AA:1922", $now, $later, "false")

        + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

        + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

  • It looks like this is a known issue (bug 174380) with SAM 5.2 and SWISv3. Try the Unmanage call while connected to SWISv2 (Connect-Swis -v2).

Reply Children