OS/2 Code - Detail View


Date

Name

Plattform

Language

Kurzbeschreibung

Owner

Link

17.11.2001

SNAPSHOT.REXX

OS/2

REXX

DB2 Snapshot Steuerung

Gernot Ruban

 

DB2 ist ein Produkt der
IBM Corporation. Bitte
Copyright-  und Trademark-Hinweise beachten!

/****************************************************************REXX*/
/* SNAPSHOT   DB2 Snapshot fr Intervall, interaktiv                 */
/*-------------------------------------------------------------------*/
/* ARGUMENTE: Node     - Node/Instance                               */
/*            Database - (opt.) Database                             */
/*            Comment  - (opt.) Kommentar                            */
/*-------------------------------------------------------------------*/
/* CALLS....: DB2      - Command Interface                           */
/*-------------------------------------------------------------------*/
/* RCKGABE:  n/a      - Datei wird rausgeschrieben                  */
/*                       0 - alles ok                                */
/*                       4 - Bereinigung erforderlich                */
/*                       20- Fehler                                  */
/*-------------------------------------------------------------------*/
/* ŽNDERUNG : $RUB/22.09.97 - erste Version                          */
/*            $RUB/24.09.97 - wenn DB fehlt, ALL DATABASES           */
/*********************************************************************/

/*********************************************************************/
/* Parameter Auswertungen                                            */
/*********************************************************************/
    parse upper arg parms
    parse value parms with node "," database "," comment
   
    If node = ""                
    then do
         Say "SNAPSHOT node[,database][,comment]"
         Say "         node=Instance, lokale Inst.=DB2"
         exit 20
    end

/*********************************************************************/
/* REXX Utilities aus DLL bei Bedarf hinzuladen                      */
/*********************************************************************/
    if RxFuncQuery("SQLDBS")        <> 0
    then call RXFuncAdd "SQLDBS",        "SQLAR",    "SQLDBS"
    if RxFuncQuery("SQLEXEC")       <> 0
    then call RXFuncAdd "SQLEXEC",       "SQLAR",    "SQLEXEC"
    if RxFuncQuery("SysSleep")      <> 0
    then call RxFuncAdd "SysSleep",      "RexxUtil", "SysSleep"
    if RxFuncQuery("SysSearchPath")      <> 0
    then call RxFuncAdd "SysSearchPath", "RexxUtil", "SysSearchPath"
    if RxFuncQuery("SysFileDelete")      <> 0
    then call RxFuncAdd "SysFileDelete", "RexxUtil", "SysFileDelete"

/*********************************************************************/
/* Snapshot File Name ermitteln, Header ausgeben                     */
/*********************************************************************/
    address CMD "@CLS"

    snapfile = "SNAP"right(date("D"),3,"0")
    ext = "001"
    sf = SysSearchPath("PATH",snapfile"."ext)
    do while sf <> ""
       ext = ext + 1
       sf = SysSearchPath("PATH",snapfile"."right(ext,3,"0"))
    end /* do */
    snapfile = Snapfile"."right(ext,3,"0")
    msgout = snapfile
            
/*********************************************************************/
/* Snapshot starten                                                  */
/*********************************************************************/
    Call SysFileDelete MsgOut
    Call SayMsg("SNAPSHOT - DB2/2 V2 Monitor Snapshot")
    sf = SysSearchPath("PATH",snapfile)   
    Call SayMsg(" Snapshot Output: "sf)
    Call SayMsg(" Node...........: "node)
    Call SayMsg(" Database.......: "database)
    Call SayMsg(" Comment........: "Comment)  
    Call SayMsg(" Vorbereit.Start: "time("N")" "date())

    address CMD "@DB2 DETACH >nul"
    address CMD "@DB2 ATTACH TO "node
    address CMD "@DB2 UPDATE MONITOR SWITCHES USING BUFFERPOOL ON"
    address CMD "@DB2 UPDATE MONITOR SWITCHES USING SORT ON >nul"
    address CMD "@DB2 UPDATE MONITOR SWITCHES USING LOCK ON >nul"
    address CMD "@DB2 UPDATE MONITOR SWITCHES USING TABLE ON >nul"
    address CMD "@DB2 UPDATE MONITOR SWITCHES USING UOW ON >nul"
    address CMD "@DB2 UPDATE MONITOR SWITCHES USING STATEMENT ON >nul"
    if database <>"" then address CMD "@DB2 ACTIVATE DATABASE "database
    if database = "" then address CMD "@DB2 RESET MONITOR ALL"
    if database <>"" then address CMD "@DB2 RESET MONITOR FOR DATABASE "database
    Call SayMsg(" Intervall Start: "time("N")" "date())

/*********************************************************************/
/* Loop 3600 oder Unterbrechung, dann Snapshot ziehen                */
/*********************************************************************/
    Say "<Strg>+<Unterbr> fr das Beenden des Snapshot Intervalls (Auto=3600 secs)"
    SIGNAL ON HALT  NAME HaltEnter
    Call SysSleep 3600
 
    SIGNAL OFF HALT
    Call SayMsg(" Intervall Ende : "time("N")" (abgelaufen)")
   
Resume:
   
    If Database = ""
    then do
         address CMD "DB2 GET SNAPSHOT FOR DBM >>"sf
         address CMD "DB2 GET SNAPSHOT FOR ALL DATABASES >>"sf
    end
    If Database <>"" then address CMD "DB2 GET SNAPSHOT FOR ALL ON "database" >>"sf
    if database <>"" then address CMD "@DB2 DEACTIVATE DATABASE "database
    address CMD "@DB2 DETACH"
   
/*********************************************************************/
/* Ende der Prozedur und MSG-File auf File-Server kopieren           */
/*********************************************************************/
    Call SayMsg(" Snapshot Ende..: "time("N")" "date())
    Call SayMsg(" Snapshot Output: "sf)
    Call SayMsg("")
   
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(" Intervall Ende : "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 "src" "Version" Verarbeitung endet mit RC="cc".",
               date("o")"-"time());
   exit cc

return

© Gernot Ruban