Subscribe to Windows IT Pro
January 17, 2006 12:00 AM

Keep Tabs on Replications

Monitor data-sync problems between replication partners
Windows IT Pro
InstantDoc ID #48746
Rating: (0)
Downloads
48746.zip

ReplicationTest Scripting Tricks
In addition to the techniques I've described, ReplicationTest uses a couple coding tricks that you might want to add to your scripting tool belt: code that anticipates future requirements changes and code that combines the contents of two files. Let's look at these in a bit more detail.

Anticipating future requirements. After you've been creating scripts for a while, you'll begin to anticipate changes to scripts that users might request in the future. Often, you can easily add code to the original script to accommodate these anticipated changes. By coding proactively, you can minimize the productivity loss that can occur when, several months down the road, you need to refamiliarize yourself with the code and add and debug new sections to accommodate a user request. The original requirements for ReplicationTest were for the script to send an email notification only when the specified variation percentage was exceeded. However, I knew it would be only a matter of time before someone wanted ReplicationTest to return results on every script run and not just when the threshold was met. To address this possible additional requirement, I used the % ScriptBehav% variable. Configuring this variable to A tells the script to always notify the mail recipients. Setting it to B tells the script to notify recipients only when the threshold is exceeded.

Combining two files. Sometimes you'll need to combine the contents of two files as I did in ReplicationTest. I needed to add a header to the Blat email message—but only if the mailmessage file was created. Thus, I needed to append text to the beginning of an existing file. Although you can use the Copy command to combine two files into a new third file, I wanted to avoid introducing in the email and pager messages the annoying characters that can result from a Copy operation. Instead, I used the Type command with a redirection operator (>>) to echo the lines from one file to a new file, as Listing 3 shows.

Using ReplicationTest
I tested ReplicationTest on a Windows XP Service Pack 1 (SP1) system. To get the ReplicationTest script working in your environment, follow these steps:

1. Download the ReplicationTest and Mathomatic scripts from the Windows Scripting SolutionsWeb site. Go to http://www.windowsitpro.com/windowsscripting, enter 48746 in the InstantDoc ID text box, then click the 48746.zip hotlink. Line-wrap limitations in the print article could cause errors if you try to copy and paste line-wrapped code into your script.

2. Configure the following items:

  • Path to the four utilities that ReplicationTest uses: diruse.exe (version 1.20), sleep.exe (available in the Microsoft Windows Server 2003 Resource Kit and Microsoft Windows XP Professional Resource Kit), blat.exe, and Mathomatic. (Note: To use the Mathomatic script, you need to first install ActivePerl on the machine on which you'll run the ReplicationTest script. You can download ActivePerl at http://www.activestate.com/ products/download/download .plex?id=activeperl.)
  • Mail-message recipients: You can specify multiple recipients by using commas (not spaces) to separate the email addresses.
  • From addressee: Check with your email administrator to determine whether your mail system requires valid email addresses. If it supports nonvalid addresses as well, you can use a sending address such as ReplTestScript@yourcompany.com.
  • SMTP mail server through which you want the message sent.

3. Configure the size setting for Diruse to use: K (for KB) or M (for MB). You might need to fine-tune your size and decimal settings after running the script to attain more granular results.

4. Configure the number of decimal place values you want. For example, a setting of 4 would result in percentage values such as 5.1234%.

5. Configure the script behavior: A=Always notify or B=Notify only if threshold is exceeded.

6. Run the script following the syntax

ReplicationTest.bat
  source_location
  destination_location
  percent_of_variation_threshold 

For example, the command might look like

ReplicationTest.bat
  \\servera\srcloc
  \\serverb\destloc
  10.5 

7. If the source or destination location paths have spaces, be sure to use double quotes to encapsulate these paths in your run command, which might look like

ReplicationTest.bat 
  "\\servera\srcloc\folder A"
  "\\serverb\destloc\folder A"
 10.5 

8. Test the script on a small local folder area before using it on larger remote locations.

9. Use a user account that has at least Read permissions on the source and destination folders.

10. If you need regular reports, set up ReplicationTest as a scheduled task and run it as often as you require.

Take Charge of Replications
The ReplicationTest script should give you a good handle on how data replication or a large data migration is proceeding. By using the script during a replication, you'll be able to detect and take action on directory-size and file-count variations before they become a problem.

Dick Lewis (dlewis@windowsitpro.com) is a senior systems engineer with Lewis Technology in Riverside, California. He is an MCSE and an MCT, specializing in enterprise management of Windows Server 2003, Windows 2000, and Windows NT servers and workstations.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.