Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BLRENTRY

BLRENTRY.m

Go to the documentation of this file.
  1. BLRENTRY ; IHS/MSC/MKK - Monitor for Debug Global ; 22-Oct-2013 09:22 ; MKK
  1. ;;5.2;LR;**1033**;NOV 01, 1997
  1. ;
  1. EEP ; EP - Ersatz Entry
  1. D EEP^BLRGMENU
  1. Q
  1. ;
  1. ; Make sure ^BLRENTRY global doesn't get too large
  1. CHKENTRY ; EP
  1. Q ; For now, don't do this.
  1. ;
  1. NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
  1. ;
  1. S CURDIR=$$SUCICDIR()
  1. ;
  1. S GLOBAL="BLRENTRY"
  1. ;
  1. ; GLOSIZE returned as # of blocks.
  1. S X=##class(%Library.GlobalEdit).GetGlobalSize(CURDIR,GLOBAL,.GLOSIZE,,1)
  1. ;
  1. ; MBSIZE = Global size in megabytes. Assumes standard configuration of 1 block = 8 KB = 8192 Bytes
  1. S MBSIZE=(GLOSIZE*8192)/(1024*1024)
  1. ;
  1. Q:+$G(MBSIZE)<=10 ; 10 MB is the maximum allowed
  1. ;
  1. ; ^BLRENTRY size is > 10 MB, start over
  1. S GLOBAL="^BLRENTRY"
  1. K @GLOBAL
  1. ;
  1. D KEEPTRAK(CURDIR,MBSIZE)
  1. ;
  1. Q
  1. ;
  1. SUCICDIR() ; Set UCI's Current DIRectory
  1. NEW CURNAME,SUCICDIR
  1. ;
  1. S SUCICDIR=$G(^BLRENTRY("A"))
  1. Q:$L(SUCICDIR) SUCICDIR ; If already stored, skip rest of code
  1. ;
  1. S CURNAME=$NAMESPACE ; Get UCI Namespace name
  1. ;
  1. ; The following is necessary because a Cache system can be setup to
  1. ; have a default directory that IS NOT the cache.dat file's direc-
  1. ; tory. If the S $NAMESPACE= command is not made, the GetDirectory()
  1. ; call does NOT return the cache.dat file's directory, but the "default"
  1. ; "file output" directory.
  1. S $NAMESPACE="%SYS" ; "Change directory" to %SYS, which will ALWAYS exist
  1. S $NAMESPACE=CURNAME ; "Change directory" back to Namespace directory
  1. ;
  1. ; GetDirectory() will now retrieve cache.dat file directory
  1. S SUCICDIR=##class(%File).GetDirectory()
  1. ;
  1. ; Store cache.dat directory
  1. S ^BLRENTRY("A")=SUCICDIR
  1. ;
  1. Q SUCICDIR
  1. ;
  1. ;
  1. KEEPTRAK(CURDIR,MBSIZE) ; EP - Keep track of resets
  1. NEW CNT,NOWDATE
  1. ;
  1. ; Store cache.dat directory
  1. S ^BLRENTRY("A")=CURDIR
  1. ;
  1. S NOWDATE=$$DT^XLFDT
  1. ;
  1. ; Setup ^XTMP per SAC, if necessary
  1. I $L($G(^XTMP("BLRENTRY",0)))<1 D
  1. . S $P(^XTMP("BLRENTRY",0),"^",2)=$$DT^XLFDT
  1. . S $P(^XTMP("BLRENTRY",0),"^",3)="Debug Global ^BLRENTRY Report"
  1. ;
  1. ; Set/Reset "purge" date
  1. S $P(^XTMP("BLRENTRY",0),"^")=$$HTFM^XLFDT(+$H+90)
  1. ;
  1. S CNT=1+$O(^XTMP("BLRENTRY","GLOSIZE",NOWDATE,"A"),-1)
  1. S ^XTMP("BLRENTRY","GLOSIZE",NOWDATE,CNT)=MBSIZE_"^"_$$HTE^XLFDT($H,"2MZ")
  1. ;
  1. D:CNT=2 TWICEDAY(NOWDATE)
  1. D:CNT>5 STOPIT(NOWDATE) ; Reset 'Take Snapshots' field
  1. ;
  1. Q
  1. ;
  1. TWICEDAY(NOWDATE) ; EP - If Twice in one day, alert folks once a day
  1. Q:$D(^XTMP("BLRENTRY","GLOSIZE",NOWDATE,"ALERTED"))
  1. ;
  1. NEW STR,INDENT
  1. ;
  1. S ^XTMP("BLRENTRY","GLOSIZE",NOWDATE,"ALERTED",$H)=""
  1. ;
  1. S INDENT=$J("",5)
  1. S STR(1)=INDENT_$$MAKBANNR("BLRENTRY Global Reset Twice In One Day!",50,">","<")
  1. S STR(2)=" "
  1. S STR(3)=INDENT_"The BLRENTRY Global has been Reset twice Today."
  1. S STR(4)=" "
  1. S STR(5)=INDENT_"Such an event is indicative of a runaway process."
  1. S STR(6)=" "
  1. S STR(7)=INDENT_"Please Contact the Site Manager and inform them"
  1. S STR(8)=INDENT_"of this e-mail IMMEDIATELY."
  1. ;
  1. D MAILALMI^BLRUTIL3("BLRENTRY Global Too Large",.STR,"BLRENTRY Monitor",1)
  1. Q
  1. ;
  1. STOPIT(NOWDATE) ; EP - BLRENTRY Global reset. Emergency STOP.
  1. NEW ERRS,FDA,INDENT,STR
  1. ;
  1. ; Set 'Take Snapshots' Field to NO
  1. D ^XBFMK
  1. S FDA(9009029,DUZ(2)_",",1)=0
  1. D FILE^DIE("K","FDA","ERRS")
  1. ;
  1. I $D(ERRS) D Q ; If errors, store and quit
  1. . S ^TMP("BLRENTRY",$J,DUZ(2),"1")=0
  1. . M ^TMP("BLRENTRY",$J,DUZ(2),"ERRS")=ERRS
  1. . S ^TMP("BLRENTRY",$J,DUZ(2),"FORCED 'TAKE SNAPSHOTS' TO OFF **FAILED**",$H)=""
  1. ;
  1. S ^XTMP("BLRENTRY","GLOSIZE",NOWDATE,"FORCED 'TAKE SNAPSHOTS' TO OFF",$H)=$G(DUZ(2))
  1. ;
  1. S INDENT=$J("",5)
  1. ;
  1. S STR(1)=INDENT_$$MAKBANNR("BLR MASTER CONTROL File Reset!",50,">","<")
  1. S STR(2)=" "
  1. S STR(3)=INDENT_"The 'TAKE SNAPSHOTS' field of the BLR MASTER"
  1. S STR(4)=INDENT_"CONTROL file for Entry "_DUZ(2)_" has been"
  1. S STR(5)=INDENT_"forcibly set to OFF."
  1. S STR(6)=" "
  1. S STR(7)=INDENT_"This event was caused by the BLRENTRY MONITOR"
  1. S STR(8)=INDENT_"process when the ^BLRENTRY global was reset more"
  1. S STR(9)=INDENT_"than 5 times in one day."
  1. S STR(10)=" "
  1. S STR(11)=INDENT_"It is indicative of a runaway process."
  1. S STR(12)=" "
  1. S STR(13)=INDENT_"Please Contact the Site Manager and inform them"
  1. S STR(14)=INDENT_"of this e-mail IMMEDIATELY."
  1. ;
  1. D MAILALMI^BLRUTIL3("BLR MASTER CONTROL FILE 'TAKE SNAPSHOTS' FIELD RESET",.STR,"BLRENTRY Monitor",1)
  1. ;
  1. Q
  1. ;
  1. MAKBANNR(ASTR,RM,LF,RF) ; EP - MaKe a BANNeR string
  1. NEW HALFLEN,LEFT,TMPSTR,RIGHT
  1. ;
  1. ; Make certain Right Margin (RM) is set
  1. S:+$G(RM)<1 RM=$G(IOM,80)
  1. ;
  1. ; Adjust RM, if necessary
  1. S:$L($G(ASTR))>RM RM=$L(ASTR)+4
  1. ;
  1. ; Make certain LF and RF variables set
  1. I $G(LF)="",$G(RF)="" S (LF,RF)="="
  1. I $G(RF)="",$G(LF)'="" S RF=LF
  1. I $G(LF)="",$G(RF)'="" S LF=RF
  1. ;
  1. ; Set the midpoint variable, minus half the length of the string
  1. S HALFLEN=(RM\2)-(($L(ASTR))\2)
  1. ;
  1. S $P(LEFT,LF,HALFLEN)="" ; Left side of the string
  1. S $P(RIGHT,RF,HALFLEN)="" ; Right side of the string
  1. ;
  1. ; Make the Banner string
  1. S:$L(ASTR) TMPSTR=LEFT_" "_ASTR_" "_RIGHT
  1. S:$L(ASTR)<1 TMPSTR=LF_LEFT_RIGHT_RF
  1. ;
  1. ; If necessary, adjust Banner string's length
  1. S:$L(TMPSTR)<RM TMPSTR=TMPSTR_RF
  1. S:$L(TMPSTR)>RM TMPSTR=$E(TMPSTR,1,RM)
  1. ;
  1. Q TMPSTR
  1. ;
  1. TESTSHOW ; EP - Test -- Just SHOW the size
  1. NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
  1. ;
  1. S CURDIR=$$SUCICDIR()
  1. ;
  1. S GLOBAL="BLRENTRY"
  1. ;
  1. ; GLOSIZE returned as # of blocks.
  1. S X=##class(%Library.GlobalEdit).GetGlobalSize(CURDIR,GLOBAL,.GLOSIZE,,1)
  1. ;
  1. ; MBSIZE = Global size in megabytes. Assumes standard configuration of 1 block = 8 KB = 8192 Bytes
  1. S MBSIZE=(GLOSIZE*8192)/(1024*1024)
  1. ;
  1. S GLOSTR=$FN(GLOSIZE,"",2)
  1. S MBSTR=$FN(MBSIZE,"",2)
  1. S JUSTSIZE=$S($L(GLOSTR)>$L(MBSTR):$L(GLOSTR),$L(MBSTR)>$L(GLOSTR):$L(MBSTR),1:$L(GLOSTR))
  1. ;
  1. W !!,"Size of ^BLRENTRY",!,?4,"GLOSIZE = ",$J(GLOSTR,JUSTSIZE)," blocks",!,?5,"MBSIZE = ",$J(MBSTR,JUSTSIZE)," MB",!!
  1. Q