Port last activity: last time seen up

Do you think will be usefull store in database last time was up with traffic one port?
For example to reutilize a port because they are no used in the last year, for example.

1 Like

If you are not “cleaning” eventlog you can try to use db query directly.

select device_id,message,reference from eventlog where device_id = XXX AND type = ‘interface’ AND UNIX_TIMESTAMP(datetime) >= UNIX_TIMESTAMP(NOW() - INTERVAL 365 DAY);

“Reference” will be the port_id. I suppose you can easily script this.
Maybe you will get some more info by looking at this topic:

I’ve found another option using ifLastChange

select port_id,ifName,ifOperStatus,ifLastChange,uptime, last_polled, IF(ifOperStatus=‘up’,last_polled, IF(ifLastChange=0,NULL,date_sub(last_polled,INTERVAL uptime-round(ifLastChange/100) SECOND))) as last_activity from ports p inner join devices d on p.device_id=d.device_id;

1 Like

Careful when devices get rebooted and uptime goes back to 0, I seem to remember all the ifLastChanges go with it.

When I tried to build something similar, I joined to the ports_fdb table to see when MACs were last seen on a port, as these would survive a device reboot. But as limes-github said depends how long you are keeping that data before cleanup.

I want the ability to tell how long it has been since a switch port has been used. LibreNMS provides “Last Seen” information about nodes in the FDB, but we don’t have that info about switch ports. I would like to see this “Last Seen” info on this page:

https://librenms.mydomain.com/device/device=1/tab=ports/view=basic/

(I understand that ifLastChanges is reset after a reboot, but it is still useful information)