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."

Reply
  • 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."

Children