source: FOIAVistA/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDUTL1.m@ 1614

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

initial load of FOIAVistA 6/30/08 version

File size: 6.6 KB
Line 
1KMPDUTL1 ;OAK/RAK,KAK - CM TOOLS Utilities ;2/17/04 10:51
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;**3**;Mar 22, 2002
3 ;
4CONT(KMPDEXT) ;-- function displays 'return to continue' message at bottom of page
5 ;--------------------------------------------------------------------
6 ; KMPDEXT 0 = do not show 'to exit' text
7 ; 1 = show 'to exit' text
8 ;
9 ; Return: 0 = continue
10 ; 1 = quit
11 ;--------------------------------------------------------------------
12 ;
13 N DIR,X,Y
14 ;
15 S KMPDEXT=+$G(KMPDEXT)
16 F Q:$Y>(IOSL-3) W !
17 S DIR(0)="EA"
18 S DIR("A")="Press RETURN to continue"_$S(KMPDEXT:" or '^' to exit: ",1:": ")
19 D ^DIR
20 Q +$G(Y)
21 ;
22CURSTAT(STAT) ;-- current status
23 ;---------------------------------------------------------------------
24 ; input: STAT (optional) = data from $$TSKSTAT^KMPSUTL1
25 ; output: See codes below
26 ;---------------------------------------------------------------------
27 ;
28 N RESULT,SITNUM,STRTDT
29 ;
30 S RESULT="",SITNUM=^DD("SITE",1),STRTDT=$G(^XTMP("KMPS",SITNUM,0))
31 ;
32 I $D(^XTMP("KMPS","ERROR")) Q "6^ERRORS RECORDED"
33 I $D(^XTMP("KMPS","STOP")) Q "7^STOPPING"
34 I $D(^XTMP("KMPS","START")) L +^XTMP("KMPS"):0 I $T L -^XTMP("KMPS") Q "5^DID NOT COMPLETE"
35 I +STRTDT I +$H-STRTDT>2 Q "5^DID NOT COMPLETE"
36 I +STRTDT I +$H-STRTDT>1 Q "4^RUNNING TOO LONG"
37 I $D(^XTMP("KMPS","START")) Q "0^RUNNING"
38 I $D(STAT) Q $P(STAT,U,1,2)
39 E Q "3^NOT RUNNING"
40 Q "9^UNKNOWN"
41 ;
42SYSINFO() ;-- returns system information
43 ;---------------------------------------------------------------------
44 ; Returns:
45 ; "^" piece 1 - type of M platform
46 ; "^" piece 2 - $ZV => name and version of M system
47 ; "^" piece 3 - operating system version
48 ;
49 ;---------------------------------------------------------------------
50 ;
51 N MPLTF,OSVER,SYSINFO
52 ;
53 S MPLTF=$$MPLTF(),OSVER=$$OSVER(MPLTF)
54 S SYSINFO=MPLTF_U_$ZV_U_OSVER
55 Q SYSINFO
56 ;
57MPLTF() ;-- returns the type of M platform
58 ;---------------------------------------------------------------------
59 ; Returns: DSM for DSM platform
60 ; CVMS for Cache for OpenVMS platform
61 ; CWINNT for Cache for Windows NT platform
62 ;---------------------------------------------------------------------
63 ;
64 N MPLTF,ZV
65 ;
66 S ZV=$ZV
67 S MPLTF=$S(ZV["DSM":"DSM",ZV["VMS":"CVMS",ZV["Windows":"CWINNT",1:"UNK")
68 Q MPLTF
69 ;
70OSVER(MPLTF) ;-- returns the operating system version
71 ;---------------------------------------------------------------------
72 ; input: MPLTF = type of M platform
73 ;---------------------------------------------------------------------
74 ;
75 I $G(MPLTF)="" Q ""
76 ;
77 I MPLTF["DSM" Q $ZC(%GETSYI,"VERSION")
78 I MPLTF["CVMS" Q $$CVMSVER^KMPDUTL5()
79 I MPLTF["CWINNT" Q $$CWNTVER^KMPDUTL5()
80 Q ""
81 ;
82TSKSTAT(OPT) ;-- status of scheduled task option
83 ;---------------------------------------------------------------------
84 ; input OPT = option name
85 ;
86 ; output RTN = by "^" piece
87 ; 1 - status code
88 ; 2 - literal condition
89 ; 3 - scheduled date@time (day)
90 ; 4 - numeric day-of-week
91 ; 5 - expanded scheduled frequency
92 ; 6 - short form frequency
93 ; 7 - task id
94 ; 8 - queued by
95 ; 9 - user status
96 ;
97 ; where status code^condition:
98 ; = 0^SCHEDULED
99 ; = 1^NOT SCHEDULED and 'scheduled date@time' will
100 ; be UNKNOWN and 'numeric day of week' will be -1
101 ; = 2^NOT RESCHEDULED
102 ; = 3^MISSING when OPT does not exist
103 ; = 9^UNKNOWN
104 ; = ""^UNDEFINED
105 ;
106 ; where user status = ACTIVE or NOT ACTIVE
107 ;---------------------------------------------------------------------
108 ;
109 Q:$G(OPT)="" "^UNDEFINED"
110 ;
111 N ACTV,DA,DAY,DOW,FREQ,RTN,TSK,TSKINFO,USER,Y
112 ;
113 S (DOW,FREQ)=-1
114 S RTN="9^UNKNOWN^NO DATE^-1^UNKNOWN^^^UNKNOWN^NOT ACTIVE"
115 ;
116 I '$D(^DIC(19,"B",OPT)) S $P(RTN,U,1,2)="3^MISSING" Q RTN
117 S DA=$O(^DIC(19,"B",OPT,0)),DA=+$O(^DIC(19.2,"B",DA,0))
118 S TSKINFO=$G(^DIC(19.2,DA,0)),(DOW,Y)=$P(TSKINFO,U,2),FREQ=$P(TSKINFO,U,6)
119 D:+Y DD^%DT S $P(TSKINFO,U,2)=Y
120 I DOW'="" S DAY=$$DOW^XLFDT(DOW),DOW=$$DOW^XLFDT(DOW,1)
121 S TSK=+$G(^DIC(19.2,+DA,1))
122 I (DOW="")!(TSK="") S $P(RTN,U,1,2)="1^NOT SCHEDULED"
123 E D
124 .S $P(RTN,U,1,2)="0^SCHEDULED"
125 .I FREQ="" S $P(RTN,U,1,2)="2^NOT RESCHEDULED"
126 .; queued to run at
127 .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
128 ; rescheduling frequency
129 I FREQ?1.3N1A D
130 .S $P(RTN,U,5,6)=+FREQ_" "_$S(FREQ["D":"day",FREQ["M":"month",1:FREQ)_$S(+FREQ>1:"s",1:"")_U_FREQ
131 E S $P(RTN,U,5,6)=$S(FREQ="":"UNKNOWN",1:FREQ)_U_FREQ
132 ; task id
133 S $P(RTN,U,7)=TSK
134 ; find if the user is active
135 I TSK D
136 .S TSKINFO=$G(^%ZTSK(TSK,0))
137 .S USER=+$P(TSKINFO,U,3)
138 .S ACTV=+$$ACTIVE^XUSER(USER)
139 .; queued by
140 .S $P(RTN,U,8)=$P($G(^VA(200,USER,0)),U)
141 I $G(ACTV) S $P(RTN,U,9)="ACTIVE"
142 Q RTN
143 ;
144VERPTCH(PKG,RTNARRY) ;-- returns current version and patch status of specified CM package
145 ;---------------------------------------------------------------------
146 ; input PKG = 'D' for CM TOOLS
147 ; 'R' for RUM
148 ; 'S' for SAGG
149 ; Return array (passed by reference) in format:
150 ; output RTNARRY = -1 for error
151 ; RTNARRY(0) = number of routines^total rtns ok^total rtns bad^total rtns missing
152 ; RTNARRY(rtn name) = {0=good 1=bad 2=missing routine}^released version^released patch(es)^site version^site patch(es)
153 ;
154 ; This code will reference line tag PTCHINFO^KMP_pkg_UTL for the
155 ; following patch information text starting at PTCHINFO+1:
156 ;
157 ; ;;routine name ^ current version ^ current patch(es)
158 ;
159 ; Example:
160 ; PATCHINFO ;-- patch information
161 ; ;;KMPSGE^1.8^**1,2**
162 ; ;;KMPSUTL^1.8^**1,2**
163 ; last line > ;;
164 ;---------------------------------------------------------------------
165 ;
166 K RTNARRY
167 ;
168 N BAD,I,INFO,INFOSITE,OK,OUT,PTCH,PTCHSITE,RTN
169 N TAG,TOTBAD,TOTMISS,TOTOK,TOTRTN,X,VER,VERSITE
170 ;
171 I $G(PKG)=""!("DRS"'[$G(PKG))!($L(PKG)'=1) S RTNARRY=-1 Q
172 S X="KMP"_PKG_"UTL"
173 X ^%ZOSF("TEST") I '$T S RTNARRY=-1 Q
174 ;
175 S (OUT,TOTBAD,TOTMISS,TOTOK,TOTRTN)=0
176 F I=1:1 D Q:OUT
177 .S TAG="PTCHINFO+"_I_"^KMP"_PKG_"UTL"
178 .S INFO=$P($T(@TAG),";;",2)
179 .I INFO="" S OUT=1 Q
180 .S RTN=$P(INFO,U),VER=$P(INFO,U,2),PTCH=$P(INFO,U,3)
181 .; if routine is missing
182 .I $T(@(RTN_"^"_RTN))="" D Q
183 ..S TOTMISS=TOTMISS+1,TOTRTN=TOTRTN+1
184 ..S RTNARRY(RTN)="2^"_VER_U_PTCH_"^^"
185 .X "ZL @RTN S INFOSITE=$T(+2)"
186 .S VERSITE=$P(INFOSITE,";",3),PTCHSITE=$P(INFOSITE,";",5)
187 .I VERSITE'=VER!(PTCHSITE'=PTCH) S BAD=1,OK=0
188 .E S BAD=0,OK=1
189 .S TOTBAD=TOTBAD+BAD,TOTOK=TOTOK+OK,TOTRTN=TOTRTN+1
190 .S RTNARRY(RTN)=BAD_U_VER_U_PTCH_U_VERSITE_U_PTCHSITE
191 S RTNARRY(0)=TOTRTN_U_TOTOK_U_TOTBAD_U_TOTMISS
192 Q
Note: See TracBrowser for help on using the repository browser.