source: FOIAVistA/trunk/r/CAPACITY_MANAGEMENT_RUM-KMPR/KMPRUTL1.m@ 1751

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

initial load of FOIAVistA 6/30/08 version

File size: 5.8 KB
Line 
1KMPRUTL1 ;OAK/KAK/RAK - Resource Usage Monitor Utility ;11/19/04 10:32
2 ;;2.0;CAPACITY MANAGEMENT - RUM;**1**;May 28, 2003
3 ;
4DATERNG(KMPUY,KMPUSTR,KMPUEND) ;-- date range
5 ;---------------------------------------------------------------------
6 ; KMPUY..... Value returned in four pieces:
7 ; fmstartdate^fmenddate^ouputstartdate^outputenddate
8 ;
9 ; Piece one and two are the date ranges in fileman format.
10 ; Piece three and four are the same dates in output format:
11 ; dy-Mon-yr
12 ;
13 ; ********
14 ; * NOTE *
15 ; ********
16 ; - The first piece will always be the earliest date entered.
17 ;
18 ; Optional Parameters:
19 ;
20 ; KMPUSTR... If defined, the earliest date that may be selected.
21 ; (must be in fileman format)
22 ;
23 ; KMPUEND... If defined, the latest date that may be selected.
24 ; (must be in fileman format)
25 ;-----------------------------------------------------------------------
26 ;
27 N DATE1,DATE2,DIR,DIRUT,LINE,X,Y
28 ;
29 S KMPUY="",KMPUSTR=$G(KMPUSTR),KMPUEND=$G(KMPUEND)
30 ;
31RANGE ;-- Ask date ranges
32 S DIR(0)="DOA^"_$S(KMPUSTR:KMPUSTR,1:"")_":"_$S(KMPUEND:KMPUEND,1:"")_":E)"
33 S DIR("A")="Start with Date: "
34 S:KMPUSTR DIR("B")=$$FMTE^XLFDT(KMPUSTR,2)
35 S DIR("?")=" "
36 S DIR("?",1)="Enter the starting date.",LINE=2
37 ; if starting date.
38 I KMPUSTR D
39 .S DIR("?",LINE)="Date must not precede "_$$FMTE^XLFDT(KMPUSTR)
40 .S LINE=LINE+1
41 ; if ending date.
42 I KMPUEND S DIR("?",LINE)="Date must not follow "_$$FMTE^XLFDT(KMPUEND)
43 W ! D ^DIR I $D(DIRUT) S KMPUY="" Q
44 S DATE1=Y
45 S DIR("A")=" End with Date: "
46 S:KMPUEND DIR("B")=$$FMTE^XLFDT(KMPUEND,2)
47 S DIR("?",1)="Enter the ending date."
48 D ^DIR G:Y="" RANGE I Y="^" S KMPUY="" Q
49 S DATE2=Y
50 ; Set earliest date into first piece.
51 S KMPUY=$S(DATE2<DATE1:DATE2,1:DATE1)_U_$S(DATE2>DATE1:DATE2,1:DATE1)
52 S $P(KMPUY,U,3)=$$FMTE^XLFDT($P(KMPUY,U))
53 S $P(KMPUY,U,4)=$$FMTE^XLFDT($P(KMPUY,U,2))
54 ;
55 Q
56 ;
57ENVCHECK(KMPRENV,KMPRQIET) ;-- environment check.
58 ;-----------------------------------------------------------------------
59 ; KMPRENV... Result of environment check in format:
60 ; KMPRENV=Number^Text
61 ; 1-99: system status (not an error condition).
62 ; 0 - RUM turned on and background job queued
63 ; 1 - RUM is not turned on
64 ; 2 - 'KMPR BACKGROUND' job has been queued to run
65 ;
66 ; 100>: error condition.
67 ; 100 - RUM not available for 'OS' at this time
68 ; 200 - RUM is on but the option 'KMPR BACKGROUND DRIVER'
69 ; is not scheduled to run."
70 ; 201 - The RUM background driver option [KMPR BACKGROUND
71 ; DRIVER] is missing
72 ;
73 ; KMPRQIET.. Output message: 0 - output message (not quiet).
74 ; 1 - do not output message (quiet).
75 ;-----------------------------------------------------------------------
76 ;
77 K KMPRENV
78 S KMPRENV="0^RUM turned on and background job queued"
79 S KMPRQIET=+$G(KMPRQIET)
80 ;
81 N IEN,IEN1,TEXT
82 ;
83 ; check for operating system availability.
84 S TEXT=$P($G(^%ZOSF("OS")),U)
85 I TEXT'["DSM"&(TEXT'["OpenM") D Q
86 .S KMPRENV="100^RUM not available for '"_TEXT_"' at this time"
87 .D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
88 ;
89 ; if rum not started quit.
90 I '$G(^%ZTSCH("LOGRSRC")) D Q
91 .S KMPRENV="1^RUM is not turned on"
92 .D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
93 ;
94 S TEXT="KMPR BACKGROUND DRIVER"
95 S IEN=$O(^DIC(19,"B",TEXT,0))
96 I 'IEN D Q
97 .S KMPRENV="201^The RUM background driver option [KMPR BACKGROUND DRIVER] is missing"
98 .D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
99 ;
100 S IEN1=$O(^DIC(19.2,"B",IEN,0))
101 I 'IEN1!($P($G(^DIC(19.2,+IEN1,1)),U)']"") D
102 .S KMPRENV="200^RUM is on but the option '"_TEXT_"' is not scheduled to run"
103 ;
104 Q:KMPRQIET
105 D ENVOUTPT(KMPRENV,1,1) I +KMPRENV<100 Q
106 ;
107 K DIR S DIR(0)="YO",DIR("B")="YES"
108 S DIR("A")="Do you want me to queue this option to run every night at 1 a.m."
109 W ! D ^DIR Q:'Y
110 ;
111 D QUEBKG
112 ;
113 W !
114 S KMPRENV="0^RUM turned on and background job queued"
115 ;
116 Q
117 ;
118ENVOUTPT(KMPRENV,KMPRHILT,KMPRCNTR) ;-- environment check output.
119 ;-----------------------------------------------------------------------
120 ; KMPRENV... Environment output (see ENVCHECK).
121 ; KMPRHILT.. Highlight text: 0 - do not highlight.
122 ; 1 - highlight text.
123 ; KMPRCNTR.. Center text: 0 - do not center text.
124 ; 1 - center text.
125 ;-----------------------------------------------------------------------
126 ;
127 S KMPRENV=$G(KMPRENV),KMPRHILT=+$G(KMPRHILT),KMPRCNTR=+$G(KMPRCNTR)
128 Q:KMPRENV=""
129 ;
130 N INDENT,IORVOFF,IORVON,TEXT
131 S X="IORVOFF;IORVON" D ENDR^%ZISS
132 S KMPRENV=$P(KMPRENV,U,2)
133 S:KMPRHILT KMPRENV=IORVON_" "_KMPRENV_" "_IORVOFF
134 S TEXT(1)=KMPRENV
135 I KMPRCNTR S INDENT=80-$L(TEXT(1))\2,TEXT(1,"F")="!?"_INDENT
136 D EN^DDIOL(.TEXT)
137 ;
138 Q
139 ;
140PKG(PACKAGE) ; Select Package(s)
141 ; Output Variable:
142 ; PACKAGE = Contains array of package names
143 ; = PACKAGE("^") if DTOUT or DUOUT
144 ;
145 N DIR,DTOUT,DUOUT,Y
146 S DIR(0)="FO^1:999:0"
147 F D Q:$D(DTOUT)!$D(DUOUT)!(Y="")
148 .S DIR("A")="Select Package Namespace" D ^DIR I Y'="" S PACKAGE(Y)=""
149 .I Y=" " W !,*7,"Please enter a valid package namespace.",!
150 S:$D(DTOUT)!$D(DUOUT)!('$D(PACKAGE)) PACKAGE("^")=""
151 W !
152 Q
153 ;
154QUEBKG ;-- queue background job KMPR BACKGROUND DRIVER
155 N DA,DIK,FDA,ERROR,IEN,IEN1,IENZ,TEXT,X,Y,Z
156 S:'$G(DT) DT=$$DT^XLFDT
157 S TEXT="KMPR BACKGROUND DRIVER"
158 S IEN=$O(^DIC(19,"B",TEXT,0)) Q:'IEN
159 S IEN1=$O(^DIC(19.2,"B",IEN,0))
160 ; if already in file 19.2 then kill.
161 I IEN1 S DIK="^DIC(19.2,",DA=IEN1 D ^DIK
162 ; schedule for tomorrow@1am.
163 S FDA($J,19.2,"+1,",.01)=IEN
164 ; queued to run at what time - set to tomorrow@1am
165 S FDA($J,19.2,"+1,",2)=$$FMADD^XLFDT(DT,1)_".01"
166 ; rescheduling frequency.
167 S FDA($J,19.2,"+1,",6)="1D"
168 D UPDATE^DIE("","FDA($J)",.IENZ,"ERROR")
169 I $D(ERROR) D MSG^DIALOG("W","",60,10,"ERROR")
170 Q
Note: See TracBrowser for help on using the repository browser.