From: Stephen L Johnson Date: Fri, 5 Nov 1999 21:02:20 +0000 (+0000) Subject: Initial import X-Git-Tag: start~27 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6de93d24d95019ce07edc2c31aad7579ff35581a;p=spong.git Initial import --- diff --git a/www/docs/spong-client-mod-template.html b/www/docs/spong-client-mod-template.html new file mode 100755 index 0000000..83aeb2e --- /dev/null +++ b/www/docs/spong-client-mod-template.html @@ -0,0 +1,64 @@ + + + + + + + Spong Client Module Template + + + +

+spong-client Module Template

+ +
+
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 should always be 'check_' and 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 track the registry name to the +your check function. +

The registry name does not always have to match up to the service name +as in this case of '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 regiestry name 'my_mailq', but you would use the service +name 'mailq' in the &status() function when reporting you +info back to the server. +

check_mailq: +

# Register my routine with plugin 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"; +

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

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

Please note the final line. It is always required for a module file. +
  +
  + + diff --git a/www/docs/spong-network-mod-template.html b/www/docs/spong-network-mod-template.html new file mode 100755 index 0000000..649dd12 --- /dev/null +++ b/www/docs/spong-network-mod-template.html @@ -0,0 +1,85 @@ + + + + + + + spong-network Module Template + + + +

+spong-network Module Template

+ +
+
This template assumes that you are creating  a network check called +'dns'. The name of the file created should be 'check_dns'. The file name +should always be 'check_' and 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 $PLUGINS{'registry-name'} is the +key to the registry mechanism. It's what track the registry name to the +your check function. +

The registry name does not always have to match up to the service name +as in this case of 'dns'. If you where creating a new and improved function +to ping and traceroute, you could create a module called 'ping_trace'. +You would use the registry name 'ping_trace', but you would use the service +name 'ping' in the &status() function when reporting you info +back to the server. +

# Register the routine with the plugin registry +
$PLUGINS{'dns'} = \&check_dns; +

# Check to see if they have the Net::DNS module installed, and if +they do we +
# can then do DNS queries, and see if DNS servers are alive. +

eval "require Net::DNS;"; +
if( ! $@ ) { $dns = 1; } else { $dns = 0; } +

# This check will (if the Net::DNS module is available) connect +to a DNS server +
# and ask that server to resolve it's own name.  If it can +do that, then we +
# assume it is ok - If it can't then something is wrong. +

sub check_dns { +
   my( $host ) = @_; +
   my( $color, $summary, $message ) = ( "green", "", +"" ); +
  +
   if( ! $dns ) { +
      $summary = "can't do DNS lookups, +Net::DNS not installed"; +
      &debug( "dns - $host - $color, +$summary" ); +
      return ( "yellow", $summary, +
               +"In order to do DNS queries you must install the Net::DNS " . +
               +"Perl module.\nYou can find the module at your nearest CPAN " . +
               +"archive or http://www.perl.com/CPAN/\n" ); +
   } +
  +
   my $resolver = new Net::DNS::Resolver; +
   $resolver->nameservers( $host ); +
   $resolver->retrans(2); +
   $resolver->retry(1); +
   $resolver->recurse(0); +
   my $q = $resolver->search( $host, "A" ); +
  +
   if( defined $q && defined $q->answer && +defined (($q->answer)[0]) ) { +
      $color = "green"; +
      $summary = "dns ok"; +
   } else { +
      $color = "red"; +
      $summary = "can't resolve $host"; +
      $message = "can't resolve $host\n"; +
   } +
  +
   &debug( "dns - $host - $color, $summary" ); +
   return( $color, $summary, $message ); +
} +

# I;m included perl code, I need this line. +
1; +

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