1 | %ZOSVKR ;SF/KAK/RAK - Collect RUM Statistics for OpenM/Cache;8/20/99 08:43 ;3/27/00 11:24
|
---|
2 | ;;8.0;KERNEL;**90,94,107,122,143,186**;May 1, 2003 11:49 am
|
---|
3 | ;
|
---|
4 | RO(OPT) ; Record option resource usage in ^KMPTMP("KMPR"
|
---|
5 | ;
|
---|
6 | N KMPRTYP S KMPRTYP=0 ; option
|
---|
7 | G EN
|
---|
8 | ;
|
---|
9 | RP(PRTCL) ; Record protocol resource usage in ^KMPTMP("KMPR"
|
---|
10 | ; Variable PRTCL = option_name^protocol_name
|
---|
11 | ;
|
---|
12 | ; quit if rum is turned off
|
---|
13 | Q:'$G(^%ZTSCH("LOGRSRC"))
|
---|
14 | ;
|
---|
15 | N OPT
|
---|
16 | S OPT=$P(PRTCL,"^"),PRTCL=$P(PRTCL,"^",2)
|
---|
17 | Q:PRTCL=""
|
---|
18 | ;
|
---|
19 | N KMPRTYP S KMPRTYP=1 ; protocol
|
---|
20 | G EN
|
---|
21 | ;
|
---|
22 | RU(KMPROPT,KMPRTYP,KMPRSTAT) ;-- set resource usage into ^KMPTMP("KMPR"
|
---|
23 | ;----------------------------------------------------------------------
|
---|
24 | ; KMPROPT... Option name (may be option, protocol, rpc, etc.)
|
---|
25 | ; KMPRTYP...
|
---|
26 | ; Type of option:
|
---|
27 | ; 0 - Option
|
---|
28 | ; 1 - Protocol
|
---|
29 | ; 2 - RPC (Remote Procedure Call)
|
---|
30 | ; 3 - HL7
|
---|
31 | ; KMPRSTAT..
|
---|
32 | ; Status (for future use):
|
---|
33 | ; 1 - start
|
---|
34 | ; 2 - stop
|
---|
35 | ;----------------------------------------------------------------------
|
---|
36 | ;
|
---|
37 | Q:$G(KMPROPT)=""
|
---|
38 | ;
|
---|
39 | S KMPRTYP=+$G(KMPRTYP)
|
---|
40 | S KMPRSTAT=$G(KMPRSTAT)
|
---|
41 | ;
|
---|
42 | N OPT,PRTCL
|
---|
43 | ;
|
---|
44 | ; OPT = option name
|
---|
45 | ; PRTCL = protocol name (optional)
|
---|
46 | S OPT=$P(KMPROPT,"^"),PRTCL=$P(KMPROPT,"^",2)
|
---|
47 | ;
|
---|
48 | EN ;
|
---|
49 | ; CURHDAY... current $H day
|
---|
50 | ; CURHSEC... current $H seconds
|
---|
51 | ; CURSTAT... current stats
|
---|
52 | ; DIFF...... difference (CURSTAT minus PREVSTAT)
|
---|
53 | ; NODE...... current node
|
---|
54 | ; PREVHDAY.. previous $H day
|
---|
55 | ; PREVHSEC.. previous $H seconds
|
---|
56 | ; PREVSTAT.. previous stats
|
---|
57 | ; PRIMETM... prime time (1) or non-prime time (0)
|
---|
58 | ;
|
---|
59 | N ACTV,ARRAY,CURHDAY,CURHSEC,CURSTAT,CURRHR,DIFF
|
---|
60 | N I,NODE,PREVHDAY,PREVHSEC,PREVSTAT,PRIMETM,Y
|
---|
61 | ;
|
---|
62 | ; quit if not in "PROD" uci
|
---|
63 | S Y="" X $G(^%ZOSF("UCI")) Q:Y'[$G(^%ZOSF("PROD"))
|
---|
64 | ;
|
---|
65 | D GETENV^%ZOSV S NODE=$P(Y,"^",3),U="^"
|
---|
66 | I KMPRTYP I OPT="" S:$P($G(KMPR("JOB",NODE,$J)),"^",10)["$LOGIN$" OPT="$LOGIN$"
|
---|
67 | I OPT="" Q:'+$G(^XUTL("XQ",$J,"T")) S OPT=$P($G(^XUTL("XQ",$J,^XUTL("XQ",$J,"T"))),"^",2) Q:OPT=""
|
---|
68 | ;
|
---|
69 | ; CURSTAT = current stats for this $job
|
---|
70 | ; = cpu^dio^bio^pg_fault^cmd^glo^$H_day^$H_sec^ascii_time
|
---|
71 | S CURSTAT=$P($$STATS,"^",1,9)
|
---|
72 | Q:CURSTAT=""
|
---|
73 | ;
|
---|
74 | S CURHDAY=$P(CURSTAT,"^",7),CURHSEC=$P(CURSTAT,"^",8)
|
---|
75 | ;
|
---|
76 | ; PREVSTAT = previous stats for this $job
|
---|
77 | S PREVSTAT=$G(KMPR("JOB",NODE,$J))
|
---|
78 | ;
|
---|
79 | ; if previous option was tagged as being run from taskman(!)
|
---|
80 | ; then mark current OPTion as running from taskman(!)
|
---|
81 | I $P($P(PREVSTAT,"^",10),"***")=("!"_OPT) S OPT="!"_OPT
|
---|
82 | ;
|
---|
83 | ; concatenate to CURSTAT: ...^OPTion^option_type
|
---|
84 | S CURSTAT=CURSTAT_"^"_$S(KMPRTYP=2:"`"_OPT,KMPRTYP=3:"&"_OPT,1:OPT)_"***"_$G(PRTCL)_"^"_$G(XQT)
|
---|
85 | S KMPR("JOB",NODE,$J)=CURSTAT
|
---|
86 | ;
|
---|
87 | ; if option and login or taskman
|
---|
88 | I 'KMPRTYP I OPT="$LOGIN$"!(OPT="$STRT ZTMS$") Q
|
---|
89 | ;
|
---|
90 | I OPT="$LOGOUT$"!(OPT="$STOP ZTMS$")!(OPT="XUPROGMODE") K KMPR("JOB",NODE,$J)
|
---|
91 | ;
|
---|
92 | Q:PREVSTAT=""
|
---|
93 | ;
|
---|
94 | ; check for negative numbers for m commands and glo references
|
---|
95 | F I=5,6 I $P(CURSTAT,"^",I)<0 D
|
---|
96 | .S $P(CURSTAT,"^",I)=$P(CURSTAT,"^",I)+(2**31)+(2**31)
|
---|
97 | .I $P(PREVSTAT,"^",I)<0 S $P(PREVSTAT,"^",I)=$P(PREVSTAT,"^",I)+(2**31)+(2**31)
|
---|
98 | ;
|
---|
99 | S PREVHDAY=$P(PREVSTAT,"^",7),$P(PREVSTAT,"^",7)=$P(PREVSTAT,"^",8)
|
---|
100 | ;
|
---|
101 | ; quit if not $h
|
---|
102 | Q:'PREVHDAY
|
---|
103 | ;
|
---|
104 | ; if option has been running more than one day
|
---|
105 | ; add the number of seconds in each day to the current $H seconds
|
---|
106 | S $P(CURSTAT,"^",7)=(CURHDAY-PREVHDAY)*86400+CURHSEC
|
---|
107 | ;
|
---|
108 | ; difference = current stats minus previous stats
|
---|
109 | ; DIFF = CURSTAT - PREVSTAT
|
---|
110 | ; = cpu^dio^bio^pg_fault^cmd^glo^elapsed_sec
|
---|
111 | F I=1:1:7 S $P(DIFF,"^",I)=$P(CURSTAT,"^",I)-$P(PREVSTAT,"^",I)
|
---|
112 | ;
|
---|
113 | ; quit if negative m commands or global references
|
---|
114 | Q:$P(DIFF,"^",5)<0
|
---|
115 | Q:$P(DIFF,"^",6)<0
|
---|
116 | ;
|
---|
117 | ; option name
|
---|
118 | S OPT=$P(PREVSTAT,"^",10)
|
---|
119 | ;
|
---|
120 | ; PRIMETM = 0: non-prime time
|
---|
121 | ; 1: prime time
|
---|
122 | S PRIMETM=0
|
---|
123 | ;
|
---|
124 | ; set prime time = 1 if after 8am and before 5pm
|
---|
125 | ; non-workday prime time and non-prime time will be converted
|
---|
126 | ; into non-workday time in nightly background job (KMPRBD02)
|
---|
127 | I CURHSEC>28799&(CURHSEC<61201) S PRIMETM=1
|
---|
128 | ;
|
---|
129 | ; global location for data storage
|
---|
130 | S ARRAY=$G(^KMPTMP("KMPR","DLY",NODE,CURHDAY,OPT,$J,PRIMETM))
|
---|
131 | ;
|
---|
132 | ; seven elements for this option
|
---|
133 | F I=1:1:7 S $P(ARRAY,"^",I)=$P($G(ARRAY),"^",I)+$P(DIFF,"^",I)
|
---|
134 | ; 8th piece is occurrence counter for this option
|
---|
135 | S $P(ARRAY,"^",8)=$P(ARRAY,"^",8)+1
|
---|
136 | ;
|
---|
137 | ; current hour => 0 - 23
|
---|
138 | S CURRHR=CURHSEC\3600
|
---|
139 | ;
|
---|
140 | ; time starts at zero hour - shift everything by 10 so zero hour
|
---|
141 | ; begins at 10th piece, hour 1 is 11th, ... and hour 23 is 33rd piece
|
---|
142 | ;
|
---|
143 | ; record last hour this option ran - this will be moved to file 8971.1
|
---|
144 | ; hourly stats are only attributed to the current hour
|
---|
145 | ;
|
---|
146 | ; add ~1 if this job runs from top of hour to 60 seconds
|
---|
147 | ; this will give active number of jobs per hour
|
---|
148 | S ACTV=$P(ARRAY,"^",(CURRHR+10)),$P(ACTV,"~")=$P(ACTV,"~")+1
|
---|
149 | I (($P(CURSTAT,"^",8)#3600)-$P(DIFF,"^",7))<60 S $P(ACTV,"~",2)=1
|
---|
150 | S $P(ARRAY,"^",(CURRHR+10))=ACTV
|
---|
151 | ;
|
---|
152 | ; 9th piece: current $h seconds ~ elapsed seconds ~ difference
|
---|
153 | S $P(ARRAY,"^",9)=($P(CURSTAT,"^",8))_"~"_($P(DIFF,"^",7))_"~"_(($P(CURSTAT,"^",8)#3600)-$P(DIFF,"^",7))
|
---|
154 | ;
|
---|
155 | ; set into global
|
---|
156 | S ^KMPTMP("KMPR","DLY",NODE,CURHDAY,OPT,$J,PRIMETM)=ARRAY
|
---|
157 | ;
|
---|
158 | Q
|
---|
159 | ;
|
---|
160 | STATS() ;-- extrinsic - return current stats for this $job
|
---|
161 | ;
|
---|
162 | N H,RETURN,V,VER,ZH,ZT
|
---|
163 | ;
|
---|
164 | S RETURN="",ZT=$P($ZTIMESTAMP,".",2),V=$V(-1,$J),VER=$P($P($P($ZV,") ",2)," "),".",1,2)
|
---|
165 | ;
|
---|
166 | ; if version is less than 4
|
---|
167 | I (+VER)<4 D
|
---|
168 | .; cpu^dio^bio^pg_fault^cmd^glo^$H_date^$H_sec^time in thousands
|
---|
169 | .; -> no cpu^dio^bio^pg_fault information is returned
|
---|
170 | .S RETURN="^^^^"_$P($P(V,"^",7),",")_"^"_$P($P(V,"^",7),",",2)_"^"_+$H_"^"_$P($H,",",2)_"."_ZT_"^"_ZT
|
---|
171 | ;
|
---|
172 | ; if version is 4 or greater
|
---|
173 | E D
|
---|
174 | .S ZH=$ZU(171),ZT=$P($ZTIMESTAMP,".",2)
|
---|
175 | .S H=$P(ZH,",",3),H=$E(H,13,23),H=+$H_","_($P(H,":")*3600+($P(H,":",2)*60))_"."_ZT
|
---|
176 | .; cpu^dio^bio^pg_fault^cmd^glo^$H_date^$H_sec^ascii_time^$s
|
---|
177 | .S RETURN=$P(ZH,",")_"^"_$P(ZH,",",7)_"^"_$P(ZH,",",8)_"^"_$P(ZH,",",4)_"^"_$P($P(V,"^",7),",")_"^"_$P($P(V,"^",7),",",2)_"^"_$P(H,",")_"^"_$P(H,",",2)_"^"_$P(ZH,",",3)_"^"_$S
|
---|
178 | ;
|
---|
179 | Q RETURN
|
---|
180 |
|
---|