- KMPRUTL1 ;OAK/KAK/RAK - Resource Usage Monitor Utility ;1/30/13 08:32
- ;;2.0;CAPACITY MANAGEMENT - RUM;**1,2**;May 28, 2003;Build 12
- ;
- DATERNG(KMPUY,KMPUSTR,KMPUEND) ;-- date range
- ;---------------------------------------------------------------------
- ; KMPUY..... Value returned in four pieces:
- ; fmstartdate^fmenddate^ouputstartdate^outputenddate
- ;
- ; Piece one and two are the date ranges in fileman format.
- ; Piece three and four are the same dates in output format:
- ; dy-Mon-yr
- ;
- ; ********
- ; * NOTE *
- ; ********
- ; - The first piece will always be the earliest date entered.
- ;
- ; Optional Parameters:
- ;
- ; KMPUSTR... If defined, the earliest date that may be selected.
- ; (must be in fileman format)
- ;
- ; KMPUEND... If defined, the latest date that may be selected.
- ; (must be in fileman format)
- ;-----------------------------------------------------------------------
- ;
- N DATE1,DATE2,DIR,DIRUT,LINE,X,Y
- ;
- S KMPUY="",KMPUSTR=$G(KMPUSTR),KMPUEND=$G(KMPUEND)
- ;
- RANGE ;-- Ask date ranges
- S DIR(0)="DOA^"_$S(KMPUSTR:KMPUSTR,1:"")_":"_$S(KMPUEND:KMPUEND,1:"")_":E"
- S DIR("A")="Start with Date: "
- S:KMPUSTR DIR("B")=$$FMTE^XLFDT(KMPUSTR,2)
- S DIR("?")=" "
- S DIR("?",1)="Enter the starting date.",LINE=2
- ; if starting date.
- I KMPUSTR D
- .S DIR("?",LINE)="Date must not precede "_$$FMTE^XLFDT(KMPUSTR)
- .S LINE=LINE+1
- ; if ending date.
- I KMPUEND S DIR("?",LINE)="Date must not follow "_$$FMTE^XLFDT(KMPUEND)
- W ! D ^DIR I $D(DIRUT) S KMPUY="" Q
- S DATE1=Y
- S DIR("A")=" End with Date: "
- S:KMPUEND DIR("B")=$$FMTE^XLFDT(KMPUEND,2)
- S DIR("?",1)="Enter the ending date."
- D ^DIR G:Y="" RANGE I Y="^" S KMPUY="" Q
- S DATE2=Y
- ; Set earliest date into first piece.
- S KMPUY=$S(DATE2<DATE1:DATE2,1:DATE1)_U_$S(DATE2>DATE1:DATE2,1:DATE1)
- S $P(KMPUY,U,3)=$$FMTE^XLFDT($P(KMPUY,U))
- S $P(KMPUY,U,4)=$$FMTE^XLFDT($P(KMPUY,U,2))
- ;
- Q
- ;
- 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
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPRUTL1 6162 printed Feb 18, 2025@23:08:09 Page 2
- KMPRUTL1 ;OAK/KAK/RAK - Resource Usage Monitor Utility ;1/30/13 08:32
- +1 ;;2.0;CAPACITY MANAGEMENT - RUM;**1,2**;May 28, 2003;Build 12
- +2 ;
- DATERNG(KMPUY,KMPUSTR,KMPUEND) ;-- date range
- +1 ;---------------------------------------------------------------------
- +2 ; KMPUY..... Value returned in four pieces:
- +3 ; fmstartdate^fmenddate^ouputstartdate^outputenddate
- +4 ;
- +5 ; Piece one and two are the date ranges in fileman format.
- +6 ; Piece three and four are the same dates in output format:
- +7 ; dy-Mon-yr
- +8 ;
- +9 ; ********
- +10 ; * NOTE *
- +11 ; ********
- +12 ; - The first piece will always be the earliest date entered.
- +13 ;
- +14 ; Optional Parameters:
- +15 ;
- +16 ; KMPUSTR... If defined, the earliest date that may be selected.
- +17 ; (must be in fileman format)
- +18 ;
- +19 ; KMPUEND... If defined, the latest date that may be selected.
- +20 ; (must be in fileman format)
- +21 ;-----------------------------------------------------------------------
- +22 ;
- +23 NEW DATE1,DATE2,DIR,DIRUT,LINE,X,Y
- +24 ;
- +25 SET KMPUY=""
- SET KMPUSTR=$GET(KMPUSTR)
- SET KMPUEND=$GET(KMPUEND)
- +26 ;
- RANGE ;-- Ask date ranges
- +1 SET DIR(0)="DOA^"_$SELECT(KMPUSTR:KMPUSTR,1:"")_":"_$SELECT(KMPUEND:KMPUEND,1:"")_":E"
- +2 SET DIR("A")="Start with Date: "
- +3 if KMPUSTR
- SET DIR("B")=$$FMTE^XLFDT(KMPUSTR,2)
- +4 SET DIR("?")=" "
- +5 SET DIR("?",1)="Enter the starting date."
- SET LINE=2
- +6 ; if starting date.
- +7 IF KMPUSTR
- Begin DoDot:1
- +8 SET DIR("?",LINE)="Date must not precede "_$$FMTE^XLFDT(KMPUSTR)
- +9 SET LINE=LINE+1
- End DoDot:1
- +10 ; if ending date.
- +11 IF KMPUEND
- SET DIR("?",LINE)="Date must not follow "_$$FMTE^XLFDT(KMPUEND)
- +12 WRITE !
- DO ^DIR
- IF $DATA(DIRUT)
- SET KMPUY=""
- QUIT
- +13 SET DATE1=Y
- +14 SET DIR("A")=" End with Date: "
- +15 if KMPUEND
- SET DIR("B")=$$FMTE^XLFDT(KMPUEND,2)
- +16 SET DIR("?",1)="Enter the ending date."
- +17 DO ^DIR
- if Y=""
- GOTO RANGE
- IF Y="^"
- SET KMPUY=""
- QUIT
- +18 SET DATE2=Y
- +19 ; Set earliest date into first piece.
- +20 SET KMPUY=$SELECT(DATE2<DATE1:DATE2,1:DATE1)_U_$SELECT(DATE2>DATE1:DATE2,1:DATE1)
- +21 SET $PIECE(KMPUY,U,3)=$$FMTE^XLFDT($PIECE(KMPUY,U))
- +22 SET $PIECE(KMPUY,U,4)=$$FMTE^XLFDT($PIECE(KMPUY,U,2))
- +23 ;
- +24 QUIT
- +25 ;
- 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