This is a follow up post to the switchstack sql code from last week.
Recently, I noticed issues with my CPU stack member reporting, which showed duplicates. It turns out that there were duplicate entries in the SwitchStackMember table through some problems with Orion recently (don’t ask me the details, I’m not the admin). The problem resulted in the same node and stackswitches having several unique stack id’s in this table, thus being reported several times.
I had to perform a manual cleanup of the database, but to speed things up, I created a query to find duplicates:
SELECT NodeID, MemberID, Role, MacAddress, COUNT(*) FROM [dbo].[NPM_SwitchStackMember]
GROUP BY NodeID, MemberID, Role, MacAddress
HAVING COUNT(*)>1
This shows all duplicates in the table and allows me to remove them. I wasn’t sure what would happen if I remove all entries all at once , so I decided to keep the lowest ID of each stack switch as this was the original entry.
Hope this helps