Quantcast
Channel: THWACK: All Content - Orion SDK
Viewing all 2677 articles
Browse latest View live

How to fetch Total Ingress & Egress Bytes for Orion.NetFlow.IPAddressGroups using SDK

$
0
0

Hi All,

I have SWQL Studio and NTA installed. I created multiple IP Address Group and would like to get Ingress and Egress Bytes for a particular IPAddressGroup using SWQL Studio. What are the inputs that I should give in the SWQL Query to fetch Ingress and Egress Byte count:

 

This is the SWQL on right side pane from Orion.NetFlow.IPAddressGroupsConversationsTop:

SELECT ConversationID, SourceIPGroupID, DestinationIPGroupID, SourceIPGroupName, DestinationIPGroupName, NodeID, InterfaceID, TotalBytes, TotalPackets, TotalBytesIngress, TotalBytesEgress, TotalPacketsIngress, TotalPacketsEgress
FROM Orion.NetFlow.IPAddressGroupsConversationsTop

WHERE SourceIPGroupName='Airoli-Axis'

I am getting the below output when execute the SQL Query:

"The parameters 'Filter,Limit,Topkey' are missing for entry Orion.NetFlow.IPAddressGroupsConversationsTop"

Does anyone tested with the above and help me out.

 

thanks in advance

Arun


How do I add CPU, RAM, and Disk pollers to a new SNMP node via the Python API?

$
0
0

I am attempting to add nodes via SNMP using python.  I have previously been using ICMP to add the nodes only for Status and response time polling, but would like to expand further and gather more information automatically.  Is there a good way to try to authenticate over SNMP using the SNMP string, and if the string verifies, add the node?  I currently am using this snippet of code, and it does successfully add an SNMP node, but the only statistics that show up on the node page are for Average Response Time and Packet Loss, but CPU load, Memory, and any disks are not detected.  I may not be fully understanding the polling aspect and how it works in regards to the API, but I would like to essentially recreate what happens when I "List Resources" on a node and select which disks, CPU, RAM, and other properties to monitor.  If someone could take a look at my poller options and let me know if I am making a mistake somewhere that would be great.


Also, can I use some sort of try/catch exception handling when adding SNMP nodes, in case the string does not authenticate, I can revert back to adding the node via simply ICMP?


Thanks!


uri = swis.create(EntityType,   IPAddress = IP_input,   IPAddressGUID = ip_to_guid(IP_input),   Caption = str(IP_input),   DynamicIP = False,   EngineID = 1,   Status = 1,   UnManaged = False,   Allow64BitCounters = True,   ObjectSubType = "SNMP",   MachineType = "",   VendorIcon = "",   RediscoveryInterval = 30,   PollInterval = 60,   StatCollection = 1,   City = "REDACTED",   Managed_Monitored = "REDACTED",     Node_Type = "TBD",   ALERT_CPU = 90,   ALERT_RAM = 90,   Community = 'REDACTED',   SNMPVersion=2   )  # Get all object properties for new node added  obj = swis.read(uri)  snmpDetailsUri = swis.create("Orion.Pollers", PollerType = "N.Details.SNMP.Generic", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])  snmpUptimeUri = swis.create("Orion.Pollers", PollerType = "N.Uptime.SNMP.Generic", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])  snmpCpuUri = swis.create("Orion.Pollers", PollerType = "N.Cpu.SNMP.HrProcessorLoad", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])  snmpMemoryUri = swis.create("Orion.Pollers", PollerType = "N.Memory.SNMP.NetSnmpReal", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])  snmpAssetInventoryUri = swis.create("Orion.Pollers", PollerType = "N.AssetInventory.Snmp.Generic", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])  snmpResponseTimeUri = swis.create("Orion.Pollers", PollerType = "N.ResponseTime.SNMP.Native", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])  snmpStatusUri = swis.create("Orion.Pollers", PollerType = "N.Status.SNMP.Native", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])  snmpTopologyUri = swis.create("Orion.Pollers", PollerType = "N.Topology_Layer3.SNMP.ipNetToMedia", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])

Powershell scripts to automatically unmanage\remanage a node using the Orion SDK

$
0
0

First, I'll share the script. Then, I'll explain why we need it and how it helps us in our environment.

To use the script you must have the Orion SDK installed on the monitored node.

 

Take the text below, paste in Powershell ISE and save it as a PS1.

------------------------------------ Start PS1 -----------------------------------------------------------------

 

# 2014-07-21 Node Unmanage script for SolarWinds SDK Powershell

# by Joe Dissmeyer | Thwack - @JoeDissmeyer | Twitter - @JoeDissmeyer | www.joedissmeyer.com

# This script will unmanage a single node in the Orion database. First, it finds the node number in the Orion database, then it will unmanage it for 99 years.

# This script assumes you are running it LOCALLY from an already managed node AND that the machine has the Orion SDK v1.9 installed on it.

# If the machine is not already managed in SolarWinds this script will fail without warning.

# Replace ORIONSERVERNAME with the appropriate values.

# ORIONSERVERNAME = Your Orion poller instance. (Ex. 'SOLARWINDS01.DOMAIN.LOCAL'). Single quotes are important.

 

# Load the SolarWinds Powershell snapin. Needed in order to execute the script. Requires the Orion SDK 1.9 installed on the machine this script is running from.

Add-PSSnapin SwisSnapin

 

 

# SolarWinds user name and password section. Create an Orion local account that only has node management rights. Enter the user name and password here.

