mldvx4 has asked for the wisdom of the Perl Monks concerning the following question:

I have some iptables rules that produces entries in files such as /proc/self/net/xt_recent/DEFAULT
The files contain entries like the following:

src=203.0.113.123 ttl: 64 last_seen: 122885298 oldest_pkt: 4 122852593, 12285459
5, 122858603, 122885298, 122822088, 122823091, 122825095, 122829189, 122829439, 
122829829, 122830078, 122830341, 122830591, 122831092, 122832095, 122834099, 122
835401, 122835651, 122836152, 122837155, 122838498, 122838748, 122839249, 122840
078, 122840328, 122840829, 122841831, 122843835, 122847843, 122850840, 122851090
, 122851591

Apparently those times are 'jiffy' and not 'epoch'. I have no idea where to start in converting jiffies to a normal time format. What module(s) can help to convert them to usable times?

Replies are listed 'Best First'.
Re: Converting jiffies to normal time
by Corion (Patriarch) on Jan 04, 2017 at 19:49 UTC

    It seems that jiffies are just system ticks since the last reboot. This Stackoverflow question on the same topic except for Python seems to confirm that.

    So, to get back to the "normal" timeformat, you would have to find the uptime of the system where these jiffies come from, and the tick rate of that system, and then divide the jiffie number by the tick rate to get the number of seconds since system reboot. If you add that to the time of last reboot, you get an epoch timestamp.

    This seems to me to be a straightforward calculation, but I don't know of any module that implements it for you.

      Thanks. I guess Unix::Uptime or Sys::Load can provide the uptime. Is one recommended over the other?

      Is there a best practice for determining tick rate? Sys::Info::Device::CPU can return the clock speed.