Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - chkup


chkup - checks that host is up and specified ports are available.


chkup [ -c <config_file> ] [ -d ] [ -l ] [ -r <rcpt_email_addr> ] [ -v ] < clientid >


chkup is a Bourne shell script which should work equally well on all versions of UNIX, Linux and Mac OS X.


chkup uses nmap to check that specified ports are open on a remote host. This functionality duplicates a small part of that in chkfw but I find is useful for those clients that have sites to which I have no access but which nevertheless need monitoring.

NB . A short client id is normally given in preference to a host name on the command line. This is used to identify the configuration stanza in the configuration file which will have the required hostname or IP address. If no configuration file is found or if the client id is not found in the configuration file chkup will assume that clientid=hostname .


-c    Use the specified configuration file in preference to the default "/usr/local/etc/" . If no configuration file is found the script will attempt to soldier on with the information it has from the command line.

-l    Use the local syslog facility to record the results of the check.

-r <email_address> Send alerts to the specified user address. This will be used in preference to the recipient specified in the configuration file and is useful when testing the script. If no recipient is specified either on the command line nor in the configuration file chkup will send alerts to the invoking user's local mailbox.

-d    Start in debug mode. The -x    option is set within the shell.

-v    Set verbose mode. Ordinarily chkup operates silently unless show stopping problems are detected. In verbose mode chkup reports on each significant action.


chkup -l -v merlin

Check that ports specified in the default configuration file, "/usr/local/" , are available on the host merlin and log the the results using the syslog facility.

Verbose mode will be used causing chkup to report significant actions to standard out or standard error.


The script will check the configuration file for the client id "". If no entry is found, as seems likely, "" will be assumed to be a hostname and nmap will be run with the " -Pn " option. No ports will be specified.


The script is quite crude having very little error checking. The consequences of unexpected input are untested. Where multiple ports are checked if any are open this is reported as success. This needs dealing with urgently.


chkdf, chkftpd, chkfw, clean, secscan.


Clifford W Fulford, City Linux. Contact or +44 (0)709 229 5385.

The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.