2 from pykdump.API import *
4 Copyright (c) 2019 Cray Inc. All Rights Reserved.
5 Utility to print jiffies as date and time
12 description_short = "Print the date and time for a jiffies timestamp."
14 # Get current time in jiffies and in seconds. Compute the offset of
15 # the timestamp in jiffies from current time and convert to seconds.
16 # Subtract the offset from current time in seconds and convert result
17 # to a datetime string.
18 def jiffies2date(jts):
19 scur = crashlib.time.get_wallclock_seconds()
21 jcur = readSymbol('jiffies')
24 soffset = (jcur - int(jts)) / sys_info.HZ
26 stime = scur - soffset
27 date = time.asctime(time.localtime(stime))
28 print('%s (epoch: %d)' % (date, stime))
30 if __name__ == "__main__":
31 description = "Print the date and time of a given jiffies timestamp. " + \
32 "Also includes seconds since epoch."
33 parser = argparse.ArgumentParser(description=description)
34 parser.add_argument("timestamp", nargs="?", default=0, type=int,
35 help="the timestamp in jiffies to be converted to date/time")
36 args = parser.parse_args()
37 jiffies2date(args.timestamp)