SOLVED:Leftover ports of deleted devices... how to remove!

Hello,

due to (my) unproper usage of autodiscovery I had several devices multiple times in my database,
so I deleted these extra devices.

I somehow managed, that I have “leftover ports”, meaning these ports are assigned to devices that no longer exist, eg.:

MariaDB [librenms]> SELECT COUNT(*) FROM ports where device_id = "27";
+----------+
| COUNT(*) |
+----------+
|      159 |
+----------+
1 row in set (0.001 sec)

MariaDB [librenms]> SELECT * from devices where device_id = "27";
Empty set (0.001 sec)

Of course these ports also appear in the WUI.

How can I fix this?

Would a

DELETE FROM ports WHERE device_id = "27";

be sufficient or are there any other references that have to be removed?

Thank you for your help!

Hi,
I think you can do that in the Web-UI. Check the pull down menu “Ports” → “deleted Ports” (between Service and Health Menu) and then purge deleted ports.
Hope it is that what you looking for.

bye

@TheGracens thank you for your reply and sorry for my delay!

Unfortunately this is not the solution for me.
I know about the deleted ports (ports that existed on a device but now are no longer there), but my list is empty (actually right now there’s no “deleted” you could select from the “Ports” menu).

In my case I have ports that reference to devices that are no longer there… because I deleted the devices.
No clue how I managed that the ports assigned to these devices have not been deleted in this procedure…

So IMHO these leftover ports can only be removed manually in the database .

My question is, is it valid to just delete these ports as I described in my last post?
Or will I cause the next rouble through this?

Thank you for your help!

Hi,
I believe purge-ports.php can solve your problem, have you tried with it?

1 Like

Now that you told me about the script, I did! :smiley:

That’s what I was looking for!

From the database i created a list will all the port-IDs and dumped it into a file.
This file can be read by the script (with -f) and all the orphaned ports are purged.

@SantiagoSilvaZ Thank you for your help, you saved my day!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.