NVSTMPC ;emc/maw-clean inactive jobs nodes in ^TMP ; 07/09/2004
;;2.1;EMC SYSTEM UTILITIES; Jul 03, 2002
;;vsts/fyb - Modified to run on either Cache or DSM
;
; -- included in NVSMENU KIDs BUILD jls/oiofo 1/21/06 NOON
;
S NVSHPID=$$CNV^XLFUTL($J,16)
S NVSHP3=$E(NVSHPID,1,3)
D GETENV^%ZOSV
S NVSHNODE=$P(Y,"^",3)
W !!,"CLEAN INACTIVE JOB NODES IN ^TMP GLOBAL"
W !!,"Current Node: ",?18,NVSHNODE
W !!,"This procedure will process down through the specified"
W !,"number of subscript levels searching for PID numbers."
W !,"When a PID is found, for those whose first three digits"
W !,"match this node's hexidecimal PID prefix, a check is"
W !,"invoked to determine if that PID is active. If it is"
W !,"inactive, you have the choice of either reporting that"
W !,"PID, or have this procedure delete that global node."
W !,"If you choose to delete them, you will also be asked"
W !,"whether you want to be prompted to delete the nodes,"
W !,"or allow this process to automatically delete them."
W !!,"*NOTE: THIS CLEAN UP IS SPECIFIC TO THIS NODE ONLY*"
W !,"IT MUST BE RUN ON EACH NODE IN YOUR CLUSTER IN ORDER"
W !,"TO CLEAN UP THE ^TMP GLOBAL ON EACH NODE."
S DIR(0)="NA^1:3"
S DIR("A")="How many subscript levels deep should I search (1-3)? "
S DIR("B")=2
S DIR("?")="2 subscript levels is usually deep enough."
W ! D ^DIR K DIR
I $D(DIRUT) K DIRUT,DTOUT,X,Y Q
S NVSSUBS=+Y
S DIR(0)="SA^C:Clean;R:Report"
S DIR("A")="[C]lean up the nodes or [R]eport only? "
S DIR("?")="Enter 'R' and inactive PID nodes will be listed -- not deleted."
S DIR("?",1)="Enter 'C' and inactive PID nodes can be deleted."
S DIR("B")="Report"
W ! D ^DIR K DIR
I $D(DIRUT) K DIRUT,DTOUT,NVSSUBS,X,Y Q
S NVSTYPE=Y
I NVSTYPE="C" D
.S DIR(0)="SA^Y:Yes;N:No"
.S DIR("A")="Do you wish me to prompt you to delete each node? "
.S DIR("B")="NO"
.S DIR("?")="Answer 'NO' and I will automatically delete the nodes."
.S DIR("?",1)="Answer 'YES' and I will prompt you do delete the nodes."
.W ! D ^DIR K DIR
.I $D(DIRUT) D Q
..S NVSASK="Y"
..K DIRUT,DTOUT,X,Y
.S NVSASK=Y
W !!,"Process type: ",$S(NVSTYPE="R":"Report only",1:"Clean up nodes")
I NVSTYPE="C" W !,"Action type : ",$S(NVSASK="Y":"Prompt for deletion",1:"Automatic deletion")
W !,"Subscripts: ",NVSSUBS
S DIR(0)="YA"
S DIR("A")="Okay to continue? "
S DIR("B")="NO"
W ! D ^DIR K DIR
I Y=1 D
.W !!,"Job starting ",$$FMTE^XLFDT($$NOW^XLFDT)
.I NVSTYPE="R" W !,"**REPORT ONLY**"
.F NVSSUB=1:1:NVSSUBS D
..S NVSLVL="LVL"_NVSSUB
..D @NVSLVL
.W !!,"All processing complete on node ",$ZU(110)
K DIRUT,DTOUT,NVSASK,NVSHNODE,NVSHPID,NVSHP3,NVSLVL,NVSSUB,NVSSUBS,NVSTYPE,X,Y
Q
;
LVL1 ; first-level subscript...
W !!,"First level..."
S NVSICNT=0
S X1=""
F S X1=$O(^TMP(X1)) Q:X1="" D
.; is X1 a PID?...
.I +X1=0 Q
.I X1\1'=X1 Q
.I $E($$CNV^XLFUTL(X1,16),1,3)'=NVSHP3 Q
.; X1 is a PID on this node, is PID active?...
.I $D(^$JOB(X1))'=0 Q ; Job is active
.S NVSICNT=NVSICNT+1
.W !?2,"^TMP(",X1,"..."
.I NVSTYPE="R" Q
.S NVSDEL=$S(NVSASK="N":1,1:0)
.I NVSASK="Y" D OKDEL(.NVSDEL)
.I 'NVSDEL W " -- not deleted." Q
.K ^TMP(X1)
.W " -- deleted."
W !!,NVSICNT," inactive PID",$S(NVSICNT>1:"s",1:"")," at first subscript level."
K NVSDEL,NVSICNT,X1
Q
;
LVL2 ; second-level subscript...
W !!,"Second level..."
S NVSICNT=0
S X1=" "
F S X1=$O(^TMP(X1)) Q:X1="" D
.S X2=""
.F S X2=$O(^TMP(X1,X2)) Q:X2="" D
..; is X2 a PID?...
..I +X2=0 Q
..I X2\1'=X2 Q
..I $E($$CNV^XLFUTL(X2,16),1,3)'=NVSHP3 Q
..; X2 is a PID on this node, is PID active?...
..I $D(^$JOB(X2))'=0 Q ; Job is active
..S NVSICNT=NVSICNT+1
..W !?2,"^TMP(",X1,",",X2,"..."
..I NVSTYPE="R" Q
..S NVSDEL=$S(NVSASK="N":1,1:0)
..I NVSASK="Y" D OKDEL(.NVSDEL)
..I 'NVSDEL W " -- not deleted." Q
..K ^TMP(X1,X2)
..W " -- deleted."
W !!,NVSICNT," inactive PID",$S(NVSICNT>1:"s",1:"")," at second subscript level."
K NVSDEL,NVSICNT,X1,X2
Q
;
LVL3 ; third-level subscript...
W !!,"Third level..."
S NVSICNT=0
S X1=" "
F S X1=$O(^TMP(X1)) Q:X1="" D
.S X2=" "
.F S X2=$O(^TMP(X1,X2)) Q:X2="" D
..S X3=""
..F S X3=$O(^TMP(X1,X2,X3)) Q:X3="" D
...; is X3 a PID?...
...I +X3=0 Q
...I X3\1'=X3 Q
...I $E($$CNV^XLFUTL(X3,16),1,3)'=NVSHP3 Q
...; X3 is a PID on this node, is the PID active?...
...I $D(^$JOB(X3))'=0 Q ; Job is active
...S NVSICNT=NVSICNT+1
...W !?2,"^TMP(",X1,",",X2,",",X3,"..."
...I NVSTYPE="R" Q
...S NVSDEL=$S(NVSASK="N":1,1:0)
...I NVSASK="Y" D OKDEL(.NVSDEL)
...I 'NVSDEL W " -- not deleted." Q
...K ^TMP(X1,X2,X3)
...W " -- deleted."
W !!,NVSICNT," inactive PID",$S(NVSICNT>1:"s",1:"")," at third subscript level."
K NVSDEL,NVSICNT,X1,X2,X3
Q
;
OKDEL(OK) ; ask okay to delete...
; OK is passed by reference, returned 0 if NO 1 if YES
N DIR,DIRUT,DTOUT,X,Y
S DIR(0)="YA"
S DIR("A")=" Okay to delete? "
S DIR("B")="NO"
D ^DIR K DIR
S OK=+Y
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HNVSTMPC 5043 printed Dec 13, 2024@02:17:40 Page 2
NVSTMPC ;emc/maw-clean inactive jobs nodes in ^TMP ; 07/09/2004
+1 ;;2.1;EMC SYSTEM UTILITIES; Jul 03, 2002
+2 ;;vsts/fyb - Modified to run on either Cache or DSM
+3 ;
+4 ; -- included in NVSMENU KIDs BUILD jls/oiofo 1/21/06 NOON
+5 ;
+6 SET NVSHPID=$$CNV^XLFUTL($JOB,16)
+7 SET NVSHP3=$EXTRACT(NVSHPID,1,3)
+8 DO GETENV^%ZOSV
+9 SET NVSHNODE=$PIECE(Y,"^",3)
+10 WRITE !!,"CLEAN INACTIVE JOB NODES IN ^TMP GLOBAL"
+11 WRITE !!,"Current Node: ",?18,NVSHNODE
+12 WRITE !!,"This procedure will process down through the specified"
+13 WRITE !,"number of subscript levels searching for PID numbers."
+14 WRITE !,"When a PID is found, for those whose first three digits"
+15 WRITE !,"match this node's hexidecimal PID prefix, a check is"
+16 WRITE !,"invoked to determine if that PID is active. If it is"
+17 WRITE !,"inactive, you have the choice of either reporting that"
+18 WRITE !,"PID, or have this procedure delete that global node."
+19 WRITE !,"If you choose to delete them, you will also be asked"
+20 WRITE !,"whether you want to be prompted to delete the nodes,"
+21 WRITE !,"or allow this process to automatically delete them."
+22 WRITE !!,"*NOTE: THIS CLEAN UP IS SPECIFIC TO THIS NODE ONLY*"
+23 WRITE !,"IT MUST BE RUN ON EACH NODE IN YOUR CLUSTER IN ORDER"
+24 WRITE !,"TO CLEAN UP THE ^TMP GLOBAL ON EACH NODE."
+25 SET DIR(0)="NA^1:3"
+26 SET DIR("A")="How many subscript levels deep should I search (1-3)? "
+27 SET DIR("B")=2
+28 SET DIR("?")="2 subscript levels is usually deep enough."
+29 WRITE !
DO ^DIR
KILL DIR
+30 IF $DATA(DIRUT)
KILL DIRUT,DTOUT,X,Y
QUIT
+31 SET NVSSUBS=+Y
+32 SET DIR(0)="SA^C:Clean;R:Report"
+33 SET DIR("A")="[C]lean up the nodes or [R]eport only? "
+34 SET DIR("?")="Enter 'R' and inactive PID nodes will be listed -- not deleted."
+35 SET DIR("?",1)="Enter 'C' and inactive PID nodes can be deleted."
+36 SET DIR("B")="Report"
+37 WRITE !
DO ^DIR
KILL DIR
+38 IF $DATA(DIRUT)
KILL DIRUT,DTOUT,NVSSUBS,X,Y
QUIT
+39 SET NVSTYPE=Y
+40 IF NVSTYPE="C"
Begin DoDot:1
+41 SET DIR(0)="SA^Y:Yes;N:No"
+42 SET DIR("A")="Do you wish me to prompt you to delete each node? "
+43 SET DIR("B")="NO"
+44 SET DIR("?")="Answer 'NO' and I will automatically delete the nodes."
+45 SET DIR("?",1)="Answer 'YES' and I will prompt you do delete the nodes."
+46 WRITE !
DO ^DIR
KILL DIR
+47 IF $DATA(DIRUT)
Begin DoDot:2
+48 SET NVSASK="Y"
+49 KILL DIRUT,DTOUT,X,Y
End DoDot:2
QUIT
+50 SET NVSASK=Y
End DoDot:1
+51 WRITE !!,"Process type: ",$SELECT(NVSTYPE="R":"Report only",1:"Clean up nodes")
+52 IF NVSTYPE="C"
WRITE !,"Action type : ",$SELECT(NVSASK="Y":"Prompt for deletion",1:"Automatic deletion")
+53 WRITE !,"Subscripts: ",NVSSUBS
+54 SET DIR(0)="YA"
+55 SET DIR("A")="Okay to continue? "
+56 SET DIR("B")="NO"
+57 WRITE !
DO ^DIR
KILL DIR
+58 IF Y=1
Begin DoDot:1
+59 WRITE !!,"Job starting ",$$FMTE^XLFDT($$NOW^XLFDT)
+60 IF NVSTYPE="R"
WRITE !,"**REPORT ONLY**"
+61 FOR NVSSUB=1:1:NVSSUBS
Begin DoDot:2
+62 SET NVSLVL="LVL"_NVSSUB
+63 DO @NVSLVL
End DoDot:2
+64 WRITE !!,"All processing complete on node ",$ZU(110)
End DoDot:1
+65 KILL DIRUT,DTOUT,NVSASK,NVSHNODE,NVSHPID,NVSHP3,NVSLVL,NVSSUB,NVSSUBS,NVSTYPE,X,Y
+66 QUIT
+67 ;
LVL1 ; first-level subscript...
+1 WRITE !!,"First level..."
+2 SET NVSICNT=0
+3 SET X1=""
+4 FOR
SET X1=$ORDER(^TMP(X1))
if X1=""
QUIT
Begin DoDot:1
+5 ; is X1 a PID?...
+6 IF +X1=0
QUIT
+7 IF X1\1'=X1
QUIT
+8 IF $EXTRACT($$CNV^XLFUTL(X1,16),1,3)'=NVSHP3
QUIT
+9 ; X1 is a PID on this node, is PID active?...
+10 ; Job is active