$username = "SWnodemanagement"

$password = "MyP@44w0$d"

 

# This section allows the password to be embedded in this script. Without it the script will not work.

$secstr = New-Object -TypeName System.Security.SecureString

$password .ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

# The actual job

$ORIONSERVERNAME = 'SWServer1.domain.local'

$nodename = $env:COMPUTERNAME

 

$swis = Connect-Swis -Credential $cred -host $orionservername

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '$nodename%'"

$now =[DateTime ]:: Now

$later =$now.AddYears(99)

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

 

------------------------------------ End PS1 -----------------------------------------------------------------

 

 

 

And now the Remanage script. Again, save as a .PS1 file.

------------------------------------ Start PS1 -----------------------------------------------------------------

 

# 2014-07-21 Node Remanage script for SolarWinds SDK Powershell

# by Joe Dissmeyer | Thwack - @JoeDissmeyer | Twitter - @JoeDissmeyer | www.joedissmeyer.com

# This script will remanage a single node in the Orion database.

# This script assumes you are running it LOCALLY from an already managed node AND that the machine has the Orion SDK v1.9 installed on it.

# If the machine is not already managed in SolarWinds this script will fail without warning.

# Replace ORIONSERVERNAME with the appropriate values.

# ORIONSERVERNAME = Your Orion poller instance. (Ex. 'SOLARWINDS01.DOMAIN.LOCAL'). Single quotes are important.

 

 

# Load the SolarWinds Powershell snapin. Needed in order to execute the script. Requires the Orion SDK 1.9 installed on the machine this script is running from.

Add-PSSnapin SwisSnapin

 

 

# SolarWinds user name and password section. Create an Orion local account that only has node management rights. Enter the user name and password here.

$username = "SWnodemanagement"

$password = "MyP@44w0%d"

 

 

# This section allows the password to be embedded in this script. Without it the script will not work.

$secstr = New-Object -TypeName System.Security.SecureString

$password .ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

 

# The actual job

$ORIONSERVERNAME = 'SWServer1.domain.local'

$nodename = $env:COMPUTERNAME

 

 

$swis = Connect-Swis -Credential $cred -host $orionservername

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '$nodename%'"

$now =[DateTime ]:: Now

$later =$now.AddYears(99)

Invoke-SwisVerb $swis Orion.Nodes Remanage @("N: $nodeid ", $now ,$later , "false")

 

------------------------------------ End PS1 -----------------------------------------------------------------

 

Explanation:

My company had a very unique need to monitor our enterprise Windows application that runs not only on standard desktop PCs, but also runs on mobile tablets connected to WiFi access points. These tablets run the standard Windows 7 Professional OS so it makes it easy to set up application monitoring in SolarWinds SAM for these machines. However, the problem comes at the end of the day when these tablets are turned off and placed in their charging docks for the night. As you can imagine, this creates an administrative nightmare (not to mention an email alert flood) in SolarWinds when this happens.

 

SolarWinds Orion NPM and SAM is designed to always keep an eye on a node or application that is entered in it's database. It is not designed to monitor an application or node only "part of the time" --- well, at least it isn't designed for this purpose out of the box. So instead, we have to create a workaround that will suit our needs. What we needed to do was figure out how to automatically "unmanage" these Windows tablet PCs in SolarWinds when they are shut down for the night, but also automatically "re-manage" them once they boot up. This is where the script comes into play.

 

The idea is to take the Unmanage script and apply it as a shut down script in Group Policy, then take the Remanage script and apply it as a boot up script in Group Policy.

Here is why this works for us:

The business is supposed to gracefully shut down the tablet by clicking Start > Shut down. If not, then an email alert triggers that informs us that the application is down on the machine.

If the tablet goes offline in the middle of the day for any reason, we will receive an email alert about that node.

When the machine is shut down properly, the node is automatically unmanaged in SolarWinds.

When the machine boots up and someone logs into the machine, the node is automatically remanaged in SolarWinds.

 

But here is an even better use for these scripts --- Scheduled Server Maintenance! How many times have we, server administrators, had to patch Windows Servers during scheduled maintenance hours? Normally you would have to go into SolarWinds and unmanage the node first BEFORE rebooting as not to trigger an email alert. Well with these scripts you wouldn't have to worry about that as much since this would be automatic.

 

Final notes:

Of course, this is just one way to go about auto-managing nodes in SolarWinds. There are some alternatives to doing this using the Orion SDK and Powershell which is to, instead, use the built-in .NET properties in Powershell 2.0 to access the Orion SQL database directly, find the node ID, and unmanage it in that manner. For those that are interested in how do to this without the Orion SDK, let me know and I'd be happy to elaborate.

Python Orion SDK - Q: HowTo discover new device into NPM BUT disabling some standard pollers

$
0
0

I am busy to rewrite my scripts with Python and to move away from SOAP/Perl.

We found some information on the web that advise to add new devices into the auto discovery. As result that each discovered node enabled some resources that I don't want to have like:

* Hardware Health Hardware

* EnergyWise

* VLAN

* Topology: Layer 2

* Topology: Layer 3

 

The idea was to create a profile/template which disabled those items but so far I found was to create/use a template for interfaces and interface types.

 

When the discovery has completed then I found out that this is added into the table [Solarwinds_Dev].[dbo].[Pollers]

Columns : [PollerID],[PollerType],[NetObject],[NetObjectType],[NetObjectID],[Enabled]

The column NetObjectID is actualy the NodeID of our device.

