From 7351717717e4108cced7048bd022e505b8bc3de7 Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Mon, 26 Jun 2000 04:12:54 +0000 Subject: [PATCH] added file into CVS respository --- pod/spong-server-mod-template.pod | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 pod/spong-server-mod-template.pod diff --git a/pod/spong-server-mod-template.pod b/pod/spong-server-mod-template.pod new file mode 100755 index 0000000..aae30b4 --- /dev/null +++ b/pod/spong-server-mod-template.pod @@ -0,0 +1,81 @@ +=head1 NAME + +spong-server-mod-tempate - how to build a spong-server data module + +=head1 DESCRIPTION + +This template will be a simple example that will write incoming 'cpu' +status updates into a queueing directory. Each file will have the +host's name plus the current time are it's file name. + +The file name of the module must begin with 'data_'. The registry key can +be anything, but it should be consistent with the procedure's name. And the +registry must be unique among the other loaded modules; otherwise, one +module will overlay the other. + +The line that has the assignment to C<$DATAFUNCS{'registry-name'}> is the +key to the registry mechanism. It's what ties the registry name to the +your data module. + +data_cpu_queue: + + # Register the routine with the plugin registry + $DATAFUNCS{'cpu_queue'} = \&data_cpu_queue; + + $CPU_QUEUE_DIR = "/var/spool/spong-queue"; # The spooling directory + + sub data_cpu_queue { + my( $host, $service, $color, $start, $time, $sum, $message ) = @_; + + if ( $service ne 'cpu' ) { return; } + + my( $file ) = "$CPU_QUEUE_DIR/$host-" . time(); + + if (! open(FH,"> $file") ) { + &main::error("plugin::data_cpu_queue: Could not open file $file: $!"); + return; + } + + print FH "hostname: $host\n"; + print FH "color: $color\n"; + print FH "start-time: $start\n"; + print FH "last-update: $time\n"; + print FH "summary: $sum\n"; + print FH "message:\n$message\n"; + + close FH; + + &main::debug("plugin::data_cpu_queue: event written to file $file",5); + } + + # I'm included perl code, I need this line. + 1; + +Please note the final line. It is always required for a module file. + +You should use the Cmain::error()> function to log any error encountered +in your module. The Cmain::error()> function is used to write output +whenever something interesting happens in your module. + +Any configuration varirables needed for your data modules can be put into the +Global section of your module as shown above. Of it can be added into the +F or FhostE> configuration files. +Configuration variables for your module should be named to match them up +with the name of your customized check. + +=head1 SEE ALSO + +L, L, L + +=head1 AUTHOR + +Stephen L Johnson > + +=head1 HISTORY + +Based on code/ideas from Sean MacGuire (BB), and Helen Harrison (Pong). Ed Hill +original converted Big Brother (http://www.bb4.com) 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. + -- 2.30.2