KMPVCBG ;SP/JML - VSM background utility functions ;11/1/2023
;;4.0;CAPACITY MANAGEMENT;**1,2,3,4**;3/1/2018;Build 36
;
; Reference to ^XMD in ICR #10070
; Reference to $$SITE^VASITE in ICR #10112
;
MONLIST(KMPVML) ; Return list of configured Monitors
K KMPVML
N KMPVIEN,KMPVMKEY,KMPVNAME
S KMPVMKEY=""
F S KMPVMKEY=$O(^KMPV(8969,"B",KMPVMKEY)) Q:KMPVMKEY="" D
.S KMPVIEN=$O(^KMPV(8969,"B",KMPVMKEY,""))
.I KMPVIEN>0 D
..S KMPVNAME=$$GETVAL^KMPVCCFG(KMPVMKEY,"FULL NAME",8969)
..S KMPVML(KMPVMKEY)=KMPVNAME
Q
;
STARTALL ; start all monitors - DON'T MOVE FROM THIS ROUTINE, CALLED BY ZSTU
N KMPMKEY
S KMPMKEY=""
F S KMPMKEY=$O(^KMPV(8969,"B",KMPMKEY)) Q:KMPMKEY="" D
.D STARTMON(KMPMKEY,1,1)
D CFGMSG^KMPUTLW()
Q
;
STOPALL ; stop all monitors
N KMPMKEY
S KMPMKEY=""
F S KMPMKEY=$O(^KMPV(8969,"B",KMPMKEY)) Q:KMPMKEY="" D
.D STOPMON(KMPMKEY,1,1)
D CFGMSG^KMPUTLW()
Q
;
ALLOW(KMPVMKEY) ;
N KMPCALLOW,KMPNALLOW,KMPVERR,DIR,Y
S KMPCALLOW=$$GETVAL^KMPVCCFG(KMPVMKEY,"ALLOW TEST SYSTEM",8969)
S KMPNALLOW=$S(KMPCALLOW="NO":"YES",1:"NO")
K DIR S DIR(0)="Y",DIR("B")="No"
S DIR("?")="Answer YES to set ALLOW TEST to "_KMPNALLOW_" for "_KMPVMKEY
S DIR("A")="Do you want to set ALLOW TEST to "_KMPNALLOW_" for "_KMPVMKEY
D ^DIR
I $G(Y)=1 D SETONE^KMPVCCFG(KMPVMKEY,"ALLOW TEST SYSTEM",KMPNALLOW,.KMPVERR)
Q
;
STARTMON(KMPVMKEY,KMPVAUTO,KMPNOCFG) ; Schedule transmission task in TaskMan and set ONOFF to ON
N DA,DIE,DIR,DR,DTOUT,DUOUT,X,Y
N KMPROUT,KMPRT,KMPRUN,KMPVEARR,KMPVER,KMPVERROR,KMPVRFREQ,KMPVOPT,KMPVSTAT,KMPVSTRT,KMP2QUIT
;
S KMPVAUTO=+$G(KMPVAUTO)
S KMPNOCFG=+$G(KMPNOCFG)
; Do not start monitor in test if ALLOW TEST SYSTEM is set to NO
I $$PROD^KMPVCCFG()="test",$$GETVAL^KMPVCCFG(KMPVMKEY,"ALLOW TEST SYSTEM",8969)="NO" D Q
.Q:KMPVAUTO=1
.N DIR S DIR(0)="E"
.S DIR("A",1)="",DIR("A",2)="Cannot start monitor in test environment"
.S DIR("A",3)="'ALLOW TEST SYSTEM' is set to 'NO'",DIR("A")="Press any key to continue"
.D ^DIR
I 'KMPVAUTO D D ^DIR Q:$D(DTOUT)!$D(DUOUT)
.W ! K DIR S DIR(0)="Y",DIR("B")="No"
.S DIR("?")="Answer YES to start collecting "_KMPVMKEY_" data"
.S DIR("A")="Do you want to start "_KMPVMKEY_" collection?"
I ($G(Y)=1)!KMPVAUTO D
.S KMPVSTAT=$$SETONE^KMPVCCFG(KMPVMKEY,"ONOFF","ON",.KMPVEARR)
.I KMPVSTAT=0 D
..I KMPVMKEY="VBEM" S DIE=8989.3,DA=1,DR="300///YES" D ^DIE
..I KMPVMKEY="VCSM" S ^KMPTMP("KMPD-CPRS")=1
.I KMPNOCFG'=1 D CFGMSG^KMPUTLW()
Q
;
STOPMON(KMPVMKEY,KMPVAUTO,KMPNOCFG) ; Un-schedule transmission task in TaskMan and set ONOFF to OFF
N DA,DIE,DIR,DR,DTOUT,DUOUT,X,Y
N KMPVEARR,KMPVER,KMPVERROR,KMPVOPT,KMPVSTAT
;
S KMPVAUTO=+$G(KMPVAUTO)
S KMPNOCFG=+$G(KMPNOCFG)
I 'KMPVAUTO D D ^DIR Q:$D(DTOUT)!$D(DUOUT)
.W ! K DIR S DIR(0)="Y",DIR("B")="No"
.S DIR("?")="Answer YES to stop collecting "_KMPVMKEY_" data"
.S DIR("A")="Do you want to stop "_KMPVMKEY_" collection?"
I ($G(Y)=1)!KMPVAUTO D
.S KMPVSTAT=$$SETONE^KMPVCCFG(KMPVMKEY,"ONOFF","OFF",.KMPVEARR)
.I KMPVSTAT=0 D
..I KMPVMKEY="VBEM" S DIE=8989.3,DA=1,DR="300///NO" D ^DIE
..I KMPVMKEY="VTCM" K ^KMPTMP("KMPV","VTCM","TEMP")
..I KMPVMKEY="VCSM" S ^KMPTMP("KMPD-CPRS")=""
I KMPNOCFG'=1 D CFGMSG^KMPUTLW()
Q
;
PURGEDLY(KMPVMKEY) ; Purge any data older than VSM CONFIURATION file specifies
N KMPDDAT1,KMPDID,KMPDSUB,KMPI,KMPID,KMPSINF,KMPTEXT,KMPVCURH,KMPVDAY,KMPVH,KMPVKEEP,KMPVNODE
N KMPBB,KMPPATH,KMPMATCH,KMPFILE,KMPFILES,KMPDFILE,KMPCSHEAD
S KMPVH="",KMPVCURH=+$H,KMPVKEEP=$$GETVAL^KMPVCCFG(KMPVMKEY,"DAYS TO KEEP DATA",8969)
D GETENV^%ZOSV S KMPVNODE=$P(Y,U,3)_":"_$P($P(Y,U,4),":",2)
;Q:$$ISBENODE^KMPVCCFG(KMPVNODE)=0 ; ^KMPTMP no longer mapped to back end
S KMPSINF=$$SITEINFO^KMPVCCFG(),KMPI=2
; always kill the TRANSMIT node
K ^KMPTMP("KMPV",KMPVMKEY,"TRANSMIT")
; kill daily
F S KMPVH=$O(^KMPTMP("KMPV",KMPVMKEY,"DLY",KMPVH)) Q:KMPVH="" D
.I (KMPVCURH-KMPVH)>KMPVKEEP D
..K ^KMPTMP("KMPV",KMPVMKEY,"DLY",KMPVH)
..S KMPTEXT(KMPI)=KMPVMKEY_" DLY node for "_$ZD(KMPVH),KMPI=KMPI+1
; kill retry
F S KMPVH=$O(^KMPTMP("KMPV",KMPVMKEY,"RETRY",KMPVNODE,KMPVH)) Q:KMPVH="" D
.I (KMPVCURH-KMPVH)>KMPVKEEP D
..K ^KMPTMP("KMPV",KMPVMKEY,"RETRY",KMPVNODE,KMPVH)
..S KMPTEXT(KMPI)=KMPVMKEY_" RETRY node for "_$ZD(KMPVH)_" on node "_KMPVNODE,KMPI=KMPI+1
; kill COMPRESS node for VBEM
I KMPVMKEY="VBEM" D
.S KMPVH=""
.F S KMPVH=$O(^KMPTMP("KMPV",KMPVMKEY,"COMPRESS",KMPVNODE,KMPVH)) Q:KMPVH="" D
..I (KMPVCURH-KMPVH)>KMPVKEEP D
...K ^KMPTMP("KMPV",KMPVMKEY,"COMPRESS",KMPVNODE,KMPVH)
...S KMPTEXT(KMPI)=KMPVMKEY_" COMPRESS node for "_$ZD(KMPVH)_" on node "_KMPVNODE,KMPI=KMPI+1
; check for old VCSM data - keep this section last
I KMPVMKEY="VCSM" D
.S KMPDSUB="",KMPCSHEAD=1
.F S KMPDSUB=$O(^KMPTMP("KMPDT",KMPDSUB)) Q:KMPDSUB="" D
..S KMPDID=""
..F S KMPDID=$O(^KMPTMP("KMPDT",KMPDSUB,KMPDID)) Q:KMPDID="" D
...S KMPDDAT1=$G(^KMPTMP("KMPDT",KMPDSUB,KMPDID))
...S KMPVDAY=$P($P(KMPDDAT1,U),",",1)
...Q:+KMPVDAY=0
...I (KMPVCURH-KMPVDAY)>KMPVKEEP D
....K ^KMPTMP("KMPDT",KMPDSUB,KMPDID)
....I KMPCSHEAD S KMPTEXT(KMPI)=KMPVMKEY_" Coversheet data for "_KMPVDAY,KMPI=KMPI+1,KMPCSHEAD=0
....I KMPI<1000 S KMPTEXT(KMPI)=KMPDSUB_"**"_KMPDID_"**"_KMPDDAT1,KMPI=KMPI+1
; failsafe to purge any temp vsm files
I "VTCM:VBEM:VHLM"[KMPVMKEY D
.S KMPPATH=$$DEFDIR^%ZISH()
.I KMPVMKEY="VTCM" S KMPMATCH("VistaSystemMonitor*.txt")="" ;to catch synthetic files
.I KMPVMKEY="VBEM" S KMPMATCH("businessevent*.txt")=""
.I KMPVMKEY="VHLM" S KMPMATCH("hlseven*.txt")=""
.S KMPBB=$$LIST^%ZISH(KMPPATH,"KMPMATCH","KMPFILES")
.S KMPFILE="",KMPI=$O(KMPTEXT("A"),-1)+2
.F S KMPFILE=$O(KMPFILES(KMPFILE)) Q:KMPFILE="" D
..S KMPDFILE(KMPFILE)=""
..S KMPTEXT(KMPI)="Deleting file: "_KMPFILE,KMPI=KMPI+1
.S KMPBB=$$DEL^%ZISH(KMPPATH,$NA(KMPDFILE))
.I KMPBB=0 D
..S KMPI=$O(KMPTEXT("A"),-1)
..S KMPTEXT(KMPI)="Failed to delete 1 or more temp files"
;
I $D(KMPTEXT) D
.S KMPTEXT("SUBJECT")="VSM ALERT: Data deletion at "_$P(KMPSINF,"^")
.S KMPTEXT(1)="Purging data older than DAYS TO KEEP DATA"
.D INFOMSG^KMPUTLW(.KMPTEXT)
Q
;
KMPVTSK(KMPVNSP) ; CHECK CREATE OR RESUME KMPVRUN TASK IN CACHE TASKMGR
D TASK^KMPTASK($G(KMPVNSP))
Q
;
ROUTCHK(KMPROUT) ; Check to see if routine is running
N KMPRS,KMPRUN
S KMPRUN=0
S KMPRS=##class(%ResultSet).%New("%SYS.ProcessQuery:SS")
D KMPRS.Execute(1)
F Q:'KMPRS.Next()!(KMPRUN=1) I KMPRS.Routine=KMPROUT S KMPRUN=1
Q KMPRUN
;
CANMESS(MTYPE,KMPVMKEY,KMPVSITE,KMPVD) ; Repeatable, configured informational mail messages --- legacy
N KMPVEMAIL,KMPVTEXT,XMSUB,XMY
I MTYPE="JOBLATE" D
.S KMPVTEXT($J,1)="Daily "_KMPVMKEY_" job behind for "_$P(KMPVSITE,"^",2)
.S KMPVTEXT($J,2)="Number of days behind: "_KMPVD
.S KMPVTEXT($J,3)="Message date: "_$ZD(+$H)
.S XMSUB=KMPVMKEY_" DAILY JOB NOT RUN: "_$P(KMPVSITE,"^",2)_" Production="_$$PROD^KMPVCCFG
I MTYPE="DELETE" D
.S KMPVTEXT($J,1)="Purging "_KMPVMKEY_" data for "_$P(KMPVSITE,"^",2)
.S KMPVTEXT($J,2)="Data purged for: "_KMPVD
.S KMPVTEXT($J,3)="Message date: "_$ZD(+$H)
.S XMSUB=KMPVMKEY_" PURGING DATA -- NOT TRANSMITTED: "_$P(KMPVSITE,"^",2)_" Production="_$$PROD^KMPVCCFG
I MTYPE="TRANWARN" D
.S KMPVTEXT($J,1)="Data transmissions of "_KMPVMKEY_" data late for "_$P(KMPVSITE,"^",2)
.S KMPVTEXT($J,2)="Message date: "_$ZD(+$H)
.S XMSUB=KMPVMKEY_" Late Transmission Warning: "_$P(KMPVSITE,"^",2)_" Production="_$$PROD^KMPVCCFG
I MTYPE="FAILTRAN" D
.S KMPVTEXT($J,1)="Failed transmission for "_$P(KMPVSITE,"^",2)
.S KMPVTEXT($J,2)="Collection date: "_KMPVD
.S KMPVTEXT($J,3)="Message date: "_$ZD(+$H)
.S XMSUB=KMPVMKEY_" FAILED "_KMPVMKEY_" TRANSMISSION: "_$P(KMPVSITE,"^",2)_" "_KMPVD_" Production="_$$PROD^KMPVCCFG
I MTYPE="KILL" D
.S KMPVTEXT($J,1)="All data deleted at "_$P(KMPVSITE,"^",2)_" for "_KMPVMKEY
.S KMPVTEXT($J,2)="Username: "_$$USERNAME^KMPVCCFG(DUZ)
.S KMPVTEXT($J,3)="Message date: "_$ZD(+$H)
.S XMSUB="EMERGENCY DATA DELETION AT "_$P(KMPVSITE,"^",2)_" "_KMPVMKEY_" Production="_$$PROD^KMPVCCFG
Q:$D(XMSUB)=""
S XMTEXT="KMPVTEXT("_$J_","
S KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"NATIONAL SUPPORT EMAIL ADDRESS",8969) I KMPVEMAIL'="" S XMY(KMPVEMAIL)=""
S KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"LOCAL SUPPORT EMAIL ADDRESS",8969) I KMPVEMAIL'="" S XMY(KMPVEMAIL)=""
D ^XMD ;supported by ICR #10070
Q
;
SUPMSG(KMPVTEXT) ; Send email to local/national support mail groups ---- legacy
N KMPVEMAIL,KMPVPROD,XMSUB,XMTEXT,XMY,XMZ
S KMPVPROD=$$PROD^KMPVCCFG()
;
S XMSUB=KMPVTEXT_" Prod="_KMPVPROD
S XMTEXT="KMPVTEXT("
S KMPVMKEY=""
F S KMPVMKEY=$O(^KMPV(8969,"B",KMPVMKEY)) Q:KMPVMKEY="" D
.S KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"LOCAL SUPPORT EMAIL ADDRESS",8969) I KMPVEMAIL'="" S XMY(KMPVEMAIL)=""
.S KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"NATIONAL SUPPORT EMAIL ADDRESS",8969) I KMPVEMAIL'="" S XMY(KMPVEMAIL)=""
D ^XMD ;supported by ICR #10070
Q
;
DBAMSG(KMPVTEXT) ; Send email to national support mail groups --- legacy
N KMPVEMAIL,KMPVPROD,XMSUB,XMTEXT,XMY,XMZ
S KMPVPROD=$$PROD^KMPVCCFG()
;
S XMSUB=KMPVTEXT_" Prod="_KMPVPROD
S XMTEXT="KMPVTEXT("
S KMPVMKEY=""
F S KMPVMKEY=$O(^KMPV(8969,"B",KMPVMKEY)) Q:KMPVMKEY="" D
.S KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"NATIONAL SUPPORT EMAIL ADDRESS",8969) I KMPVEMAIL'="" S XMY(KMPVEMAIL)=""
D ^XMD ;supported by ICR #10070
Q
;
CFGMSG(KMPVRQNAM) ; Send configuration data to update Location Table at National VSM Database --- legacy
N KMPVDOM,KMPVEMAIL,KMPVLN,KMPVMKEY,KMPVPROD,KMPVSINF,KMPVSITE,KMPVUP,KMPVUPCFG,XMSUB,XMTEXT,XMY,XMZ
S KMPVPROD=$$PROD^KMPVCCFG()
;
I $G(KMPVRQNAM)="" S KMPVRQNAM=$$USERNAME^KMPVCCFG($G(DUZ))
S KMPVSITE=$$SITE^VASITE ;supported by ICR #10112
S KMPVLN=1
S KMPVUP="KMP CFG"
S KMPVDOM=$P($$NETNAME^XMXUTIL(.5),"@",2) ;IA 2734
S KMPVSINF=$$SITEINFO^KMPVCCFG()
S KMPVUP(KMPVLN)="SYSTEM ID="_KMPVSINF,KMPVLN=KMPVLN+1
S KMPVUP(KMPVLN)="UPDATE CONFIG="_+$H_"^"_KMPVRQNAM,KMPVLN=KMPVLN+1
S KMPVUP(KMPVLN)="SYSTEM CONFIG="_$$SYSCFG^KMPVCCFG(),KMPVLN=KMPVLN+1
S KMPVMKEY=""
F S KMPVMKEY=$O(^KMPV(8969,"B",KMPVMKEY)) Q:KMPVMKEY="" D
.S KMPVUP(KMPVLN)="MONITOR CONFIG="_$$CFGSTR^KMPVCCFG(KMPVMKEY),KMPVLN=KMPVLN+1
S XMSUB=KMPVUP,XMTEXT="KMPVUP("
S KMPVMKEY=""
F S KMPVMKEY=$O(^KMPV(8969,"B",KMPVMKEY)) Q:KMPVMKEY="" D
.S KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"VSM CFG EMAIL ADDRESS",8969) I KMPVEMAIL'="" S XMY(KMPVEMAIL)=""
D ^XMD ;supported by ICR #10070
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPVCBG 10580 printed Dec 13, 2024@01:41:59 Page 2
KMPVCBG ;SP/JML - VSM background utility functions ;11/1/2023
+1 ;;4.0;CAPACITY MANAGEMENT;**1,2,3,4**;3/1/2018;Build 36
+2 ;
+3 ; Reference to ^XMD in ICR #10070
+4 ; Reference to $$SITE^VASITE in ICR #10112
+5 ;
MONLIST(KMPVML) ; Return list of configured Monitors
+1 KILL KMPVML
+2 NEW KMPVIEN,KMPVMKEY,KMPVNAME
+3 SET KMPVMKEY=""
+4 FOR
SET KMPVMKEY=$ORDER(^KMPV(8969,"B",KMPVMKEY))
if KMPVMKEY=""
QUIT
Begin DoDot:1
+5 SET KMPVIEN=$ORDER(^KMPV(8969,"B",KMPVMKEY,""))
+6 IF KMPVIEN>0
Begin DoDot:2
+7 SET KMPVNAME=$$GETVAL^KMPVCCFG(KMPVMKEY,"FULL NAME",8969)
+8 SET KMPVML(KMPVMKEY)=KMPVNAME
End DoDot:2
End DoDot:1
+9 QUIT
+10 ;
STARTALL ; start all monitors - DON'T MOVE FROM THIS ROUTINE, CALLED BY ZSTU
+1 NEW KMPMKEY
+2 SET KMPMKEY=""
+3 FOR
SET KMPMKEY=$ORDER(^KMPV(8969,"B",KMPMKEY))
if KMPMKEY=""
QUIT
Begin DoDot:1
+4 DO STARTMON(KMPMKEY,1,1)
End DoDot:1
+5 DO CFGMSG^KMPUTLW()
+6 QUIT
+7 ;
STOPALL ; stop all monitors
+1 NEW KMPMKEY
+2 SET KMPMKEY=""
+3 FOR
SET KMPMKEY=$ORDER(^KMPV(8969,"B",KMPMKEY))
if KMPMKEY=""
QUIT
Begin DoDot:1
+4 DO STOPMON(KMPMKEY,1,1)
End DoDot:1
+5 DO CFGMSG^KMPUTLW()
+6 QUIT
+7 ;
ALLOW(KMPVMKEY) ;
+1 NEW KMPCALLOW,KMPNALLOW,KMPVERR,DIR,Y
+2 SET KMPCALLOW=$$GETVAL^KMPVCCFG(KMPVMKEY,"ALLOW TEST SYSTEM",8969)
+3 SET KMPNALLOW=$SELECT(KMPCALLOW="NO":"YES",1:"NO")
+4 KILL DIR
SET DIR(0)="Y"
SET DIR("B")="No"
+5 SET DIR("?")="Answer YES to set ALLOW TEST to "_KMPNALLOW_" for "_KMPVMKEY
+6 SET DIR("A")="Do you want to set ALLOW TEST to "_KMPNALLOW_" for "_KMPVMKEY
+7 DO ^DIR
+8 IF $GET(Y)=1
DO SETONE^KMPVCCFG(KMPVMKEY,"ALLOW TEST SYSTEM",KMPNALLOW,.KMPVERR)
+9 QUIT
+10 ;
STARTMON(KMPVMKEY,KMPVAUTO,KMPNOCFG) ; Schedule transmission task in TaskMan and set ONOFF to ON
+1 NEW DA,DIE,DIR,DR,DTOUT,DUOUT,X,Y
+2 NEW KMPROUT,KMPRT,KMPRUN,KMPVEARR,KMPVER,KMPVERROR,KMPVRFREQ,KMPVOPT,KMPVSTAT,KMPVSTRT,KMP2QUIT
+3 ;
+4 SET KMPVAUTO=+$GET(KMPVAUTO)
+5 SET KMPNOCFG=+$GET(KMPNOCFG)
+6 ; Do not start monitor in test if ALLOW TEST SYSTEM is set to NO
+7 IF $$PROD^KMPVCCFG()="test"
IF $$GETVAL^KMPVCCFG(KMPVMKEY,"ALLOW TEST SYSTEM",8969)="NO"
Begin DoDot:1
+8 if KMPVAUTO=1
QUIT
+9 NEW DIR
SET DIR(0)="E"
+10 SET DIR("A",1)=""
SET DIR("A",2)="Cannot start monitor in test environment"
+11 SET DIR("A",3)="'ALLOW TEST SYSTEM' is set to 'NO'"
SET DIR("A")="Press any key to continue"
+12 DO ^DIR
End DoDot:1
QUIT
+13 IF 'KMPVAUTO
Begin DoDot:1
+14 WRITE !
KILL DIR
SET DIR(0)="Y"
SET DIR("B")="No"
+15 SET DIR("?")="Answer YES to start collecting "_KMPVMKEY_" data"
+16 SET DIR("A")="Do you want to start "_KMPVMKEY_" collection?"
End DoDot:1
DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+17 IF ($GET(Y)=1)!KMPVAUTO
Begin DoDot:1
+18 SET KMPVSTAT=$$SETONE^KMPVCCFG(KMPVMKEY,"ONOFF","ON",.KMPVEARR)
+19 IF KMPVSTAT=0
Begin DoDot:2
+20 IF KMPVMKEY="VBEM"
SET DIE=8989.3
SET DA=1
SET DR="300///YES"
DO ^DIE
+21 IF KMPVMKEY="VCSM"
SET ^KMPTMP("KMPD-CPRS")=1
End DoDot:2
+22 IF KMPNOCFG'=1
DO CFGMSG^KMPUTLW()
End DoDot:1
+23 QUIT
+24 ;
STOPMON(KMPVMKEY,KMPVAUTO,KMPNOCFG) ; Un-schedule transmission task in TaskMan and set ONOFF to OFF
+1 NEW DA,DIE,DIR,DR,DTOUT,DUOUT,X,Y
+2 NEW KMPVEARR,KMPVER,KMPVERROR,KMPVOPT,KMPVSTAT
+3 ;
+4 SET KMPVAUTO=+$GET(KMPVAUTO)
+5 SET KMPNOCFG=+$GET(KMPNOCFG)
+6 IF 'KMPVAUTO
Begin DoDot:1
+7 WRITE !
KILL DIR
SET DIR(0)="Y"
SET DIR("B")="No"
+8 SET DIR("?")="Answer YES to stop collecting "_KMPVMKEY_" data"
+9 SET DIR("A")="Do you want to stop "_KMPVMKEY_" collection?"
End DoDot:1
DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+10 IF ($GET(Y)=1)!KMPVAUTO
Begin DoDot:1
+11 SET KMPVSTAT=$$SETONE^KMPVCCFG(KMPVMKEY,"ONOFF","OFF",.KMPVEARR)
+12 IF KMPVSTAT=0
Begin DoDot:2
+13 IF KMPVMKEY="VBEM"
SET DIE=8989.3
SET DA=1
SET DR="300///NO"
DO ^DIE
+14 IF KMPVMKEY="VTCM"
KILL ^KMPTMP("KMPV","VTCM","TEMP")
+15 IF KMPVMKEY="VCSM"
SET ^KMPTMP("KMPD-CPRS")=""
End DoDot:2
End DoDot:1
+16 IF KMPNOCFG'=1
DO CFGMSG^KMPUTLW()
+17 QUIT
+18 ;
PURGEDLY(KMPVMKEY) ; Purge any data older than VSM CONFIURATION file specifies
+1 NEW KMPDDAT1,KMPDID,KMPDSUB,KMPI,KMPID,KMPSINF,KMPTEXT,KMPVCURH,KMPVDAY,KMPVH,KMPVKEEP,KMPVNODE
+2 NEW KMPBB,KMPPATH,KMPMATCH,KMPFILE,KMPFILES,KMPDFILE,KMPCSHEAD
+3 SET KMPVH=""
SET KMPVCURH=+$HOROLOG
SET KMPVKEEP=$$GETVAL^KMPVCCFG(KMPVMKEY,"DAYS TO KEEP DATA",8969)
+4 DO GETENV^%ZOSV
SET KMPVNODE=$PIECE(Y,U,3)_":"_$PIECE($PIECE(Y,U,4),":",2)
+5 ;Q:$$ISBENODE^KMPVCCFG(KMPVNODE)=0 ; ^KMPTMP no longer mapped to back end
+6 SET KMPSINF=$$SITEINFO^KMPVCCFG()
SET KMPI=2
+7 ; always kill the TRANSMIT node
+8 KILL ^KMPTMP("KMPV",KMPVMKEY,"TRANSMIT")
+9 ; kill daily
+10 FOR
SET KMPVH=$ORDER(^KMPTMP("KMPV",KMPVMKEY,"DLY",KMPVH))
if KMPVH=""
QUIT
Begin DoDot:1
+11 IF (KMPVCURH-KMPVH)>KMPVKEEP
Begin DoDot:2
+12 KILL ^KMPTMP("KMPV",KMPVMKEY,"DLY",KMPVH)
+13 SET KMPTEXT(KMPI)=KMPVMKEY_" DLY node for "_$ZD(KMPVH)
SET KMPI=KMPI+1
End DoDot:2
End DoDot:1
+14 ; kill retry
+15 FOR
SET KMPVH=$ORDER(^KMPTMP("KMPV",KMPVMKEY,"RETRY",KMPVNODE,KMPVH))
if KMPVH=""
QUIT
Begin DoDot:1
+16 IF (KMPVCURH-KMPVH)>KMPVKEEP
Begin DoDot:2
+17 KILL ^KMPTMP("KMPV",KMPVMKEY,"RETRY",KMPVNODE,KMPVH)
+18 SET KMPTEXT(KMPI)=KMPVMKEY_" RETRY node for "_$ZD(KMPVH)_" on node "_KMPVNODE
SET KMPI=KMPI+1
End DoDot:2
End DoDot:1
+19 ; kill COMPRESS node for VBEM
+20 IF KMPVMKEY="VBEM"
Begin DoDot:1
+21 SET KMPVH=""
+22 FOR
SET KMPVH=$ORDER(^KMPTMP("KMPV",KMPVMKEY,"COMPRESS",KMPVNODE,KMPVH))
if KMPVH=""
QUIT
Begin DoDot:2
+23 IF (KMPVCURH-KMPVH)>KMPVKEEP
Begin DoDot:3
+24 KILL ^KMPTMP("KMPV",KMPVMKEY,"COMPRESS",KMPVNODE,KMPVH)
+25 SET KMPTEXT(KMPI)=KMPVMKEY_" COMPRESS node for "_$ZD(KMPVH)_" on node "_KMPVNODE
SET KMPI=KMPI+1
End DoDot:3
End DoDot:2
End DoDot:1
+26 ; check for old VCSM data - keep this section last
+27 IF KMPVMKEY="VCSM"
Begin DoDot:1
+28 SET KMPDSUB=""
SET KMPCSHEAD=1
+29 FOR
SET KMPDSUB=$ORDER(^KMPTMP("KMPDT",KMPDSUB))
if KMPDSUB=""
QUIT
Begin DoDot:2
+30 SET KMPDID=""
+31 FOR
SET KMPDID=$ORDER(^KMPTMP("KMPDT",KMPDSUB,KMPDID))
if KMPDID=""
QUIT
Begin DoDot:3
+32 SET KMPDDAT1=$GET(^KMPTMP("KMPDT",KMPDSUB,KMPDID))
+33 SET KMPVDAY=$PIECE($PIECE(KMPDDAT1,U),",",1)
+34 if +KMPVDAY=0
QUIT
+35 IF (KMPVCURH-KMPVDAY)>KMPVKEEP
Begin DoDot:4
+36 KILL ^KMPTMP("KMPDT",KMPDSUB,KMPDID)
+37 IF KMPCSHEAD
SET KMPTEXT(KMPI)=KMPVMKEY_" Coversheet data for "_KMPVDAY
SET KMPI=KMPI+1
SET KMPCSHEAD=0
+38 IF KMPI<1000
SET KMPTEXT(KMPI)=KMPDSUB_"**"_KMPDID_"**"_KMPDDAT1
SET KMPI=KMPI+1
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+39 ; failsafe to purge any temp vsm files
+40 IF "VTCM:VBEM:VHLM"[KMPVMKEY
Begin DoDot:1
+41 SET KMPPATH=$$DEFDIR^%ZISH()
+42 ;to catch synthetic files
IF KMPVMKEY="VTCM"
SET KMPMATCH("VistaSystemMonitor*.txt")=""
+43 IF KMPVMKEY="VBEM"
SET KMPMATCH("businessevent*.txt")=""
+44 IF KMPVMKEY="VHLM"
SET KMPMATCH("hlseven*.txt")=""
+45 SET KMPBB=$$LIST^%ZISH(KMPPATH,"KMPMATCH","KMPFILES")
+46 SET KMPFILE=""
SET KMPI=$ORDER(KMPTEXT("A"),-1)+2
+47 FOR
SET KMPFILE=$ORDER(KMPFILES(KMPFILE))
if KMPFILE=""
QUIT
Begin DoDot:2
+48 SET KMPDFILE(KMPFILE)=""
+49 SET KMPTEXT(KMPI)="Deleting file: "_KMPFILE
SET KMPI=KMPI+1
End DoDot:2
+50 SET KMPBB=$$DEL^%ZISH(KMPPATH,$NAME(KMPDFILE))
+51 IF KMPBB=0
Begin DoDot:2
+52 SET KMPI=$ORDER(KMPTEXT("A"),-1)
+53 SET KMPTEXT(KMPI)="Failed to delete 1 or more temp files"
End DoDot:2
End DoDot:1
+54 ;
+55 IF $DATA(KMPTEXT)
Begin DoDot:1
+56 SET KMPTEXT("SUBJECT")="VSM ALERT: Data deletion at "_$PIECE(KMPSINF,"^")
+57 SET KMPTEXT(1)="Purging data older than DAYS TO KEEP DATA"
+58 DO INFOMSG^KMPUTLW(.KMPTEXT)
End DoDot:1
+59 QUIT
+60 ;
KMPVTSK(KMPVNSP) ; CHECK CREATE OR RESUME KMPVRUN TASK IN CACHE TASKMGR
+1 DO TASK^KMPTASK($GET(KMPVNSP))
+2 QUIT
+3 ;
ROUTCHK(KMPROUT) ; Check to see if routine is running
+1 NEW KMPRS,KMPRUN
+2 SET KMPRUN=0
+3 SET KMPRS=##class(%ResultSet).%New("%SYS.ProcessQuery:SS")
+4 DO KMPRS.Execute(1)
+5 FOR
if 'KMPRS.Next()!(KMPRUN=1)
QUIT
IF KMPRS.Routine=KMPROUT
SET KMPRUN=1
+6 QUIT KMPRUN
+7 ;
CANMESS(MTYPE,KMPVMKEY,KMPVSITE,KMPVD) ; Repeatable, configured informational mail messages --- legacy
+1 NEW KMPVEMAIL,KMPVTEXT,XMSUB,XMY
+2 IF MTYPE="JOBLATE"
Begin DoDot:1
+3 SET KMPVTEXT($JOB,1)="Daily "_KMPVMKEY_" job behind for "_$PIECE(KMPVSITE,"^",2)
+4 SET KMPVTEXT($JOB,2)="Number of days behind: "_KMPVD
+5 SET KMPVTEXT($JOB,3)="Message date: "_$ZD(+$HOROLOG)
+6 SET XMSUB=KMPVMKEY_" DAILY JOB NOT RUN: "_$PIECE(KMPVSITE,"^",2)_" Production="_$$PROD^KMPVCCFG
End DoDot:1
+7 IF MTYPE="DELETE"
Begin DoDot:1
+8 SET KMPVTEXT($JOB,1)="Purging "_KMPVMKEY_" data for "_$PIECE(KMPVSITE,"^",2)
+9 SET KMPVTEXT($JOB,2)="Data purged for: "_KMPVD
+10 SET KMPVTEXT($JOB,3)="Message date: "_$ZD(+$HOROLOG)
+11 SET XMSUB=KMPVMKEY_" PURGING DATA -- NOT TRANSMITTED: "_$PIECE(KMPVSITE,"^",2)_" Production="_$$PROD^KMPVCCFG
End DoDot:1
+12 IF MTYPE="TRANWARN"
Begin DoDot:1
+13 SET KMPVTEXT($JOB,1)="Data transmissions of "_KMPVMKEY_" data late for "_$PIECE(KMPVSITE,"^",2)
+14 SET KMPVTEXT($JOB,2)="Message date: "_$ZD(+$HOROLOG)
+15 SET XMSUB=KMPVMKEY_" Late Transmission Warning: "_$PIECE(KMPVSITE,"^",2)_" Production="_$$PROD^KMPVCCFG
End DoDot:1
+16 IF MTYPE="FAILTRAN"
Begin DoDot:1
+17 SET KMPVTEXT($JOB,1)="Failed transmission for "_$PIECE(KMPVSITE,"^",2)
+18 SET KMPVTEXT($JOB,2)="Collection date: "_KMPVD
+19 SET KMPVTEXT($JOB,3)="Message date: "_$ZD(+$HOROLOG)
+20 SET XMSUB=KMPVMKEY_" FAILED "_KMPVMKEY_" TRANSMISSION: "_$PIECE(KMPVSITE,"^",2)_" "_KMPVD_" Production="_$$PROD^KMPVCCFG
End DoDot:1
+21 IF MTYPE="KILL"
Begin DoDot:1
+22 SET KMPVTEXT($JOB,1)="All data deleted at "_$PIECE(KMPVSITE,"^",2)_" for "_KMPVMKEY
+23 SET KMPVTEXT($JOB,2)="Username: "_$$USERNAME^KMPVCCFG(DUZ)
+24 SET KMPVTEXT($JOB,3)="Message date: "_$ZD(+$HOROLOG)
+25 SET XMSUB="EMERGENCY DATA DELETION AT "_$PIECE(KMPVSITE,"^",2)_" "_KMPVMKEY_" Production="_$$PROD^KMPVCCFG
End DoDot:1
+26 if $DATA(XMSUB)=""
QUIT
+27 SET XMTEXT="KMPVTEXT("_$JOB_","
+28 SET KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"NATIONAL SUPPORT EMAIL ADDRESS",8969)
IF KMPVEMAIL'=""
SET XMY(KMPVEMAIL)=""
+29 SET KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"LOCAL SUPPORT EMAIL ADDRESS",8969)
IF KMPVEMAIL'=""
SET XMY(KMPVEMAIL)=""
+30 ;supported by ICR #10070
DO ^XMD
+31 QUIT
+32 ;
SUPMSG(KMPVTEXT) ; Send email to local/national support mail groups ---- legacy
+1 NEW KMPVEMAIL,KMPVPROD,XMSUB,XMTEXT,XMY,XMZ
+2 SET KMPVPROD=$$PROD^KMPVCCFG()
+3 ;
+4 SET XMSUB=KMPVTEXT_" Prod="_KMPVPROD
+5 SET XMTEXT="KMPVTEXT("
+6 SET KMPVMKEY=""
+7 FOR
SET KMPVMKEY=$ORDER(^KMPV(8969,"B",KMPVMKEY))
if KMPVMKEY=""
QUIT
Begin DoDot:1
+8 SET KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"LOCAL SUPPORT EMAIL ADDRESS",8969)
IF KMPVEMAIL'=""
SET XMY(KMPVEMAIL)=""
+9 SET KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"NATIONAL SUPPORT EMAIL ADDRESS",8969)
IF KMPVEMAIL'=""
SET XMY(KMPVEMAIL)=""
End DoDot:1
+10 ;supported by ICR #10070
DO ^XMD
+11 QUIT
+12 ;
DBAMSG(KMPVTEXT) ; Send email to national support mail groups --- legacy
+1 NEW KMPVEMAIL,KMPVPROD,XMSUB,XMTEXT,XMY,XMZ
+2 SET KMPVPROD=$$PROD^KMPVCCFG()
+3 ;
+4 SET XMSUB=KMPVTEXT_" Prod="_KMPVPROD
+5 SET XMTEXT="KMPVTEXT("
+6 SET KMPVMKEY=""
+7 FOR
SET KMPVMKEY=$ORDER(^KMPV(8969,"B",KMPVMKEY))
if KMPVMKEY=""
QUIT
Begin DoDot:1
+8 SET KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"NATIONAL SUPPORT EMAIL ADDRESS",8969)
IF KMPVEMAIL'=""
SET XMY(KMPVEMAIL)=""
End DoDot:1
+9 ;supported by ICR #10070
DO ^XMD
+10 QUIT
+11 ;
CFGMSG(KMPVRQNAM) ; Send configuration data to update Location Table at National VSM Database --- legacy
+1 NEW KMPVDOM,KMPVEMAIL,KMPVLN,KMPVMKEY,KMPVPROD,KMPVSINF,KMPVSITE,KMPVUP,KMPVUPCFG,XMSUB,XMTEXT,XMY,XMZ
+2 SET KMPVPROD=$$PROD^KMPVCCFG()
+3 ;
+4 IF $GET(KMPVRQNAM)=""
SET KMPVRQNAM=$$USERNAME^KMPVCCFG($GET(DUZ))
+5 ;supported by ICR #10112
SET KMPVSITE=$$SITE^VASITE
+6 SET KMPVLN=1
+7 SET KMPVUP="KMP CFG"
+8 ;IA 2734
SET KMPVDOM=$PIECE($$NETNAME^XMXUTIL(.5),"@",2)
+9 SET KMPVSINF=$$SITEINFO^KMPVCCFG()
+10 SET KMPVUP(KMPVLN)="SYSTEM ID="_KMPVSINF
SET KMPVLN=KMPVLN+1
+11 SET KMPVUP(KMPVLN)="UPDATE CONFIG="_+$HOROLOG_"^"_KMPVRQNAM
SET KMPVLN=KMPVLN+1
+12 SET KMPVUP(KMPVLN)="SYSTEM CONFIG="_$$SYSCFG^KMPVCCFG()
SET KMPVLN=KMPVLN+1
+13 SET KMPVMKEY=""
+14 FOR
SET KMPVMKEY=$ORDER(^KMPV(8969,"B",KMPVMKEY))
if KMPVMKEY=""
QUIT
Begin DoDot:1
+15 SET KMPVUP(KMPVLN)="MONITOR CONFIG="_$$CFGSTR^KMPVCCFG(KMPVMKEY)
SET KMPVLN=KMPVLN+1
End DoDot:1
+16 SET XMSUB=KMPVUP
SET XMTEXT="KMPVUP("
+17 SET KMPVMKEY=""
+18 FOR
SET KMPVMKEY=$ORDER(^KMPV(8969,"B",KMPVMKEY))
if KMPVMKEY=""
QUIT
Begin DoDot:1
+19 SET KMPVEMAIL=$$GETVAL^KMPVCCFG(KMPVMKEY,"VSM CFG EMAIL ADDRESS",8969)
IF KMPVEMAIL'=""
SET XMY(KMPVEMAIL)=""
End DoDot:1
+20 ;supported by ICR #10070
DO ^XMD
+21 QUIT