PollerIDPollerType                          NetObject NetObjectType   NetObjectID Enabled

22065   N.ResponseTime.ICMP.Native          N:588     N               588         1

22066   N.Status.ICMP.Native                N:588     N               588         1

22067   N.ResponseTime.SNMP.Native          N:588     N               588         0

22068   N.Status.SNMP.Native                N:588     N               588         0

22069   N.Details.SNMP.Generic              N:588     N               588         1

22070   N.Uptime.SNMP.Generi                N:588     N               588         1

22071   N.Cpu.SNMP.CiscoGen3                N:588     N               588         1

22072   N.Memory.SNMP.CiscoGen3             N:588     N               588         1

22073   N.Topology_Vlans.SNMP.VtpVlan       N:588     N               588         1

22074   N.Topology_Layer2.SNMP.Dot1dTpFdb   N:588     N               588         1

22075   N.Topology_CDP.SNMP.cdpCacheTable   N:588     N               588         1

22076   N.Topology_LLDP.SNMP.lldpRemoteSystemsData  N:588   N         588         1

22077   N.Topology_PortsMap.SNMP.Dot1dBase  N:588     N               588         1

22078   N.Topology_Layer3.SNMP.ipNetToMedia N:588     N               588         1

22079   N.EnergyWise.SNMP.Cisco             N:588     N               588         1

22080   N.SwitchStack.SNMP.Cisco            N:588     N               588         1

22081   N.HardwareHealthMonitoring.SNMP.NPM.Cisco   N:588   N         588         1

 

On THWACK I have found a solution to create pollers for a Node but this creates additional entries on the table [Solarwinds_Dev].[dbo].[Pollers] for that Node.

It doesn't update or delete unselected PollerTypes but only adding the same pollers with a different Enabled value.

This creates duplicate PollerTypes for the same Node but with a different Enabled value.

As result it keeps using the old settings.

 

Updating entries directly on the database is something I don't like to do but I did a test.

Change the entries on the Enabled column to value seems to work for :

 

                    : N.Topology_CDP.SNMP.cdpCacheTable

                    : N.Topology_LLDP.SNMP.lldpRemoteSystemsData

Topology Layer 3    : N.Topology_Layer3.SNMP.ipNetToMedia

Topology Layer 2    : N.Topology_Layer2.SNMP.Dot1dTpFdb

EnergyWise          : PollerType N.EnergyWise.SNMP.Cisco

 

But it doesn't seems to work for which I conclude that there some other hidden entries somewhere on the database.

Hardware Health Hardware    : N.HardwareHealthMonitoring.SNMP.NPM.Cisco

VLAN                        : N.Topology_Vlans.SNMP.VtpVlan

 

 

##### script discover.py #####

import sys

import time

from orionsdk import SwisClient

from pprint import pprint

 

def solarwindsDiscovery(hosts):

    # Init SWIS API

    npm_server = 'solarwinds-dev.example.com'

    username = 'scripting'

    password = 'somesecretpassword'

 

    verify = False

    if not verify:

        from requests.packages.urllib3.exceptions import InsecureRequestWarning

        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

 

    swis = SwisClient(npm_server, username, password)

 

    bulkList_hosts = []

    for host in hosts:

        bulkList_hosts.append({'Address': host})

   

    snmpv3_credential_id = 12

    snmpv2_credential_id = 6

    snmpv2_oldcredential_id = 3

 

    # make Discovery Profile

    orion_engine_id = 2

    corePluginContext = {

        'BulkList':  bulkList_hosts,

        'Credentials': [

            {

                'CredentialID': snmpv3_credential_id,

                'Order': 1

            },

            {

                'CredentialID': snmpv2_credential_id,

                'Order': 2

            },

            {

                'CredentialID': snmpv2_oldcredential_id,

                'Order': 3

            }

        ],

        'WmiRetriesCount': 0,

        'WmiRetryIntervalMiliseconds': 1000,

        'IsDiscoveryForVimEnabled': False

    }

    corePluginConfig = swis.invoke('Orion.Discovery', 'CreateCorePluginConfiguration', corePluginContext)

 

    interfacesPluginContext = {

        'AutoImportStatus': [],  # Also available: Down, Shutdown, Up

        'AutoImportVlanPortTypes': ['Trunk', 'Access', 'Unknown'],

        'AutoImportVirtualTypes': ['Physical', 'Virtual'],  # Also available: Unknown

        'AutoImportExpressionFilter':

                                   [{'Prop': 'Descr', 'Op': '!Any', 'Val': 'null'},

                                   {'Prop': 'Descr', 'Op': '!Any', 'Val': 'vlan'},

                                   {'Prop': 'Descr', 'Op': '!Any', 'Val': 'loopback'},

                                   {'Prop': 'Alias', 'Op': '!Regex', 'Val': '^$'},

                                   {'Prop': 'Name', 'Op': '!Regex', 'Val': '^t1'}]

        # Available values for Prop: Type, Name, Descr, Alias, Node, All, Vlan

        # Available values for Op: All, !All, Any, !Any, Equals, !Equals, Regex, !Regex, #All, !#All, #Any, !#Any

        # Val is the literal value to compare Prop to

        # If more than one expression is provided, the interface must match all of the expressions to be imported

        # To specify more than one number or string for the All and Any operators (including variants), separate them by spaces

    }

    interfacesPluginConfig = swis.invoke('Orion.NPM.Interfaces', 'CreateInterfacesPluginConfiguration', interfacesPluginContext)

 

    discoveryProfile = {

        'Name': 'discover_one_node.py',

        'EngineID': orion_engine_id,

        'JobTimeoutSeconds': 3600,

        'SearchTimeoutMiliseconds': 5000,

        'SnmpTimeoutMiliseconds': 5000,

        'SnmpRetries': 2,

        'RepeatIntervalMiliseconds': 1800,

        'SnmpPort': 161,

        'HopCount': 0,

        'PreferredSnmpVersion': 'SNMP3',

        'DisableIcmp': False,

        'ImportDownInterface': False,

        'ImportUpInterface': False,

        'ImportShutdownInterface': False,

        'AllowDuplicateNodes': False,

        'IsAutoImport': True,

        #  'IsHidden" set to True will remove the discovery profile after it completes

        'IsHidden': True,

        'PluginConfigurations': [{'PluginConfigurationItem': corePluginConfig}, {'PluginConfigurationItem': interfacesPluginConfig}]

    }

 

    # Start Discovery

    print("Running discovery...")

    discoveryProfileID = swis.invoke('Orion.Discovery', 'StartDiscovery', discoveryProfile)

    print("Returned discovery profile id {}".format(discoveryProfileID))

 

    '''

        discoveryStatusState = {0: "Unknown", 1: "InProgress", 2: "Finished", 3: "Error", 4: "NotScheduled", 5: "Scheduled",

                            6: "NotCompleted", 7: "Canceling", 8: "ReadyForImport"}

    '''

    # Wait until it's done with discovery before we start assigning custom pollers or populating custom properties

    running = True  # InProgress

    while running:

        sys.stdout.write('.')

        sys.stdout.flush()

        query = "SELECT Status FROM Orion.DiscoveryProfiles WHERE ProfileID = " + str(discoveryProfileID)

        result = swis.query(query)

        # pprint(result)

        # Example output .{'results': [{'Status': <discoveryStatusState>}]}

 

        if len(result['results']) < 1:

            # When we don't have any records from the Orion.DiscoveryProfiles

            # This will results to an empty list

            running = False

        else:

            time.sleep(5)       # wait 5 seconds

 

    print(' ')

    print('Done with discovery')

 

    query = "SELECT Result, ResultDescription, ErrorMessage, BatchID FROM Orion.DiscoveryLogs WHERE ProfileID = '" + str(discoveryProfileID) + "' "

    discovered = swis.query(query)

 

    if (discovered['results'][0]['Result']) != 2:

        print(discovered['results'][0]['ResultDescription'])

        print(discovered['results'][0]['ErrorMessage'])

    else:

        # Import finished

        print(discovered['results'][0]['ResultDescription'])

 

