I'm automating provisioning/configuring Linux boxes using Ansible. I just finished automating the SNMP install/config, and I'd like to add steps that would add the linux server as a node to Solarwindws. Is this possbile? Or is SWIS only for queries?
Hello,
it should be possible by using the CRUD operations. Good place to start and find out how it works is the Samples section on Github. Highest number of samples are for Powershell (and example script for Python as well), so this is good place for investigation, but in general the flow will be :1. Define the Object (Node) properties (like IP address, caption, DNS, community, SNMP version)
2. Create the Object
3. Create pollers
If you know want to add more subobjects (Interfaces, Volumes), do this after the Node was created and you know the NodeId to use as part of the propertyBag.
While I'm a little inexperienced with the whole NPM setup, I was able to successfully run the Python GitHub sample.
What would a basic function look like to add a single node with no custom properties look like? I am unsure of what methods to run in general.
Thanks for the response. It looks like there will be a bit of a trial and error plus a learning curve to see if an automated solution will work in our environment. I'll give this a try when there is a lull in the stream of monitoring requests for our newly installed Solarwinds monitor.
The way I started automating things here newly added Nodes get a comment (custom property) set on them stating they have just been added. \
I can then go and do a 'list resources' on them and expand my scripts slowly to automate more and more of the addition process
now if I could add UnDP and UDT polling I would not need to touch added nodes to complete their provisioning...
It would look like this, but you'll either have to install the SWIS client via pip (pip install swisclient) or rename the SwisClient.py file to lowercase swisclient.py and place it alongside this script.
** Caveat: Since there's currently no way to force a rediscover you either need to wait the 30 minutes (or whatever your rediscovery interval is set to) or click 'Rediscover' in the web console. Since I don't want to click buttons if I'm automating the process I went ahead and ran some snmpwalk commands to populate the sysoid, machine type, description, icon, etc. so it looks like a healthy node before the discovery runs. If you're interested in that, let me know.
import reimport requestsimport swisclientdef main(): npm_server = 'localhost' username = 'admin' password = '' swis = swisclient.SwisClient(npm_server, username, password) print("Add an SNMP v2c node:") # fill these in for the node you want to add! node_name = '' ip_address = '' community = '' # set up property bag for the new node props = { 'Caption': node_name, 'IPAddress': ip_address, 'DynamicIP': False, 'EngineID': 1, 'Status': 1, 'Allow64BitCounters': 1, 'ObjectSubType': 'SNMP', 'SNMPVersion': 2, 'SysObjectID': '', 'MachineType': '', 'Vendor': '', 'VendorIcon': '', 'RediscoveryInterval': 30, 'PollInterval': 120, 'ChildStatus': 1, 'StatCollection': 10, 'Community': community, 'NodeDescription': '', } print("Adding node {}... ".format(props['IPAddress']), end="") results = swis.create('Orion.Nodes', **props) print("DONE!") # extract the nodeID from the result nodeid = re.search('(\d+)$', results).group(0) 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.Status.SNMP.Native': False, 'N.ResponseTime.SNMP.Native': False, 'N.Topology_Layer3.SNMP.ipNetToMedia': False, 'N.Routing.SNMP.Ipv4CidrRoutingTable': 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!")requests.packages.urllib3.disable_warnings()if __name__ == '__main__': main()
--
Steven Klassen
Developer Analyst @ Loop1 Systems, Inc.
http://www.loop1systems.com/
Re: UnDP - if you just need to assign existing pollers to nodes, this is already supported. See NPM Universal Device Pollers · solarwinds/OrionSDK Wiki · GitHub
nice example!
do you have a code for bulk loading? let say 5 devices? sorry having issues with Loop Statement