DB2 ist ein Produkt der
IBM Corporation. Bitte Copyright- und Trademark-Hinweise beachten!
/****************************************************************REXX*/
/* EVENTMON Event Monitor starten/stoppen/Ausgabe aufbereiten */
/*-------------------------------------------------------------------*/
/* ARGUMENTE: Database - Datenbankname */
/* Path - (opt.) Event Monitor Log Path */
/* Comment - (opt.) Kommentar */
/*-------------------------------------------------------------------*/
/* CALLS....: DB2 - Command Interface */
/* DB2EVA - DB2 Event Analyzer */
/*-------------------------------------------------------------------*/
/* RCKGABE: n/a - DB2EVA wird aufgerufen */
/*-------------------------------------------------------------------*/
/* ŽNDERUNG : $RUB/22.09.97 - erste Version */
/* $RUB/29.09.97 - Korrekturen */
/* $RUB/14.10.97 - nach Refresh von DB2EVA */
/*********************************************************************/
parse arg parms
parse value parms with database "," path "," period "," comment
if RxFuncQuery("SysSleep") <> 0
then call RxFuncAdd "SysSleep", "RexxUtil", "SysSleep"
if RxFuncQuery("SysFileTree") <> 0
then call RxFuncAdd "SysFileTree", "RexxUtil", "SysFileTree"
/*********************************************************************/
/* Parameter Auswertungen */
/*********************************************************************/
if Database = ""
then do
Say "EVENTMON database[,path][,period][,comment]"
Say " path ..: e.g. G:\MONITOR (dflt=Current Directory)"
say " period : Event Monitoring Period in seconds (dflt=3600)"
say " comment: any comment to monitoring period"
say " LOG file will be written to current directory."
exit 20
end
Database = translate(Database)
If path = "" then path = directory()
if period = "" then period = 3600
If Comment = "" then Comment = "EVM Start: "date()" "Time()
msgout = "EVENTMON.LOG"
x = SysFileTree(path"\*.EVT","EVTFiles","F")
if x > 0 | EVTFiles.0 = 0
then evtlog = "00000000.EVT"
else do
evtlog = word(value("EVTFiles."evtfiles.0),5)
evtlog = filespec("N",evtlog)
/* evtno = substr(evtlog,1,8) */
/* evtlog = right(evtno+1,8,"0")||substr(evtlog,9)*/
end
/*********************************************************************/
/* Event Monitor starten */
/*********************************************************************/
Call SayMsg("EVENTMON - DB2/2 V2 Event Monitor Controller")
Call SayMsg(" Database.........: "Database)
Call SayMsg(" Event Log Path...: "Path"\"evtlog)
Call SayMsg(" Monitor Period...: "period)
Call SayMsg(" Comment..........: "Comment)
address CMD "@DB2 CONNECT RESET >nul"
address CMD "@DB2 CONNECT TO "database
if rc <> 0
then do
Call SayMsg("Probleme mit CONNECT, RC="rc)
Call Verarbeitungsende(20)
end
address CMD "DB2 SET EVENT MONITOR EVENTMON STATE=0 >nul"
address CMD "@DB2 DROP EVENT MONITOR EVENTMON >nul"
address CMD "DB2 CREATE EVENT MONITOR EVENTMON FOR DATABASE,TABLES,DEADLOCKS,CONNECTIONS,STATEMENTS,TRANSACTIONS",
"WRITE TO FILE '"path"' BUFFERSIZE 1 NONBLOCKED APPEND MANUALSTART"
/* "WRITE TO FILE '"path"' BUFFERSIZE 128 BLOCKED REPLACE MANUALSTART" */
if rc <> 0
then do
Call SayMsg("Probleme mit CREATE Event, RC="rc)
Call Verarbeitungsende(20)
end
address CMD "DB2 SET EVENT MONITOR EVENTMON STATE=1"
if rc <> 0
then do
Call SayMsg("Event Monitor konnte nicht aktiviert werden, RC="rc)
address CMD "@DB2 CONNECT RESET >nul"
Call Verarbeitungsende(20)
end
Call SayMsg(" Monitor started..: "time("N")" "date())
address CMD "@DB2 CONNECT RESET >nul"
/*********************************************************************/
/* Loop 3600 oder Unterbrechung, dann Event Monitor stoppen */
/*********************************************************************/
Say "<Ctrl>+<break> to end monitor period (auto after "period" secs)"
SIGNAL ON HALT NAME HaltEnter
Call SysSleep period
SIGNAL OFF HALT
Call SayMsg(" Monitor ended....: "time("N")" (abgelaufen)")
Resume:
address CMD "@DB2 CONNECT TO "database
address CMD "DB2 SET EVENT MONITOR EVENTMON STATE=0"
/*address CMD "DB2EVA -path "path*/
address CMD "DB2EVA -db "database" -evm EVENTMON -conn"
address CMD "@DB2 DROP EVENT MONITOR EVENTMON >nul"
address CMD "@DB2 CONNECT RESET >nul"
Call SayMsg(" Housekeeping Ev's: EVENTMON dropped")
Call SayMsg(" Housekeeping Logs: kept")
Call SayMsg(" Ende EVENTMON ")
/*********************************************************************/
/* Ende der Prozedur und MSG-File auf File-Server kopieren */
/*********************************************************************/
Exit 0
/*********************************************************************/
/* Anzeige/Ausgabe von Verarbeitungsprotokoll */
/*********************************************************************/
SayMsg: procedure expose MSGOut
parse arg MSG
Say MSG
Call LineOut MSGOut, Msg
Call Stream MSGOut,"C", "CLOSE"
return
/*********************************************************************/
/* HALT Condition */
/*********************************************************************/
HaltEnter:
Call SayMsg(" Monitor ended....: "time("N")" (unterbrochen)")
signal resume
return
/*********************************************************************/
/* Error Condition */
/*********************************************************************/
ERROR:
call SayMSG("DB011E Fehler in REXX Prozedur")
call VerarbeitungsEnde(20)
return
SyntaxErr:
Return
/*********************************************************************/
/* Ausgabe der Nachricht fr Verarbeitungsende */
/*********************************************************************/
VerarbeitungsEnde:
arg cc
Call SayMSG("DB010E EVENTMON V1 Verarbeitung endet mit RC="cc".",
date("o")"-"time());
exit cc
return
© Gernot Ruban