[Table of Contents][Index]



spong-client-mod-template - how to create modules for spong-client


This document describes how to create your own plug-in modules for the spong-client program. Your modules can be your own new custom check or they can replacements for the core Spong modules.

This template assumes that you are creating a new client check called 'mailq'. The name of the file created should be 'check_mailq'. The file name for spong-client modules should always be 'check_' plus the registry name (e.g. for the foo check, the registry name is 'foo' and the file name is 'check_foo').

The line that has the assignment to $CHECKFUNC{'registry-name'} is the key to the registry mechanism. It's what ties the registry name to the actual checking function.

The registry name does not always have to match up to the service name as in this case of out module 'mailq'. If you where creating a new and improved function to check mail queues, you could create a module called 'my_mailq'. You would use the registry name 'my_mailq', but you would use the service name 'mailq' in the &status() function when reporting your info back to the server.


  # Register my routine with plug-in registry
  $CHECKFUNCS{'mailq'} = &check_mailq;

  # Sendmail mail queue check for mail servers. It checks the number of mail
  # message queued against the $MAILQWARN AND $MAILQCRIT variables.
  # It runs the command in the config variable $MAILQ to do it's check.

  sub check_mailq {
     my($mqcnt, $message, $color, $summary );

     open (FOO,"$MAILQ |");

     $mqcnt = 0;
     while (<FOO>) {
        if (/Mail Queue\s+\((\d+)/) { $mqcnt = $1; }

        # Grab enough to get the first 10 entries.
        if (++$lines <= 35) { $message .= $_ };
     close FOO;

     $color = "green";

     if ($mqcnt > $MAILQWARN) { $color = "yellow"; }
     if ($mqcnt > $MAILQCRIT) { $color = "red"; }
     $summary = "Mail Queue count = $mqcnt"

     &main::debug("mailq - $color, $summary")
     &main::status( $SPONGSERVER, $HOST, "mailq", $color,
                    $summary, $message );


  # I'm include perl code, I need this line.

Please note the final line. It is always required for a module file.

The $MAILQWARN and $MAILQCRIT variables are added to the spong.conf or spong.conf.<hostname> configuration files. These variable define the warning and alert threshold levels for your custom check.

Configuration variable for your custom checks should be named to match them up with the name of your customized check. In our case, we started our variable names with MAILQ with matches up nicely with our module name of 'mailq'. Naming the threshold variables $WARN_SPOOL_LEVEL and $CRIT_SPOOL_LEVEL would have made it unclear as to which check they belonged to. Keep the names similar, it will make it easier on you and others to administer your setup in the future.


the developer-guide entry elsewhere in this document, the spong-client entry elsewhere in this document, the spong.conf manpage


Stephen L Johnson <>


Based on code/ideas from Sean MacGuire (BB), and Helen Harrison (Pong). Ed Hill original converted Big Brother ( into Perl which diverged from Big Brother to become Spong. Ed Hill continued Spong development until version 2.1. Stephen L Johnson took over development in October, 1999 with his changes which became Spong 2.5.

[Top] Generated by Pod::HTML 0.43 on Wed Jun 13 11:17:42 2001