Closed Andyjb8 closed 10 months ago
I don't have an environment with only one poller to test on, can you try some things out and provide the results?
I'd like to know what these queries return: SELECT count(EngineId) as NumEngines FROM Orion.Engines SELECT Nodes, EngineID FROM Orion.Engines ORDER BY Nodes asc
I'm probably not doing the logic the best there, but it sounds like the count query is returning something other than 1 (possibly 0?) which puts the index out of range on "queryengines['results'][0]['NumEngines']"
It looks like it was returning nothing. which explains why I got the "list index out of range" error. I am not sure if this is the best way to do it, but updated to this and it works with one poller, but I haven't tested it with multiple pollers yet.
def get_least_used_polling_engine(self):
queryengines = self.swis.query("SELECT count(EngineId) as NumEngines FROM Orion.Engines")
totalpollingengines = queryengines['results'][0]['NumEngines']
if totalpollingengines != 1:
queryleast = self.swis.query("SELECT TOP 1 Nodes, EngineID FROM Orion.Engines WHERE EngineID != 1 ORDER BY Nodes asc")
if queryleast['results']: # Check if results are not empty
leastusedpollingengine = queryleast['results'][0]['EngineID']
return leastusedpollingengine
else:
return "1" # Replace with an appropriate default EngineID if necessary
else:
return "1" # Default value when there's only one engine
yep this is similar to what I planned to do, just needed you to confirm my suspicions. I guess Orion.Engines just doesn't get populated at all in a single-poller environment. I'll push out a bugfix this weekend, thanks!
I pushed 1.0.3 to update the logic for get_least_used_polling_engine. Converting the count to an int and using a greater than comparison should handle the 0 count. Let me know if this doesn't work for you, tested OK on my multiple poller env.
I get the below "get_least_used_polling_engine\nIndexError: list index out of range error" on with standalone solarwinds server. Here my playbook task:
name: Add SNMP node to Solarwinds solarwinds.orion.orion_node: <<: *solarwinds_info state: present name: "{{ inventory_hostname }}" ip_address: "{{ ansible_host }}" polling_method: SNMP snmp_version: 3 snmpv3_auth_key: "{{ snmpv3_auth_pass}}" snmpv3_auth_method: SHA1 snmpv3_priv_key: "{{ snmpv3_priv_pass}}" snmpv3_priv_method: AES128 snmpv3_username: "{{ snmpv3_user}}" delegate_to: localhost
If I add the this option: "polling_engine: 1" it resolved the issue. Also, I don't have this issue in production with HA deployment of solarinwinds and can leave off the polling_engine option and have no problems.
TASK [Add SNMP node to Solarwinds] ***** task path: /home/andrewba/automation/playbooks/orion_add_node.yml:44 Trying secret FileVaultSecret(filename='/home/andrewba/vault.pass') for vault_id=default Trying secret FileVaultSecret(filename='/home/andrewba/vault.pass') for vault_id=default