Quozl's Pung, A Script-Friendly TCP/IP Server Tester

| quozl@us.netrek.org | up |

12th October 2003

Introduction

Is your server working? The best way to find out is to try connecting a client to it, according to the protocol that it speaks. But there is a faster way to check for simple problems. This program is a simple server tester. It tries to connect to the TCP/IP server but does not transfer any data. It is intended to be used in scripts that check a list of servers, and it can help to detect the following conditions:

However, this method of testing has limits. There is no validation of the protocol used by the server, nor any testing of the data transfer that the server and client would normally perform. So pung cannot be used to detect:

Since most failures fall into the first list rather than the second, Pung has some potential use. Based on the return status code and output, actions can be taken by regular scripts. Quozl uses a script that compares a list of Pung results with a known-good list, and if there are differences launching an xterm that displays them.

#!/bin/csh
cd ~/bin
checker.csh > latest.txt
sdiff -s -l latest.txt normal.txt | \
grep "\|" | \
cut -f 1 -d\| > differences.txt
set LINES=`wc -l differences.txt`
if ( "$LINES[1]" != "0" ) then
    xterm -T checker -bg black -fg red \
    -e view differences.txt
endif
The script checker.csh (not shown) contains a list of Pung invokations for critical servers. It is run once when all servers are working and the results saved in normal.txt. The script above performs the check again, compares the output, tests the differences count, and launches the xterm to view the differences.

Resources

Usage

Pung version 1.1, Copyright (C) 2003 James Cameron
Pung comes with ABSOLUTELY NO WARRANTY; for details see source.
This is free software, and you are welcome to redistribute it
under certain conditions; see source for details.

Usage: pung host port [timeout]

Attempts a TCP/IP connection only to the host on the given port,
and displays the result on standard output.  No data is
transferred.  Returns a status code;

         0 = Connection accepted
         1 = Non-existent host
         2 = Non-existent service
         3 = connect() call failed

Pung is intended for use in automated testing of TCP/IP servers.
The host and port arguments may be alphabetic or numeric.

Examples:       pung localhost telnet
                pung 127.0.0.1 23

The optional timeout in seconds may be used to restrict the time
spent waiting for a connection to occur.

FAQ

What about UDP, and can I get it to mail me?


| quozl@us.netrek.org | up |