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.