KMPDUTL1 ;OAK/RAK,KAK,JML - CM TOOLS Utilities ;2/17/04
;;4.0;CAPACITY MANAGEMENT;;11/15/2017;Build 38
;
CONT(KMPDEXT) ;-- function displays 'return to continue' message at bottom of page
;--------------------------------------------------------------------
; KMPDEXT 0 = do not show 'to exit' text
; 1 = show 'to exit' text
;
; Return: 0 = continue
; 1 = quit
;--------------------------------------------------------------------
;
N DIR,X,Y
;
S KMPDEXT=+$G(KMPDEXT)
F Q:$Y>(IOSL-3) W !
S DIR(0)="EA"
S DIR("A")="Press RETURN to continue"_$S(KMPDEXT:" or '^' to exit: ",1:": ")
D ^DIR
Q +$G(Y)
;
CURSTAT(STAT) ;-- current status
;---------------------------------------------------------------------
; input: STAT (optional) = data from $$TSKSTAT^KMPSUTL1
; output: See codes below
;---------------------------------------------------------------------
;
N RESULT,SITNUM,STRTDT
;
S RESULT="",SITNUM=^DD("SITE",1),STRTDT=$G(^XTMP("KMPS",SITNUM,0))
;
I $D(^XTMP("KMPS","ERROR")) Q "6^ERRORS RECORDED"
I $D(^XTMP("KMPS","STOP")) Q "7^STOPPING"
I $D(^XTMP("KMPS","START")) L +^XTMP("KMPS"):0 I $T L -^XTMP("KMPS") Q "5^DID NOT COMPLETE"
I +STRTDT I +$H-STRTDT>2 Q "5^DID NOT COMPLETE"
I +STRTDT I +$H-STRTDT>1 Q "4^RUNNING TOO LONG"
I $D(^XTMP("KMPS","START")) Q "0^RUNNING"
I $D(STAT) Q $P(STAT,U,1,2)
E Q "3^NOT RUNNING"
Q "9^UNKNOWN"
;
SYSINFO() ;-- returns system information
;---------------------------------------------------------------------
; Returns:
; "^" piece 1 - type of M platform
; "^" piece 2 - $ZV => name and version of M system
; "^" piece 3 - operating system version
;
;---------------------------------------------------------------------
;
N MPLTF,OSVER,SYSINFO
;
S MPLTF=$$MPLTF(),OSVER=$$OSVER(MPLTF)
S SYSINFO=MPLTF_U_$ZV_U_OSVER
Q SYSINFO
;
MPLTF() ;-- returns the type of M platform
;---------------------------------------------------------------------
; Returns: DSM for DSM platform
; CVMS for Cache for OpenVMS platform
; CWINNT for Cache for Windows NT platform
;---------------------------------------------------------------------
;
N MPLTF,ZV
;
S ZV=$ZV
S MPLTF=$S(ZV["DSM":"DSM",ZV["VMS":"CVMS",ZV["Windows":"CWINNT",1:"UNK")
Q MPLTF
;
OSVER(MPLTF) ;-- returns the operating system version
;---------------------------------------------------------------------
; input: MPLTF = type of M platform
;---------------------------------------------------------------------
;
I $G(MPLTF)="" Q ""
;
I MPLTF["DSM" Q $ZC(%GETSYI,"VERSION")
I MPLTF["CVMS" Q $$CVMSVER^KMPDUTL5()
I MPLTF["CWINNT" Q $$CWNTVER^KMPDUTL5()
Q ""
;
TSKSTAT(OPT) ;-- status of scheduled task option
;---------------------------------------------------------------------
; input OPT = option name
;
; output RTN = by "^" piece
; 1 - status code
; 2 - literal condition
; 3 - scheduled date@time (day)
; 4 - numeric day-of-week
; 5 - expanded scheduled frequency
; 6 - short form frequency
; 7 - task id
; 8 - queued by
; 9 - user status
;
; where status code^condition:
; = 0^SCHEDULED
; = 1^NOT SCHEDULED and 'scheduled date@time' will
; be UNKNOWN and 'numeric day of week' will be -1
; = 2^NOT RESCHEDULED
; = 3^MISSING when OPT does not exist
; = 9^UNKNOWN
; = ""^UNDEFINED
;
; where user status = ACTIVE or NOT ACTIVE
;---------------------------------------------------------------------
;
Q:$G(OPT)="" "^UNDEFINED"
;
N ACTV,DA,DAY,DOW,FREQ,RTN,TSK,TSKINFO,USER
;
S (DOW,FREQ)=-1
S RTN="9^UNKNOWN^NO DATE^-1^UNKNOWN^^^UNKNOWN^NOT ACTIVE"
;
I '$D(^DIC(19,"B",OPT)) S $P(RTN,U,1,2)="3^MISSING" Q RTN
S DA=$O(^DIC(19,"B",OPT,0)),DA=+$O(^DIC(19.2,"B",DA,0))
S TSKINFO=$G(^DIC(19.2,DA,0)),(DOW,Y)=$P(TSKINFO,U,2),FREQ=$P(TSKINFO,U,6)
S $P(TSKINFO,U,2)=$$FMTE^XLFDT($P(TSKINFO,U,2))
I DOW'="" S DAY=$$DOW^XLFDT(DOW),DOW=$$DOW^XLFDT(DOW,1)
K:$G(DAY)="day" DAY
S TSK=+$G(^DIC(19.2,+DA,1))
I (DOW="")!(TSK="") S $P(RTN,U,1,2)="1^NOT SCHEDULED"
E D
.S $P(RTN,U,1,2)="0^SCHEDULED"
.I FREQ="" S $P(RTN,U,1,2)="2^NOT RESCHEDULED"
.; queued to run at
.S $P(RTN,U,3,4)=$S($P(TSKINFO,U,2)="":"NO DATE",1:$P(TSKINFO,U,2))_$S($D(DAY):" ("_DAY_")",1:"")_U_DOW
; rescheduling frequency
I FREQ?1.3N1A D
.S $P(RTN,U,5,6)=+FREQ_" "_$S(FREQ["D":"day",FREQ["M":"month",1:FREQ)_$S(+FREQ>1:"s",1:"")_U_FREQ
E S $P(RTN,U,5,6)=$S(FREQ="":"UNKNOWN",1:FREQ)_U_FREQ
; task id
S $P(RTN,U,7)=TSK
; find if the user is active
I TSK D
.S TSKINFO=$G(^%ZTSK(TSK,0))
.S USER=+$P(TSKINFO,U,3)
.S ACTV=+$$ACTIVE^XUSER(USER)
.; queued by
.S $P(RTN,U,8)=$P($G(^VA(200,USER,0)),U)
I $G(ACTV) S $P(RTN,U,9)="ACTIVE"
Q RTN
;
VERPTCH(PKG,RTNARRY) ;-- returns current version and patch status of specified CM package
;---------------------------------------------------------------------
; input PKG = 'D' for CM TOOLS
; 'R' for RUM - DECOMMISSIONED
; 'S' for SAGG
; Return array (passed by reference) in format:
; output RTNARRY = -1 for error
; RTNARRY(0) = number of routines^total rtns ok^total rtns bad^total rtns missing
; RTNARRY(rtn name) = {0=good 1=bad 2=missing routine}^released version^released patch(es)^site version^site patch(es)
;
; This code will reference line tag PTCHINFO^KMP_pkg_UTL for the
; following patch information text starting at PTCHINFO+1:
;
; ;;routine name ^ current version ^ current patch(es)
;
; Example:
; PATCHINFO ;-- patch information
; ;;KMPSGE^1.8^**1,2**
; ;;KMPSUTL^1.8^**1,2**
; last line > ;;
;---------------------------------------------------------------------
;
K RTNARRY
;
N BAD,I,INFO,INFOSITE,OK,OUT,PTCH,PTCHSITE,RTN
N TAG,TOTBAD,TOTMISS,TOTOK,TOTRTN,X,VER,VERSITE
;
I $G(PKG)=""!("DS"'[$G(PKG))!($L(PKG)'=1) S RTNARRY=-1 Q
S X="KMP"_PKG_"UTL"
X ^%ZOSF("TEST") I '$T S RTNARRY=-1 Q
;
S (OUT,TOTBAD,TOTMISS,TOTOK,TOTRTN)=0
F I=1:1 D Q:OUT
.S TAG="PTCHINFO+"_I_"^KMP"_PKG_"UTL"
.S INFO=$P($T(@TAG),";;",2)
.I INFO="" S OUT=1 Q
.S RTN=$P(INFO,U),VER=$P(INFO,U,2),PTCH=$P(INFO,U,3)
.; if routine is missing
.I $T(@(RTN_"^"_RTN))="" D Q
..S TOTMISS=TOTMISS+1,TOTRTN=TOTRTN+1
..S RTNARRY(RTN)="2^"_VER_U_PTCH_"^^"
.X "ZL @RTN S INFOSITE=$T(+2)"
.S VERSITE=$P(INFOSITE,";",3),PTCHSITE=$P(INFOSITE,";",5)
.I VERSITE'=VER!(PTCHSITE'=PTCH) S BAD=1,OK=0
.E S BAD=0,OK=1
.S TOTBAD=TOTBAD+BAD,TOTOK=TOTOK+OK,TOTRTN=TOTRTN+1
.S RTNARRY(RTN)=BAD_U_VER_U_PTCH_U_VERSITE_U_PTCHSITE
S RTNARRY(0)=TOTRTN_U_TOTOK_U_TOTBAD_U_TOTMISS
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDUTL1 7010 printed Oct 16, 2024@17:42:09 Page 2
KMPDUTL1 ;OAK/RAK,KAK,JML - CM TOOLS Utilities ;2/17/04
+1 ;;4.0;CAPACITY MANAGEMENT;;11/15/2017;Build 38
+2 ;
CONT(KMPDEXT) ;-- function displays 'return to continue' message at bottom of page
+1 ;--------------------------------------------------------------------
+2 ; KMPDEXT 0 = do not show 'to exit' text
+3 ; 1 = show 'to exit' text
+4 ;
+5 ; Return: 0 = continue
+6 ; 1 = quit
+7 ;--------------------------------------------------------------------
+8 ;
+9 NEW DIR,X,Y
+10 ;
+11 SET KMPDEXT=+$GET(KMPDEXT)
+12 FOR
if $Y>(IOSL-3)
QUIT
WRITE !
+13 SET DIR(0)="EA"
+14 SET DIR("A")="Press RETURN to continue"_$SELECT(KMPDEXT:" or '^' to exit: ",1:": ")
+15 DO ^DIR
+16 QUIT +$GET(Y)
+17 ;
CURSTAT(STAT) ;-- current status
+1 ;---------------------------------------------------------------------
+2 ; input: STAT (optional) = data from $$TSKSTAT^KMPSUTL1
+3 ; output: See codes below
+4 ;---------------------------------------------------------------------
+5 ;
+6 NEW RESULT,SITNUM,STRTDT
+7 ;
+8 SET RESULT=""
SET SITNUM=^DD("SITE",1)
SET STRTDT=$GET(^XTMP("KMPS",SITNUM,0))
+9 ;
+10 IF $DATA(^XTMP("KMPS","ERROR"))
QUIT "6^ERRORS RECORDED"
+11 IF $DATA(^XTMP("KMPS","STOP"))
QUIT "7^STOPPING"
+12 IF $DATA(^XTMP("KMPS","START"))
LOCK +^XTMP("KMPS"):0
IF $TEST
LOCK -^XTMP("KMPS")
QUIT "5^DID NOT COMPLETE"
+13 IF +STRTDT
IF +$HOROLOG-STRTDT>2
QUIT "5^DID NOT COMPLETE"
+14 IF +STRTDT
IF +$HOROLOG-STRTDT>1
QUIT "4^RUNNING TOO LONG"
+15 IF $DATA(^XTMP("KMPS","START"))
QUIT "0^RUNNING"
+16 IF $DATA(STAT)
QUIT $PIECE(STAT,U,1,2)
+17 IF '$TEST
QUIT "3^NOT RUNNING"
+18 QUIT "9^UNKNOWN"
+19 ;
SYSINFO() ;-- returns system information
+1 ;---------------------------------------------------------------------
+2 ; Returns:
+3 ; "^" piece 1 - type of M platform
+4 ; "^" piece 2 - $ZV => name and version of M system
+5 ; "^" piece 3 - operating system version
+6 ;
+7 ;---------------------------------------------------------------------
+8 ;
+9 NEW MPLTF,OSVER,SYSINFO
+10 ;
+11 SET MPLTF=$$MPLTF()
SET OSVER=$$OSVER(MPLTF)
+12 SET SYSINFO=MPLTF_U_$ZV_U_OSVER
+13 QUIT SYSINFO
+14 ;
MPLTF() ;-- returns the type of M platform
+1 ;---------------------------------------------------------------------
+2 ; Returns: DSM for DSM platform
+3 ; CVMS for Cache for OpenVMS platform
+4 ; CWINNT for Cache for Windows NT platform
+5 ;---------------------------------------------------------------------
+6 ;
+7 NEW MPLTF,ZV
+8 ;
+9 SET ZV=$ZV
+10 SET MPLTF=$SELECT(ZV["DSM":"DSM",ZV["VMS":"CVMS",ZV["Windows":"CWINNT",1:"UNK")
+11 QUIT MPLTF
+12 ;
OSVER(MPLTF) ;-- returns the operating system version
+1 ;---------------------------------------------------------------------
+2 ; input: MPLTF = type of M platform
+3 ;---------------------------------------------------------------------
+4 ;
+5 IF $GET(MPLTF)=""
QUIT ""
+6 ;
+7 IF MPLTF["DSM"
QUIT $ZC(%GETSYI,"VERSION")
+8 IF MPLTF["CVMS"
QUIT $$CVMSVER^KMPDUTL5()
+9 IF MPLTF["CWINNT"
QUIT $$CWNTVER^KMPDUTL5()
+10 QUIT ""
+11 ;
TSKSTAT(OPT) ;-- status of scheduled task option
+1 ;---------------------------------------------------------------------
+2 ; input OPT = option name
+3 ;
+4 ; output RTN = by "^" piece
+5 ; 1 - status code
+6 ; 2 - literal condition
+7 ; 3 - scheduled date@time (day)
+8 ; 4 - numeric day-of-week
+9 ; 5 - expanded scheduled frequency
+10 ; 6 - short form frequency
+11 ; 7 - task id
+12 ; 8 - queued by
+13 ; 9 - user status
+14 ;
+15 ; where status code^condition:
+16 ; = 0^SCHEDULED
+17 ; = 1^NOT SCHEDULED and 'scheduled date@time' will
+18 ; be UNKNOWN and 'numeric day of week' will be -1
+19 ; = 2^NOT RESCHEDULED
+20 ; = 3^MISSING when OPT does not exist
+21 ; = 9^UNKNOWN
+22 ; = ""^UNDEFINED
+23 ;
+24 ; where user status = ACTIVE or NOT ACTIVE
+25 ;---------------------------------------------------------------------
+26 ;
+27 if $GET(OPT)=""
QUIT "^UNDEFINED"
+28 ;
+29 NEW ACTV,DA,DAY,DOW,FREQ,RTN,TSK,TSKINFO,USER
+30 ;
+31 SET (DOW,FREQ)=-1
+32 SET RTN="9^UNKNOWN^NO DATE^-1^UNKNOWN^^^UNKNOWN^NOT ACTIVE"
+33 ;
+34 IF '$DATA(^DIC(19,"B",OPT))
SET $PIECE(RTN,U,1,2)="3^MISSING"
QUIT RTN
+35 SET DA=$ORDER(^DIC(19,"B",OPT,0))
SET DA=+$ORDER(^DIC(19.2,"B",DA,0))
+36 SET TSKINFO=$GET(^DIC(19.2,DA,0))
SET (DOW,Y)=$PIECE(TSKINFO,U,2)
SET FREQ=$PIECE(TSKINFO,U,6)
+37 SET $PIECE(TSKINFO,U,2)=$$FMTE^XLFDT($PIECE(TSKINFO,U,2))
+38 IF DOW'=""
SET DAY=$$DOW^XLFDT(DOW)
SET DOW=$$DOW^XLFDT(DOW,1)
+39 if $GET(DAY)="day"
KILL DAY
+40 SET TSK=+$GET(^DIC(19.2,+DA,1))
+41 IF (DOW="")!(TSK="")
SET $PIECE(RTN,U,1,2)="1^NOT SCHEDULED"
+42 IF '$TEST
Begin DoDot:1
+43 SET $PIECE(RTN,U,1,2)="0^SCHEDULED"
+44 IF FREQ=""
SET $PIECE(RTN,U,1,2)="2^NOT RESCHEDULED"
+45 ; queued to run at
+46 SET $PIECE(RTN,U,3,4)=$SELECT($PIECE(TSKINFO,U,2)="":"NO DATE",1:$PIECE(TSKINFO,U,2))_$SELECT($DATA(DAY):" ("_DAY_")",1:"")_U_DOW
End DoDot:1
+47 ; rescheduling frequency
+48 IF FREQ?1.3N1A
Begin DoDot:1
+49 SET $PIECE(RTN,U,5,6)=+FREQ_" "_$SELECT(FREQ["D":"day",FREQ["M":"month",1:FREQ)_$SELECT(+FREQ>1:"s",1:"")_U_FREQ
End DoDot:1
+50 IF '$TEST
SET $PIECE(RTN,U,5,6)=$SELECT(FREQ="":"UNKNOWN",1:FREQ)_U_FREQ
+51 ; task id
+52 SET $PIECE(RTN,U,7)=TSK
+53 ; find if the user is active
+54 IF TSK
Begin DoDot:1
+55 SET TSKINFO=$GET(^%ZTSK(TSK,0))
+56 SET USER=+$PIECE(TSKINFO,U,3)
+57 SET ACTV=+$$ACTIVE^XUSER(USER)
+58 ; queued by
+59 SET $PIECE(RTN,U,8)=$PIECE($GET(^VA(200,USER,0)),U)
End DoDot:1
+60 IF $GET(ACTV)
SET $PIECE(RTN,U,9)="ACTIVE"
+61 QUIT RTN
+62 ;
VERPTCH(PKG,RTNARRY) ;-- returns current version and patch status of specified CM package
+1 ;---------------------------------------------------------------------
+2 ; input PKG = 'D' for CM TOOLS
+3 ; 'R' for RUM - DECOMMISSIONED
+4 ; 'S' for SAGG
+5 ; Return array (passed by reference) in format:
+6 ; output RTNARRY = -1 for error
+7 ; RTNARRY(0) = number of routines^total rtns ok^total rtns bad^total rtns missing
+8 ; RTNARRY(rtn name) = {0=good 1=bad 2=missing routine}^released version^released patch(es)^site version^site patch(es)
+9 ;
+10 ; This code will reference line tag PTCHINFO^KMP_pkg_UTL for the
+11 ; following patch information text starting at PTCHINFO+1:
+12 ;
+13 ; ;;routine name ^ current version ^ current patch(es)
+14 ;
+15 ; Example:
+16 ; PATCHINFO ;-- patch information
+17 ; ;;KMPSGE^1.8^**1,2**
+18 ; ;;KMPSUTL^1.8^**1,2**
+19 ; last line > ;;
+20 ;---------------------------------------------------------------------
+21 ;
+22 KILL RTNARRY
+23 ;
+24 NEW BAD,I,INFO,INFOSITE,OK,OUT,PTCH,PTCHSITE,RTN
+25 NEW TAG,TOTBAD,TOTMISS,TOTOK,TOTRTN,X,VER,VERSITE
+26 ;
+27 IF $GET(PKG)=""!("DS"'[$GET(PKG))!($LENGTH(PKG)'=1)
SET RTNARRY=-1
QUIT
+28 SET X="KMP"_PKG_"UTL"
+29 XECUTE ^%ZOSF("TEST")
IF '$TEST
SET RTNARRY=-1
QUIT
+30 ;
+31 SET (OUT,TOTBAD,TOTMISS,TOTOK,TOTRTN)=0
+32 FOR I=1:1
Begin DoDot:1
+33 SET TAG="PTCHINFO+"_I_"^KMP"_PKG_"UTL"
+34 SET INFO=$PIECE($TEXT(@TAG),";;",2)
+35 IF INFO=""
SET OUT=1
QUIT
+36 SET RTN=$PIECE(INFO,U)
SET VER=$PIECE(INFO,U,2)
SET PTCH=$PIECE(INFO,U,3)
+37 ; if routine is missing
+38 IF $TEXT(@(RTN_"^"_RTN))=""
Begin DoDot:2
+39 SET TOTMISS=TOTMISS+1
SET TOTRTN=TOTRTN+1
+40 SET RTNARRY(RTN)="2^"_VER_U_PTCH_"^^"
End DoDot:2
QUIT
+41 XECUTE "ZL @RTN S INFOSITE=$T(+2)"
+42 SET VERSITE=$PIECE(INFOSITE,";",3)
SET PTCHSITE=$PIECE(INFOSITE,";",5)
+43 IF VERSITE'=VER!(PTCHSITE'=PTCH)
SET BAD=1
SET OK=0
+44 IF '$TEST
SET BAD=0
SET OK=1
+45 SET TOTBAD=TOTBAD+BAD
SET TOTOK=TOTOK+OK
SET TOTRTN=TOTRTN+1
+46 SET RTNARRY(RTN)=BAD_U_VER_U_PTCH_U_VERSITE_U_PTCHSITE
End DoDot:1
if OUT
QUIT
+47 SET RTNARRY(0)=TOTRTN_U_TOTOK_U_TOTBAD_U_TOTMISS
+48 QUIT