From: Stephen L Johnson Date: Thu, 16 Dec 1999 06:36:41 +0000 (+0000) Subject: New spong-server module template document. X-Git-Tag: spong-2_6-beta8~1 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2c159e8a233b0d79859cb07c33d83cf719dd785;p=spong.git New spong-server module template document. --- diff --git a/www/docs/spong-server-mod-template.html b/www/docs/spong-server-mod-template.html new file mode 100755 index 0000000..5f83ab2 --- /dev/null +++ b/www/docs/spong-server-mod-template.html @@ -0,0 +1,60 @@ + + + + + + + spong-server Data Module Template + + + +

+spong-server Data Module Template

+ +
+
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 overylay the other. + +

The line that has the assignment to $DATAFUNCS{'registry-name'} is the +key to the registry mechanism. It's what used to track the registry name to the +your data module. + +

+# 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();
+
+   open(FH,"> $file") or
+      die("plugin::data_cpu_queue: Could not open file $file: $!");
+
+   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;
+}
+
+# I'm included perl code, I need this line.
+1;
+
+ +

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