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"])