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!
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'."
# 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'."
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'."
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."
Here is some quick info which assumes you are somewhat familiar with using the SDK already.
The following verbs were added to the Orion.APM.Application entity
CreateApplication
int CreateApplication(int nodeId, int applicationTemplateId, int credentialSetId, bool skipIfDuplicate)
Description
Assigns a template to a node and returns the Application Id of the application
Parameters
DeleteApplication
void CreateApplication(int applicationId)
Deletes an application
PollNow
void PollNow(int applicationId)
Forces the application to be polled
Spectacular! Seems to work well, but I need to upgrade to SAM 5.2 in order for the script to work, but it pulled everything it needed from SWIS!
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.
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?
It looks like the credentialSetID argument is required for the Orion.APM.Application "CreateApplication" verb, so how does one deploy an application monitor that inherits credentials from the application template?
Credentials from SAM credential library are expected to have credentialSetID > 0, but this method should be able to accept following special ids for credentials:
credentialSetID = 0 ...<None>
credentialSetID = -3 ...<Inherit Windows credential from node> (should be used only for WMI nodes)
credentialSetID = -4 ...<Inherit credentials from template>
That works! Thanks!
I have download OrionSDK-1.9 and installed it on my SAM 6.1.1 when i try to run SAM.Application.ps1 through PS i am getting below error
"Get-SwisData : Invalid username or password.
At C:\Program Files (x86)\SolarWinds\Orion SDK\Samples\PowerShell\SAM.Application.ps1:35 char:11
+ $nodeId = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE IP_Address=@i ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-SwisData], MessageSecurityException
+ FullyQualifiedErrorId : SwisError,SwisPowerShell.GetSwisData
Can't find node with IP '10.43.2.221'."
I am using right username and password.
Could you please let me know what i am doing wrong.
Thanks.
Could you post the "Connect-Swis" line so I can see what options you are using?
Hi swapnilm
You should lookup that thread. Access to Orion.NodesCustomProperties denied for NPM 10.5
$username = "IP-0A2B02DD\Administrator"
I was wondering if this works on appinsight? and if so how can I pass a parameter such as the instance name?
vikkyg86, this functionality doesn't work for AppInsight applications. This is something we're considering for the future.
thanks for the response. Is there a new version of the SDK on the horizon with any new functionalities. with NPM 12 out are any existing functions deprecated?