1. Technology

Creating a simple service monitoring CGI script

By

4 of 5

Printing the HTML
Creating a simple service monitoring CGI script
Now that we've tested each of the services in our configuration by attempting a TCP socket connection, let's look at how we use the CGI Perl module to create a very simplistic output page and display what we've learned. CGI.pm eliminates the need to write messy HTML inside your Perl scripts by giving you functions to create all the necessary tags.

First we start by printing the header information which includes the HTTP headers and document content type. Then we use start_html to start an HTML page with the title Simple Service Status and also print a header using h1. Finally, we print the value of $status which contains the results of all our socket connection attempts, and close it out with an end_html that closes our document out.

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

©2014 About.com. All rights reserved.