DX NetOps

Expand all | Collapse all

Convert timetick to time

Jump to Best Answer
  • 1.  Convert timetick to time

    Posted 04-04-2017 06:38 AM

    Hi!

     

    Anyone already certificate the convertion from a number to a readable string? Example:

    Timetick: 338003 ----> Human-friendly: 56 minutes 20 seconds

     

    Giving an example, the calculation for the timetick 1525917187:

     

    1525917187 / 8640000 = days (+remainder) = 176.6107855324074
    0.6107855324074 * 24 = hours (+remainder) = 14.65885277777778
    0.65885277777778 * 60 = minutes (+remainder) = 39.53116666666667
    0.53116666666667 * 60 = seconds.milliseconds = 31.87

     

    Now I want to translate this into a XML. This value will be available into component description.



  • 2.  Re: Convert timetick to time

    Posted 04-04-2017 11:36 AM

    Hello Diogo,

     

    To best answer this, can you provide more context about this question?

     

    What is your goal, or what is the target, of this new time based value you want to use?

     

    Thanks,

    Mike



  • 3.  Re: Convert timetick to time

    Posted 04-04-2017 11:43 AM

    I want to put the Access Point Uptime into description field, the Metric Family is auto-updated each hour.

    The device is a wireless controller, it contains components, each one an AP. The components inventory shows the device, the component name and the description, I wanna to add more details into desc.



  • 4.  Re: Convert timetick to time
    Best Answer

    Posted 04-20-2017 06:47 AM

    I found the solution. For example, for Cisco WLC APs:

     

    secondsTimetick=snmpProtectedDiv(cLLwappUpTime, 100);

    seconds = (secondsTimetick%60);
    minutes = snmpProtectedDiv((secondsTimetick%3600), 60);
    hours = snmpProtectedDiv((secondsTimetick%86400), 3600);
    days = snmpProtectedDiv(secondsTimetick, 86400);

    return snmpRound(days) + " days, " + snmpRound(hours) + " hours, " + snmpRound(minutes) + " minutes, " + snmpRound(seconds) + " seconds";