Merge branch 'master' of octo@verplant.org:/var/lib/git/collectd
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 9 Feb 2008 16:46:48 +0000 (17:46 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 9 Feb 2008 16:46:48 +0000 (17:46 +0100)
README
configure.in
contrib/examples/MyPlugin.pm
contrib/examples/myplugin.c
src/collectd.pod
src/collectdmon.pod

diff --git a/README b/README
index 2a5502c..a16e9ec 100644 (file)
--- a/README
+++ b/README
@@ -5,8 +5,9 @@ http://collectd.org/
 About
 -----
 
-  collectd is a small daemon which collects statistics about a computer's
-  usage and writes then into RRD files.
+  collectd is a small daemon which collects system information periodically
+  and provides mechanisms to store and monitor the values in a variety of
+  ways.
 
 
 Features
@@ -209,9 +210,36 @@ Features
     - logfile
       Writes logmessages to a file or STDOUT/STDERR.
 
+    - perl
+      Log messages are propagated to plugins written in Perl as well.
+      See collectd-perl(5).
+
     - syslog
       Logs to the standard UNIX logging mechanism, syslog.
 
+  * Notifications can be handled by the following plugins:
+
+    - exec
+      Execute a program or script to handle the notification.
+      See collectd-exec(5).
+
+    - logfile
+      Writes the notification message to a file or STDOUT/STDERR.
+
+    - network
+      Send the notification to a remote host to handle it somehow.
+
+    - perl
+      Notifications are propagated to plugins written in Perl as well.
+      See collectd-perl(5).
+
+  * Miscellaneous plugins:
+
+    - uuid
+      Sets the hostname to an unique identifier. This is meant for setups
+      where each client may migrate to another physical host, possibly going
+      through one or more name changes in the process.
+
   * Performance: Since collectd is running as a daemon it doesn't spend much
     time starting up again and again. With the exception of the exec plugin no
     processes are forked. Caching in output plugins, such as the rrdtool and
@@ -279,6 +307,9 @@ Prerequisites
   * libcurl (optional)
     If you want to use the `apache' and/or `nginx' plugins.
 
+  * libhal (optional)
+    If present, the uuid plugin will check for UUID from HAL.
+
   * libiptc (optional)
     For querying iptables counters.
 
index 284dff0..1dcae70 100644 (file)
@@ -698,6 +698,8 @@ AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to r
                librrd_cflags="-I$withval/include"
                librrd_ldflags="-L$withval/lib"
                with_rrdtool="yes"
+       else
+               with_rrdtool="$withval"
        fi
 ], [with_rrdtool="yes"])
 if test "x$with_rrdtool" = "xyes"
@@ -761,6 +763,8 @@ AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Pa
                then
                        with_libpthread="no (disabled)"
                fi
+       else
+               with_libpthread="$withval"
        fi
 ], [with_libpthread="yes"])
 if test "x$with_libpthread" = "xyes"
@@ -900,6 +904,8 @@ AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [P
                LDFLAGS="$LDFLAGS -L$withval/lib"
                CPPFLAGS="$CPPFLAGS -I$withval/include"
                with_libstatgrab="yes"
+       else
+               with_libstatgrab="$withval"
        fi
 ],
 [
@@ -1138,7 +1144,10 @@ AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to
        then
                with_liboping="no"
                with_own_liboping="no"
-       fi
+       else if test "x$withval" = "xyes"
+       then
+               with_liboping="yes"
+       fi; fi
 ],
 [
        with_liboping="yes"
@@ -1172,6 +1181,8 @@ AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to l
                LDFLAGS="$LDFLAGS -L$withval/lib"
                CPPFLAGS="$CPPFLAGS -I$withval/include"
                with_libpcap="yes"
+       else
+               with_libpcap="$withval"
        fi
 ],
 [
@@ -1210,6 +1221,8 @@ AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to l
                CPPFLAGS="$CPPFLAGS -I$withval/include"
                perl_interpreter="$withval/bin/perl"
                with_libperl="yes"
+       else
+               with_libperl="$withval"
        fi
 ],
 [
@@ -1303,6 +1316,8 @@ AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to l
                LDFLAGS="$LDFLAGS -L$withval/lib"
                CPPFLAGS="$CPPFLAGS -I$withval/include"
                with_libiptc="yes"
+       else
+               with_libiptc="$withval"
        fi
 ],
 [
@@ -2084,6 +2099,9 @@ AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@
        then
                PERL_BINDINGS_OPTIONS="$withval"
                with_perl_bindings="yes"
+       else
+               PERL_BINDINGS_OPTIONS=""
+               with_perl_bindings="$withval"
        fi
 ],
 [
index b852272..1a0247f 100644 (file)
@@ -34,6 +34,7 @@ my $dataset =
 
 # This code is executed after loading the plugin to register it with collectd.
 plugin_register (TYPE_LOG, 'myplugin', 'my_log');
+plugin_register (TYPE_NOTIF, 'myplugin', 'my_notify');
 plugin_register (TYPE_DATASET, 'myplugin', $dataset);
 plugin_register (TYPE_INIT, 'myplugin', 'my_init');
 plugin_register (TYPE_READ, 'myplugin', 'my_read');
@@ -85,8 +86,7 @@ sub my_write
        my $vl   = shift;
 
        if (scalar (@$ds) != scalar (@{$vl->{'values'}})) {
-               plugin_log (LOG_WARNING,
-                       "DS number does not match values length");
+               plugin_log (LOG_WARNING, "DS number does not match values length");
                return;
        }
 
@@ -126,3 +126,38 @@ sub my_log
        return 1;
 } # my_log ()
 
