source: WorldVistAEHR/trunk/r/TOOLKIT-AWCM-XD-XIN-XPAR-XQAB-XT-XUC-XUR-ZIN-ZTED/XTSUMCK.m@ 1234

Last change on this file since 1234 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 6.0 KB
Line 
1XTSUMCK ;Boise/MAW,SFISC/RSD -compute routine checksums ;10/04/96 11:11
2 ;;8.0;KERNEL;**44**;Jul 10, 1995
3 ;^XTMP("XTSUMCK",DUZ)=end time^home cpu^status^task #^start time^# rtns
4 ;^XTMP("XTSUMCK",DUZ,"SYS",system)=end time^active^status^task #^end time^# rtns
5 I '$G(DUZ) W *7,!!,"DUZ UNDEFINED...ABORTED." Q
6 S:'$D(DT) DT=$$DT^XLFDT S:'$D(U) U="^"
7 N DIR,I,XTCKSUM,XTHOME,XTROU,DIRUT,X,Y
8 X ^%ZOSF("UCI") S XTHOME=Y
9 ;set expiration date on ^XTMP
10 S ^XTMP("XTSUMCK",0)=$$FMADD^XLFDT(DT,7)_U_DT
11 W !!,"You're on ",XTHOME,". Checksums for selected routines on other systems",!,"will be compared to those on this system."
12 I $G(^XTMP("XTSUMCK",DUZ))'="" S X=^XTMP("XTSUMCK",DUZ) D Q:$D(DIRUT)
13 .W *7,!!,"A checksum job, launched on ",$$FMTE^XLFDT($P(X,U,5))," from ",$P(X,U,2)," is",!," already on file."
14 .W:$P(X,U,3)]"" !," It has a status of: ",$P(X,U,3)
15 .S DIR(0)="Y",DIR("A")="Okay to delete the existing data",DIR("B")="NO"
16 .D ^DIR
17 .I Y'=1 W !!,"Nothing deleted...this job aborted." S DIRUT=1 Q
18 .K ^XTMP("XTSUMCK",DUZ) S ^(DUZ)=""
19 K ^UTILITY($J) W ! X ^%ZOSF("RSEL")
20 I '$D(^UTILITY($J)) W !,"No routines selected." Q
21 S ^XTMP("XTSUMCK",DUZ)=U_XTHOME_"^Loading routines^^"_$$NOW^XLFDT
22 ;move list of routines into XTMP
23 M ^XTMP("XTSUMCK",DUZ,"ROU")=^UTILITY($J)
24 K ^UTILITY($J),DIR
25 ;find systems to move to
26 S Y=$P(XTHOME,",",2),I=0
27 F S I=$O(^%ZIS(14.5,I)) Q:'I S X=$G(^(I,0)) S:$P(X,U)]""&$P(X,U,11)&($P(X,U)'=Y) ^XTMP("XTSUMCK",DUZ,"SYS",$P(X,U))=""
28SYS I '$D(^XTMP("XTSUMCK",DUZ,"SYS")) W !!,"No Systems to Check",! G ABORT
29 W !!,"I will Check the Routines on the following Systems:",!
30 S I="" F S I=$O(^XTMP("XTSUMCK",DUZ,"SYS",I)) Q:I="" W ?3,I,!
31 W ! S DIR(0)="Y",DIR("A")="Accept this list and continue",DIR("B")="YES"
32 S DIR("?",1)="Enter Yes if you want to check the routines on the listed Systems",DIR("?")="Enter No if you want to create your own list of Systems."
33 D ^DIR G ZTLD:Y,ABORT:$D(DIRUT) D G SYS
34 .N DIC K ^XTMP("XTSUMCK",DUZ,"SYS")
35 .S DIC="^%ZIS(14.5,",DIC(0)="AEMQZ",DIC("S")="S %=^(0) I $P(%,U)'=$P(XTHOME,"","",2),$P(%,U,11)"
36 .;ask for systems
37 .F D ^DIC Q:Y'>0 S ^XTMP("XTSUMCK",DUZ,"SYS",Y(0,0))=""
38ZTLD ;queue build of master routine set checksums
39 N ZTRTN,ZTDESC,ZTIO,ZTSAVE,ZTUCI,ZTCPU,ZTSK
40 S ZTRTN="MSTR^XTSUMCK",ZTDESC="Routine Checksum Checker",ZTIO="",ZTSAVE("DUZ")="",ZTSAVE("XTHOME")="",ZTUCI=$P(XTHOME,","),ZTCPU=$P(XTHOME,",",2)
41 D ^%ZTLOAD
42 W !!
43 I '$G(ZTSK) W *7,"Error...not queued!!" G ABORT
44 I $G(ZTSK) D
45 .S $P(^XTMP("XTSUMCK",DUZ),U,3,4)="Queued to run^"_ZTSK
46 .W "Task number ",ZTSK," will calculate checksums for the selected"
47 .W !,"routines here on ",XTHOME,"."
48 .W !!,"These values will be used for comparison with the same routine set on all"
49 .W !,"the other systems. You will receive an alert when the job finishes. The"
50 .W !,"alert action will allow you to view/print the report that lists any"
51 .W !,"routines that do not match the ""master"" calculated checksums."
52 K ^UTILITY($J)
53 Q
54MSTR ;TaskMan entry point
55 ;first, calculate the checksums for the "master" routine set
56 S $P(^XTMP("XTSUMCK",DUZ),U,3)="Calculating checksums",XTDUZ=DUZ,XTX=""
57 F XTCNT=0:1 S XTX=$O(^XTMP("XTSUMCK",DUZ,"ROU",XTX)) Q:XTX="" D
58 .S X=XTX
59 .X ^%ZOSF("RSUM")
60 .S ^XTMP("XTSUMCK",DUZ,"ROU",XTX)=Y
61 ;next, job the checksum module on the other systems
62 S $P(^XTMP("XTSUMCK",DUZ),U,6)=XTCNT,XTX=""
63 F S XTX=$O(^XTMP("XTSUMCK",DUZ,"SYS",XTX)) Q:XTX="" D
64 .N ZTSK,ZTCPU,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH
65 .S ZTCPU=XTX,ZTRTN="CHK^XTSUMCK",ZTSAVE("XTDUZ")="",ZTUCI=$P(XTHOME,","),ZTDESC="Routine Checksum Checker for "_ZTUCI_","_ZTCPU,ZTDTH=$H,ZTIO=""
66 .D ^%ZTLOAD
67 .I $G(ZTSK) S ^XTMP("XTSUMCK",DUZ,"SYS",XTX)="^^Job Tasked^"_ZTSK,XTSUMCK(XTX)="0^"_$H Q
68 .S %=$$NOW^XLFDT,^XTMP("XTSUMCK",DUZ,"SYS",XTX)=%_"^^ERROR -- Job couldn't be tasked^^"_%
69 ;monitor background tasks
70 ;checking for completion of all checksum jobs. Once all completed,
71 ;an alert is set up to notify the requester.
72 S $P(^XTMP("XTSUMCK",DUZ),U,3)="Waiting for jobs to finish",XTSFLG=""
73 F D Q:XTFLG H 60
74 .S XTFLG=1,XTSYS=""
75 .F S XTSYS=$O(^XTMP("XTSUMCK",DUZ,"SYS",XTSYS)) Q:XTSYS="" S X=^(XTSYS) D:'X
76 ..S XTFLG=0
77 ..;not complete, if still active then reset counter
78 ..I $P(XTSUMCK(XTSYS),U,2)'=$P(X,U,2) S XTSUMCK(XTSYS)="0^"_$P(X,U,2) Q
79 ..;hasn't been active for at least 30 minutes
80 ..I XTSUMCK(XTSYS)>30 S X=^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS),$P(X,U)=$$NOW^XLFDT,$P(X,U,3)="ERROR - was idle for more than 30 minutes",^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS)=X
81 ..S $P(XTSUMCK(XTSYS),U)=XTSUMCK(XTSYS)+1
82 ;log the date.time job completed
83 S XTX=^XTMP("XTSUMCK",DUZ),XTX=$$NOW^XLFDT_U_$P(XTX,U,2)_"^Completed ^"_$P(XTX,U,4,6),^XTMP("XTSUMCK",DUZ)=XTX
84 ;send an alert that the checksum job completed
85 S XQA(DUZ)=""
86 S XQAMSG="Routine checksum job completed."
87 S XQAROU="^XTSUMCK1"
88 D SETUP^XQALERT
89 I $D(ZTQUEUED) S ZTREQ="@"
90 Q
91CHK ;jobbed entry point...
92 ;XTDUZ=DUZ of the user who started the checksum job...
93 X ^%ZOSF("UCI") S XTSYS=$P(Y,",",2)
94 I $$NEWERR^%ZTER N $ETRAP,$ESTACK S $ETRAP="D ERR^XTSUMCK"
95 E S X="ERR^XTSUMCK",@^%ZOSF("TRAP")
96 S XTMST=$P(^XTMP("XTSUMCK",XTDUZ),U,2),XTHM=$P(XTMST,",")_","_XTSYS
97 S X=^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS),$P(X,U,2,3)=$H_"^Checking Routines",$P(X,U,5)=$$NOW^XLFDT,^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS)=X
98 S XTROU=""
99 F XTCNT=0:1 S XTROU=$O(^XTMP("XTSUMCK",XTDUZ,"ROU",XTROU)) Q:XTROU="" D
100 .S:'(XTCNT#10) $P(^XTMP("XTSUMCK",XTDUZ,XTSYS),U,2)=$H
101 .I $T(^@XTROU)="" S ^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS,XTROU)="NOT ON THIS SYSTEM" Q
102 .S XTCKSUM=+^XTMP("XTSUMCK",XTDUZ,"ROU",XTROU)
103 .S X=XTROU
104 .X ^%ZOSF("RSUM")
105 .I Y=XTCKSUM Q
106 .S ^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS,XTROU)="Checksum on "_XTHM_" = "_Y_" :: on "_XTMST_" = "_XTCKSUM
107 S X=^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS),$P(X,U)=$$NOW^XLFDT,$P(X,U,3)="Normal Completion",$P(X,U,6)=XTCNT,^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS)=X
108 Q
109ABORT K ^XTMP("XTSUMCK",DUZ)
110 Q
111ERR ;error in background job
112 S X=^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS),$P(X,U)=$$NOW^XLFDT,$P(X,U,3)="ERROR - Job terminated before completion",^XTMP("XTSUMCK",XTDUZ,"SYS",XTSYS)=X
113 D ^%ZTER,UNWIND^%ZTER
114 Q
Note: See TracBrowser for help on using the repository browser.