Snmp uptime refactor

“I don’t think anything should use snmpEngineTime for
uptime reporting. Restarting the SNMP service on a device would then
leave you with an uptime that’s much shorter than the system’s actual

Quoted from UBNT forums regarding an issue I’ve opened linked to bad uptime display on librenms for their equipments.
The displayed uptime error in our code is based on the fact that there is a difference between sysUpTime and snmpEngineTime, and choose to use the later.

should we remove the usage of snmpEngineTime from device uptime display?

I’m not sure I trust UBNT based on the way they’ve written mibs sometimes.

Here’s the original PR to fix uptime:

What we have is different again now so it’s changed along the way. Basically snmpEngineTime is the fallback because it can cope with uptimes over 4xx days where as sysUpTime can’t afaik.

maybe is a good ideea to take snmpEngineTime in cosideration if sysUpTime is greater than 497 days?

That’s what my initial PR did, it checked if enginetime was > uptime and used it if it was.

You can’t obviously use uptime itself to check if it was over 497 days as it rolls after that so you won’t know if that’s from a reboot or not.

It should be:

Use Unix-agent uptime if we have that, if not use sysUpTime if <= snmpEngineTime, else use snmpEngineTime afaik.