requests.packages.urllib3.disable_warnings()

 

if __name__ == '__main__':

    hosts = [ '192.168.0.1' , '192.168.0.2']

    solarwindsDiscovery(hosts)

 

##### end script discover.py #####

 

 

##### script add_poller.py #####

from __future__ import print_function

import re

import requests

from orionsdk import SwisClient

from pprint import pprint

 

def main():

# Init SWIS API

    npm_server = 'solarwinds-dev.example.com'

    username = 'scripting'

    password = 'somesecretpassword'

    nodeid = '588'

 

    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("Add pollers into node:")

 

    pollers_enabled = {

        'N.Status.ICMP.Native': True,

        'N.Status.SNMP.Native': False,

        'N.ResponseTime.ICMP.Native': True,

        'N.ResponseTime.SNMP.Native': False,

        'N.Details.SNMP.Generic': True,

        'N.Uptime.SNMP.Generic': True,

        'N.Cpu.SNMP.HrProcessorLoad': True,

        'N.Memory.SNMP.NetSnmpReal': True,

        'N.AssetInventory.Snmp.Generic': True,

        'N.Topology_CDP.SNMP.cdpCacheTable': False,

        'N.Topology_LLDP.SNMP.lldpRemoteSystemsData': False,

        'N.Topology_Layer3.SNMP.ipNetToMedia': False,

        'N.Routing.SNMP.Ipv4CidrRoutingTable': False,

        'N.Routing.SNMP.Ipv4RoutingTable': False,

        'N.EnergyWise.SNMP.Cisco': False,

        'N.Topology_Vlans.SNMP.VtpVlan': False,

        'N.Topology_PortsMap.SNMP.Dot1dBaseNoVLANs': False,

        'N.HardwareHealthMonitoring.SNMP.NPM.Cisco': False,

        'N.EnergyWise.SNMP.Cisco' : False,

        'N.Topology_Layer2.SNMP.Dot1dTpFdb' : False,

        'N.Topology_Layer3.SNMP.Dot1dTpFdb' : False

    }

 

    pollers = []

    for k in pollers_enabled:

        pollers.append(

        {

        'PollerType': k,

        'NetObject': 'N:' + nodeid,

        'NetObjectType': 'N',

        'NetObjectID': nodeid,

        'Enabled': pollers_enabled[k]

        }

    )

 

    for poller in pollers:

        print(" Adding poller type: {} with status {}... ".format(poller['PollerType'], poller['Enabled']), end="")

        response = swis.create('Orion.Pollers', **poller)

        print("DONE!")

 

 

    response = swis.invoke('Orion.Nodes', 'PollNow', 'N:' + nodeid)

 

requests.packages.urllib3.disable_warnings()

 

if __name__ == '__main__':

    main()

 

 

##### end script add_poller.py #####

 

If this is possible, can you some provide me how I can do this ?

SDK verb to unmonitor aws cloud instance?

$
0
0

We have an issue where cloud instances are reverting to an unknown state instead of terminating- looking for a swis verb to call to accomplish the same result as going into the Choose Instances/VM's under cloud setting and choosing do not monitor for some nodes.

SQWL Query to select SourcePort and DestinationPort

$
0
0

Hello,

 

I am trying to run this query in SWQL:

 

SELECT TotalBytes, TotalPackets, SourceIPSort, DestIPSort, Protocol, ProtocolName, SourcePortName, DestPortName, SourcePort, DestPort, SourceAppID, DestAppID, StartTime, SourceSinglePort, DestSinglePort, DisplayName, Description, InstanceType, Uri, InstanceSiteId

FROM Orion.NetFlow.ConversationsDetailReport

(Filter='NSF:C:10000000001-255249000001;TD:2016-11-22T00:00:00~2017-11-23T00:00:00,1,True,True')

 

However, there seem to be no results.

 

Is this table populated at all? And is it possible to upload data onto it?

 

Your help would be really appreciated.

 

Paolo

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()

Can't query Status from Orion.F5.VirtualServers

$
0
0

I'm trying to get an F5 virtualserver status through API. NPM 12.1

 

Here is the query I'm passing

GET /SolarWinds/InformationService/v3/Json/Query?query=SELECT+NodeID+,+Name+,+EnabledState+,+Description+,+Status+,+DisplayName+FROM+orion.f5.virtualservers+where+name+like+'%257001' HTTP/1.1

 

Here's the error

