You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

The script table.pl takes PingER data and provides a table for various network performance metrics (such as RTTs, Packet Loss, Throughput, etc) from monitored to monitoring hosts in a simple but color-coded fashion (documentation available here). The script was originally written by Dr. Les Cottrell. Later Zafar Gilani modified it. The script now conforms to perl warnings and tainting mode. New version is now installed both at SLAC and SEECS.

Changes in Version 0.6, Dated 10/07/2010

This tutorial assumes that the reader has basic knowledge of Perl scripting.

Using "strict"

To make sure all the variables (scalars, arrays and hashes) are declared before usage, use the following line just below top of the script:

..
use strict;
..
Using "warnings" and "tainting"

To make sure that all warnings are displayed at the standard output (stdout) one should enable warnings. This helps to solve problems with a script.

Tainting on the other hand is used to make sure that a CGI script is logically secure. Taint (T) mode puts a Perl script into paranoid mode and treats all user supplied input as tainted and bad unless the programmer explicitly OKs the data. Read more here.

To display warnings (w), add the following line at the top of the script:

#!/usr/bin/perl -w

The above is pretty much an older style of Perl coding. One can also use:

..
use warnings;
..

To enable tainting (T), just add the letter 'T' at the end of the top line of a script:

#!/usr/bin/perl -wT

Once tainting is enabled, it has to be used at the command prompt as well or the script won't run. If one tried to run the script without tainting option (-T) from command line, the script fails with following message:

zafar@pinger $ perl table.pl
"-T" is on the #! line, it must also be used on the command line at table.pl line 1.
Elaborate "warnings"

Warnings are often not self-explanatory. One can use diagnostics option to elaborate the warnings. The following helps elaborate on warnings.

..
use diagnostics -verbose;
..

How to go about the business?

Don't enable all the options above in one go. There will be a humongous number of warnings and error messages. The best way to do this is to go stepwise. Enable the above options one by one, in the order written below. This must be followed by test running the script:

  1. strict
  2. warnings (enabled diagnostics as required)
  3. tainting

Once one of the options are enabled, run the program and entertain the warnings and solve error messages. This shall be repeated until all the messages are resolved for that particular step. Also test the html output of the script by saving and accessing the html script via a web browser. A correct output looks something like below:

  • No labels