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.
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;
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)