Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XTERSUM

XTERSUM.m

Go to the documentation of this file.
  1. XTERSUM ;ISF/RCR,RWF - Error Trap Summary Utilities ;03/25/09 11:12
  1. ;;8.0;KERNEL;**431**;Jul 10, 1995;Build 35
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. QUIT
  1. ; ; All code is accessed by alternate entry points.
  1. ; >D ADD^XTERSUM ; Will gather the latest Error Traps and drop into FM
  1. ; >D SCAN^XTERSUM("T-30","NOW","UNDEF") - Generate Selected Error
  1. ; Argument list for Start Date (def:first date on file),
  1. ; Stop Date (def:last date recorded for an error),
  1. ; An optional select string (def:"")
  1. ; Alternate Entry Point to invoke the collection from the error trap.
  1. ; Requires no inputs and defaults to thiry days ago, now, and no
  1. ; selection criteria (everything is selected to be added).
  1. ALL ; Include all errors in the history - Probably only run at a New Site.
  1. D SCAN("t-900","NOW","")
  1. QUIT
  1. ; =========
  1. ; Actually, now the invocation can be shortened to D SCAN^XTERSUM("T-30")
  1. ADD ; Include all errors in the last 30 days
  1. D SCAN("t-30","NOW","")
  1. QUIT
  1. ; =========
  1. TODAY ; Just do Today. Was added when there was concern for performance
  1. D SCAN("t","NOW","")
  1. QUIT
  1. ; =========
  1. ; Call as >D REL^XTERSUM("t-1")
  1. REL(X) ; Process from the starting time/date (in X) and NOW.
  1. D SCAN($G(X,"T"),"NOW","")
  1. QUIT
  1. ; =========
  1. ;
  1. ; %D1, %D2 Optional Start (%D1) and End (%D2) Dates
  1. ; %TY - Optional Type of Error to Scan For and Return
  1. ; Sample Call: D SCAN^XTERSUM("T-3","NOW","UNDEF")
  1. SCAN(%D1,%D2,%TY) ; Alternative Entry Point for Demand Runs
  1. S %D1=$G(%D1),%D2=$G(%D2),%TY=$G(%TY)
  1. S:'$L(%D1) %D1=$O(^%ZTER(1,0)) S:'$L(%D2) %D2="NOW"
  1. N %AR,%EN,%LOC,%ZE1,%ZE2,%K,%K1,%K2,%RT,%T1,%T2,%Y1,%Y2
  1. N %CD,%GR,%H,%I,%J,%ST,%ZE,%ZH,%TS,%EC,%MC,%PL
  1. N %DUZ,%VTQUED,%XQY,%XQY0,%XUENV,%XWBTBF,%XWBTBUF,%ZTSK,%ZTQUED
  1. S U="^"
  1. S %LOC="9999"
  1. S %K=$$LOCATE^XTERSUM1()
  1. I $L(%K) S %LOC=%K
  1. S %Y1=$$DEFDAT^XTERSUM1(%D1,"")
  1. S %Y2=$$DEFDAT^XTERSUM1(%D2,"NOW")
  1. S %K1=$P(%Y1,"^",2),%T1=$P(%Y1,"^",3)
  1. S %K2=$P(%Y2,"^",2),%T2=$P(%Y2,"^",3)
  1. S %K=%K1
  1. F D S %K=$O(^%ZTER(1,%K)) Q:%K>%K2 Q:%K'?1.7N
  1. . S %EN=0
  1. . F S %EN=$O(^%ZTER(1,%K,1,%EN)) Q:%EN'?1.N D
  1. . . D:$$GETER(%EN,%TY) ; Load the new Error
  1. . . . N D0
  1. . . . D COMPILE ; ; Set the Extracted Values into the Output Array
  1. . . . S D0=$$INCR(%ZE) ; Create a new record in ^%ZTER(3.077,
  1. . . . D:D0
  1. . . . . L +^%ZTER(3.077,D0):5 ; Small Lock Window, Grab, Do, Release
  1. . . . . D PLACERR ; ; To build the XTERSUM Record
  1. . . . . L -^%ZTER(3.077,D0)
  1. . . . .QUIT
  1. . . .QUIT
  1. . .QUIT
  1. .QUIT
  1. ;See if need to Send summary to consolidation site.
  1. I $P($G(^XTV(8989.3,1,"ZTER")),U,2) D SEND^XTERSUM3
  1. QUIT
  1. ; =========
  1. ; Need to get %D1 and %D2 into Fileman Standard Time/Date
  1. ; Then Verify the %TYpe for Identification, "" is default.
  1. ; Search ^%ZTER(1,+$H,1,%EN,"GR") ; Last Global Reference,
  1. ; Search ^%ZTER(1,+$H,1,%EN,"H") ; Date/Time Stamp of the Error,
  1. ; Search ^%ZTER(1,+$H,1,%EN,"I") ; The Current Device Used,
  1. ; Search ^%ZTER(1,+$H,1,%EN,"LINE") ; Last Line of Code
  1. ; Search ^%ZTER(1,+$H,1,%EN,"ZE") ; Error Encountered
  1. ; Search ^%ZTER(1,+$H,1,%EN,"ZK") ; System Time and Utilization Sig.
  1. ; Scan for the "ZV" for %STACK to trace the activity? (Later)
  1. ; Inputs
  1. ; %K - Which Day's Errors to Examine, SYMBOL TABLE
  1. ; D0 - %EN, points to the error for the day in %K
  1. ; %SR - Search String = %TY. Usually Null
  1. ; Outputs
  1. ; %TS Returned as 1 = Success, and 0 = Failed to find the search string
  1. ; %CD = Code with Error
  1. ; %GR = Last Global Reference
  1. ; %H = Horolog date and time that the Error Occurred
  1. ; %I = Current Device Used
  1. ; %J = Job Identifier
  1. ; %ST = Stack Frames
  1. ; %ZE = Error Description
  1. ; %ZH = System time and Utilization Signature
  1. ; ................
  1. GETER(K1,%SR) ; Extract the data needed for the next Error Analysis
  1. N %TS
  1. S %CD=$G(^%ZTER(1,%K,1,K1,"LINE"))
  1. S %GR=$TR($G(^%ZTER(1,%K,1,K1,"GR")),"^","~")
  1. S %H=$G(^%ZTER(1,%K,1,K1,"H"))
  1. S %I=$G(^%ZTER(1,%K,1,K1,"I"))
  1. S %J=$G(^%ZTER(1,%K,1,K1,"J"))
  1. S %ZE=$G(^%ZTER(1,%K,1,K1,"ZE"))
  1. S %ZH=$TR($G(^%ZTER(1,%K,1,K1,"ZH")),"^",",")
  1. S %ST=$TR($$GETSTK(%K,K1),"^","~")
  1. S %TS=(%ZH_%CD[%SR) ; Separate because of String Length Problem
  1. S:%H %H=$$HTFM^XLFDT(%H)
  1. S %TS=%TS!(%GR_%H_%I_%J[%SR)
  1. S %TS=%TS!(%ST[%SR)
  1. I '%TS K %CD,%GR,%H,%I,%J,%ST
  1. QUIT %TS
  1. ; =========
  1. COMPILE ; Compile the information from ^%ZTER into the Output Array, %AR
  1. N A,B,C1,C2,C3,C4,D
  1. S A=$TR($E($P(%ZE,", ",1,2),1,63),"^","~")
  1. ; For Cache, Strip Out the Name of the Routine and Label
  1. S:A["<"&($P(A,"<",2)[">") A=$P(A,">",2)_", "_$P(A,">")_">"
  1. Q:A=""
  1. ;
  1. S B="",D=0
  1. S D=$O(^%ZTER(3.077,"B",$E(A,1,30),""))
  1. S:D B=$G(^%ZTER(3.077,D,0))
  1. S C1=$P(B,"^"),C2=$P(B,"^",2),C3=$P(B,"^",3),C4=$P(B,"^",4)
  1. S:C2="" C2=%H
  1. S:C2>%H C2=%H
  1. S:C3="" C3=%H
  1. S:C3<%H C3=%H
  1. S:C4="" C4=$P($P(%ZE,":"),"^",2)
  1. S:C4="" C4="[Unknown Xecute]"
  1. S %AR(0)=C1_U_C2_U_C3_U_C4
  1. S %AR(2)=%CD ;line
  1. S %AR(3)=%GR ;global
  1. S %AR(6)=%ST ;stack
  1. QUIT
  1. ; =========
  1. ; All of the parts are known at this point, now we need to find out
  1. ; if they are already recorded. Call FMT to get the error in a standard
  1. ; format.
  1. INCR(V) ; Build a New Record in ^%ZTER(3.077,
  1. N C,D0,RTN,T,DO,DD,DIC,X,Y
  1. I $G(V)="" Q 0 ; Input Value missing
  1. ;
  1. S V=$$FMT(V) ;Get V in standard form
  1. S RTN=$P($G(%AR(0)),"^",4)
  1. S:RTN="" RTN="[No RTN]" ; Error is in an Execute, so no routine
  1. S D0=$O(^%ZTER(3.077,"B",$E(V,1,30),""))
  1. ; Need a 0 in D0 to create a new entry (New Error in New Location)
  1. ; in this file (3.077)
  1. D:'D0
  1. . S $P(%AR(0),U)=V
  1. . L +^%ZTER(3.077,0):15
  1. . S DIC="^%ZTER(3.077,",DIC(0)="FL",X=V
  1. . D FILE^DICN S D0=+Y
  1. . L -^%ZTER(3.077,0)
  1. . QUIT
  1. ;%ZTER placed the .01, See if need to set the rest of the data
  1. D:'$D(^%ZTER(3.077,D0,2))
  1. . S ^%ZTER(3.077,D0,0)=%AR(0)
  1. . S ^%ZTER(3.077,D0,1,0)="^3.07701^^"
  1. . S ^%ZTER(3.077,D0,2)=%AR(2)
  1. . S ^%ZTER(3.077,D0,3)=%AR(3)
  1. . S:$G(%AR(6))'="" ^%ZTER(3.077,D0,6)=%AR(6)
  1. . D XREF(D0)
  1. .QUIT
  1. QUIT D0
  1. ;
  1. XREF(DA) ;Set other X-refs because %ZTER set the entry
  1. N DIK,D0
  1. S DIK="^%ZTER(3.077,",DIK(1)=.01 D EN1^DIK
  1. Q
  1. ; =========
  1. ; First, we need to fix the various errors that are generated and make
  1. ; sure that they are consistant with our standard error representations.
  1. ; Some additional work might be needed here to reflect the differences of
  1. ; other MUMPS implementations which do not follow the DSM error format.
  1. FMT(V) ;Format the error string
  1. S V=$$FMT^%ZTER(V)
  1. S V=$TR($E($P(V,", ",1,2),1,63),"^","~")
  1. ; Adjustment for Cache - MTZ/RCR 23MAR2005
  1. ; Move the error description
  1. ;I V["<"&($P(V,"<",2)[">") S V=$P(V,">",2)_", "_$P(V,">")_">"
  1. Q V
  1. ; =========
  1. ; Inputs are collected from the Error Trap
  1. ; Everything has been collected; Now Create the SubRecord in
  1. ; ^%ZTER(3.077, But first check to see if the entity has not already
  1. ; been collected. If found;
  1. ; Returns the subIEN for the entity (D1 level).
  1. ; If NOT found, Return 0
  1. PLACERR ;
  1. N %L,D1,KEY,T,T1,T2
  1. S T=$G(^%ZTER(3.077,D0,0))
  1. S KEY=%K_":"_%LOC ;_":"_%EN
  1. S D1=$O(^%ZTER(3.077,D0,1,"B",KEY,""))
  1. D:'D1 ; Skip if already created
  1. . S:'$D(^%ZTER(3.077,D0,1,0)) ^%ZTER(3.077,D0,1,0)="^3.07701^"
  1. . S D1=$P(^%ZTER(3.077,D0,1,0),U,3)+1
  1. . S $P(^%ZTER(3.077,D0,1,0),U,3,4)=D1_U_D1
  1. . S ^%ZTER(3.077,D0,1,"B",KEY,D1)=""
  1. . S ^%ZTER(3.077,D0,1,D1,0)=KEY_U_%H_U_%ZH_U_$G(%DUZ)
  1. . S:%CD'=$G(^%ZTER(3.077,D0,2)) ^%ZTER(3.077,D0,1,D1,1)=%CD ;line
  1. . S:%GR'=$G(^%ZTER(3.077,D0,3)) ^%ZTER(3.077,D0,1,D1,2)=%GR ;global
  1. . F S %L=$L(%XUENV,"^") Q:%L=3 D
  1. . . S %XUENV=$P(%XUENV,"^",1,3)
  1. . . I %L<3 S $P(%XUENV,U,3)="[?]"
  1. . .QUIT
  1. . I "^^[?]"[%XUENV S %XUENV="^^"
  1. . S ^%ZTER(3.077,D0,1,D1,3)=%DUZ_U_%XQY_U_%XQY0_U_%ZTSK_U_%XUENV_U_%XWBTBF
  1. . S:%ST'=$G(^%ZTER(3.077,D0,6)) ^%ZTER(3.077,D0,1,D1,6)=%ST ;stack
  1. . S %AR(0)=$G(%AR(0))
  1. . S T1=$P(T,U,2,4),T2=$P($G(%AR(0)),U,2,4)
  1. . S:T1'=T2 $P(^%ZTER(3.077,D0,0),U,2,4)=T2
  1. .QUIT
  1. QUIT
  1. ; =========
  1. ; Build a data structure to reflect the Stack and the code at
  1. ; different stack levels of the error trap capture. Store in
  1. ; the %ST string for transfer to the record.
  1. ; While scanning the symbols, pick up the following symbols if
  1. ; available; from symbol table;
  1. ; Output
  1. ; %DUZ << DUZ = The User Identifier
  1. ; %ZTSK << ZTSK = The TASK Pointer being performed
  1. ; %XQY << XQY = The OPTION being performed
  1. ; %XQY0 << XQY0 = The Name of the OPTION
  1. ; %ZTQUED << ZTQUEUED = 0 means Submanager, .5 Subman in Cleanup
  1. ; other number = Task Being Performed.
  1. ; %XUENV << XUENV = Operational Environment and CPU of the Problem
  1. ; piece 1 = Global Volume
  1. ; piece 2 = Routine Volume
  1. ; piece 3 = CPU Used
  1. ; %XWBTBUF << XWBTBUF = RPC Broker Action
  1. GETSTK(X1,X2) ; Build the Stack String
  1. N BF,BFD,ST,T,T0,V0
  1. S (V0,T0)=0,ST=""
  1. S (%DUZ,%VTQUED,%XQY,%XQY0,%XWBTBF,%ZTSK)="",%XUENV="^^"
  1. F S V0=$O(^%ZTER(1,X1,1,X2,"ZV",V0)) Q:V0'>0 D
  1. . S BF=$G(^(V0,0))
  1. . S BFD=$G(^("D"))
  1. . D:BF["$STACK("
  1. . . I BF[",""ECODE"")" S %EC=BFD Q
  1. . . I BF[",""MCODE"")" S %MC=BFD Q
  1. . . I BF[",""PLACE"")" D Q
  1. . . . S %PL=BFD
  1. . . . S %PL=$P(%PL," ")_":"_$E($P(%PL," ",2),2,999)
  1. . . . S:%EC'="" %PL="*"_%PL
  1. . . . S ST=ST_">"_%PL
  1. . . . S:$L(ST)>240 ST=$P(ST,">",1,5)_"> ... >"_$P(ST,">",8,999)
  1. . . .QUIT
  1. . .QUIT
  1. . I BF="DUZ" S %DUZ=BFD Q
  1. . I BF="ZTQUED" S %ZTQUED=BFD Q
  1. . I BF="XQY" S %XQY=BFD Q
  1. . I BF="XQY0" S %XQY0=$P(BFD,U,2) Q
  1. . I BF="XUENV" S %XUENV=$P(BFD,U,1,3) Q
  1. . I BF="XWBTBUF" S %XWBTBUF=$P(BFD,U) Q
  1. . I BF="ZTSK" S %ZTSK=BFD Q
  1. .QUIT
  1. QUIT "["_$E(ST,2,999)_"]"
  1. ; =========
  1. ;
  1. ; Check the Cross References for the expected data
  1. ; But first check to see if the entity has not already been collected.
  1. ; If FOUND, Returns the IEN for the entity.
  1. ; If Not fOUND, Return 0.
  1. ; Need a 0 to create a new entry in this file (3.077)
  1. CHKXRF(XX,K1,K2) ;
  1. N KEY
  1. S KEY=+$G(K2)
  1. S:XX="" XX="B"
  1. S K1=$G(K1)
  1. I K1="" Q 0 ; Bad Second Argument
  1. ;
  1. I '$D(^%ZTER(3.077,XX,K1,KEY)) S KEY=$O(^%ZTER(3.077,XX,K1,KEY))
  1. S:KEY="" KEY=0
  1. QUIT KEY
  1. ; =========