KMPRUTL1 ;SFISC/KAK/RAK - Resource Usage Monitor Utility ; 03 Mar 2000 1:45 PM
;;1.0;CAPACITY MANAGEMENT - RUM;**1,2**;Dec 09, 1998
;
ENVCHECK(KMPRENV,KMPRQIET) ;-- environment check.
;-----------------------------------------------------------------------
; KMPRENV... Result of environment check in format:
; KMPRENV=Number^Text
; 1-99: system status (not an error condition).
; 0 - RUM turned on and background job queued
; 1 - RUM is not turned on
; 2 - 'KMPR BACKGROUND' job has been queued to run
;
; 100>: error condition.
; 100 - RUM not available for 'OS' at this time
; 200 - RUM is on but the option 'KMPR BACKGROUND DRIVER'
; is not scheduled to run."
; 201 - The RUM background driver option [KMPR BACKGROUND
; DRIVER] is missing
;
; KMPRQIET.. Output message: 0 - output message (not quiet).
; 1 - do not output message (quiet).
;-----------------------------------------------------------------------
;
K KMPRENV
S KMPRENV="0^RUM turned on and background job queued"
S KMPRQIET=+$G(KMPRQIET)
;
N IEN,IEN1,TEXT
;
; check for operating system availability.
S TEXT=$P($G(^%ZOSF("OS")),U)
I TEXT'["DSM"&(TEXT'["OpenM") D Q
.S KMPRENV="100^RUM not available for '"_TEXT_"' at this time"
.D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
;
; if rum not started quit.
I '$G(^%ZTSCH("LOGRSRC")) D Q
.S KMPRENV="1^RUM is not turned on"
.D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
;
S TEXT="KMPR BACKGROUND DRIVER"
S IEN=$O(^DIC(19,"B",TEXT,0))
I 'IEN D Q
.S KMPRENV="201^The RUM background driver option [KMPR BACKGROUND DRIVER] is missing"
.D:'KMPRQIET ENVOUTPT(KMPRENV,1,1)
;
S IEN1=$O(^DIC(19.2,"B",IEN,0))
I 'IEN1!($P($G(^DIC(19.2,+IEN1,1)),U)']"") D
.S KMPRENV="200^RUM is on but the option '"_TEXT_"' is not scheduled to run"
;
Q:KMPRQIET
D ENVOUTPT(KMPRENV,1,1) I +KMPRENV<100 Q
;
K DIR S DIR(0)="YO",DIR("B")="YES"
S DIR("A")="Do you want me to queue this option to run every night at 1 a.m."
W ! D ^DIR Q:'Y
;
D QUEBKG
;
W !
S KMPRENV="0^RUM turned on and background job queued"
;
Q
;
ENVOUTPT(KMPRENV,KMPRHILT,KMPRCNTR) ;-- environment check output.
;-----------------------------------------------------------------------
; KMPRENV... Environment output (see ENVCHECK).
; KMPRHILT.. Highlight text: 0 - do not highlight.
; 1 - highlight text.
; KMPRCNTR.. Center text: 0 - do not center text.
; 1 - center text.
;-----------------------------------------------------------------------
;
S KMPRENV=$G(KMPRENV),KMPRHILT=+$G(KMPRHILT),KMPRCNTR=+$G(KMPRCNTR)
Q:KMPRENV=""
;
N INDENT,IORVOFF,IORVON,TEXT
S X="IORVOFF;IORVON" D ENDR^%ZISS
S KMPRENV=$P(KMPRENV,U,2)
S:KMPRHILT KMPRENV=IORVON_" "_KMPRENV_" "_IORVOFF
S TEXT(1)=KMPRENV
I KMPRCNTR S INDENT=80-$L(TEXT(1))\2,TEXT(1,"F")="!?"_INDENT
D EN^DDIOL(.TEXT)
;
Q
;
PKG(PACKAGE) ; Select Package(s)
; Output Variable:
; PACKAGE = Contains array of package names
; = PACKAGE("^") if DTOUT or DUOUT
;
N DIR,DTOUT,DUOUT,Y
S DIR(0)="FO^1:999:0"
F D Q:$D(DTOUT)!$D(DUOUT)!(Y="")
.S DIR("A")="Select Package Namespace" D ^DIR I Y'="" S PACKAGE(Y)=""
.I Y=" " W !,*7,"Please enter a valid package namespace.",!
S:$D(DTOUT)!$D(DUOUT)!('$D(PACKAGE)) PACKAGE("^")=""
W !
Q
;
QUEBKG ;-- queue background job KMPR BACKGROUND DRIVER
N DA,DIK,FDA,ERROR,IEN,IEN1,IENZ,TEXT,X,Y,Z
S:'$G(DT) DT=$$DT^XLFDT
S TEXT="KMPR BACKGROUND DRIVER"
S IEN=$O(^DIC(19,"B",TEXT,0)) Q:'IEN
S IEN1=$O(^DIC(19.2,"B",IEN,0))
; if already in file 19.2 then kill.
I IEN1 S DIK="^DIC(19.2,",DA=IEN1 D ^DIK
; schedule for tomorrow@1am.
S FDA($J,19.2,"+1,",.01)=IEN
; queued to run at what time - set to tomorrow@1am
S FDA($J,19.2,"+1,",2)=$$FMADD^XLFDT(DT,1)_".01"
; rescheduling frequency.
S FDA($J,19.2,"+1,",6)="1D"
D UPDATE^DIE("","FDA($J)",.IENZ,"ERROR")
I $D(ERROR) D MSG^DIALOG("W","",60,10,"ERROR")
Q
KMPRUTL1 ;SFISC/KAK/RAK - Resource Usage Monitor Utility ; 03 Mar 2000 1:45 PM
+1 ;;1.0;CAPACITY MANAGEMENT - RUM;**1,2**;Dec 09, 1998
+2 ;
ENVCHECK(KMPRENV,KMPRQIET) ;-- environment check.
+1 ;-----------------------------------------------------------------------
+2 ; KMPRENV... Result of environment check in format:
+3 ; KMPRENV=Number^Text
+4 ; 1-99: system status (not an error condition).
+5 ; 0 - RUM turned on and background job queued
+6 ; 1 - RUM is not turned on
+7 ; 2 - 'KMPR BACKGROUND' job has been queued to run
+8 ;
+9 ; 100>: error condition.
+10 ; 100 - RUM not available for 'OS' at this time
+11 ; 200 - RUM is on but the option 'KMPR BACKGROUND DRIVER'
+12 ; is not scheduled to run."
+13 ; 201 - The RUM background driver option [KMPR BACKGROUND
+14 ; DRIVER] is missing
+15 ;
+16 ; KMPRQIET.. Output message: 0 - output message (not quiet).
+17 ; 1 - do not output message (quiet).
+18 ;-----------------------------------------------------------------------
+19 ;
+20 KILL KMPRENV
+21 SET KMPRENV="0^RUM turned on and background job queued"
+22 SET KMPRQIET=+$GET(KMPRQIET)
+23 ;
+24 NEW IEN,IEN1,TEXT
+25 ;
+26 ; check for operating system availability.
+27 SET TEXT=$PIECE($GET(^%ZOSF("OS")),U)
+28 IF TEXT'["DSM"&(TEXT'["OpenM")
Begin DoDot:1
+29 SET KMPRENV="100^RUM not available for '"_TEXT_"' at this time"
+30 IF 'KMPRQIET
DO ENVOUTPT(KMPRENV,1,1)
End DoDot:1
QUIT
+31 ;
+32 ; if rum not started quit.
+33 IF '$GET(^%ZTSCH("LOGRSRC"))
Begin DoDot:1
+34 SET KMPRENV="1^RUM is not turned on"
+35 IF 'KMPRQIET
DO ENVOUTPT(KMPRENV,1,1)
End DoDot:1
QUIT
+36 ;
+37 SET TEXT="KMPR BACKGROUND DRIVER"
+38 SET IEN=$ORDER(^DIC(19,"B",TEXT,0))
+39 IF 'IEN
Begin DoDot:1
+40 SET KMPRENV="201^The RUM background driver option [KMPR BACKGROUND DRIVER] is missing"
+41 IF 'KMPRQIET
DO ENVOUTPT(KMPRENV,1,1)
End DoDot:1
QUIT
+42 ;
+43 SET IEN1=$ORDER(^DIC(19.2,"B",IEN,0))
+44 IF 'IEN1!($PIECE($GET(^DIC(19.2,+IEN1,1)),U)']"")
Begin DoDot:1
+45 SET KMPRENV="200^RUM is on but the option '"_TEXT_"' is not scheduled to run"
End DoDot:1
+46 ;
+47 IF KMPRQIET
QUIT
+48 DO ENVOUTPT(KMPRENV,1,1)
IF +KMPRENV<100
QUIT
+49 ;
+50 KILL DIR
SET DIR(0)="YO"
SET DIR("B")="YES"
+51 SET DIR("A")="Do you want me to queue this option to run every night at 1 a.m."
+52 WRITE !
DO ^DIR
IF 'Y
QUIT
+53 ;
+54 DO QUEBKG
+55 ;
+56 WRITE !
+57 SET KMPRENV="0^RUM turned on and background job queued"
+58 ;
+59 QUIT
+60 ;
ENVOUTPT(KMPRENV,KMPRHILT,KMPRCNTR) ;-- environment check output.
+1 ;-----------------------------------------------------------------------
+2 ; KMPRENV... Environment output (see ENVCHECK).
+3 ; KMPRHILT.. Highlight text: 0 - do not highlight.
+4 ; 1 - highlight text.
+5 ; KMPRCNTR.. Center text: 0 - do not center text.
+6 ; 1 - center text.
+7 ;-----------------------------------------------------------------------
+8 ;
+9 SET KMPRENV=$GET(KMPRENV)
SET KMPRHILT=+$GET(KMPRHILT)
SET KMPRCNTR=+$GET(KMPRCNTR)
+10 IF KMPRENV=""
QUIT
+11 ;
+12 NEW INDENT,IORVOFF,IORVON,TEXT
+13 SET X="IORVOFF;IORVON"
DO ENDR^%ZISS
+14 SET KMPRENV=$PIECE(KMPRENV,U,2)
+15 IF KMPRHILT
SET KMPRENV=IORVON_" "_KMPRENV_" "_IORVOFF
+16 SET TEXT(1)=KMPRENV
+17 IF KMPRCNTR
SET INDENT=80-$LENGTH(TEXT(1))\2
SET TEXT(1,"F")="!?"_INDENT
+18 DO EN^DDIOL(.TEXT)
+19 ;
+20 QUIT
+21 ;
PKG(PACKAGE) ; Select Package(s)
+1 ; Output Variable:
+2 ; PACKAGE = Contains array of package names
+3 ; = PACKAGE("^") if DTOUT or DUOUT
+4 ;
+5 NEW DIR,DTOUT,DUOUT,Y
+6 SET DIR(0)="FO^1:999:0"
+7 FOR
Begin DoDot:1
+8 SET DIR("A")="Select Package Namespace"
DO ^DIR
IF Y'=""
SET PACKAGE(Y)=""
+9 IF Y=" "
WRITE !,*7,"Please enter a valid package namespace.",!
End DoDot:1
IF $DATA(DTOUT)!$DATA(DUOUT)!(Y="")
QUIT
+10 IF $DATA(DTOUT)!$DATA(DUOUT)!('$DATA(PACKAGE))
SET PACKAGE("^")=""
+11 WRITE !
+12 QUIT
+13 ;
QUEBKG ;-- queue background job KMPR BACKGROUND DRIVER
+1 NEW DA,DIK,FDA,ERROR,IEN,IEN1,IENZ,TEXT,X,Y,Z
+2 IF '$GET(DT)
SET DT=$$DT^XLFDT
+3 SET TEXT="KMPR BACKGROUND DRIVER"
+4 SET IEN=$ORDER(^DIC(19,"B",TEXT,0))
IF 'IEN
QUIT
+5 SET IEN1=$ORDER(^DIC(19.2,"B",IEN,0))
+6 ; if already in file 19.2 then kill.
+7 IF IEN1
SET DIK="^DIC(19.2,"
SET DA=IEN1
DO ^DIK
+8 ; schedule for tomorrow@1am.
+9 SET FDA($JOB,19.2,"+1,",.01)=IEN
+10 ; queued to run at what time - set to tomorrow@1am
+11 SET FDA($JOB,19.2,"+1,",2)=$$FMADD^XLFDT(DT,1)_".01"
+12 ; rescheduling frequency.
+13 SET FDA($JOB,19.2,"+1,",6)="1D"
+14 DO UPDATE^DIE("","FDA($J)",.IENZ,"ERROR")
+15 IF $DATA(ERROR)
DO MSG^DIALOG("W","",60,10,"ERROR")
+16 QUIT