I have automated adding nodes via IP address to Solarwinds, but it seems the new nodes must have pollers assigned to them in order for everything to work. I want to simply add these nodes via ICMP, and had assumed that setting the ObjectSubType property to "ICMP" would have been sufficient. I am fairly new to Solarwinds and haven't touched the pollers, so I'd like to figure out a simple way to add the ICMP generic poller. Here is my script thus far to add nodes from a CSV file with IP addresses. I am assuming I will need to find the node ID or the Uri after the node has been created in order to assign a poller to it, but I am not sure where to go after that.
import requests import json from getpass import getpass import csv import os import time from SWnodelist import SwisClient def ip_to_guid(IPAddress): ip = IPAddress.split('.') ip_guid = "" for part in reversed(ip): ip_guid += (format(int(part), '02x')) ip_guid += '-0000-0000-0000-000000000000' return ip_guid def add_nodes_to_solarwinds(npm_server, username, password): swis = SwisClient(npm_server, username, password) t = (time.strftime("%Y-%m-%d")) csv = open('IP_Diff-%s.csv' %t, 'r') try: for ip in csv: IP_input = ip EntityType = "Orion.Nodes" 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 = "ICMP", MachineType = "", VendorIcon = "", RediscoveryInterval = 30, PollInterval = 60, StatCollection = 1, City = "REDACTED", Node_Type = "TBD", ALERT_CPU = 90, ALERT_RAM = 90) finally: csv.close() def main(): npm_server = REDACTED username = REDACTED password = REDACTED add_nodes_to_solarwinds(npm_server,username,password) if __name__ == "__main__": main()
In your script, swis.create returns uri of the node created. Use that and perform swis.read.
obj = swis.read(uri)
swis.read will provide all the properties of the newly added node. Use that to get the nodeid of the node and use below provided code to assign ICMP poller to the node.
pollerUri = swis.create("Orion.Pollers", PollerType="N.IPAddress.ICMP.Generic", NetObject="N:" + str(obj["NodeID"]), NetObjectType="N", NetObjectID=obj["NodeID"])