Community discussions

 
wifiwizard
just joined
Topic Author
Posts: 3
Joined: Tue Jan 12, 2016 7:46 pm

OID Time Value Conversion

Thu Aug 18, 2016 5:30 am

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:

Image

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.
 
krisjanis
MikroTik Support
MikroTik Support
Posts: 391
Joined: Tue Feb 05, 2013 5:00 pm

Re: OID Time Value Conversion

Thu Aug 18, 2016 2:33 pm

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
 
wifiwizard
just joined
Topic Author
Posts: 3
Joined: Tue Jan 12, 2016 7:46 pm

Re: OID Time Value Conversion

Thu Aug 18, 2016 5:45 pm

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?
 
krisjanis
MikroTik Support
MikroTik Support
Posts: 391
Joined: Tue Feb 05, 2013 5:00 pm

Re: OID Time Value Conversion

Fri Aug 19, 2016 8:32 am

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"))
)
 
User avatar
chemarisalazar
just joined
Posts: 2
Joined: Mon Aug 06, 2018 12:37 pm
Contact:

Re: OID Time Value Conversion

Wed Jul 03, 2019 9:58 pm

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?
Experto en WISP desde 2001, desarrollo de redes Wifi públicas , conexiones VPN de alto cifrado.

WISP expert since 2001, development of public Wi-Fi networks, high-encryption VPN connections.
 
User avatar
chemarisalazar
just joined
Posts: 2
Joined: Mon Aug 06, 2018 12:37 pm
Contact:

Re: OID Time Value Conversion

Thu Jul 04, 2019 1:06 pm

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?
Experto en WISP desde 2001, desarrollo de redes Wifi públicas , conexiones VPN de alto cifrado.

WISP expert since 2001, development of public Wi-Fi networks, high-encryption VPN connections.

Who is online

Users browsing this forum: No registered users and 2 guests