source: FOIAVistA/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/ZOSVKRV.m@ 1671

Last change on this file since 1671 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.9 KB
Line 
1%ZOSVKR ;SF/KAK/RAK - Collect RUM Statistics for VAX-DSM;8/20/99 08:44 ;1/10/01 08:06
2 ;;8.0;KERNEL;**90,94,107,122,143,186**;Apr 3, 2003 9:59 am
3 ;
4RO(OPT) ; Record option resource usage in ^KMPTMP("KMPR"
5 ;
6 N KMPRTYP S KMPRTYP=0 ; option
7 G EN
8 ;
9RP(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 ;
22RU(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 ;
48EN ;
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 S NODE=$P($ZC(%GETSYI),",",4),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(!) then
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 ;
160STATS() ;-- extrinsic - return current stats for this $job
161 ;
162 N H,KMPRCMD,KMPRGLO,ZH
163 ;
164 ; S C=",",ZH=$ZH,H=$P(ZH,",",3)
165 ;
166 D JT
167 Q:KMPRCMD="" ""
168 ;
169 S ZH=$ZH,H=$P(ZH,",",3),H=$E(H,13,23),H=$P($H,",")_","_($P(H,":")*3600+($P(H,":",2)*60)+$P(H,":",3))
170 ;
171 ; current stats for this $job
172 ; cpu^dio^bio^pg_fault^cmd^glo^$H_date^$H_sec^ascii_time^$s
173 Q $P(ZH,",")_"^"_$P(ZH,",",7)_"^"_$P(ZH,",",8)_"^"_$P(ZH,",",4)_"^"_KMPRCMD_"^"_KMPRGLO_"^"_$P(H,",")_"^"_$P(H,",",2)_"^"_$P(ZH,",",3)_"^"_$S
174 ;
175JT ; Calculate the Job Table (KMPR("JTAB")) for this job
176 ; KMPR("JTAB") should be made a system wide variable
177 ;
178 N %GLSBASE,%JOB,%JOBSIZ,%JOBTAB,%MAXPROC,%PID,%SMSTART,%TYPE,KMPROUT,X
179 ;
180 ; Return the current number of commands and global references
181 ; KMPRCMD and KMPRGLO equal to null if NOT successful
182 S (KMPRCMD,KMPRGLO)="",KMPROUT=0,U="^"
183 ;
184 ; Check for correct Job Table (KMPR("JTAB")) for this job
185 I $D(KMPR("JTAB")) I $V(KMPR("JTAB")+20)=$J S %TYPE="DSM" D USER G EXIT
186 S %SMSTART=$V($ZK(GLS$SMSTART)) G:'%SMSTART EXIT
187 S %GLSBASE=$V($V(0)+44)
188 S %JOBTAB=%SMSTART+$V(%SMSTART+$V(%GLSBASE+124)),%JOBSIZ=$V(%GLSBASE+128)
189 S %MAXPROC=$V($V(%GLSBASE+84)+%SMSTART)
190 ;
191 ; Go through Job Table looking for this process
192 F %JOB=1:1:%MAXPROC Q:KMPROUT S KMPR("JTAB")=%JOB*%JOBSIZ+%JOBTAB D
193 .I $V(KMPR("JTAB")+20) S %PID=$V(KMPR("JTAB")+20),%TYPE="DSM" I %PID=$J D USER S KMPROUT=1
194 ;
195EXIT ;
196 S X=^%ZOSF("ERRTN"),@^%ZOSF("TRAP")
197 Q
198 ;
199USER ;
200 ; Watch for NONEXPR process
201 S X="UERR^%ZOSVKR",@^%ZOSF("TRAP")
202 ;
203 ; Process improperly exited DSM
204 I %TYPE="DSM",$V(KMPR("JTAB")+$ZK(JOB_B_FLAGS),-1,1)\$ZK(JOB_M_EXITED)#2 G IMPROP
205 ;
206 ; Get commands and global references from job table
207 S KMPRCMD=$V(KMPR("JTAB")),KMPRGLO=$V(KMPR("JTAB")+12)
208 Q
209UERR ;
210 ; Ignore NONEXPR (improperly exited DSM process) and SUSPENDED process
211 I $ZE["NONEXPR"!($ZE["SUSPENDED") Q
212 ZQ
213IMPROP ;
214 ; Ignore improperly exited DSM process
215 Q
Note: See TracBrowser for help on using the repository browser.