Hi
I am trying to get a list of devices that do not have a snmp trap in the orion logs, I want to use this list to run another function.
I have followed the samples on the github page and able to get a response from the query.py.
session = requests.Session()
session.timeout = 30
swis = orionsdk.SwisClient(npm_server, username, password, session = session)
print("Query Test:")
results = swis.query("SELECT TOP 3 NodeID, DisplayName FROM Orion.Nodes")
for row in results['results']:
print("{DisplayName}".format(**row))
The swql query ( works in swql studio) i am trying to run is:
SELECT Nodes.Uri, Nodes.DisplayName FROM Orion.Nodes AS Nodes
Left Join (
Select NodeID from Orion.OLM.LogEntry
WHERE MessageDateTime >= ADDDAY(-14, GETUTCDATE())
AND LogEntryTypeID = 2
group by NodeID
) logs
on
Logs.NodeID = Nodes.NodeID
where Logs.NodeID is NULL
and Nodes.CustomProperties.AdminDomain = 'xxxxx'
and Nodes.CustomProperties.SupportGroup = 'xxxxx'
The format i am using in python is:
def dayquery():
"""
SELECT Nodes.DisplayName FROM Orion.Nodes AS Nodes
Left Join (
Select NodeID from Orion.OLM.LogEntry
WHERE MessageDateTime >= ADDDAY(-7, GETUTCDATE())
AND LogEntryTypeID = 2
group by NodeID
) logs
on
Logs.NodeID = Nodes.NodeID
where Logs.NodeID is NULL
AND Nodes.CustomProperties.AdminDomain = 'xxxxx'
AND Nodes.CustomProperties.Excluded_From_SNMP_Traps != 'True'
AND Nodes.CustomProperties.SupportGroup = 'xxxxxx'
AND EngineID = '10'
"""
results = swis.query(dayquery)
for row in results['results']:
print("{DisplayName}".format(**row))
I am getting errors:
Python\Python38-32\lib\site-packages\orionsdk\swisclient.py", line 23, in query
return self._req(
Python\Python38-32\lib\site-packages\orionsdk\swisclient.py", line 63, in _req
resp.raise_for_status()
Python\Python38-32\lib\site-packages\requests\models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:xxxxxxxxx/Solarwinds/InformationService/v3/Json/query
I am just a Network engineer trying to avoid alerts on false positives, and googling my way through SQL and Python so if anyone could assist I would be greatly appreciated.
Thanks