I’m looking to convert an up time value that’s displayed in seconds to something like Days:Hours:Mins:Seconds.
I use SNMP oid value to display up time on devices in the Dude. I use the appearance of the device to show the uptime value. For example:
I believe a formula like this should work but I do not know how to implement it into the Dude.
time = “OID value”
days = time / 86400
hours = (time / 3600) - (days * 24)
minutes = (time / 60) - (days * 1440) - (hours * 60)
seconds = time mod 60
Do i need to make a script? Or right out some sort of logic in the Dude functions? Any guidance would be appreciated.
There are none more elegant oid to use for getting uptime from that device?
Like for example on ROS device you have to use: “1.3.6.1.2.1.1.3.0” and it will return same value that is displayed in ROS. Something like: 2w5d16h36m25s
Unfortunately the only more elegant time OID is device powered on up time. But we need link up time and it only displays in seconds for some reason. Isn’t there a way to make a function that would allow for the equation I posted earlier?
You could to it with functions. In there you can to basic math
Something like this. modify as you need it. I’m pretty sure that ir can be done in shorter way with less functions.
#tot_days
round(oid(“OID”)/86400)
#tot_hours
round((oid(“OID”)/3600)-(tot_days()*24))
#tot_min
round((oid(“OID”)/60)-(tot_days()*1400)-(tot_hours()*60))
#tot_up_time
concatenate(
(concatenate(tot_days(),“d”)),
(concatenate(tot_hours(),“h”)),
(concatenate(tot_min(),“m”))
)
strods:
You could to it with functions. In there you can to basic math
Something like this. modify as you need it. I’m pretty sure that ir can be done in shorter way with less functions.
#tot_days
round(oid(“OID”)/86400)
#tot_hours
round((oid(“OID”)/3600)-(tot_days()*24))
#tot_min
round((oid(“OID”)/60)-(tot_days()*1400)-(tot_hours()*60))
#tot_up_time
concatenate(
(concatenate(tot_days(),“d”)),
(concatenate(tot_hours(),“h”)),
(concatenate(tot_min(),“m”))
)
Hello,
This example works, but not show zeros to the left when the time is not two digits value. Can you help me?
strods:
You could to it with functions. In there you can to basic math
Something like this. modify as you need it. I’m pretty sure that ir can be done in shorter way with less functions.
#tot_days
round(oid(“OID”)/86400)
#tot_hours
round((oid(“OID”)/3600)-(tot_days()*24))
#tot_min
round((oid(“OID”)/60)-(tot_days()*1400)-(tot_hours()*60))
#tot_up_time
concatenate(
(concatenate(tot_days(),“d”)),
(concatenate(tot_hours(),“h”)),
(concatenate(tot_min(),“m”))
)
What can I do with this function for value always shows with hour two digit format?