Skip to content

Instantly share code, notes, and snippets.

@rbocchinfuso
Created September 30, 2014 16:31
Show Gist options
  • Save rbocchinfuso/28a52d902883058ba1a3 to your computer and use it in GitHub Desktop.
Save rbocchinfuso/28a52d902883058ba1a3 to your computer and use it in GitHub Desktop.
Data Domain Report
ECHO ON
@echo off
:: DD Report Generator
:: 3/12/2014
:: Rich Bocchinfuso
::setlocal EnableDelayedExpansion
:: ----- Requires -----
:: plink
:: blat
:: SET VARIABLES HERE
set ver=1.0
set cmd=DDreport
set user=sysadmin
set password=W1z@rd!!
set logfile=
set reportfile=DD_report.txt
set esxhostfile=ddhosts.txt
:: Location of binaries like plink and blat
set binprefix=.\bin\
:: Location of config files
set cfgprefix=.\cfg\
:: Location of output files
set outprefix=.\out\
:: Email cfg files
set toemail=to_email.txt
set ccemail=cc_email.txt
:: --------------------------------------------------------------------------------
:: DO NOT EDIT BELOW
:: --------------------------------------------------------------------------------
:: Set Date and Time
for /F "tokens=2-4 delims=/ " %%a in ('echo %date%') do set datevar=%%c%%b%%a
for /f "tokens=1-3 delims=: " %%a in ('echo %time%') do set timevar=%%a%%b%%c
:main
if "%2"=="debug" @echo on
if "%1"=="report" goto :execrepreport
if "%1"=="help" goto :help
if "%1"=="readme" goto :readme
goto :help
goto :EOF
:help
:: Help context goes here
@echo _
@echo DDreport Version %ver% Copyleft (c) 2014 Rich Bocchinfuso 2014-03-12
@echo _
@echo Usage: %cmd% [help] [report]
@echo Usage Example: %cmd% report
@echo _
@echo [commands]
@echo help: Displays this help text
@echo readme: View Readme
@echo repreport: Generates Data Domain Replication Report
goto :EOF
:execrepreport
:: Check arguments
if [%1]==[] goto EOF
echo %1 | find "#" > nul
if not errorlevel 1 goto EOF
:: Initialize Data Domain Replication Report File
echo Generating Data Domain Replication Data - %date% %time%
echo Data Domain Replication Report - %date% %time% > %outprefix%%reportfile%
echo -------------------------------------------------------------------------------- >> %outprefix%%reportfile%
echo -------------------------------------------------------------------------------- >> %outprefix%%reportfile%
for /f %%x in (%cfgprefix%%esxhostfile%) do call :success %%x
echo -------------------------------------------------------------------------------- >> %outprefix%%reportfile%
echo -------------------------------------------------------------------------------- >> %outprefix%%reportfile%
call :mailreport
goto EOF
:repreport
:: Check arguments
if [%1]==[] goto EOF
echo %1 | find "#" > nul
if not errorlevel 1 goto EOF
:: Check for successful ghettoVCB jobs
echo ...Gathering replicaiton statistics for Data Domain %1 and writing to %outprefix%%reportfile% rerport file
echo y | plink -ssh %user%@%1 -pw %password% "hostname;replication show statistics | head -1`" >> %outprefix%%reportfile%
goto EOF
:mailreport
%binprefix%blat.exe %outprefix%%reportfile% -tf %cfgprefix%%toemail% -cf %cfgprefix%%ccemail% -subject "%cmd% - Replication Report" -attacht %outprefix%%reportfile% -server mail.tishmanspeyer.com -f DDreport@tishmanspeyer.com
goto :EOF
:EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment