Home Programmierung Using Perl to build a simple Windows Application Monitoring Tool

Main Menu

Texte / Essays
Using Perl to build a simple Windows Application Monitoring Tool
Sonntag, den 07. August 2011 um 08:51 Uhr

Availability and Performance can be seen as Parameters of Software Quality or even as Parameters of System Security.

IT Management Perspective
From an IT Management Point of View you would like to have Metrics which allow measurement of System Availability and Performance. In order to improve your Operating you need a Feedback System, and, ideally some Key Performance Indicators (This also applies if there are "Service Level Agreements" to be met). These do not necessarily have to be very complicated. However, you need some Mechanism of testing and logging to obtain the data.
There are some difficulties as performance may be the result of different factors: network availability may influence access to an application and may affect KPIs whether or not the Business Division running the Application is responsible for Network Problems or not. Depending upon the Scenario and Context, validity of Measurement can be a more complex task.

Given a simpler environment, I wrote a little piece of Perl Code that allows you to perform
a monitoring on a specific Windows Binary with GUI and measuring the Time between startup, login and finished login.
Let us assume you have program (in my example I use Quicken with a password-protected file) to be monitored.
You would like to test if it can be started; after exceeding a timeout you want to kill the process.
Given that the Start-Up was successful, you want to log-in to your application (again, you set a timeout.)
Finally, you quit the program and sleep for given period of time until you re-start this loop.
You want to record timestamps between the steps mentioned above so you also can find out if the Start-Up or Login
works unusually slow. This is what the little Script does.  The main function is testbin which is called with a number of parameters.

To find the GUI Window after Application Startup and for the Login key sequence I use Win32::GuiTest.
(In this example, Login Strings are hard-coded.)
For Windows Process Control I found Win32::Process, which  allows a very practical access at Process-Level.

The Script can be easily enhanced. For example, monitoring may be extended to
first send a Ping to some Network Host to check if it is available or to perform a Database Connect
as a precondition for the following monitoring steps.