Community discussions

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

### OID Time Value Conversion

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.

krisjanis
MikroTik Support
Posts: 391
Joined: Tue Feb 05, 2013 5:00 pm

### Re: OID Time Value Conversion

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

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

### Re: OID Time Value Conversion

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"))
)

chemarisalazar
just joined
Posts: 2
Joined: Mon Aug 06, 2018 12:37 pm
Contact:

### Re: OID Time Value Conversion

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.

chemarisalazar
just joined
Posts: 2
Joined: Mon Aug 06, 2018 12:37 pm
Contact:

### Re: OID Time Value Conversion

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 3 guests