+# This function is called when plugin_dispatch_notification () has been used
+sub my_notify
+{
+       my $notif = shift;
+
+       my ($sec, $min, $hour, $mday, $mon, $year) = localtime ($notif->{'time'});
+
+       printf "NOTIF (%04d-%02d-%02d %02d:%02d:%02d): %d - ",
+                       $year + 1900, $mon + 1, $mday, $hour, $min, $sec,
+                       $notif->{'severity'};
+
+       if (defined $notif->{'host'}) {
+               print "$notif->{'host'}: ";
+       }
+
+       if (defined $notif->{'plugin'}) {
+               print "$notif->{'plugin'}: ";
+       }
+
+       if (defined $notif->{'plugin_instance'}) {
+               print "$notif->{'plugin_instance'}: ";
+       }
+
+       if (defined $notif->{'type'}) {
+               print "$notif->{'type'}: ";
+       }
+
+       if (defined $notif->{'type_instance'}) {
+               print "$notif->{'type_instance'}: ";
+       }
+
+       print "$notif->{'message'}\n";
+       return 1;
+} # my_notify ()
+
index fc7856b..cdd537a 100644 (file)
@@ -18,7 +18,8 @@
  *   is optional
  */
 
-#include <stdio.h>
+#if ! HAVE_CONFIG_H
+
 #include <stdlib.h>
 
 #include <string.h>
 # undef __USE_ISOC99
 #endif /* DISABLE_ISOC99 */
 
+#include <time.h>
+
+#endif /* ! HAVE_CONFIG */
+
 #include <collectd/collectd.h>
 #include <collectd/common.h>
 #include <collectd/plugin.h>
@@ -146,6 +151,44 @@ static void my_log (int severity, const char *msg)
 } /* static void my_log (int, const char *) */
 
 /*
+ * This function is called when plugin_dispatch_notification () has been used.
+ */
+static int my_notify (const notification_t *notif)
+{
+       char time_str[32] = "";
+       struct tm *tm = NULL;
+
+       int n = 0;
+
+       if (NULL == (tm = localtime (&notif->time)))
+               time_str[0] = '\0';
+
+       n = strftime (time_str, 32, "%F %T", tm);
+       if (n >= 32) n = 31;
+       time_str[n] = '\0';
+
+       printf ("NOTIF (%s): %i - ", time_str, notif->severity);
+
+       if ('\0' != *notif->host)
+               printf ("%s: ", notif->host);
+
+       if ('\0' != *notif->plugin)
+               printf ("%s: ", notif->plugin);
+
+       if ('\0' != *notif->plugin_instance)
+               printf ("%s: ", notif->plugin_instance);
+
+       if ('\0' != *notif->type)
+               printf ("%s: ", notif->type);
+
+       if ('\0' != *notif->type_instance)
+               printf ("%s: ", notif->type_instance);
+
+       printf ("%s\n", notif->message);
+       return 0;
+} /* static int my_notify (notification_t *) */
+
+/*
  * This function is called before shutting down collectd.
  */
 static int my_shutdown (void)
@@ -161,6 +204,7 @@ static int my_shutdown (void)
 void module_register (void)
 {
        plugin_register_log ("myplugin", my_log);
+       plugin_register_notification ("myplugin", my_notify);
        plugin_register_data_set (&ds);
        plugin_register_read ("myplugin", my_read);
        plugin_register_init ("myplugin", my_init);
index 2a326bb..b55362a 100644 (file)
@@ -89,6 +89,11 @@ C<logfile plugin> and the C<syslog plugin>. With these plugins collectd can
 provide information about issues and significant situations to the user.
 Several loglevels let you suppress uninteresting messages.
 
+Starting with version C<4.3.0> collectd has support for B<monitoring>. This is
+done by checking thresholds defined by the user. If a value is out of range, a
+notification will be dispatched to "notification plugins". See
+L<collectd.conf(5)> for more detailed information about threshold checking.
+
 Please note that some plugins, that provide other means of communicating with
 the daemon, have manpages of their own to describe their functionality in more
 detail. In particular those are L<collectd-email(5)>, L<collectd-exec(5)>,
index 5ae85fb..73ba6b8 100644 (file)
@@ -39,6 +39,24 @@ B<-f> will be added to these options. See L<collectd(1)>.
 
 =back
 
+=head1 SIGNALS
+
+B<collectdmon> accepts the following signals:
+
+=over 4
+
+=item B<SIGINT>, B<SIGTERM>
+
+These signals cause B<collectdmon> to terminate B<collectd>, wait for its
+termination and then shut down.
+
+=item B<SIGHUP>
+
+This signal causes B<collectdmon> to terminate B<collectd>, wait for its
+termination and then restart it.
+
+=back
+
 =head1 SEE ALSO
 
 L<collectd(1)>,