0

Would really appreciate help in determining how I can calculate the time passed of a Tandem (Nonstop) process since its creation.

For example: - I can get the Process creation time when I do a STATUS $proc, DETAIL and I get the textual time in "Process Creation Time" - I want to accurately calculate how much time since the process was create

My initial thought is to get the current time by #TIMESTAMP (or #JULIANTIMESTAMP), then converting the textual Process Creation time to one of the above three- or four-word format, then subctract to find the difference. Afterward, I will then convert that difference back to textual to get the actual time.

I'm having a challenge in getting this to accurately compute ... Appreciate any guidance!

Thanks!

Vu Nguyen
  • 1
  • 1

2 Answers2

1

I think that you have the right idea, there doesn't seems to be a neat way (in TACL) to get the process creation time, so you have to process the status command output. That doesn't take a variable as an OUTV parameter, so you can use a file, and do some processing in there, rather than in TACL.

I converted both timestamps to the space-separated list that #CONTIME gives, then converted those to Julian timestamps (see below).

This is probably much easier to do in (say) C, where you can call PROCESS_GETINFOLIST_ to get the creation timestamp directly. It may even be easier to do in an OSS shell, given teh better handling for timestamps in there.

?TACL ROUTINE
#FRAME

#PUSH tempfile
#SET tempfile XXTEMPXX    


[#DEF MakeTimeList ROUTINE |BODY|
#FRAME
#PUSH month day year time hour min sec centi milli

SINK [#ARGUMENT/VALUE month/WORD]
SINK [#ARGUMENT/VALUE day/WORD]
SINK [#ARGUMENT COMMA]
SINK [#ARGUMENT/VALUE year/NUMBER]
SINK [#ARGUMENT/VALUE hour/NUMBER]
SINK [#ARGUMENT/VALUE min/NUMBER]
SINK [#ARGUMENT/VALUE sec/NUMBER]
SINK [#ARGUMENT/VALUE centi/NUMBER]

[#CASE [month]
    |January| #SET month 1
    |February| #SET month 2
    |March| #SET month 3
    |April| #SET month 4
    |May| #SET month 5
    |June| #SET month 6
    |July| #SET month 7
    |August| #SET month 8
    |September| #SET month 9
    |October| #SET month 10
    |November| #SET month 11
    |December| #SET month 12
]

#SET milli [#CHARGET centi 4 TO 6]
#SET centi  [#CHARGET centi 1 TO 3]

#RESULT [year] [month] [day] [hour] [min] [sec] [centi] [milli]
#UNFRAME
]

#PUSH  start now lines line pos process


SINK [#ARGUMENT/VALUE process/ PROCESSNAME]
[#IF NOT [#PROCESSEXISTS [process]] |THEN|
    #OUTPUT [process] does not exist
]

status/out [tempfile]/[process],detail
edit [tempfile];cqab/:/ /a;cqab/./ /a;exit
filetovar [tempfile] lines
SINK [#PURGE [tempfile]]

#SET pos [#LINEFIND lines 1 Process Creation Time]
[#IF pos > 1 |THEN|
    #SET line [#LINEGET lines [pos]]
    #SET start [#CHARGET line 23 TO [#CHARCOUNT line]]  
  #SET start [MakeTimeList [start]]
  #SETMANY start, [#COMPUTETIMESTAMP [start] ]

  #SETMANY now, [#COMPUTETIMESTAMP [#CONTIME [#TIMESTAMP]] 0]
  #OUTPUT [#COMPUTE ([now] - [start])/1000000] seconds have elapsed
]

#UNFRAME
Andy Simpson
  • 367
  • 2
  • 6
0

TACL has really good process time builtin functions, try this:

?tacl routine
#frame
[#push
    inProcess processCreateTime timeRightNow
    timeDifference aMicroSecond aMilliSecond
    pctY pctM pctD pctH pctMI pctS pctMIL pctMIC
    trnY trnM trnD trnH trnMI trnS trnMIL trnMIC
]
#setmany aMicroSecond aMilliSecond , 1000000 1000
#if [#argument/value inProcess/processid]

#set processCreateTime [#processinfo/processcreationtime/[inProcess]]
[#setmany  _ pctY pctM pctD pctH pctMI pctS pctMIL pctMIC , [#interprettimestamp [processCreateTime]]]

#set timeRightNow [#juliantimestamp]
[#setmany  _ trnY trnM trnD trnH trnMI trnS trnMIL trnMIC , [#interprettimestamp [timeRightNow]]]

#output Process [#shiftstring [inProcess]] create vs now times
#set timeDifference [#compute [timeRightNow] - [processCreateTime]]
#output Created:    [pctY]-[pctM]-[pctD] [pctH]:[pctMI]:[pctS]
#output Time Now:   [trnY]-[trnM]-[trnD] [trnH]:[trnMI]:[trnS]
#output Differences:
#output in micros:   [timeDifference]
#output in mills:    [#compute [timeDifference] / [aMilliSecond]]
#output in seconds:  [#compute [timeDifference] / [aMicroSecond]]
#unframe