Quantcast
Channel: THWACK: Popular Discussions - Orion SDK
Viewing all 3719 articles
Browse latest View live

Orion SDK with PowerShell - manage/unmanage multiple nodes

$
0
0

I've been able to script unmanaging and managing nodes in powershell. However, for 400+ nodes, this ends up taking quite a while. Via script, it takes about 7 minutes to unmanage the nodes and over 10 minutes to remanage them. Doing this from the website takes about 25 seconds and no more than a minute, respectively. My guess is that the website somehow group updates the database instead of doing it one at a time. Anyone else seen this or have any idea how to do more than one node at a time? Below is sample code for how I am unmanaging a single node:

 

Invoke-SwisVerb $swis Orion.Nodes Unmanage @("N:$nodeid",$start,$end,"false")

 

Thanks for any advice you have!


NCM PowerShell examples

$
0
0

We recently started rolling NCM out and I have needed to give the Orion Server access to our devices.  As I grant the access I have been making sure that NCM can download the configs successfully by clicking "Download" for Startup and Running in the "Download Config" window on the "CONFIGS" tab of each device.  I thought this would be a good opportunity to test out kicking these downloads off through PowerShell so I tried it on a list of devices but I received an Access denied for "CanDownload" permission.  I have a test script shown below.  What I wanted it to do was use the Connection Profile that already exists on the nodes in question (In this case it is a Cisco device).  I didn't see any mention of providing credentials when using the DownloadConfig verb?  The user I am connecting with can initiate the download of configs through the website using the "Download Config" window mentioned above.  Can someone help me out with a basic example on backing up a config?  Also, if you have other cool things you are doing with NCM through the SDK please feel free to share.

 

 

$hostname = "ncmserver.jeremy.com"

$cred = Get-Credential

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

$nodeIdList = New-Object -TypeName "System.Guid[]" 1

$nodeIdList[0] = '153f4679-8bdc-4478-ba95-403352f5a175'

Invoke-SwisVerb $swis Cirrus.ConfigArchive DownloadConfig @($nodeIdList, "Running")

 

 

 

cmdlet Get-Credential at command pipeline position 1

Supply values for the following parameters:

Invoke-SwisVerb : Access denied. CanDownload permission required.

At ...\001-Solarwinds\Scripts\NCM.Test.ps1:6 char:1

