Readme for Watch.pl

August 1999

Microsoft Corporation

Watch.pl Readme

Watch.pl is a Perl script that periodically scans the service ports on a given list of servers to determine whether the services are functioning. If an error is detected, an alert is generated in the form of a Microsoft® Windows NT® event.

All Site Server services can be monitored by Event Viewer and Performance Monitor. However, it is tricky to program a set of alerts that will consistently detect the difference between a failed service and a fully functional but inactive service. Portwatch was created to confirm periodically that the services are still answering.

Portwatch consists of three files:

The default installation of Watch.pl should be run from the \Reskit\Code\Portwatch directory. Otherwise you must modify your system path.

Watch.pl

In addition to generating Windows NT events, Watch.pl sends status updates to the screen while the script is running. This allows you to monitor service status visually when Event Viewer is not running .

Note   You must edit the Watch.pl file to include your server’s IP address (hostip) and machine name (hostname).

Watch.pl is a sample Perl script that pings specified ports and reports on the status of ports described in Watch.lst. When used with the Rptevent.exe utility (also included with the Site Server 3.0 Commerce Edition Resource Kit), Watch.pl can generate custom alerts and post them to the Microsoft® Windows NT® Event Log.

Note   Watch.pl is configured to run Rptevent.exe, which is only available for platforms with Intel® processors; it is not available for DEC Alpha platforms at this time.

The Watch.pl sample script provides one example of how custom scripts can be used with Windows NT to address site management issues.  To install the Perl interpreter, refer to the instructions in the Microsoft Windows NT Resource Kit, or visit http://www.perl.com.

The Watch.pl file includes inline comments that explain the various portions of the script. You must replace the HostName and HostIP information with your own server-specific information.

The general flow of the script is as follows:

   read in list of servers & ports to monitor
   do
     for each service/port
       try to open port : alert if failed to connect
       if "send string" send it
       read response from service
       check response with "expect string" : alert if string is not found
     send a 'heartbeat' status event with up/down report
     sleep n seconds
   until stopped

Watch.lst

The configuration file contains five fields, which are separated by colons. The Watch.lst file is a sample, and the data fields must be changed to reflect your server-specific information.

The fields are:

<IP Address>:<Netbios Name>:<IP Port>:<Send String>:<Expect String>:
<Failure Notice>

Rptevent.exe

Rptevent.exe is a program that "reports events." That is, it generates a Windows NT event in the application logs. Watch.pl calls Rptevent.exe to generate events concerning the status of ports described in Watch.lst.

Note   This program is not available on the DEC Alpha platform. In addition, when using Site Server 3.0 Service Pack 2, Rptevent.exe does not record events in the Event Viewer when the Watch.pl Perl script detects a failed service.

To use this tool, open a command prompt and navigate to the \Reskit\Code\Portwatch folder of your Resource Kit installation directory. From there, use the following syntax to run the tool.

If you run Rptevent.exe without any parameters, the following message is displayed:

usage : rptevent source I|W|R <message>

There is actually an error in this message, because there is no "R" option. However, it appears to have been replaced by the "E" option, which generates an Error event.

The Rptevent.exe command-line syntax is:

rptevent source type "message"

When a service doesn't answer properly, Watch.pl builds a command string like this one:

rptevent watch_pl E "watch.pl Server:Smtpusr01(10.4.13.137) Port: 25 Alert: SMTP Service Appears To Be Down"

Note   When you use the Windows NT Event Viewer to view events generated with Watch.pl, you can ignore messages like this that are displayed in the Description box when you choose Details on the View menu. The text after this message contains the detail information from Watch.pl.

The description for Event ID ( ..... ) in Source ( watch_pl) could not be found. .....

Information in this document, including URL and other Internet web site references, is subject to change without notice.  The entire risk of the use or the results of the use of this resource kit remains with the user. This resource kit is not supported and is provided as is without warranty of any kind, either express or implied. The example companies, organizations, products, people and events depicted herein are fictitious. No association with any real company, organization, product, person or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 1998-2000 Microsoft Corporation. All rights reserved.

Microsoft, BackOffice, Microsoft Press, NetMeeting, Outlook, Windows and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.