Thursday, December 6, 2007

CodeProject: Simple ICMP Service Monitor

CodeProject: Simple ICMP Service Monitor

Introduction

This simple lightweight application provides a solution for monitoring access to potentially critical network services.

Background

Working as a Network Administrator in an environment where the number of servers managed is continually growing, I had been looking for a simple utility like this one. I began the project in February and during my research came across FreePing available here. I reworked the UI and put together the source to "clone" it since I had already put in a great deal of effort at that point, and I was still interested in actually seeing how to write the code. FreePing is a nice utility and is available from tools4ever as a free download.

The ICMP class used in this demonstration was graciously provided as open source here. The timer was adapted from Mike Gold's EGG Timer demo which is available here.

How it Works

Once the Start button is pressed, the program reads the ini file and issues a ping for all of the hosts listed in the file. A separate thread is created for each host and it is passed the list view row as a parameter to allow it to control the information for that host's row. Threads are used to keep the user interface from waiting until the scan is completed to regain control.

At the completion of the scan initiation, a new thread is created which calls the Elapsed Time timer. This routine provides the information for the countdown clock located in the upper right portion of the main form. When the timer reaches 0, it is stopped and a call to the Monitors initialization routine is placed. The same routine is accessed by the Start button. This creates the Elapsed time loop needed to repeat the scans on regular intervals.