Set WMI Poller using API

Hi,

There is a great example of adding a node using the Python SDK here: ORIONSDK

We are using WMI and not SNMP, I assume that I need to simply change the `ObjectSubType` key to the value `WMI` but how do I handle authentication details?

Also in order to establish which Pollers I need to enable using the `poller_enabled` hash I need to ascertain which pollers are enabled for other hosts. I have dug through the Schema using SWQL but its hard to establish this way. Can somebody give me a leg up?

Thanks in advance!

James

Parents
  • I solved this for myself. I thought I would share the code I used:

    #!/usr/bin/env python2
    from __future__ import print_function
    import re
    import requests
    from orionsdk import SwisClient
    import sys
    import argparse

    parser = argparse.ArgumentParser(description='Add a host to SolarWinds')
    parser.add_argument('ipaddress', metavar='i', type=str,
    help='The ip address of the host to add')
    parser.add_argument('hostname', metavar='h', type=str,
    help='The hostname the host to add')

    args = parser.parse_args()

    def add_host(ip,hostname):
    npm_server = 'your_server'
    username = 'your_user'
    password = 'your_pass'

    swis = SwisClient(npm_server, username, password )

    # fill these in for the node you want to add!
    ip_address = ip
    community = 'public'

    # set up property bag for the new node
    props = {
    'IPAddress': ip_address,
    'EngineID': 1,
    'ObjectSubType': 'WMI',
    'DNS': hostname + '.INTERNAL.CNNGAD.COM',
    'SysName': hostname,
    'NodeName': hostname,
    }


    #print("Adding node {}... ".format(props['IPAddress']), end="")
    results = swis.create('Orion.Nodes', **props)

    # extract the nodeID from the result
    nodeid = re.search(r'(\d+)$', results).group(0)

    wmi_creds = {
    'NodeID' : nodeid,
    'SettingName' : 'WMICredential',
    'SettingValue' : your_credential',
    }

    response = swis.create('Orion.NodeSettings', **wmi_creds)

    regex = re.compile('swis://CUSPSOLORI01.INTERNAL.CNNGAD.COM/Orion/Orion.Nodes/NodeID=')
    if regex.search(results):
    return(0)
    else:
    return(1)

    requests.packages.urllib3.disable_warnings()


    if __name__ == '__main__':
    print(add_host(args.ipaddress,args.hostname))

Reply
  • I solved this for myself. I thought I would share the code I used:

    #!/usr/bin/env python2
    from __future__ import print_function
    import re
    import requests
    from orionsdk import SwisClient
    import sys
    import argparse

    parser = argparse.ArgumentParser(description='Add a host to SolarWinds')
    parser.add_argument('ipaddress', metavar='i', type=str,
    help='The ip address of the host to add')
    parser.add_argument('hostname', metavar='h', type=str,
    help='The hostname the host to add')

    args = parser.parse_args()

    def add_host(ip,hostname):
    npm_server = 'your_server'
    username = 'your_user'
    password = 'your_pass'

    swis = SwisClient(npm_server, username, password )

    # fill these in for the node you want to add!
    ip_address = ip
    community = 'public'

    # set up property bag for the new node
    props = {
    'IPAddress': ip_address,
    'EngineID': 1,
    'ObjectSubType': 'WMI',
    'DNS': hostname + '.INTERNAL.CNNGAD.COM',
    'SysName': hostname,
    'NodeName': hostname,
    }


    #print("Adding node {}... ".format(props['IPAddress']), end="")
    results = swis.create('Orion.Nodes', **props)

    # extract the nodeID from the result
    nodeid = re.search(r'(\d+)$', results).group(0)

    wmi_creds = {
    'NodeID' : nodeid,
    'SettingName' : 'WMICredential',
    'SettingValue' : your_credential',
    }

    response = swis.create('Orion.NodeSettings', **wmi_creds)

    regex = re.compile('swis://CUSPSOLORI01.INTERNAL.CNNGAD.COM/Orion/Orion.Nodes/NodeID=')
    if regex.search(results):
    return(0)
    else:
    return(1)

    requests.packages.urllib3.disable_warnings()


    if __name__ == '__main__':
    print(add_host(args.ipaddress,args.hostname))

Children
No Data