{"Message":"Cannot resolve property Status","ExceptionType":"SolarWinds.Data.Query.ParserException","FullException":"SolarWinds.Data.Query.ParserException: Cannot resolve property Status\u000d\u000a   at SolarWinds.Data.Query.Processor.SemanticChecker.HandleNonQualifiedPropertyName(EntityExpression entityExpression)\u000d\u000a   at SolarWinds.Data.Query.Swql.ParseTreeDuplicator.Visit(ColumnExpression column)\u000d\u000a   at SolarWinds.Data.Query.Processor.SemanticChecker.Visit(ColumnExpression column)\u000d\u000a   at SolarWinds.Data.Query.Swql.ParseTreeDuplicatorNoState.Visit(SelectClause select)\u000d\u000a   at SolarWinds.Data.Query.Processor.SemanticChecker.Visit(SelectStatement statement)\u000d\u000a   at SolarWinds.Data.Query.Processor.SemanticChecker.Process(SelectStatement statement, PreProcessorState state, String replaceStatementTagWith)\u000d\u000a   at SolarWinds.Data.Query.Processor.SemanticChecker.Process(SelectStatement statement, PreProcessorState state)\u000d\u000a   at SolarWinds.Data.Quer* Connection #0 to host [blank] left intact

* Closing connection #0

y.Processor.PreProcessor.Process(SelectStatement selectStatement, PreProcessorState& preProcessorState)\u000d\u000a   at SolarWinds.Data.Query.Engine.QueryProcessor.ProcessInternal(String query, IQueryExecutionContext context)\u000d\u000a   at SolarWinds.InformationService.Core.QueryPlanCache.GetQueryPlan(String query, String username, Boolean federationEnabled, Func`1 buildQueryPlan)\u000d\u000a   at SolarWinds.InformationService.Core.InformationService.RunQuery(String query, IDictionary`2 parameters, IDataSerializer serializer)"}

 

If I take out Status, I get the good query result.

It seems like the schema doesn't match from SolarWinds Information Service v3.0 Schema Documentation Index

The Orion.F5.Pools table throws an error at me and I can't query anything from it. The Orion.F5.VirtualServers has partial, as well as Orion.F5.Device

 

I don't have access to the database directly to analyze.


Create/Update operations are not working for Orion.Accounts through SolarWinds Rest API

$
0
0

We are trying to create Accounts in Solar winds system through Rest API URI: https://<HOST>:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Accounts but, we are getting following error message in the API response.

SolarWinds.Data.AccessDeniedException: Operation not supported on Orion.Accounts\u000d\u000a at SolarWinds.InformationService.Core.CrudProcessor.CreateAccessDeniedException(String message)

 

We have provide the admin access to the API login, Can you please let us know if Create/update operations are supported on Orion.Accounts object through Restful API?. If not, Can you please suggest any alternative APIs available in Solarwinds to achieve this reuirement?.

Rest API 403 after a WEB UI Certificate upgrade

$
0
0

Anyone have experience/direction/hints on this type of problem?

 

--Steve

 

Case #1360290

 

WEB UI Certificate (443) was upgraded and working API calls started receiving 403 errors.  Certificates were replaced on UI (443) and we still received the 403 error.

 

API certificates were not touched.

 

The account can login to the Web UI.

 

Note following example has IP, hostname and account name replaced.

 

$  curl  -v -k -u rjf\\myADaccount https://TheHost.rjf.com:17778/SolarWinds/InformationService/v3/Json/Query

Enter host password for user 'rjf\\myADaccount':

* STATE: INIT => CONNECT handle 0x600057930; line 1410 (connection #-5000)

* Added connection 0. The cache now contains 1 members

* STATE: CONNECT => WAITRESOLVE handle 0x600057930; line 1446 (connection #0)

*   Trying 99.99.999.999...

* TCP_NODELAY set

* STATE: WAITRESOLVE => WAITCONNECT handle 0x600057930; line 1527 (connection #0)

* Connected to TheHost.rjf.com (99.99.99.999) port 17778 (#0)

* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600057930; line 1579 (connection #0)

* Marked for [keep alive]: HTTP default

* ALPN, offering h2

* ALPN, offering http/1.1

* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH

* successfully set certificate verify locations:

*   CAfile: /etc/pki/tls/certs/ca-bundle.crt

  CApath: none

* TLSv1.2 (OUT), TLS header, Certificate Status (22):

* TLSv1.2 (OUT), TLS handshake, Client hello (1):

* STATE: SENDPROTOCONNECT => PROTOCONNECT handle 0x600057930; line 1593 (connection #0)

* TLSv1.0 (IN), TLS handshake, Server hello (2):

* TLSv1.0 (IN), TLS handshake, Certificate (11):

* TLSv1.0 (IN), TLS handshake, Server key exchange (12):

* TLSv1.0 (IN), TLS handshake, Server finished (14):

* TLSv1.0 (OUT), TLS handshake, Client key exchange (16):

* TLSv1.0 (OUT), TLS change cipher, Client hello (1):

* TLSv1.0 (OUT), TLS handshake, Finished (20):

* TLSv1.0 (IN), TLS change cipher, Client hello (1):

* TLSv1.0 (IN), TLS handshake, Finished (20):

* SSL connection using TLSv1.0 / ECDHE-RSA-AES256-SHA

* ALPN, server did not agree to a protocol

* Server certificate:

*  subject: CN=SolarWinds-Orion

*  start date: Jan 29 17:05:33 2015 GMT

*  expire date: Dec 31 23:59:59 2039 GMT

*  issuer: CN=SolarWinds-Orion

*  SSL certificate verify result: self signed certificate (18), continuing anyway.

* STATE: PROTOCONNECT => DO handle 0x600057930; line 1614 (connection #0)

* Server auth using Basic with user 'rjf\\myADaccount'

> GET /SolarWinds/InformationService/v3/Json/Query HTTP/1.1

> Host: TheHost.rjf.com:17778

> Authorization: Basic ***removed***

> User-Agent: curl/7.54.1

> Accept: */*

>

* STATE: DO => DO_DONE handle 0x600057930; line 1676 (connection #0)

* STATE: DO_DONE => WAITPERFORM handle 0x600057930; line 1801 (connection #0)

* STATE: WAITPERFORM => PERFORM handle 0x600057930; line 1811 (connection #0)

* HTTP 1.1 or later with persistent connection, pipelining supported

< HTTP/1.1 403 Forbidden

< Content-Length: 0

* Server Microsoft-HTTPAPI/2.0 is not blacklisted

< Server: Microsoft-HTTPAPI/2.0

< Date: Thu, 30 Nov 2017 15:58:23 GMT

<

* STATE: PERFORM => DONE handle 0x600057930; line 1980 (connection #0)

* multi_done

* Connection #0 to host TheHost.rjf.com left intact

Add UDT ports via API

$
0
0

I have not found a way to do this, but maybe I'm not looking in the right place. We've got Python scripts for discovering and adding nodes and interfaces via API no problem. We're using corePluginConfig  and  interfacesPluginConfig to accomplish this. But I have not seen a similar "ports" PluginConfig (i.e. portsPluginConfig). When we started down the road of automating device entry, we assumed UDT ports would also be available to us via API. Like when we import discovered results in the web console, the Interfaces screen (with all of its selection criteria and filtering) is followed by an almost identical Ports screen. So it seemed safe to assume we would be able to include UDT ports when automating device entry via API.

 

Hopefully I'm just missing something and the option to do this is available.

 

Thanks!

how to add volumes to monitored resources via rest API & curl

$
0
0

whenever i add a node, i currently have to go into the node, click List Resources and add the volumes i want to be monitored. how do i add these volumes automatically via the Rest API and curl in linux?

SDK or API to show fixed disks not monitored

$
0
0

I´m looking for an API or SDK to show me all fixed disks not monitored yet.

Get-SwisData and REST API terminating remote connections to Information Service

$
0
0

I am having issues returning any data from the Information Service via Powershell or REST API, from any machine other than the actual Solarwinds server itself.

 

On the solarwinds server, this works:

Import-Module SwisPowerShell

$creds = Get-Credential '(DOMAIN)\(Username)'

$swis = Connect-Swis -Credential $creds -Hostname (solarwinds Hostname)

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

 

Using a local Orion account (non ActiveDirectory user account) on the solarwinds server, also works:

Import-Module SwisPowerShell

$swis = Connect-Swis -UserName (local orion username) -Password (password) -Hostname (solarwinds Hostname)

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

 

on any remote host I get this:

Import-Module SwisPowerShell

$creds = Get-Credential '(DOMAIN)\(Username)'

$swis = Connect-Swis -Credential $creds -Hostname (Orion Hostname)

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

 

Get-SwisData : The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was

'00:00:59.9934985'.

At line:2 char:1

+ Get-SwisData $swis 'SELECT NodeID, Caption FROM Orion.Nodes'

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

    + CategoryInfo          : NotSpecified: (:) [Get-SwisData], CommunicationException

    + FullyQualifiedErrorId : System.ServiceModel.CommunicationException,SwisPowerShell.GetSwisData

 

 

I can see Ports 17777 and 17778 are bound to the Network card and listening

C:\> netstat -an

 

Active Connections

  Proto  Local Address          Foreign Address        State

 

  TCP    0.0.0.0:17777          0.0.0.0:0              LISTENING

  TCP    0.0.0.0:17778          0.0.0.0:0              LISTENING

 

I can see a TCP reset happening at the Solarwinds server itself immediately when I run Get-SwisData ....

So I know it's not a firewall between the remote hosts and the Solarwinds server.

 

I've tried using Postman to send a call to the REST service as per this:

https://loop1.com/swblog/using-the-rest-api-to-get-the-most-out-of-solarwinds-part-1/

 

I get back:
Could not get any responseThere was an error connecting to https://(solarwinds server hostname):17778/SolarWinds/InformationService/v3/Json?query=SELECT%20Caption,%20IPAddress%20FROM%20Orion.Nodes%20WHERE%20Vendor%20=%20'Cisco;.

 

It acts like the SolarWinds server isn't listening for anything other than connections to Localhost, but netstat confirms that's not the case.

Python Orion SDK : Create credentials set without adding a new node

$
0
0

Hello,

 

I want to create a SNMPv2/SNMPv3 credential set on our NPM Orion when the credential doesn't yet exit in our Orion.Credentials table.

I realize when adding a credential set requires to add entries into 2 different tables.

I wonder if this is possible to do with the API using Python.

 

################## SCRIPT

from __future__ import print_function

import re

import requests

from orionsdk import SwisClient

from pprint import pprint

 

def main():

     # Init SWIS API

    npm_server = 'solarwinds-dev.example.com'

    username = 'scripting'

    password = 'somesecretpassword'

 

    # Dict with as key the SNMP names and as value if it exist

    # We initiate our values as False

     required_snmp =     { 'SNMPv3 readonly' :

                                [ {

                                    'SNMP' : 3 ,

                                    'status' : False ,

                                    'username' : 'testuser',

                                    'auth_proto' : 'sha',

                                    'auth_pass' : 'mysecret123',

                                    'priv_proto' : 'aes',

                                    'priv_pass' : 'specialpass' } ] ,

                            'SNMPv2 comstring' :

                                [ {

                                    'SNMP' : 2 ,

                                    'status' : False,

                                    'community' : 'comstring' } ]

                        }

 

     verify = False

     if not verify:

          from requests.packages.urllib3.exceptions import InsecureRequestWarning

          requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

 

     swis = SwisClient(npm_server, username, password)

     credentialdata = swis.query("SELECT Name FROM Orion.Credential WHERE CredentialType LIKE 'SolarWinds.Orion.Core.Models.Credentials.SnmpCredentialsV%'")

 

     if len(credentialdata['results']) < 1:

          # No records found

          print("No records found")

     else:

          # Loop through dict required_snmp

          for snmpname in required_snmp:

 

          # Loop through pollerdata to collect key names.

          for keys in credentialdata['results']:

          if snmpname == keys['Name']:

               required_snmp[snmpname][0]['status'] = True             # Change status for this SNMP name to True

 

    '''

    Let's do a loop on our require_snmpnames dict

    Values with False needs to be added into our Orion Credential set.

    If the name starts with SNMPv2 then we need to define the community name

    If the name starts with SNMPv3 then we need to define:

        () username

        () authentication protocol

        () authentication password

        () privacy protocol

        () privacy passphrase

    '''

     for snmpname in required_snmp:

          if required_snmp[snmpname][0]['status'] is False and required_snmp[snmpname][0]['SNMP'] == 2:

               # Add credential set

                 print("Added SNMPv2")

 

          if required_snmp[snmpname][0]['status'] is False and required_snmp[snmpname][0]['SNMP'] == 3:

               # Add credential set

                    print("Added SNMPv3")

 

################## SCRIPT END

 

################## TABLES

Table : <Orion.Credential>

[ID], [Name], [Description],[CredentialType],[CredentialOwner]

  |

  |

[CredentialID] , [Name], [Value], [Encrypted]

Table : <Orion.CredentialProperty>

 

For SNMPv2

<Orion.CredentialProperty>.[Name]

Community

 

For SNMPv3

<Orion.CredentialProperty>.[Name]

UserName

AuthenticaionType

AuthenticationPassword

AuthenticationKeyIsPassword

PrivacyType

PrivacyPassword

PrivacyKeyIsPassword


Using Custom Properties with orionsdk group creation

$
0
0

I'm trying to create groups using the Python orionsdk sample code.

 

It works fine for me when I'm using default node properties (e.g. Vendor), but when I use a custom property name the dynamic query is defaulting to AssetTag.

 

i.e. This works fine

# group members
[

   {'Name': 'Windows Devices', 'Definition': "filter:/Orion.Nodes[Vendor='Windows']"}

]

)

 

And this doesn't - it results in a dynamic query for AssetTag='core'

 

# group members
[

   {'Name': 'Core network devices', 'Definition': "filter:/Orion.Nodes[NMS_Role='core']"}

]

)

 

Is there a limitation with the CreateContainer method that means I can't use custom properties, or is there another explanation?

Need some help with API Discovery script

$
0
0

I'm using powershell 4 and Orion Platform 2017.3.2.SP2, took some example scripts from others that were reported to be working and cleaned them up for my environment but when I try to run them in my environment they will run for a few seconds/minutes and then I keep getting errors saying that parsing of discovery results failed.

 

Everything looks good from the powershell side as far as it not kicking back any errors.

 

here is the script

 

 

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

    Add-PSSnapin "SwisSnapin"

}

 

 

#define target host and credentials

$hostname = 'localhost'

$user = "admin"

$password = "password"

# create a connection to the SolarWinds API

$swis = connect-swis -host $hostname -username $user -password $password -ignoresslerrors

 

$CorePluginConfigurationContext = ([xml]"

<CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>

    <BulkList>

    <IpAddress><Address>10.40.40.63</Address></IpAddress>

    </BulkList>

    <Credentials>

        <SharedCredentialInfo>

            <CredentialID>57</CredentialID>

            <Order>1</Order>

        </SharedCredentialInfo>

    </Credentials>

    <WmiRetriesCount>1</WmiRetriesCount>

    <WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds>

</CorePluginConfigurationContext>

").DocumentElement

$CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)

$InterfacesPluginConfigurationContext = ([xml]"

<InterfacesDiscoveryPluginContext xmlns='http://schemas.solarwinds.com/2008/Interfaces'

                                  xmlns:a='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>

    <AutoImportStatus>

        <a:string>Up</a:string>

        <a:string>Down</a:string>

        <a:string>Shutdown</a:string>

    </AutoImportStatus>

    <AutoImportVirtualTypes>

        <a:string>Virtual</a:string>

        <a:string>Physical</a:string>

    </AutoImportVirtualTypes>

    <AutoImportVlanPortTypes>

        <a:string>Trunk</a:string>

        <a:string>Access</a:string>

        <a:string>Unknown</a:string>

    </AutoImportVlanPortTypes>

    <UseDefaults>true</UseDefaults>

</InterfacesDiscoveryPluginContext>

").DocumentElement

$InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)

$EngineID = 9

$DeleteProfileAfterDiscoveryCompletes = "false"

$StartDiscoveryContext = ([xml]"

<StartDiscoveryContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>

    <Name> Test $([DateTime]::Now)</Name>

    <EngineId>$EngineID</EngineId>

    <JobTimeoutSeconds>3600</JobTimeoutSeconds>

    <SearchTimeoutMiliseconds>2500</SearchTimeoutMiliseconds>

    <SnmpTimeoutMiliseconds>2500</SnmpTimeoutMiliseconds>

    <SnmpRetries>1</SnmpRetries>

    <RepeatIntervalMiliseconds>2500000</RepeatIntervalMiliseconds>

    <SnmpPort>161</SnmpPort>

    <HopCount>0</HopCount>

    <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>

    <DisableIcmp>false</DisableIcmp>

    <AllowDuplicateNodes>false</AllowDuplicateNodes>

    <IsAutoImport>false</IsAutoImport>

    <IsHidden>false</IsHidden>

    <PluginConfigurations>

        <PluginConfiguration>

            <PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>

            <PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>

        </PluginConfiguration>

    </PluginConfigurations>

</StartDiscoveryContext>

").DocumentElement

$DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText

 

 

 

 

 

This is what I see in my discoverprofiles table

174 Test 12/06/2017 13:22:460NULL93f6df1a9c-e8aa-44c0-a58b-bfe29a0a2f20002500250012500TrueFalseFalseFalseFalse060NULLNULL
Parsing of discovery result failed.
FalseFalse<?xml version="1.0"?>
<ReportSchedule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:nil="true" />

 

No entry gets added to the discoverylogs for these

 

Anyone have any suggestions?

 

I already tried modeling my discovery after what was in this post and the wiki, i basically get the same results no matter which one I use.

API Network Discovery

OrionSDK/DiscoverSnmpV3Node.ps1 at master · solarwinds/OrionSDK · GitHub

Acknowledge Alerts with a curl

$
0
0

I have seen a bunch of ways to acknowledge an alert using various methods but so far none of it seems to work. Below is a screen shot from Postman. I get the true, but in the end the alert is not acknowledged.

 

Thoughts Wanted On Refactoring the PowerOrion PowerShell Module

$
0
0

Hi Folks.

 

Since the (unofficial) PowerOrion module I worked on a few years ago has gone a bit stale, I've decided to invest some time in revamping the existing functionality, and then expanding on it.

 

Some of my thoughts at present include:

  • Publishing and updating it separately from the main Orion SDK
  • Breaking cmdlets out into individual files. This should make it easier to scale, and should also simplify the next point
  • Adding Unit Tests.
  • Increasing performance by rewriting cmdlets where possible to use native bulk update functionality.
  • Extending support for other use cases.
  • Publishing to the PowerShell gallery, to simplify installation of the module  (such as the IPAM functionality)

 

One of the biggest drivers for me however, is the unit testing. By writing tests first for each cmdlet, it will be possible ensure that the cmdlets work as designed, and changes to the code later won't break anything. 

 

I've set up a new repo for the module over on Github. The plan at present is to refactor the old code first, and write the unit tests for each functionality, just to come up to parity with the existing code (fixing bugs along the way!). Then the module will be published to the gallery. Going forward then there will be a good framework in place for newer functionality.https://github.com/solarwinds/PowerOrion

 

What I would like to ask of the Thwack community is for feedback on the above, but also, what cmdlets would you like to see added? Perhaps you have a short script that can be converted to a function, to allow code reuse? Or did you find bugs in the existing module that I might have missed?  I've started tracking the work to be done on the issues page, so if there is anything enhancements/bugs etc please either add an issue over on Github, or in the comments below.

INTERFACE UTILIZATION to 3 party app (from the API)

$
0
0

Hi

 

 

Any one use the API to report to 3 party  portal ?

 

/sja

Viewing all 2677 articles
Browse latest View live


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