Skip to content

Commit

Permalink
Fix broken SQL to identify trap agent
Browse files Browse the repository at this point in the history
All netboxes have an IP address, but not all netboxes have
interfaces or even gwports, so left joins are necessary to still have
matches.
  • Loading branch information
lunkwill42 committed Nov 10, 2022
1 parent 5af57a5 commit 4c0e8b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/nav/snmptrapd/trap.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def _lookup_agent(self):
cur = conn.cursor()
cur.execute(
"SELECT DISTINCT netboxid, sysname, roomid "
"FROM gwportprefix "
"JOIN interface USING (interfaceid) "
"JOIN netbox USING (netboxid) "
"FROM netbox "
"LEFT JOIN interface USING (netboxid) "
"LEFT JOIN gwportprefix USING (interfaceid) "
"WHERE %s IN (ip, gwip) ",
(self.agent,),
)
Expand Down

0 comments on commit 4c0e8b9

Please sign in to comment.