From: Florian Forster Date: Fri, 3 Oct 2008 11:35:45 +0000 (+0200) Subject: Merge branch 'collectd-4.4' into collectd-4.5 X-Git-Tag: collectd-4.5.1~10 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=39ba035b60b509311874ccf89d11d240c0271a90;hp=148fe4faebc8bde13dc9e4429e687f752a6d3cde;p=collectd.git Merge branch 'collectd-4.4' into collectd-4.5 --- diff --git a/AUTHORS b/AUTHORS index 7f92d55c..234d431e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,82 +1,98 @@ -This package was written by: - Florian octo Forster +Permanent project members +========================= -apcups plugin by: - Anthony Gialluca +Florian "octo" Forster + - Initial author. -cpufreq, multimeter and irq plugin, as well as some bugfixes in the exec plugin -by: - Peter Holik +Sebastian "tokkee" Harl + - Bugfixes and enhancments in many places all around the project. + - perl plugin. + - users plugin. + - vserver plugin. + - Debian package. -hddtemp plugin by: - Vincent Stehlé -iptables plugin by: - Sjoerd van der Berg +Contributors (sorted alphabetically) +==================================== -libvirt plugin by: - Richard W. M. Jones +Alessandro Iurlano + - Initial filecount plugin. -mbmon plugin by: - Flavio Stanchina +Alvaro Barcellos + - Don't-fork patch. -memcached plugin by: - Antony Dovgal +Anthony Gialluca + - apcups plugin. -nfs plugin by: - Jason Pepas +Antony Dovgal + - memcached plugin. -perl plugin by: - Sebastian Harl +Christophe Kalt + - The version 3 `log' mode. + - Many Solaris related hints and fixes. -powerdns plugin and initial `tail' subsystem by: - Luke Herberling +Dan Berrange + - uuid plugin. -processes plugin by: - Lyonel Vincent +David Bacher + - serial plugin. -sensors plugin has been improved by: - Luboš Staněk +Flavio Stanchina + - mbmon plugin. -serial plugin by: - David Bacher +Jason Pepas + - nfs plugin. -tape plugin by: - Scott Garrett +Luboš Staněk + - sensors plugin improvements. + - Time and effort to find a nasty bug in the ntpd-plugin. -teamspeak2 plugin by: - Stefan Hacker +Luke Herberling + - powerdns plugin. + - Initial `tail' subsystem by: -users plugin by: - Sebastian Harl +Lyonel Vincent + - processes plugin. -uuid plugin by: - Dan Berrange - Richard W.M. Jones +Michael Stapelberg + - OpenBSD port of the tcpconns plugin. -vserver plugin by: - Sebastian Harl +Niki W. Waibel + - Initial autotools fixes. + - libltdl code. + - getmnt-wizardry. -PID-file patch by: - Tommie Gannert +Oleg King + - Added support for the statgrab library to + + the cpu plugin, + + the disk plugin, and + + the users plugin. -Don't-fork-patch by: - Alvaro Barcellos +Peter Holik + - cpufreq plugin. + - multimeter plugin. + - irq plugin. + - Some bugfixes in the exec plugin. + - Notifications in the ipmi plugin. -Many autotools related fixes, libltdl code, getmnt-wizardry and much help has -contributed: - Niki W. Waibel +Richard W. M. Jones + - libvirt plugin. + - uuid plugin. -The `log' mode has been written by: - Christophe Kalt +Scott Garrett + - tape plugin. -Much time and effort to find a nasty bug in the ntpd-plugin has been -contributed by: - Luboš Staněk +Sjoerd van der Berg + - iptables plugin. -Support for the statgrab library has been added to the cpu, disk and users -plugins by - Oleg King +Stefan Hacker + - teamspeak2 plugin. + +Tommie Gannert + - PID-file patch. + +Vincent Stehlé + - hddtemp plugin. collectd is available at: diff --git a/ChangeLog b/ChangeLog index 6a1ec5e7..00a04add 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2008-09-04, Version 4.5.0 + * collectd: Added the ability to flush certain identifiers. + * collectd: The concept of `notification meta data' has been + introduced. + * filecount plugin: The new filecount plugin counts the number of + files in a directory and its subdirectories. + * ipmi plugin: Sensor names have been changed to ensure unique names. + Notifications upon added and removed sensors can now be generated. + * notify_desktop plugin: This new plugin sends notifications to the + X desktop using the structure defined in the `Desktop Notification + Specification'. + * notify_email plugin: This new plugin sends out notifications via + email, using the `esmtp' library. + * onewire plugin: The new experimental(!) onewire plugin reads values, + such as temperatures, from sensors connected to the computer via the + onewire bus. + * perl plugin: Improved synchronized access to internal data structures + and fixed a possible dead-lock. + * perl plugin: Added the ability to flush certain identifiers and marked + plugin_flush_all() and plugin_flush_one() as deprecated in favor of + plugin_flush(). + * perl plugin: Added the ability to configure Perl plugins. + * postgresql plugin: The new postgresql plugin collects statistics + about or from a PostgreSQL database. + * processes plugin: The `ProcessMatch' option has been added. + * rrdtool plugin: Implement throttling of the `update queue' to lessen + IO load. + * tcpconns plugin: This plugin has been ported to OpenBSD. + * thermal plugin: The new thermal plugin collects system temperatures + using Linux ACPI thermal zone data. + 2008-09-01, Version 4.4.3 * collectd: Fix a memory leak in the threshold checking code. * memcached plugin: Fix a too short timeout and a related file diff --git a/README b/README index 904e7c73..58ce45d3 100644 --- a/README +++ b/README @@ -62,6 +62,9 @@ Features Values gathered by a custom program or script. See collectd-exec(5). + - filecount + Count the number of files in directories. + - hddtemp Harddisk temperatures using hddtempd. @@ -132,6 +135,10 @@ Features Network UPS tools: UPS current, voltage, power, charge, utilisation, temperature, etc. See upsd(8). + - onewire (EXPERIMENTAL!) + Read onewire sensors using the owcapu library of the owfs project. + Please read in collectd.conf(5) why this plugin is experimental. + - perl The perl plugin implements a Perl-interpreter into collectd. You can write your own plugins in Perl and return arbitrary values using this @@ -141,6 +148,10 @@ Features Network latency: Time to reach the default gateway or another given host. + - postgresql + PostgreSQL database statistics: active server connections, transaction + numbers, block IO, table row manipulations. + - processes Process counts: Number of running, sleeping, zombie, ... processes. @@ -230,6 +241,16 @@ Features * Notifications can be handled by the following plugins: + - notify_desktop + Send a desktop notification to a notification daemon, as defined in + the Desktop Notification Specification. To actually display the + notifications, notification-daemon is required. + See http://www.galago-project.org/specs/notification/. + + - notify_email + Send an E-mail with the notification message to the configured + recipients. + - exec Execute a program or script to handle the notification. See collectd-exec(5). @@ -315,9 +336,16 @@ Prerequisites used and should be found in various implementations for hopefully all platforms. + * CoreFoundation.framework and IOKit.framework (optional) + For compiling on Darwin in general and the `apple_sensors' plugin in + particular. + * libcurl (optional) If you want to use the `apache', `ascent', or `nginx' plugin. + * libesmtp (optional) + For the `notify_email' plugin. + * libhal (optional) If present, the uuid plugin will check for UUID from HAL. @@ -333,10 +361,17 @@ Prerequisites * libnetsnmp (optional) For the `snmp' plugin. + * libnotify (optional) + For the `notify_desktop' plugin. + * liboping (optional, if not found a version shipped with this distribution can be used) Used by the `ping' plugin to send and receive ICMP packets. + * libowcapi (optional) + Used by the `onewire' plugin to read values from onewire sensors (or the + owserver(1) daemon). + * libpcap (optional) Used to capture packets by the `dns' plugin. @@ -344,38 +379,37 @@ Prerequisites Obviously used by the `perl' plugin. The library has to be compiled with ithread support (introduced in Perl 5.6.0). + * libpq (optional) + The PostgreSQL C client library used by the `postgresql' plugin. + * librrd (optional; headers and library; rrdtool 1.0 and 1.2 both work fine) If built without `librrd' the resulting binary will be `client only', i.e. will send its values via multicast and not create any RRD files itself. Alternatively you can chose to write CSV-files (Comma Separated Values) instead. + * librt, libsocket, libkstat, libdevinfo (optional) + Various standard Solaris libraries which provide system functions. + * libsensors (optional) To read from `lm_sensors', see the `sensors' plugin. - * libstatgrab may be used to collect statistics on systems other than Linux - and/or Solaris. Note that CPU- and disk-statistics, while being provided - by this library, are not supported in collectd right now.. + * libstatgrab (optional) may be used to collect statistics on systems other + than Linux and/or Solaris. Note that CPU- and disk-statistics, while being + provided by this library, are not supported in collectd right now.. * libupsclient/nut (optional) For the `nut' plugin which queries nut's `upsd'. - * libxmms (optional) - - * librt, libsocket, libkstat, libdevinfo - Various standard Solaris libraries which provide system functions. - - * CoreFoundation.framework and IOKit.framework - For compiling on Darwin in general and the `apple_sensors' plugin in - particular. - * libvirt (optional) Collect statistics from virtual machines. * libxml2 (optional) Parse XML data. This is needed for the `ascent' and `libvirt' plugins. + * libxmms (optional) + Configuring / Compiling / Installing ------------------------------------ diff --git a/TODO b/TODO index 08fcec1e..b5cd6b50 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ -For version 4.4: -* PowerDNS plugin - -For version 4.3: -* unixsock plugin: Remove the custom cache if possible. +* Parse options/identifiers with spaces in them correctly. +* Figure out what to do with the onewire plugin. +* Custom notification messages? src/battery.c: commend not working code. diff --git a/bindings/perl/Collectd.pm b/bindings/perl/Collectd.pm index cca349ec..738206bb 100644 --- a/bindings/perl/Collectd.pm +++ b/bindings/perl/Collectd.pm @@ -56,6 +56,7 @@ our %EXPORT_TAGS = ( TYPE_LOG TYPE_NOTIF TYPE_FLUSH + TYPE_CONFIG TYPE_DATASET ) ], 'ds_types' => [ qw( @@ -98,6 +99,7 @@ our $interval_g; Exporter::export_ok_tags ('all'); my @plugins : shared = (); +my %cf_callbacks : shared = (); my %types = ( TYPE_INIT, "init", @@ -133,6 +135,8 @@ sub DEBUG { _log (scalar caller, LOG_DEBUG, shift); } sub plugin_call_all { my $type = shift; + my %plugins; + our $cb_name = undef; if (! defined $type) { @@ -148,9 +152,13 @@ sub plugin_call_all { return; } - lock @plugins; - foreach my $plugin (keys %{$plugins[$type]}) { - my $p = $plugins[$type]->{$plugin}; + { + lock %{$plugins[$type]}; + %plugins = %{$plugins[$type]}; + } + + foreach my $plugin (keys %plugins) { + my $p = $plugins{$plugin}; my $status = 0; @@ -238,7 +246,8 @@ sub plugin_register { return; } - if ((! defined $plugins[$type]) && (TYPE_DATASET != $type)) { + if ((! defined $plugins[$type]) && (TYPE_DATASET != $type) + && (TYPE_CONFIG != $type)) { ERROR ("Collectd::plugin_register: Invalid type \"$type\""); return; } @@ -246,6 +255,16 @@ sub plugin_register { if ((TYPE_DATASET == $type) && ("ARRAY" eq ref $data)) { return plugin_register_data_set ($name, $data); } + elsif ((TYPE_CONFIG == $type) && (! ref $data)) { + my $pkg = scalar caller; + + if ($data !~ m/^$pkg\:\:/) { + $data = $pkg . "::" . $data; + } + + lock %cf_callbacks; + $cf_callbacks{$name} = $data; + } elsif ((TYPE_DATASET != $type) && (! ref $data)) { my $pkg = scalar caller; @@ -261,7 +280,7 @@ sub plugin_register { cb_name => $data, ); - lock @plugins; + lock %{$plugins[$type]}; $plugins[$type]->{$name} = \%p; } else { @@ -285,8 +304,12 @@ sub plugin_unregister { if (TYPE_DATASET == $type) { return plugin_unregister_data_set ($name); } + elsif (TYPE_CONFIG == $type) { + lock %cf_callbacks; + delete $cf_callbacks{$name}; + } elsif (defined $plugins[$type]) { - lock @plugins; + lock %{$plugins[$type]}; delete $plugins[$type]->{$name}; } else { @@ -299,28 +322,101 @@ sub plugin_flush { my %args = @_; my $timeout = -1; + my @plugins = (); + my @ids = (); DEBUG ("Collectd::plugin_flush:" . (defined ($args{'timeout'}) ? " timeout = $args{'timeout'}" : "") - . (defined ($args{'plugins'}) ? " plugins = $args{'plugins'}" : "")); + . (defined ($args{'plugins'}) ? " plugins = $args{'plugins'}" : "") + . (defined ($args{'identifiers'}) + ? " identifiers = $args{'identifiers'}" : "")); if (defined ($args{'timeout'}) && ($args{'timeout'} > 0)) { $timeout = $args{'timeout'}; } - if (! defined $args{'plugins'}) { - plugin_flush_all ($timeout); + if (defined ($args{'plugins'})) { + if ("ARRAY" eq ref ($args{'plugins'})) { + @plugins = @{$args{'plugins'}}; + } + else { + @plugins = ($args{'plugins'}); + } } else { - if ("ARRAY" eq ref ($args{'plugins'})) { - foreach my $plugin (@{$args{'plugins'}}) { - plugin_flush_one ($timeout, $plugin); - } + @plugins = (undef); + } + + if (defined ($args{'identifiers'})) { + if ("ARRAY" eq ref ($args{'identifiers'})) { + @ids = @{$args{'identifiers'}}; } else { - plugin_flush_one ($timeout, $args{'plugins'}); + @ids = ($args{'identifiers'}); } } + else { + @ids = (undef); + } + + foreach my $plugin (@plugins) { + foreach my $id (@ids) { + _plugin_flush($plugin, $timeout, $id); + } + } +} + +sub plugin_flush_one { + my $timeout = shift; + my $name = shift; + + WARNING ("Collectd::plugin_flush_one is deprecated - " + . "use Collectd::plugin_flush instead."); + + if (! (defined ($timeout) && defined ($name))) { + ERROR ("Usage: Collectd::plugin_flush_one(timeout, name)"); + return; + } + + plugin_flush (plugins => $name, timeout => $timeout); +} + +sub plugin_flush_all { + my $timeout = shift; + + WARNING ("Collectd::plugin_flush_all is deprecated - " + . "use Collectd::plugin_flush instead."); + + if (! defined ($timeout)) { + ERROR ("Usage: Collectd::plugin_flush_all(timeout)"); + return; + } + + plugin_flush (timeout => $timeout); +} + +sub _plugin_dispatch_config { + my $plugin = shift; + my $config = shift; + + our $cb_name = undef; + + if (! (defined ($plugin) && defined ($config))) { + return; + } + + if (! defined $cf_callbacks{$plugin}) { + WARNING ("Found a configuration for the \"$plugin\" plugin, but " + . "the plugin isn't loaded or didn't register " + . "a configuration callback."); + return; + } + + { + lock %cf_callbacks; + $cb_name = $cf_callbacks{$plugin}; + } + call_by_name ($config); } 1; diff --git a/bindings/perl/Collectd/Unixsock.pm b/bindings/perl/Collectd/Unixsock.pm index 29fac3e9..eb6e389e 100644 --- a/bindings/perl/Collectd/Unixsock.pm +++ b/bindings/perl/Collectd/Unixsock.pm @@ -57,8 +57,19 @@ use Carp (qw(cluck confess)); use IO::Socket::UNIX; use Regexp::Common (qw(number)); +our $Debug = 0; + return (1); +sub _debug +{ + if (!$Debug) + { + return; + } + print @_; +} + sub _create_socket { my $path = shift; @@ -71,7 +82,7 @@ sub _create_socket return ($sock); } # _create_socket -=head1 VALUE IDENTIFIER +=head1 VALUE IDENTIFIERS The values in the collectd are identified using an five-tuple (host, plugin, plugin-instance, type, type-instance) where only plugin-instance and @@ -134,6 +145,22 @@ sub _parse_identifier return ($ident); } # _parse_identifier +sub _escape_argument +{ + my $string = shift; + + if ($string =~ m/^\w+$/) + { + return ("$string"); + } + + $string =~ s#\\#\\\\#g; + $string =~ s#"#\\"#g; + $string = "\"$string\""; + + return ($string); +} + =head1 PUBLIC METHODS =over 4 @@ -175,7 +202,7 @@ sub getval my %args = @_; my $status; - my $fh = $obj->{'sock'} or confess; + my $fh = $obj->{'sock'} or confess ('object has no filehandle'); my $msg; my $identifier; @@ -183,13 +210,13 @@ sub getval $identifier = _create_identifier (\%args) or return; - $msg = "GETVAL $identifier\n"; - #print "-> $msg"; - send ($fh, $msg, 0) or confess ("send: $!"); + $msg = 'GETVAL ' . _escape_argument ($identifier) . "\n"; + _debug "-> $msg"; + print $fh $msg; - $msg = undef; - recv ($fh, $msg, 1024, 0) or confess ("recv: $!"); - #print "<- $msg"; + $msg = <$fh>; + chomp ($msg); + _debug "<- $msg\n"; ($status, $msg) = split (' ', $msg, 2); if ($status <= 0) @@ -198,9 +225,12 @@ sub getval return; } - for (split (' ', $msg)) + for (my $i = 0; $i < $status; $i++) { - my $entry = $_; + my $entry = <$fh>; + chomp ($entry); + _debug "<- $entry\n"; + if ($entry =~ m/^(\w+)=NaN$/) { $ret->{$1} = undef; @@ -219,8 +249,8 @@ sub getval Submits a value-list to the daemon. If the B