@echo off @REM Check Syntax and OS :: Check Windows version IF NOT "%OS%"=="Windows_NT" GOTO Syntax :: Check command line ECHO.%1 | FIND "?" >NUL IF NOT ERRORLEVEL 1 GOTO Syntax IF [%1]==[] GOTO Syntax :: Check if TXT file exists IF NOT EXIST "%~f1" GOTO Syntax @REM Set Variables (****MUST EDIT: logpath) set logpath=c:\\logs : Keep variables local SETLOCAL :: Read variables from command line @REM Get the Filename + Path of passed argument SET TXTFile="%~f1" set email=youremail@coco.com @REM Call Choice MENU CHOICE /C 1234 /N /M "Get Logs about: Exchange ESE FailOver(1), IIS Reset(2), ClusSvc Failover(3), Custom(4) ?" ECHO You chose %ERRORLEVEL% IF ERRORLEVEL 4 GOTO RunD IF ERRORLEVEL 3 GOTO RunC IF ERRORLEVEL 2 GOTO RunB IF ERRORLEVEL 1 GOTO RunA @REM Common searches: @REM A. exchange FAIL OVER: EventId: 103 Source:ESE @REM B. IIS Stop Cmd: EventID: 2 Source: IISCTLS @REM C. exchange FAIL OVER: EventID: 1204 Source:ClusSvc Type=System @REM D. system, Service Control Manager, 7024 (MSExchangeIS Crash) @REM maybe schedulle daily from 00:00:00 to 23:59:00 @REM By Felipe Ferreira fferreira@coc.com (HP) 14-12-2006 update %DATE% @REM parameters EDIT options here :RunA set type=application set days=2 set source=ESE set errorid=103 GOTO Run :RunB @rem IIS Reset set type=system set days=5 set source=IISCTLS set errorid=2 GOTO Run :RunC @Rem Check more for Failovers set type=System set days=5 set source=ClusSvc set errorid=1204 GOTO Run :RunD Echo This will guide step by step to retrive only the logs you need. @REM -->GET DAYS ECHO Eventviewer of how many days ago? [CRTL-Z]. ECHO. :: Only one single command line is needed to receive user input FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A ECHO You typed: "%INPUT%" Set days=%INPUT% @REM --> GET TYPE ECHO Eventviewer of what type (System, Security, Application)? [CRTL-Z]. ECHO. FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A ECHO You typed: "%INPUT%" Set type=%INPUT% @REM --> GET SOURCE ECHO Eventviewer of what Source(ClusSvc, MSExchangeIS,etc...)? [CRTL-Z]. ECHO. FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A ECHO You typed: "%INPUT%" set source=%INPUT% @REM --> GET ERRORID ECHO Eventviewer ErrorID? [CRTL-Z]. ECHO. FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A ECHO You typed: "%INPUT%" set errorid=%INPUT% @REM --> GET EMAIL ECHO What EMAIL address you would like to recieve this logs? [CRTL-Z]. ECHO. FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A ECHO You typed: "%INPUT%" set email=%INPUT% @echo You want to Gather, 1.TYPE: %type%, SOURCE: %source% and EVENT ID: %errorid% , from DAYS: %days% ago. @echo And result to be sent to %email% ?[CRTL-C to cancel] Pause GOTO Run :Run c: cd\ @echo Cleaning old logs ... del %logpath%\*.txt /Q cls @echo. @echo Retriving EVENT %type% SOURCE: %source% and EVENT ID: %errorid% (from %days% ago) @echo from %INIFile% please wait... @echo. :: Search the TXT file line by line FOR /F "tokens=* delims=" %%A IN ('TYPE %TXTFile%') DO CALL :ParseINI "%%A" @echo Finished Reading %TXTFile% @REM to be continued after file has gone thru all list :Run2 :: (**********BE SURE TO SET THIS********) @echo Deleting Empty Files... cscript %logpath%\del0.vbs c: cd %logpath%\ @REM **OPTIONAL**** Could find a specific STRING inside any file by doing: @REM findstr /s /i > string.txt del %logpath%\*.rar /Q @REM RAR, check if there are erros found and send the email dir /w :: (**********BE SURE TO SET THIS********) C:\PROGRA~1\WinRAR\rar a -df -o+ Sunrise.rar *.txt :: ********SET The LOCATION OF SENDMAIL BATCH !!!************** IF EXIST %logpath%\Sunrise.rar start c:\sendmailsun.bat %email% ELSE Echo No errors Found. @REM Clean Variables ENDLOCAL set logpath= set logfile= set type= set days= set source= set errorid= set email= GOTO End :Syntax ECHO. ECHO. ECHO ECHO Pass a server list .txt with one server per line and chose your operation ECHO The current choice options are editabled. ECHO Example: dumpevt.bat servers.txt ECHO. ECHO By Felipe Ferreira fferreira@coco.com 14-12-2006 update %DATE% pause :End @echo Command Completed exit ::===== Go thru .TXT and set each line to a variable and execute; === :ParseINI SET server="%~1" IF "%server%"=="EOF" GOTO Run2 :: Store line in variable @rem SET /A logfile=%logfile% += 1 ::Clean the quotes from the servername SET server=%server:"=% ECHO Logging to: %logpath%\%server%.txt :: (**************BE SURE TO HAVE DUMPEL.EXE AND SET THE PATH TO IT********) dumpel -f %logpath%\%server%.txt -l %type% -e "%errorid%" -m "%source%" -s %server% -d %days%