1. Home
  2. Computing & Technology
  3. Perl

Creating a simple service monitoring CGI script

By Kirk Brown, About.com

3 of 5

Checking the services

This for loop is the heart of our script. It's in this loop that we go through the list of servers and attempt a plain TCP socket connection to the specified port and IP address. If the socket connection succeeds, we know that the service is up and at least accepting incoming connections. If the socket connection fails, we know that the service is not running correctly on the specified port and is down.

It's here that we use the IO::Socket Perl module to attempt the connection with the simple IO::Socket::INET->new. function that created a new socket object and attempts the connection.

Index: Creating a simple service monitoring CGI script

  1. Starting the script
  2. Configuring the services to monitor
  3. Checking the services
  4. Printing the HTML
  5. Final thoughts and installation notes

3 of 5

Explore Perl

More from About.com

  1. Home
  2. Computing & Technology
  3. Perl
  4. Applied Programming
  5. Creating a simple server monitor in Perl to check the status of your internet services.

©2008 About.com, a part of The New York Times Company.

All rights reserved.