KMPVRUN ;SP/JML - VSM Cache Task Manager driver ;11/1/2023
;;4.0;CAPACITY MANAGEMENT;**1,2,3,4**;3/1/2018;Build 36
;
; Reference to GETENV^%ZOSV in ICR #10097
; Reference to $ESTACK, $ETRAP and ^%ZTER in ICR#1621
;
RUN ; Loop VSM CONFIGURATION file and run collection routine for monitors set to "ON"
N $ESTACK,$ETRAP S $ETRAP="D ^%ZTER Q"
N DA,DIK,DUZ,FDA,Y,XMSUB,XMTEXT,XMY,U
N KMPINST,KMPNDTYP,KMPVDAT,KMPVEMAIL,KMPVFNUM,KMPVH,KMPVIEN,KMPVMKEY,KMPVNODE,KMPVPDAT,KMPVROUT,KMPVTASK
N KMPPSTAT,KMPSINF,KMPTEXT,KMPTNS,KMPVRNS,KMPVTNS,KMPFMDAY,X,X1,X2
; Stagger start times - use field not in use by current versions - value can't be 0
H $R(+$$GETVAL^KMPVCCFG("VTCM","MONITOR START DELAY",8969)+1)
S U="^",DUZ=.5,DUZ(0)="@"
D GETENV^%ZOSV S KMPVNODE=$P(Y,"^",3) ;supported by ICR #10097
S KMPINST=$P(Y,":",2),KMPNDTYP=$$NODETYPE^KMPUTLW(KMPINST)
S KMPSINF=$$SITEINFO^KMPVCCFG() ; site name^fac num^mail domain^prod/test^site code
S KMPVH=+$H
; Make sure SSL and Webapp classes exist
D KMPWEB
; Send daily configuration message
D CFGMSG^KMPUTLW("SERVER-DAILY")
; Ensure process only runs once a day
; Lock global,node - note: this node is not real, only for locking mechanism
L ^KMPV(8969.03,KMPVNODE):30
; Quit if currently locked - concurrent processes
I '$T G CLEANUP
; Create top ^XTMP node for the day
I KMPNDTYP="BE" D
.S KMPFMDAY=$$HTFM^XLFDT($H,1)
.S X1=KMPFMDAY,X2=$$GETVAL^KMPVCCFG("VTCM","DAYS TO KEEP DATA",8969) D C^%DTC
.S ^XTMP("KMP "_KMPFMDAY,0)=X_"^"_KMPFMDAY_"^Debug data for "_$ZD($H,3)
;
S KMPVIEN=$O(^KMPV(8969.03,"C",KMPVH,KMPVNODE,""))
; Quit if entry already exists for today - job was run previously
I KMPVIEN'="" G CLEANUP
;
; Once single process verified - Execute Tasks and record date/times
S FDA($J,8969.03,"+1,",.01)=+$H
S FDA($J,8969.03,"+1,",.02)=KMPVNODE
S KMPVMKEY=""
F S KMPVMKEY=$O(^KMPV(8969,"B",KMPVMKEY)) Q:KMPVMKEY="" D
.; ALWAYS - verify data is not building past configured number of days - if so for any reason, delete it
.D PURGEDLY^KMPVCBG(KMPVMKEY)
.Q:$$GETVAL^KMPVCCFG(KMPVMKEY,"ONOFF",8969)'="ON"
.S KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
.I KMPVROUT'="" D
..S KMPVTASK="RUN^"_KMPVROUT J @KMPVTASK
..S KMPVFNUM=+$$FLDNUM^DILFD(8969.03,KMPVMKEY_" RUNTIME")
..I KMPVFNUM>0 S FDA($J,8969.03,"+1,",KMPVFNUM)=$$NOW^XLFDT
D UPDATE^DIE("","FDA($J)","","")
S KMPVMKEY=""
F S KMPVMKEY=$O(^KMPV(8969,"B",KMPVMKEY)) Q:KMPVMKEY="" D
.S KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
.S KMPVTASK="RETRY^"_KMPVROUT J @KMPVTASK
;
CLEANUP ; Purge old data in VSM CACHE TASK LOG file and release lock
S KMPVPDAT=KMPVH-190
S DIK="^KMPV(8969.03,"
S KMPVDAT=""
F S KMPVDAT=$O(^KMPV(8969.03,"B",KMPVDAT)) Q:KMPVDAT>KMPVPDAT!(KMPVDAT="") D
.S DA=""
.F S DA=$O(^KMPV(8969.03,"B",KMPVDAT,DA)) Q:DA="" D ^DIK
L -^KMPV(8969.03,KMPVNODE)
Q
;
KMPWEB ;
N KMPPROPS,KMPVRNS,KMPSTAT,KMPSSL
S $ZT="ERREXIT"
S KMPVRNS=$NAMESPACE
S $NAMESPACE="%SYS"
I ##class(Security.Applications).Exists("/KMP")=0 D
.S KMPPROPS("NAME")="/KMP"
.S KMPPROPS("NameSpace")=$ZDEFNSP
.S KMPPROPS("Enabled")=1
.S KMPPROPS("AutheEnabled")=64
.S KMPPROPS("Timeout")=900
.S KMPPROPS("UseCookies")=2
.S KMPPROPS("CookiePath")="/KMP/"
.S KMPPROPS("DispatchClass")="KMP.VistaSystemMonitor"
.S KMPPROPS("MatchRoles")=":%All"
.S KMPSTAT=##class(Security.Applications).Create("/KMP",.KMPPROPS)
;
I ##class(Security.SSLConfigs).Exists("KMPHttpsClient")=0 D
.S KMPSSL=##class(Security.SSLConfigs).%New()
.S KMPSSL.Name="KMPHttpsClient"
.S KMPSTAT=KMPSSL.%Save()
S $NAMESPACE=KMPVRNS
S $ETRAP="D ERR^ZU Q"
Q
;
ERREXIT ;
S $NAMESPACE=KMPVRNS
S $ETRAP="D ERR^ZU Q"
Q
;
ZSTU ;
N KMPISBE,KMPMAP,KMPVMKEY,KMPVROUT,KMPVTASK,DA,DIE,DR
N DUZ,U
S DUZ=.5,DUZ(0)="@",U="^"
;
D GETENV^%ZOSV S KMPVNODE=$P(Y,U,3)_":"_$P($P(Y,U,4),":",2) ;supported by ICR #10097
S KMPISBE=$$ISBENODE^KMPVCCFG(KMPVNODE)
; verify or create SSL config and Web App
D KMPWEB
; verify or create Cache Task
D TASK^KMPTASK
; Set CPRS Switch as it is not mirrored, verify LOGRSRC flag
I $$GETVAL^KMPVCCFG("VCSM","ONOFF",8969)="ON" S ^KMPTMP("KMPD-CPRS")=1
I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969)="ON" S DIE=8989.3,DA=1,DR="300///YES" D ^DIE
; Start VTCM, VBEM and VCSM collections on all nodes
F KMPVMKEY="VTCM","VBEM","VCSM" D
.Q:$$GETVAL^KMPVCCFG(KMPVMKEY,"ONOFF",8969)'="ON"
.S KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
.I KMPVROUT'="" S KMPVTASK="RUN^"_KMPVROUT J @KMPVTASK
; Restart specifics collections on the BE
I KMPISBE D
.F KMPVMKEY="VETM","VHLM","VMCM" D
..Q:$$GETVAL^KMPVCCFG(KMPVMKEY,"ONOFF",8969)'="ON"
..S KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
..I KMPVROUT'="" S KMPVTASK="RUN^"_KMPVROUT J @KMPVTASK
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPVRUN 4884 printed Dec 13, 2024@01:42:03 Page 2
KMPVRUN ;SP/JML - VSM Cache Task Manager driver ;11/1/2023
+1 ;;4.0;CAPACITY MANAGEMENT;**1,2,3,4**;3/1/2018;Build 36
+2 ;
+3 ; Reference to GETENV^%ZOSV in ICR #10097
+4 ; Reference to $ESTACK, $ETRAP and ^%ZTER in ICR#1621
+5 ;
RUN ; Loop VSM CONFIGURATION file and run collection routine for monitors set to "ON"
+1 NEW $ESTACK,$ETRAP
SET $ETRAP="D ^%ZTER Q"
+2 NEW DA,DIK,DUZ,FDA,Y,XMSUB,XMTEXT,XMY,U
+3 NEW KMPINST,KMPNDTYP,KMPVDAT,KMPVEMAIL,KMPVFNUM,KMPVH,KMPVIEN,KMPVMKEY,KMPVNODE,KMPVPDAT,KMPVROUT,KMPVTASK
+4 NEW KMPPSTAT,KMPSINF,KMPTEXT,KMPTNS,KMPVRNS,KMPVTNS,KMPFMDAY,X,X1,X2
+5 ; Stagger start times - use field not in use by current versions - value can't be 0
+6 HANG $RANDOM(+$$GETVAL^KMPVCCFG("VTCM","MONITOR START DELAY",8969)+1)
+7 SET U="^"
SET DUZ=.5
SET DUZ(0)="@"
+8 ;supported by ICR #10097
DO GETENV^%ZOSV
SET KMPVNODE=$PIECE(Y,"^",3)
+9 SET KMPINST=$PIECE(Y,":",2)
SET KMPNDTYP=$$NODETYPE^KMPUTLW(KMPINST)
+10 ; site name^fac num^mail domain^prod/test^site code
SET KMPSINF=$$SITEINFO^KMPVCCFG()
+11 SET KMPVH=+$HOROLOG
+12 ; Make sure SSL and Webapp classes exist
+13 DO KMPWEB
+14 ; Send daily configuration message
+15 DO CFGMSG^KMPUTLW("SERVER-DAILY")
+16 ; Ensure process only runs once a day
+17 ; Lock global,node - note: this node is not real, only for locking mechanism
+18 LOCK ^KMPV(8969.03,KMPVNODE):30
+19 ; Quit if currently locked - concurrent processes
+20 IF '$TEST
GOTO CLEANUP
+21 ; Create top ^XTMP node for the day
+22 IF KMPNDTYP="BE"
Begin DoDot:1
+23 SET KMPFMDAY=$$HTFM^XLFDT($HOROLOG,1)
+24 SET X1=KMPFMDAY
SET X2=$$GETVAL^KMPVCCFG("VTCM","DAYS TO KEEP DATA",8969)
DO C^%DTC
+25 SET ^XTMP("KMP "_KMPFMDAY,0)=X_"^"_KMPFMDAY_"^Debug data for "_$ZD($HOROLOG,3)
End DoDot:1
+26 ;
+27 SET KMPVIEN=$ORDER(^KMPV(8969.03,"C",KMPVH,KMPVNODE,""))
+28 ; Quit if entry already exists for today - job was run previously
+29 IF KMPVIEN'=""
GOTO CLEANUP
+30 ;
+31 ; Once single process verified - Execute Tasks and record date/times
+32 SET FDA($JOB,8969.03,"+1,",.01)=+$HOROLOG
+33 SET FDA($JOB,8969.03,"+1,",.02)=KMPVNODE
+34 SET KMPVMKEY=""
+35 FOR
SET KMPVMKEY=$ORDER(^KMPV(8969,"B",KMPVMKEY))
if KMPVMKEY=""
QUIT
Begin DoDot:1
+36 ; ALWAYS - verify data is not building past configured number of days - if so for any reason, delete it
+37 DO PURGEDLY^KMPVCBG(KMPVMKEY)
+38 if $$GETVAL^KMPVCCFG(KMPVMKEY,"ONOFF",8969)'="ON"
QUIT
+39 SET KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
+40 IF KMPVROUT'=""
Begin DoDot:2
+41 SET KMPVTASK="RUN^"_KMPVROUT
JOB @KMPVTASK
+42 SET KMPVFNUM=+$$FLDNUM^DILFD(8969.03,KMPVMKEY_" RUNTIME")
+43 IF KMPVFNUM>0
SET FDA($JOB,8969.03,"+1,",KMPVFNUM)=$$NOW^XLFDT
End DoDot:2
End DoDot:1
+44 DO UPDATE^DIE("","FDA($J)","","")
+45 SET KMPVMKEY=""
+46 FOR
SET KMPVMKEY=$ORDER(^KMPV(8969,"B",KMPVMKEY))
if KMPVMKEY=""
QUIT
Begin DoDot:1
+47 SET KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
+48 SET KMPVTASK="RETRY^"_KMPVROUT
JOB @KMPVTASK
End DoDot:1
+49 ;
CLEANUP ; Purge old data in VSM CACHE TASK LOG file and release lock
+1 SET KMPVPDAT=KMPVH-190
+2 SET DIK="^KMPV(8969.03,"
+3 SET KMPVDAT=""
+4 FOR
SET KMPVDAT=$ORDER(^KMPV(8969.03,"B",KMPVDAT))
if KMPVDAT>KMPVPDAT!(KMPVDAT="")
QUIT
Begin DoDot:1
+5 SET DA=""
+6 FOR
SET DA=$ORDER(^KMPV(8969.03,"B",KMPVDAT,DA))
if DA=""
QUIT
DO ^DIK
End DoDot:1
+7 LOCK -^KMPV(8969.03,KMPVNODE)
+8 QUIT
+9 ;
KMPWEB ;
+1 NEW KMPPROPS,KMPVRNS,KMPSTAT,KMPSSL
+2 SET $ZT="ERREXIT"
+3
*** ERROR ***
SET KMPVRNS=$NAMESPACE
+4
*** ERROR ***
SET $NAMESPACE="%SYS"
+5 IF ##class(Security.Applications).Exists("/KMP")=0
Begin DoDot:1
+6 SET KMPPROPS("NAME")="/KMP"
+7 SET KMPPROPS("NameSpace")=$ZDEFNSP
+8 SET KMPPROPS("Enabled")=1
+9 SET KMPPROPS("AutheEnabled")=64
+10 SET KMPPROPS("Timeout")=900
+11 SET KMPPROPS("UseCookies")=2
+12 SET KMPPROPS("CookiePath")="/KMP/"
+13 SET KMPPROPS("DispatchClass")="KMP.VistaSystemMonitor"
+14 SET KMPPROPS("MatchRoles")=":%All"
+15 SET KMPSTAT=##class(Security.Applications).Create("/KMP",.KMPPROPS)
End DoDot:1
+16 ;
+17 IF ##class(Security.SSLConfigs).Exists("KMPHttpsClient")=0
Begin DoDot:1
+18 SET KMPSSL=##class(Security.SSLConfigs).%New()
+19 SET KMPSSL.Name="KMPHttpsClient"
+20 SET KMPSTAT=KMPSSL.%Save()
End DoDot:1
+21
*** ERROR ***
SET $NAMESPACE=KMPVRNS
+22 SET $ETRAP="D ERR^ZU Q"
+23 QUIT
+24 ;
ERREXIT ;
+1
*** ERROR ***
SET $NAMESPACE=KMPVRNS
+2 SET $ETRAP="D ERR^ZU Q"
+3 QUIT
+4 ;
ZSTU ;
+1 NEW KMPISBE,KMPMAP,KMPVMKEY,KMPVROUT,KMPVTASK,DA,DIE,DR
+2 NEW DUZ,U
+3 SET DUZ=.5
SET DUZ(0)="@"
SET U="^"
+4 ;
+5 ;supported by ICR #10097
DO GETENV^%ZOSV
SET KMPVNODE=$PIECE(Y,U,3)_":"_$PIECE($PIECE(Y,U,4),":",2)
+6 SET KMPISBE=$$ISBENODE^KMPVCCFG(KMPVNODE)
+7 ; verify or create SSL config and Web App
+8 DO KMPWEB
+9 ; verify or create Cache Task
+10 DO TASK^KMPTASK
+11 ; Set CPRS Switch as it is not mirrored, verify LOGRSRC flag
+12 IF $$GETVAL^KMPVCCFG("VCSM","ONOFF",8969)="ON"
SET ^KMPTMP("KMPD-CPRS")=1
+13 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969)="ON"
SET DIE=8989.3
SET DA=1
SET DR="300///YES"
DO ^DIE
+14 ; Start VTCM, VBEM and VCSM collections on all nodes
+15 FOR KMPVMKEY="VTCM","VBEM","VCSM"
Begin DoDot:1
+16 if $$GETVAL^KMPVCCFG(KMPVMKEY,"ONOFF",8969)'="ON"
QUIT
+17 SET KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
+18 IF KMPVROUT'=""
SET KMPVTASK="RUN^"_KMPVROUT
JOB @KMPVTASK
End DoDot:1
+19 ; Restart specifics collections on the BE
+20 IF KMPISBE
Begin DoDot:1
+21 FOR KMPVMKEY="VETM","VHLM","VMCM"
Begin DoDot:2
+22 if $$GETVAL^KMPVCCFG(KMPVMKEY,"ONOFF",8969)'="ON"
QUIT
+23 SET KMPVROUT=$$GETVAL^KMPVCCFG(KMPVMKEY,"CACHE DAILY TASK",8969)
+24 IF KMPVROUT'=""
SET KMPVTASK="RUN^"_KMPVROUT
JOB @KMPVTASK
End DoDot:2
End DoDot:1
+25 QUIT