+ Invoke-SwisVerb $swis Cirrus.ConfigArchive DownloadConfig @($nodeIdLi ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

 

Thanks,

Jeremy

Unable to connect to Solarwinds from REST API using AD account

$
0
0

Hi everyone

I am using REST API to query solarwinds data. The fact is when I authenticate by using Solarwinds local user account I can connect to Solarwinds from my API. But when I use an Active Directory account, it’s not work. I can’t connect to Solarwinds from REST API (nor from SWQL) using AD account. But our security policy require to connect with an AD account. Did someone already experienced this problem and could help me?

 

King regards,

 

Tokey

 

IPAM + PowerShell

$
0
0

Greetings,

 

Used the following to get an available IP:How to use the IPAM API and get "Free IP Address"

 

Getting an error while trying to update any information:

Set-SwisObject : Operation not supported on IPAM.IPNode

 

While using the following:

 

$ip = Get-SwisData $swis 'SELECT TOP 1 I.DisplayName FROM IPAM.IPNode I WHERE Status=2 AND I.Subnet.DisplayName = ''1.1.0.0/24'''

$ipobject = Get-SwisObject -Uri (Get-SwisData $swis ('SELECT Uri from IPAM.IPNode where IPAddress = ''' + $ip + '''')) -SwisConnection $swis

 

$customProps = @{

  Description="TACOS";

}

 

Set-SwisObject -Uri $ipobject.Uri -SwisConnection $swis -Properties $customProps

 

Anyone trying to reserve IPs???

Trying to add a node with the add_node.py script

$
0
0

I get the following errors:

 

Add an SNMP v2c node:

/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html

  InsecureRequestWarning)

Adding node 127.0.0.1... DONE!

Traceback (most recent call last):

  File "add_node2.py", line 71, in <module>

    main()

  File "add_node2.py", line 33, in main

    nodeid = re.search('(\d+)$', results).group(0)

  File "/usr/lib64/python2.7/re.py", line 142, in search

    return _compile(pattern, flags).search(string)

TypeError: expected string or buffer

 

Any ideas?

Javascript in a Custom HTML Resource and the API

$
0
0

Hi, I am often asked to create dashboards that include visual options that are not presently available within Orion's native resources.  I am currently exploring the possibility of retrieving the data from the API and creating the required graphs with one of the many existing Javascript visualisation packages that are currently available.

 

Is this actually feasible or will CORS restrictions within the browser and/or the web service prevent this from working?  Secondly, is it going to be necessary to embed credentials in the javascript or is there a way either pass forward the authentication from the existing orion session OR a magic user that has read only access to the SDK available that we could use for this?

Unable to connect to Solarwinds from REST API using AD account

$
0
0

Hi everyone

I am using REST API to query solarwinds data. The fact is when I authenticate by using Solarwinds local user account I can connect to Solarwinds from my API. But when I use an Active Directory account, it’s not work. I can’t connect to Solarwinds from REST API (nor from SWQL) using AD account. But our security policy require to connect with an AD account. Did someone already experienced this problem and could help me?

 

King regards,

 

Tokey

 

Concat Orion Variable with string in SWQL?

$
0
0

Hello,

I am trying to automate naming my nodes in Orion using custom properties .  I think CASE in SWQL would be a simple way to do this but am having problems concatenating a string with a Orion variable.

 

  CASE

      WHEN  IPAddress LIKE '192.168.10.%' THEN ${City}

      WHEN  IPAddress LIKE '%.100' THEN ${City} + '-DC'

      WHEN  IPAddress LIKE '%.101' THEN ${City} + '-EXCH'    ELSE ${Caption} END AS N.Caption

 

SWQL doesn't like using the plus sign.  Any sugestions?  Thanks for your help!


Does the default config backup job do write command on cisco devices after uploaded its config?

$
0
0

Hello,

Can you help me with this question, please?

Copy Discovery Job

$
0
0

I am trying to discover how to copy a discovery job, change it's name and subnet and add it.  Any ideas on how you would go about this?

 

I have a discovery job defined and I have about 150 of these to make.  The only difference in each of the discoveries is the name and the subnet.

 

Ideas?

 

Thanks

Upgrade from NMP 11.0.1 to 11.5 breaks SDK 1.10 set CustomProperties

$
0
0
Hello all,

I want to thank those that released the SDK.  It's a great tool and we've used it extensively.
We have a powershell script, using v1.10.16.0 of the SDK, which we use to add nodes, setup pollers, and set the nodes Custom Properties.  After upgrading Orion Network Performance Monitor from 11.0.1 to 11.5 values for Custom Properties no longer get set.  It's as if the initial node creation seems to no longer create the ground work or index for custom properties to be added/edited.  When we run the script there's no errors generated.
After a node is added via the PS script, if you go in through the WebGUI, and edit the custom properties of the node, save it and go back, the values for those custom properties have reverted back to the origional values.  We are not seeing any issues if a node is manually added via the GUI.  I have a feeling some of the tables have been split and it's almost like the '
Has anyone else run into this issue?
# Basic add node, add n-pollers, set some custom props (p.s. what circle of hell did I enter trying to copy and paste into this form's editor?)
#PSSnapin presence check/add
if (!(Get-PSSnapin-Name"SwisSnapin"-ErrorActionSilentlyContinue))
    { Add-PSSnapinSwisSnapin-ErrorActionSilentlyContinue }
# Default values
[string]$AlertingTier="SysOps Linux - P1 Very Urgent"
[string]$Access_KCNDataCenter="No"
[String]$KCNHardwareType="None"
[string]$ResponsibleGroup="Server Operations (Linux)"
[string]$Community="public"
[string]$SiteAddressState="MO"
ip2guid($ipString) {
  $ip=[System.Net.IPAddress]::Parse($ipString)
  $src=$ip.GetAddressBytes();
  $data=new-objectbyte[]16
  $src.CopyTo($data,$data.Length -$src.Length)
  $dest=new-objectbyte[]16
  [Array]::Copy($data,12,$dest,0,4)
  [Array]::Copy($data,10,$dest,4,2)
  [Array]::Copy($data,8,$dest,6,2)
  [Array]::Copy($data,6,$dest,8,2)
  [Array]::Copy($data,0,$dest,10,6)

  return (New-ObjectGuid (,$dest)).ToString()
}
AddPoller($PollerType) {
  $poller["PollerType"]=$PollerType;
  $pollerUri=New-SwisObject$swis-EntityType"Orion.Pollers"-Properties$poller
}

# Connect to SolarWinds
$SWhost ="cgslpwiswnpm01.centric.com"
$username="user"
$password =Read-Host-Prompt"Enter password"-AsSecureString
$cred =New-Object-typenameSystem.Management.Automation.PSCredential-argumentlist$username,$password
$swis = Connect-Swis-host$SWhost-cred$cred
# For simplicity just putting in a host and IP
# In the script we have steps to verify fqdn and ip
$hostname = 'somehost'
$ip = '10.0.0.1'
$ipGuid=ip2guid($ip)
# add a node
$newNodeProps= @{
  EntityType="Orion.Nodes";
  IPAddress=$ip;
  IPAddressGUID=$ipGuid;
  Caption=$hostname;
  DynamicIP=$False;
  Engine=1;
  Status=1;
  UnManaged=$False;
  Allow64BitCounters=$False;
  SysObjectID="";
  MachineType="";
  VendorIcon="";
  ObjectSubType="SNMP";
  SNMPVersion=2;
  Community=$Community;
}
$newNodeUri=New-SwisObject$swis-EntityType"Orion.Nodes"-Properties$newNodeProps
$nodeProps=Get-SwisObject$swis-Uri$newNodeUri

# register specific pollers for the node
$poller= @{
  NetObject="N:"+$nodeProps["NodeID"];
  NetObjectType="N";
  NetObjectID=$nodeProps["NodeID"];
}
### Create N-type Pollers
AddPoller("N.Status.SNMP.Native");
AddPoller("N.ResponseTime.ICMP.Native");
AddPoller("N.Details.SNMP.Generic");
AddPoller("N.Uptime.SNMP.Generic");
AddPoller("N.Cpu.SNMP.NetSnmpSystemStats");
AddPoller("N.Cpu.SNMP.NetSnmpCpuIdle");
AddPoller("N.Memory.SNMP.NetSnmpReal");
AddPoller("N.IPAddress.ICMP.Generic");

## Prepare a custom property value
$customProps= @{
  AlertingTier=$AlertingTier;
  ResponsibleGroup=$ResponsibleGroup;
  KCNHardwareType=$KCNHardwareType;
  SiteAddressState=$SiteAddressState;
  Comments="Host added by script";

## Build the Custom Properties node URI
$SWNodeURICP="$newNodeUri/CustomProperties"
## Set Custom Properties
Set-SwisObject$swis-Uri$SWNodeURICP-Properties$customProps



SDK Admin Manual

$
0
0

I have just downloaded OrionSDK-1.9.zip and extracted the msi, but there is no trace of pdf file for the documentation.

After installing the msi , I found it in C:\Program Files (x86)\SolarWinds\Orion SDK\Documentation as Orion SDK.pdf.

Just in case anybody is wondering about that.

IPAM + PowerShell

$
0
0

Greetings,

 

Used the following to get an available IP:How to use the IPAM API and get "Free IP Address"

 

Getting an error while trying to update any information:

Set-SwisObject : Operation not supported on IPAM.IPNode

 

While using the following:

 

$ip = Get-SwisData $swis 'SELECT TOP 1 I.DisplayName FROM IPAM.IPNode I WHERE Status=2 AND I.Subnet.DisplayName = ''1.1.0.0/24'''

$ipobject = Get-SwisObject -Uri (Get-SwisData $swis ('SELECT Uri from IPAM.IPNode where IPAddress = ''' + $ip + '''')) -SwisConnection $swis

 

$customProps = @{

  Description="TACOS";

}

 

Set-SwisObject -Uri $ipobject.Uri -SwisConnection $swis -Properties $customProps

 

Anyone trying to reserve IPs???

I have never worked with Solar Winds to add servers. I am trying to add aserver through the Manage Nodes and it says Test Failed. I ping the server and it is there. What am I doing wrong or missing?

$
0
0

I am trying to add a server to Orion. Using the Manage Nodes section, I put in the server name and it comes back as Test Failed. I can ping the server.

Help with Best Way to Retrieve a List of Objects Based on Alert Trigger Condition Scopes (Summary Report)

$
0
0

Before I spend anymore time working on this, I wanted to post this to see if there is a better way.  I need a report that will tell me what objects each configured Alert can trigger on based on an alert's Trigger Condition Scope (Kind of like a big Summary Report of the "All Objects this Alert Can Trigger but instead of being for one object, I want it for all objects and all alerts.)  Since I can't find whatever Query drives the "All Objects this Alert Can Trigger" and use that to just build a SWQL/SQL statement, I figured I could just parse the XML from the "Trigger" field in the AlertConfigurations table.  The problem there is that while I'm pretty good with SQL/SWQL, I'm more comfortable with PowerShell and feel like it'd be easier to parse the XML using that instead of some complex LIKE statement in SQL/SWQL.  Especially since PowerShell can navigate through the XML in that Trigger field so well.

 

Even though XML is pretty easy to manipulate in PowerShell, I feel like there is probably a better way, so I'm hoping somebody can advise me on this (especially aLTeReGo or tdanner, but anyone knowledgeable is fine) before I waste a bunch of time creating the PowerShell script or learning how to work with and parse XML in SQL/SWQL and creating a complex query to evaluate all of these.  I want to say I found the SWQL query that the "All Objects this Alert Can Trigger" uses once a few months ago either in a log file (due to a "Long Running Query" warning message in the SWIS or OrionWebsite log file), but even with Verbose logging turned on I don't see anything about that resource's backend code.  I found the files that drive that resource in the InetPub folder but they don't have the query in there at all either, so I'm guessing it's buried in a DLL file somewhere.


Javascript in a Custom HTML Resource and the API

$
0
0

Hi, I am often asked to create dashboards that include visual options that are not presently available within Orion's native resources.  I am currently exploring the possibility of retrieving the data from the API and creating the required graphs with one of the many existing Javascript visualisation packages that are currently available.

 

Is this actually feasible or will CORS restrictions within the browser and/or the web service prevent this from working?  Secondly, is it going to be necessary to embed credentials in the javascript or is there a way either pass forward the authentication from the existing orion session OR a magic user that has read only access to the SDK available that we could use for this?

Orion SDK sample script error

$
0
0

Hello,

 

I'm attempting to run a couple sample Python scripts from the Orion SDK.  I have a script I wrote myself and the 2 sample scripts from the SDK that error out with the following:

 

Traceback (most recent call last):

  File "sw-test2.py", line 18, in <module>

    results = swis.query("SELECT TOP 3 NodeID, DisplayName FROM Orion.Nodes")

  File "/usr/local/lib/python2.7/dist-packages/orionsdk/swisclient.py", line 24, in query

    {'query': query, 'parameters': params}).json()

  File "/usr/local/lib/python2.7/dist-packages/orionsdk/swisclient.py", line 50, in _req

    headers={'Content-Type': 'application/json'})

  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 50, in request

    response = session.request(method=method, url=url, **kwargs)

  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 465, in request

    resp = self.send(prep, **send_kwargs)

  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 573, in send

    r = adapter.send(request, **kwargs)

  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 415, in send

    raise ConnectionError(err, request=request)

requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))

 

I can telnet to TCP 17778.

 

Here is one of the sample scripts:

 

import requests

from orionsdk import SwisClient

 

 

npm_server = 'X.X.X.X'

username = 'Xuser'

password = 'Xpassword'

 

 

verify = False

if not verify:

    from requests.packages.urllib3.exceptions import InsecureRequestWarning

    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

 

 

 

 

swis = SwisClient(npm_server, username, password)

 

 

print("Query Test:")

results = swis.query("SELECT TOP 3 NodeID, DisplayName FROM Orion.Nodes")

#results = swis.query("SELECT SysName, FROM Orion.Nodes, WHERE SysName LIKE '%ASRT%'")

 

 

for row in results['results']:

    #print("{NodeID:<5}: {DisplayName}".format(**row))

    print row

 

 

If I use curl:

 

# curl -k -v -u Xuser:Xpassword https://X.x.x.x:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+TOP+5+Caption+FROM+Orion.Nodes

*   Trying X.x.x.x...

* Connected to X.x.x.x (X.x.x.x) port 17778 (#0)

* found 173 certificates in /etc/ssl/certs/ca-certificates.crt

* found 697 certificates in /etc/ssl/certs

* ALPN, offering http/1.1

* gnutls_handshake() failed: Error in the pull function.

* Closing connection 0

curl: (35) gnutls_handshake() failed: Error in the pull function.

 

Can anyone suggest things that I should look at?

 

Thanks,

 

Mike

Is it Possible?

$
0
0

First of all, I am no programmer and do not pretend to be one.

 

Management is wanting my team to build "application" views.  It was proposed to use our CMDB feed to populate the custom properties with the application name.

 

So, my question is.  Is this something that is possible using SWIS?  What I'm thinking is, have it do an initial population and a daily update to look for any changes.

 

Before I go down the route of finding someone to build the integration, has anyone tried this or something similar?  If successfully building the integration, any tips / suggestions?

Setting CreateCorePluginConfiguration details for Orion.Discovery in python

$
0
0

I've been trying to manage adding and removing nodes using the API.  My language of choice is python.  I have most of the discovery profile details figured out, but am not able to understand how to set things linke the Volume Types, Vlan Port Types, etc...

 

I'm not able to figure out how to specify that I only want Flash and Ram volume types. Only Access and Trunk interfaces.

I've tried various permutations of (Look at the code for the details of where this is applied):

    'AutoImportStatus': [{'IfAutoImportStatus':'Up'}],    'AutoImportVlanPortTypes': [{'Trunk': False}, {'Access':False}]    'AutoImportVlanPortTypes': [{'VlanPortType':'Trunk'}, {'VlanPortType':'Access'}],    'AutoImportVolumeTypes': [{'VolumeType': 'FlashMemory'},{'VolumeType': 'RAM'}]

 

 

Here is the python code I have so far:

from __future__ import print_function
import re
import requests
from orionsdk import SwisClient


def main():
    npm_server = 'MyServer'    username = 'MyUser'    password = 'MyPass'    names = ['MyDev1','MyDev2','MyDev3']    bulkList_names = []    for name in names:        bulkList_names.append({'Address': name})    print (bulkList_names)    orion_engine_id = 1    swis = SwisClient(npm_server, username, password)    corePluginContext = {    'BulkList': bulkList_names,    'Credentials': [    {    'CredentialID': 5,    'Order': 1    }    ],    'WmiRetriesCount': 0,    'WmiRetryIntervalMiliseconds': 1000,    'IsDiscoveryForVimEnabled': False,
#    'AutoImportStatus': [{'IfAutoImportStatus':'Up'}],
#    'AutoImportVlanPortTypes': [{'Trunk': False}, {'Access':False}]
#    'AutoImportVlanPortTypes': [{'VlanPortType':'Trunk'}, {'VlanPortType':'Access'}],
#    'AutoImportVolumeTypes': [{'VolumeType': 'FlashMemory'},{'VolumeType': 'RAM'}]    }    corePluginConfig = swis.invoke('Orion.Discovery', 'CreateCorePluginConfiguration', corePluginContext)    discoveryProfile = {    'Name': 'API discovery',    'EngineID': orion_engine_id,    'JobTimeoutSeconds': 3600,    'SearchTimeoutMiliseconds': 5000,    'SnmpTimeoutMiliseconds': 5000,    'SnmpRetries': 2,    'RepeatIntervalMiliseconds': 1800,    'SnmpPort': 161,    'HopCount': 0,    'PreferredSnmpVersion': 'SNMP2c',    'DisableIcmp': False,    'AllowDuplicateNodes': False,    'IsAutoImport': True,    'IsHidden': False,    'PluginConfigurations': [{'PluginConfigurationItem': corePluginConfig}]    }    print("Running discovery...")    result = swis.invoke('Orion.Discovery', 'StartDiscovery', discoveryProfile)    print("Returned discovery profile id {}".format(result))


requests.packages.urllib3.disable_warnings()


if __name__ == '__main__':
    main()

PowerShell or Python ?

$
0
0

Ive taken a few python classes at school a while back and while I enjoyed it I never used it too much in the real world. From doing research and reading various posts I seem to have this feeling that knowing powershell vs python would put me in a much better position to excel as a SolarWinds admin.  Curious on Tdanners and others thoughts. 

Viewing all 3719 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>