Wednesday, August 18, 2010

Monitoring DFSR

I have developped the following batch file to monitor disk space utilization in a Windows 2003 R2 DFSR environment. I think it can also be used in a Windows 2008 R2 environment.

DFSR Staging folders and Conflict and Deleted Folders are monitored as well as disk space on concerned hard drives. DFSR hidden folder is the folder containing the SimilarityTable database, which could grow up under some circunstances.

You just have to replace hostname1 and hostname2 with the name of the members of your DFSR Replication Group. And replace also the location of
- DFSR hidden folder (which in my case is g$\system volume information\dfsr)
- DFSR conflictanddeleted folder (which is in my case g$\data_to_replicate\DfsrPrivate\ConflictAndDeleted)
- DFSR staging folder (which in my case is g$\data_to_replicate\DfsrPrivate\Staging)
The batch script must bu run from a third host with an account that has full privilege on DFSR members.

Here's the DOS batch file. Copy it to a text file and save it as monitor_dfsr.bat.

@echo off
setLocal EnableDelayedExpansion
echo Date Time Hidden_MB_1 Hidden_MB_2 Conflict_MB_1 Conflict_MB_2 Conflict_#_1 Conflict_#_2 Staging_MB_1 Staging_MB_2 DiskFree_F_1 DiskFree_F_2 > c:\supervi_PROD.txt
set member1=hostname1
set member2=hostname2


set /a temp_to_sum1a=0
set /a value1a=0
set /a sum1a=0
set Fldr1a=\\%member1%\g$\system volume information\dfsr
FOR /R "%Fldr1a%" %%I IN (*) DO (
set /a temp_to_sum1a=%%~zI/1024
set /a value1a=!value1a!+!temp_to_sum1a!
set /a dfsr_hidden_size_1a=!value1a!/1024

set /a temp_to_sum1b=0
set /a value1b=0
set /a sum1b=0
set Fldr1b=\\%member2%\g$\system volume information\dfsr
FOR /R "%Fldr1b%" %%I IN (*) DO (
set /a temp_to_sum1b=%%~zI/1024
set /a value1b=!value1b!+!temp_to_sum1b!
set /a dfsr_hidden_size_1b=!value1b!/1024

set /a temp_to_sum2a=0
set /a value2a=0
set /a sum2a=0
set Fldr2a=\\%member1%\g$\data_to_replicate\DfsrPrivate\ConflictAndDeleted
FOR /R "%Fldr2a%" %%I IN (*) DO (
set /a temp_to_sum2a=%%~zI/1024
set /a value2a=!value2a!+!temp_to_sum2a!
set /a dfsr_conflict_size_2a=!value2a!/1024

set /a temp_to_sum2b=0
set /a value2b=0
set /a sum2b=0
set Fldr2b=\\%member2%\g$\data_to_replicate\DfsrPrivate\ConflictAndDeleted
FOR /R "%Fldr2b%" %%I IN (*) DO (
set /a temp_to_sum2b=%%~zI/1024
set /a value2b=!value2b!+!temp_to_sum2b!
set /a dfsr_conflict_size_2b=!value2b!/1024

set /a how_many3a=0
set Fldr3a=\\%member1%\g$\data_to_replicate\DfsrPrivate\ConflictAndDeleted
FOR /R "%Fldr3a%" %%I IN (*) DO set /a how_many3a=!how_many3a!+1

set /a how_many3b=0
set Fldr3b=\\%member2%\g$\data_to_replicate\DfsrPrivate\ConflictAndDeleted
FOR /R "%Fldr3b%" %%I IN (*) DO set /a how_many3b=!how_many3b!+1

set /a temp_to_sum4a=0
set /a value4a=0
set /a sum4a=0
set Fldr4a=\\%member1%\g$\data_to_replicate\DfsrPrivate\Staging
FOR /R "%Fldr4a%" %%I IN (*) DO (
set /a temp_to_sum4a=%%~zI/1024
set /a value4a=!value4a!+!temp_to_sum4a!
set /a dfsr_staging_4a=!value4a!/1024

set /a temp_to_sum4b=0
set /a value4b=0
set /a sum4b=0
set Fldr4b=\\%member2%\g$\data_to_replicate\DfsrPrivate\Staging
FOR /R "%Fldr4b%" %%I IN (*) DO (
set /a temp_to_sum4b=%%~zI/1024
set /a value4b=!value4b!+!temp_to_sum4b!
set /a dfsr_staging_4b=!value4b!/1024

FOR /F "tokens=*" %%A IN ('dir \\%member1%\g$ ^| FIND "bytes free"') DO SET freedisk_f_1=%%A
FOR /F "tokens=*" %%A IN ('dir \\%member2%\g$ ^| FIND "bytes free"') DO SET freedisk_f_2=%%A

echo %date% %time% %dfsr_hidden_size_1a% %dfsr_hidden_size_1b% %dfsr_conflict_size_2a% %dfsr_conflict_size_2b% !how_many3a! !how_many3b! %dfsr_staging_4a% %dfsr_staging_4b% %freedisk_f_1% %freedisk_f_2% >> c:\supervi_PROD.txt

sleep 1000

goto beginning

1 comment:

  1. I have improved this batch file:


Related Posts Plugin for WordPress, Blogger...