Code

Merge branch 'mf/redhat' into collectd-5.2
authorFlorian Forster <octo@collectd.org>
Wed, 20 Feb 2013 13:40:46 +0000 (14:40 +0100)
committerFlorian Forster <octo@collectd.org>
Wed, 20 Feb 2013 13:40:46 +0000 (14:40 +0100)
Fixes Github issue #220.

41 files changed:
ChangeLog
README
bindings/Makefile.am
bindings/perl/uninstall_mod.pl [new file with mode: 0644]
clean.sh
configure.in
contrib/collection3/etc/collection.conf
src/Makefile.am
src/amqp.c
src/apache.c
src/apcups.c
src/ascent.c
src/bind.c
src/collectd-tg.pod [new file with mode: 0644]
src/collectd.conf.in
src/collectd.conf.pod
src/cpu.c
src/curl.c
src/curl_json.c
src/curl_xml.c
src/dbi.c
src/ethstat.c
src/libcollectdclient/Makefile.am
src/libcollectdclient/network_buffer.c
src/logfile.c
src/nginx.c
src/pf.c
src/postgresql.c
src/redis.c
src/types.db
src/utils_complain.c
src/utils_complain.h
src/utils_dns.c
src/utils_format_graphite.c
src/utils_format_graphite.h
src/utils_tail.c
src/varnish.c
src/write_graphite.c
src/write_http.c
src/zfs_arc.c
version-gen.sh

index d7dcbdf4b50364082bd6d61ef8f6610109776686..c59e112e61e466a2f823635cc536a786473a3ae3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2013-01-27, Version 5.2.1
+       * Build system: "make distcheck" has been fixed. Build fixes Solaris
+         and systems without gcrypt. Thanks to Yves Mettier for his patches.
+       * collectd: The complaint mechanism was fixed. It reported messages
+         more frequently than intended.
+       * collectd-tg: A manual page has been added.
+       * dns plugin: Build issues on FreeBSD have been fixed. Thanks to
+         Ed Schouten for his patch.
+       * ethstat plugin: Fix the "Map" config option. An incorrectly used
+         character pointer may lead to a segmentation fault.
+       * network plugin: Build issues on FreeBSD have been fixed. Thanks to
+         Ed Schouten for his patch.
+       * postgresql plugin: A memory leak in the writing code has been fixed.
+         A use-after-free issue that happened when more than one database was
+         configured was fixed. Thanks to Sebastian Harl for fixing these
+         problems.
+       * redis plugin: A build failure has been fixed. Thanks to Pierre-Yves
+         Ritschard for his patch.
+       * varnish plugin: Fix a problem with instances without name.
+       * write_graphite plugin: A regression which rendered the
+         "SeparateInstances" and "AlwaysAppendDS" options unusable has been
+         fixed. A failed assertion when using types with many data sources
+         has been fixed. Improve reporting of connection errors to not spam
+         log files too much. Thanks to Pierre-Yves Ritschard for reporting
+         the logging problem.
+       * zfs_arc plugin: Fix the type used for mutex misses. Thanks to Yves
+         Mettier for reporting this bug.
+
 2012-11-17, Version 5.2.0
        * collectd: The performance of the LISTVAL command has been improved.
          Thanks to Yves Mettier for the patch.
        * tcpconns plugin: Use a netlink socket rather than reading from /proc
          for improved performance. Thanks to Michael Stapelberg for the patch.
 
+2013-01-25, Version 5.1.2
+       * Build system: "make distcheck" has been fixed. Thanks to Yves
+         Mettier for his patches.
+       * collectd: The complaint mechanism was fixed. It reported messages
+         more frequently than intended.
+       * dns plugin: Build issues on FreeBSD have been fixed. Thanks to
+         Ed Schouten for his patch.
+       * ethstat plugin: Fix the "Map" config option. An incorrectly used
+         character pointer may lead to a segmentation fault.
+       * network plugin: Build issues on FreeBSD have been fixed. Thanks to
+         Ed Schouten for his patch.
+       * varnish plugin: Fix a problem with instances without name.
+       * write_graphite: Improve reporting of connection errors to not spam
+         log files too much. Thanks to Pierre-Yves Ritschard for reporting
+         this problem.
+       * zfs_arc plugin: Fix the type used for mutex misses. Thanks to Yves
+         Mettier for reporting this bug.
+
 2012-11-11, Version 5.1.1
        * collectd: Create new directories with mode 0777 and let umask remove
          unwanted permission bits.
diff --git a/README b/README
index 67cac046aa835e8c0a319a5097e88c74c6914fe4..45dcadb83f931d87c92fcf4ffd36e56455893d15 100644 (file)
--- a/README
+++ b/README
@@ -222,6 +222,9 @@ Features
       write your own plugins in Perl and return arbitrary values using this
       API. See collectd-perl(5).
 
+    - pf
+      Query statistics from BSD's packet filter "pf".
+
     - pinba
       Receive and dispatch timing values from Pinba, a profiling extension for
       PHP.
@@ -458,6 +461,10 @@ Features
 
   * Miscellaneous plugins:
 
+    - aggregation
+      Selects multiple value lists based on patterns or regular expressions
+      and creates new aggregated values lists from those.
+
     - threshold
       Checks values against configured thresholds and creates notifications if
       values are out of bounds. See collectd-threshold(5) for details.
index 3876cc2c06d3f6ae70b08243cd18343b1c3f5a6f..50cd727fc9030be20efd30f3b856c8c0baf814e7 100644 (file)
@@ -5,6 +5,7 @@ SUBDIRS += java
 endif
 
 EXTRA_DIST = perl/Makefile.PL \
+            perl/uninstall_mod.pl \
             perl/lib/Collectd.pm \
             perl/lib/Collectd/Unixsock.pm \
             perl/lib/Collectd/Plugins/Monitorus.pm \
@@ -33,12 +34,8 @@ install-exec-local:
 # Perl 'make uninstall' does not work as well as wanted.
 # So we do the work here.
 uninstall-local:
-       rm -f $(DESTDIR)$(mandir)/man3/Collectd::Unixsock.3pm
-       rm -f $(DESTDIR)$(datarootdir)/perl5/Collectd.pm
-       rm -f $(DESTDIR)$(datarootdir)/perl5/Collectd/Plugins/OpenVZ.pm
-       rm -f $(DESTDIR)$(datarootdir)/perl5/Collectd/Unixsock.pm
-       rm -f $(DESTDIR)$(prefix)/lib64/perl5/perllocal.pod
-       rm -f $(DESTDIR)$(prefix)/lib64/perl5/auto/Collectd/.packlist
+       @PERL@ -I$(DESTDIR)$(prefix) $(srcdir)/perl/uninstall_mod.pl Collectd
+       find $(DESTDIR)$(prefix) -name "perllocal.pod" -exec rm {} \;
 
 clean-local:
        rm -rf buildperl
@@ -48,7 +45,7 @@ perl: buildperl/Makefile
 
 buildperl/Makefile: .perl-directory-stamp buildperl/Makefile.PL \
        $(top_builddir)/config.status
-       cd buildperl && @PERL@ Makefile.PL INSTALL_BASE=$(prefix) @PERL_BINDINGS_OPTIONS@
+       cd buildperl && @PERL@ Makefile.PL INSTALL_BASE=$(DESTDIR)$(prefix) @PERL_BINDINGS_OPTIONS@
 
 buildperl/Makefile.PL: .perl-directory-stamp $(top_builddir)/config.status
 
diff --git a/bindings/perl/uninstall_mod.pl b/bindings/perl/uninstall_mod.pl
new file mode 100644 (file)
index 0000000..f8083af
--- /dev/null
@@ -0,0 +1,8 @@
+#! /usr/bin/perl
+
+use strict;
+use ExtUtils::Installed;
+
+my $mod = $ARGV[0] || die "Usage : $0 Module\n";
+my $inst = ExtUtils::Installed->new();
+unlink $inst->files($mod), $inst->packlist($mod)->packlist_file();
index 098669da892eb7f001813f383806bd925ca86483..9defb05d5a1f93297e19e4cff350a3b31b0f70ab 100755 (executable)
--- a/clean.sh
+++ b/clean.sh
@@ -47,4 +47,6 @@ true \
 && rm -f -r src/libcollectdclient/.libs \
 && rm -f src/libcollectdclient/*.o \
 && rm -f src/libcollectdclient/*.la \
-&& rm -f src/libcollectdclient/*.lo
+&& rm -f src/libcollectdclient/*.lo \
+&& rm -f bindings/.perl-directory-stamp \
+&& rm -f -r bindings/buildperl
index 98395ed14228a484c886a3659031a30b6c333c85..fc0a1d1c208e03b140455797b67608f54af2bcca 100644 (file)
@@ -24,7 +24,7 @@ m4_ifdef([LT_PACKAGE_VERSION],
        ]
 )
 
-AM_INIT_AUTOMAKE(dist-bzip2)
+AM_INIT_AUTOMAKE([tar-pax dist-bzip2])
 AC_LANG(C)
 
 AC_PREFIX_DEFAULT("/opt/collectd")
@@ -536,7 +536,20 @@ AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
 AC_CHECK_HEADERS(netinet/ip_compat.h)
 
 have_net_pfvar_h="no"
-AC_CHECK_HEADERS(net/pfvar.h, [have_net_pfvar_h="yes"])
+AC_CHECK_HEADERS(net/pfvar.h,
+               [have_net_pfvar_h="yes"],
+               [have_net_pfvar_h="no"],
+[
+#if HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+])
 
 # For the multimeter plugin
 have_termios_h="no"
index 3bb3d8b125de6d9a2ac0209f917685a560332277..5d1024fbcae80c465fff95941f8d39dc19f03527 100644 (file)
@@ -2,7 +2,7 @@
 GraphWidth 400
 #UnixSockAddr "/var/run/collectd-unixsock"
 <Type apache_bytes>
-  DataSources count
+  DataSources value
   DSName "count Bytes/s"
   RRDTitle "Apache Traffic"
   RRDVerticalLabel "Bytes/s"
@@ -10,7 +10,7 @@ GraphWidth 400
   Color count 0000ff
 </Type>
 <Type apache_requests>
-  DataSources count
+  DataSources value
   DSName "count Requests/s"
   RRDTitle "Apache Traffic"
   RRDVerticalLabel "Requests/s"
@@ -19,7 +19,7 @@ GraphWidth 400
 </Type>
 <Type apache_scoreboard>
   Module GenericStacked
-  DataSources count
+  DataSources value
   RRDTitle "Apache scoreboard on {hostname}"
   RRDVerticalLabel "Slots"
   RRDFormat "%6.2lf"
@@ -245,14 +245,14 @@ GraphWidth 400
   RRDFormat "%6.1lf"
 </Type>
 <Type conntrack>
-  DataSources conntrack
+  DataSources value
   DSName conntrack Conntrack count
   RRDTitle "nf_conntrack connections on {hostname}"
   RRDVerticalLabel "Count"
   RRDFormat "%4.0lf"
 </Type>
 <Type entropy>
-  DataSources entropy
+  DataSources value
   DSName entropy Entropy bits
   RRDTitle "Available entropy on {hostname}"
   RRDVerticalLabel "Bits"
@@ -267,7 +267,7 @@ GraphWidth 400
   Color value 00b000
 </Type>
 <Type frequency>
-  DataSources frequency
+  DataSources value
   DSName frequency Frequency
   RRDTitle "Frequency ({type_instance})"
   RRDVerticalLabel "Hertz"
@@ -542,7 +542,7 @@ GraphWidth 400
   Scale 8
 </Type>
 <Type percent>
-  DataSources percent
+  DataSources value
   DSName percent Percent
   RRDTitle "Percent ({type_instance})"
   RRDVerticalLabel "Percent"
@@ -550,7 +550,7 @@ GraphWidth 400
   Color percent 0000ff
 </Type>
 <Type ping>
-  DataSources ping
+  DataSources value
   DSName "ping Latency"
   RRDTitle "Network latency ({type_instance})"
   RRDVerticalLabel "Milliseconds"
@@ -700,7 +700,7 @@ GraphWidth 400
   Scale 0.001
 </Type>
 <Type users>
-  DataSources users
+  DataSources value
   DSName users Users
   RRDTitle "Users ({type_instance}) on {hostname}"
   RRDVerticalLabel "Users"
index 26c2355e50a0aead892ddc9fb3bc10156dc05a54..aa014100158c3622212bf5e41d6a3c8a1168d773 100644 (file)
@@ -90,6 +90,7 @@ collectdmon_SOURCES = collectdmon.c
 collectdmon_CPPFLAGS = $(AM_CPPFLAGS)
 
 collectd_nagios_SOURCES = collectd-nagios.c
+collectd_nagios_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_builddir)/src/libcollectdclient/collectd
 collectd_nagios_LDADD =
 if BUILD_WITH_LIBSOCKET
 collectd_nagios_LDADD += -lsocket
@@ -103,6 +104,7 @@ collectd_nagios_DEPENDENCIES = libcollectdclient/libcollectdclient.la
 
 
 collectdctl_SOURCES = collectdctl.c
+collectdctl_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_builddir)/src/libcollectdclient/collectd
 collectdctl_LDADD =
 if BUILD_WITH_LIBSOCKET
 collectdctl_LDADD += -lsocket
@@ -115,10 +117,14 @@ collectdctl_DEPENDENCIES = libcollectdclient/libcollectdclient.la
 
 collectd_tg_SOURCES = collectd-tg.c \
                      utils_heap.c utils_heap.h
+collectd_tg_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_builddir)/src/libcollectdclient/collectd
 collectd_tg_LDADD =
 if BUILD_WITH_LIBSOCKET
 collectd_tg_LDADD += -lsocket
 endif
+if BUILD_WITH_LIBRT
+collectd_tg_LDADD += -lrt
+endif
 if BUILD_AIX
 collectd_tg_LDADD += -lm
 endif
@@ -1369,6 +1375,7 @@ dist_man_MANS = collectd.1 \
                collectd-perl.5 \
                collectd-python.5 \
                collectd-snmp.5 \
+               collectd-tg.1 \
                collectd-threshold.5 \
                collectd-unixsock.5 \
                types.db.5
@@ -1388,6 +1395,7 @@ EXTRA_DIST +=   collectd.conf.pod \
                collectd-python.pod \
                collectd.pod \
                collectd-snmp.pod \
+               collectd-tg.pod \
                collectd-threshold.pod \
                collectd-unixsock.pod \
                postgresql_default.conf \
@@ -1410,7 +1418,7 @@ EXTRA_DIST +=   collectd.conf.pod \
        fi
 
 pinba.pb-c.c pinba.pb-c.h: pinba.proto
-       protoc-c --c_out . pinba.proto
+       protoc-c -I$(srcdir) --c_out . $(srcdir)/pinba.proto
 
 install-exec-hook:
        $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
index 9c8c6e537c6cb1d2f3907402f7c602e2f8b326b6..767a8776bbfb07ce2a26f932cf7fb5da4d22d047 100644 (file)
@@ -74,6 +74,7 @@ struct camqp_config_s
     char    *prefix;
     char    *postfix;
     char    escape_char;
+    unsigned int graphite_flags;
 
     /* subscribe only */
     char   *exchange_type;
@@ -794,7 +795,7 @@ static int camqp_write (const data_set_t *ds, const value_list_t *vl, /* {{{ */
     {
         status = format_graphite (buffer, sizeof (buffer), ds, vl,
                     conf->prefix, conf->postfix, conf->escape_char,
-                    conf->store_rates);
+                    conf->graphite_flags);
         if (status != 0)
         {
             ERROR ("amqp plugin: format_graphite failed with status %i.",
@@ -934,7 +935,11 @@ static int camqp_config_connection (oconfig_item_t *ci, /* {{{ */
                 conf->delivery_mode = CAMQP_DM_VOLATILE;
         }
         else if ((strcasecmp ("StoreRates", child->key) == 0) && publish)
+        {
             status = cf_util_get_boolean (child, &conf->store_rates);
+            (void) cf_util_get_flag (child, &conf->graphite_flags,
+                    GRAPHITE_STORE_RATES);
+        }
         else if ((strcasecmp ("Format", child->key) == 0) && publish)
             status = camqp_config_set_format (child, conf);
         else if ((strcasecmp ("GraphitePrefix", child->key) == 0) && publish)
index c31dd8752cd37c6570fa16503d6dc4a0bfe2ac20..202b73cfdc258f451b463a15ecfe9ca5b026865d 100644 (file)
@@ -373,7 +373,7 @@ static int init_host (apache_t *st) /* {{{ */
                return (-1);
        }
 
-       curl_easy_setopt (st->curl, CURLOPT_NOSIGNAL, 1);
+       curl_easy_setopt (st->curl, CURLOPT_NOSIGNAL, 1L);
        curl_easy_setopt (st->curl, CURLOPT_WRITEFUNCTION, apache_curl_callback);
        curl_easy_setopt (st->curl, CURLOPT_WRITEDATA, st);
 
@@ -425,24 +425,24 @@ static int init_host (apache_t *st) /* {{{ */
        }
 
        curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
-       curl_easy_setopt (st->curl, CURLOPT_FOLLOWLOCATION, 1);
+       curl_easy_setopt (st->curl, CURLOPT_FOLLOWLOCATION, 1L);
 
        if (st->verify_peer != 0)
        {
-               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYPEER, 1);
+               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYPEER, 1L);
        }
        else
        {
-               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYPEER, 0);
+               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYPEER, 0L);
        }
 
        if (st->verify_host != 0)
        {
-               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYHOST, 2);
+               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYHOST, 2L);
        }
        else
        {
-               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYHOST, 0);
+               curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYHOST, 0L);
        }
 
        if (st->cacert != NULL)
index 4fbbde63aad113dcbefdbc2db47e545ca3b5c241..137c0f2f17239e4b1bc429704cb5623266456fbd 100644 (file)
@@ -450,7 +450,7 @@ static int apcups_read (void)
        apcups_detail.battv    =   -1.0;
        apcups_detail.loadpct  =   -1.0;
        apcups_detail.bcharge  =   -1.0;
-       apcups_detail.timeleft =   -1.0;
+       apcups_detail.timeleft =    NAN;
        apcups_detail.itemp    = -300.0;
        apcups_detail.linefreq =   -1.0;
 
index 993e480cb1746b0464741967eb6340921365ca7b..3a7c393963b8368d605fa0497e82f1feffd2c837 100644 (file)
@@ -539,7 +539,7 @@ static int ascent_init (void) /* {{{ */
     return (-1);
   }
 
-  curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1);
+  curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L);
   curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ascent_curl_callback);
   curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
   curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, ascent_curl_error);
@@ -561,17 +561,17 @@ static int ascent_init (void) /* {{{ */
   }
 
   curl_easy_setopt (curl, CURLOPT_URL, url);
-  curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1);
+  curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
 
   if ((verify_peer == NULL) || IS_TRUE (verify_peer))
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1L);
   else
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L);
 
   if ((verify_host == NULL) || IS_TRUE (verify_host))
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2L);
   else
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L);
 
   if (cacert != NULL)
     curl_easy_setopt (curl, CURLOPT_CAINFO, cacert);
index 5b7d7a056efe7d1a693c34b6737a191b2dbab63c..288949a802113ed0a8d3b049ae02a65bc1dd3344 100644 (file)
@@ -1393,12 +1393,12 @@ static int bind_init (void) /* {{{ */
     return (-1);
   }
 
-  curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1);
+  curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L);
   curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
   curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
   curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, bind_curl_error);
   curl_easy_setopt (curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
-  curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1);
+  curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
 
   return (0);
 } /* }}} int bind_init */
diff --git a/src/collectd-tg.pod b/src/collectd-tg.pod
new file mode 100644 (file)
index 0000000..5f1b630
--- /dev/null
@@ -0,0 +1,65 @@
+=head1 NAME
+
+collectd-tg - Traffic generator for collectd.
+
+=head1 SYNOPSIS
+
+collectd-tg B<-n> I<num_vl> B<-H> I<num_hosts> B<-p> I<num_plugins> B<-i> I<interval> B<-d> I<dest> B<-D> I<dport>
+
+=head1 DESCRIPTION
+
+B<collectd-tg> generates bogus I<collectd> network traffic. While host, plugin
+and values are generated randomly, the generated traffic tries to mimic "real"
+traffic as closely as possible.
+
+=head1 ARGUMENTS AND OPTIONS
+
+The following options are understood by I<collectd-tg>. The order of the
+arguments generally doesn't matter, as long as no argument is passed more than
+once.
+
+=over 4
+
+=item B<-n> I<num_vl>
+
+Sets the number of unique I<value lists> (VL) to generate. Defaults to 10000.
+
+=item B<-H> I<num_hosts>
+
+Sets the number of unique hosts to simulate. Defaults to 1000.
+
+=item B<-p> I<num_plugins>
+
+Sets the number of unique plugins to simulate. Defaults to 20.
+
+=item B<-i> I<interval>
+
+Sets the interval in which each I<value list> is dispatched. Defaults to 10.0
+seconds.
+
+=item B<-d> I<dest>
+
+Sets the destination to which to send the generated network traffic. Defaults
+to the IPv6 multicast address, C<ff18::efc0:4a42>.
+
+=item B<-D> I<dport>
+
+Sets the destination port or service to which to send the generated network
+traffic. Defaults to I<collectd's> default port, C<25826>.
+
+=item B<-h>
+
+Print usage summary.
+
+=back
+
+=head1 SEE ALSO
+
+L<collectd(1)>,
+L<collectd.conf(5)>
+
+=head1 AUTHOR
+
+Florian Forster E<lt>octoE<nbsp>atE<nbsp>collectd.orgE<gt>
+
+=cut
index 87af1c96c390b53ba79a51356c14f46678ece771..db81a4ad5241c36ad0135a035c47051a1f9c4afd 100644 (file)
 #PIDFile     "@localstatedir@/run/@PACKAGE_NAME@.pid"
 #PluginDir   "@libdir@/@PACKAGE_NAME@"
 #TypesDB     "@prefix@/share/@PACKAGE_NAME@/types.db"
+
+#----------------------------------------------------------------------------#
+# Interval at which to query values. This may be overwritten on a per-plugin #
+# base by using the 'Interval' option of the LoadPlugin block:               #
+#   <LoadPlugin foo>                                                         #
+#       Interval 60                                                          #
+#   </LoadPlugin>                                                            #
+#----------------------------------------------------------------------------#
 #Interval     10
+
 #Timeout      2
 #ReadThreads  5
 
 #                      ValuesFrom "count"
 #              </Result>
 #      </Query>
+#      <Writer sqlstore>
+#              # See contrib/postgresql/collectd_insert.sql for details
+#              Statement "SELECT collectd_insert($1, $2, $3, $4, $5, $6, $7, $8, $9);"
+#              StoreRates true
+#      </Writer>
 #      <Database foo>
 #              Host "hostname"
 #              Port "5432"
 #              Query backend # predefined
 #              Query rt36_tickets
 #      </Database>
+#      <Database qux>
+#              Service "collectd_store"
+#              Writer sqlstore
+#              # see collectd.conf(5) for details
+#              CommitInterval 30
+#      </Database>
 #</Plugin>
 
 #<Plugin powerdns>
index aef92267f80c51c0975dcc46c94b739e3846a140..18e7f53c78e1136d2903dac26abe61df9d23f989 100644 (file)
@@ -432,7 +432,7 @@ mode will be used, i.e. delivery is guaranteed. If set to B<false> (the
 default), the I<transient> delivery mode will be used, i.e. messages may be
 lost due to high load, overflowing queues or similar issues.
 
-=item B<Format> B<Command>|B<JSON> (Publish only)
+=item B<Format> B<Command>|B<JSON>|B<Graphite> (Publish only)
 
 Selects the format in which messages are sent to the broker. If set to
 B<Command> (the default), values are sent as C<PUTVAL> commands which are
index 5448003a52b3fc8a6777002ba5ede168dd6ff500..2247d5fdc7ad377acebfb4b26ef883d473d5de5c 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -344,8 +344,6 @@ static int cpu_read (void)
 
                cpu_temp_retry_counter = 0;
                cpu_temp_retry_step    = 1;
-
-               DEBUG ("cpu_temp = %i", (int) cpu_temp);
 #endif /* PROCESSOR_TEMPERATURE */
        }
 /* #endif PROCESSOR_CPU_LOAD_INFO */
index 2160b980de5a18c3ca9a0f98a8ddf37469f18bf2..69a5b9561c12c0e0f58a9e0e9b16716f84e7f777 100644 (file)
@@ -370,14 +370,14 @@ static int cc_page_init_curl (web_page_t *wp) /* {{{ */
     return (-1);
   }
 
-  curl_easy_setopt (wp->curl, CURLOPT_NOSIGNAL, 1);
+  curl_easy_setopt (wp->curl, CURLOPT_NOSIGNAL, 1L);
   curl_easy_setopt (wp->curl, CURLOPT_WRITEFUNCTION, cc_curl_callback);
   curl_easy_setopt (wp->curl, CURLOPT_WRITEDATA, wp);
   curl_easy_setopt (wp->curl, CURLOPT_USERAGENT,
       PACKAGE_NAME"/"PACKAGE_VERSION);
   curl_easy_setopt (wp->curl, CURLOPT_ERRORBUFFER, wp->curl_errbuf);
   curl_easy_setopt (wp->curl, CURLOPT_URL, wp->url);
-  curl_easy_setopt (wp->curl, CURLOPT_FOLLOWLOCATION, 1);
+  curl_easy_setopt (wp->curl, CURLOPT_FOLLOWLOCATION, 1L);
 
   if (wp->user != NULL)
   {
@@ -399,9 +399,9 @@ static int cc_page_init_curl (web_page_t *wp) /* {{{ */
     curl_easy_setopt (wp->curl, CURLOPT_USERPWD, wp->credentials);
   }
 
-  curl_easy_setopt (wp->curl, CURLOPT_SSL_VERIFYPEER, wp->verify_peer);
+  curl_easy_setopt (wp->curl, CURLOPT_SSL_VERIFYPEER, (long) wp->verify_peer);
   curl_easy_setopt (wp->curl, CURLOPT_SSL_VERIFYHOST,
-      wp->verify_host ? 2 : 0);
+      wp->verify_host ? 2L : 0L);
   if (wp->cacert != NULL)
     curl_easy_setopt (wp->curl, CURLOPT_CAINFO, wp->cacert);
 
index cc8b4ad3cb487360fee998148cfeaa67ca4dfd93..2ddaff3594d47663277deb886603e290a1363723 100644 (file)
@@ -521,7 +521,7 @@ static int cj_init_curl (cj_t *db) /* {{{ */
     return (-1);
   }
 
-  curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1);
+  curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1L);
   curl_easy_setopt (db->curl, CURLOPT_WRITEFUNCTION, cj_curl_callback);
   curl_easy_setopt (db->curl, CURLOPT_WRITEDATA, db);
   curl_easy_setopt (db->curl, CURLOPT_USERAGENT,
@@ -549,9 +549,9 @@ static int cj_init_curl (cj_t *db) /* {{{ */
     curl_easy_setopt (db->curl, CURLOPT_USERPWD, db->credentials);
   }
 
-  curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYPEER, (int) db->verify_peer);
+  curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYPEER, (long) db->verify_peer);
   curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYHOST,
-                    (int) (db->verify_host ? 2 : 0));
+                    db->verify_host ? 2L : 0L);
   if (db->cacert != NULL)
     curl_easy_setopt (db->curl, CURLOPT_CAINFO, db->cacert);
 
index 46e0d490967456156863413912fe234deeb5abda..da90d7c8773256a2f1ae9dc1728de93343b8b3ff 100644 (file)
@@ -737,7 +737,7 @@ static int cx_init_curl (cx_t *db) /* {{{ */
     return (-1);
   }
 
-  curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1);
+  curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1L);
   curl_easy_setopt (db->curl, CURLOPT_WRITEFUNCTION, cx_curl_callback);
   curl_easy_setopt (db->curl, CURLOPT_WRITEDATA, db);
   curl_easy_setopt (db->curl, CURLOPT_USERAGENT,
index caa41ef64023d247bd14721f936b0323df0ccfae..e15de3e89075bf1380b6f7ad57566f5a2948d7f5 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
@@ -193,33 +193,6 @@ static void cdbi_database_free (cdbi_database_t *db) /* {{{ */
  * </Plugin>
  */
 
-static int cdbi_config_set_string (char **ret_string, /* {{{ */
-    oconfig_item_t *ci)
-{
-  char *string;
-
-  if ((ci->values_num != 1)
-      || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("dbi plugin: The `%s' config option "
-        "needs exactly one string argument.", ci->key);
-    return (-1);
-  }
-
-  string = strdup (ci->values[0].value.string);
-  if (string == NULL)
-  {
-    ERROR ("dbi plugin: strdup failed.");
-    return (-1);
-  }
-
-  if (*ret_string != NULL)
-    free (*ret_string);
-  *ret_string = string;
-
-  return (0);
-} /* }}} int cdbi_config_set_string */
-
 static int cdbi_config_add_database_driver_option (cdbi_database_t *db, /* {{{ */
     oconfig_item_t *ci)
 {
@@ -286,7 +259,7 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */
   }
   memset (db, 0, sizeof (*db));
 
-  status = cdbi_config_set_string (&db->name, ci);
+  status = cf_util_get_string (ci, &db->name);
   if (status != 0)
   {
     sfree (db);
@@ -299,11 +272,11 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */
     oconfig_item_t *child = ci->children + i;
 
     if (strcasecmp ("Driver", child->key) == 0)
-      status = cdbi_config_set_string (&db->driver, child);
+      status = cf_util_get_string (child, &db->driver);
     else if (strcasecmp ("DriverOption", child->key) == 0)
       status = cdbi_config_add_database_driver_option (db, child);
     else if (strcasecmp ("SelectDB", child->key) == 0)
-      status = cdbi_config_set_string (&db->select_db, child);
+      status = cf_util_get_string (child, &db->select_db);
     else if (strcasecmp ("Query", child->key) == 0)
       status = udb_query_pick_from_list (child, queries, queries_num,
           &db->queries, &db->queries_num);
index 08381a821087e275fb03922a32bc54c35ca7c3cd..dec14f3d148962df3b1aaf41eb1f50f0a7a5f92c 100644 (file)
@@ -73,7 +73,7 @@ static int ethstat_add_interface (const oconfig_item_t *ci) /* {{{ */
     return (status);
 
   interfaces_num++;
-  INFO("ethstat plugin: Registred interface %s",
+  INFO("ethstat plugin: Registered interface %s",
       interfaces[interfaces_num - 1]);
 
   return (0);
@@ -83,6 +83,7 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */
 {
   value_map_t *map;
   int status;
+  char *key;
 
   if ((ci->values_num < 2)
       || (ci->values_num > 3)
@@ -96,9 +97,17 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */
     return (-1);
   }
 
+  key = strdup (ci->values[0].value.string);
+  if (key == NULL)
+  {
+    ERROR ("ethstat plugin: strdup(3) failed.");
+    return (ENOMEM);
+  }
+
   map = malloc (sizeof (*map));
   if (map == NULL)
   {
+    sfree (key);
     ERROR ("ethstat plugin: malloc(3) failed.");
     return (ENOMEM);
   }
@@ -115,23 +124,24 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */
     if (value_map == NULL)
     {
       sfree (map);
+      sfree (key);
       ERROR ("ethstat plugin: c_avl_create() failed.");
       return (-1);
     }
   }
 
   status = c_avl_insert (value_map,
-      /* key = */ ci->values[0].value.string,
+      /* key = */ key,
       /* value = */ map);
   if (status != 0)
   {
-    sfree (map);
     if (status > 0)
-      ERROR ("ethstat plugin: Multiple mappings for \"%s\".",
-          ci->values[0].value.string);
+      ERROR ("ethstat plugin: Multiple mappings for \"%s\".", key);
     else
-      ERROR ("ethstat plugin: c_avl_insert(\"%s\") failed.",
-          ci->values[0].value.string);
+      ERROR ("ethstat plugin: c_avl_insert(\"%s\") failed.", key);
+
+    sfree (map);
+    sfree (key);
     return (-1);
   }
 
@@ -328,10 +338,31 @@ static int ethstat_read(void)
   return 0;
 }
 
+static int ethstat_shutdown (void)
+{
+  void *key = NULL;
+  void *value = NULL;
+
+  if (value_map == NULL)
+    return (0);
+
+  while (c_avl_pick (value_map, &key, &value) == 0)
+  {
+    sfree (key);
+    sfree (value);
+  }
+
+  c_avl_destroy (value_map);
+  value_map = NULL;
+
+  return (0);
+}
+
 void module_register (void)
 {
   plugin_register_complex_config ("ethstat", ethstat_config);
   plugin_register_read ("ethstat", ethstat_read);
+  plugin_register_shutdown ("ethstat", ethstat_shutdown);
 }
 
 /* vim: set sw=2 sts=2 et fdm=marker : */
index 9fbf0d19adb503e255a377dc63659fcc202a525b..1d4dff59fccc29e180aa67544285ee0a8b2330b4 100644 (file)
@@ -11,7 +11,7 @@ nodist_pkgconfig_DATA = libcollectdclient.pc
 BUILT_SOURCES = collectd/lcc_features.h
 
 libcollectdclient_la_SOURCES = client.c network.c network_buffer.c
-libcollectdclient_la_CPPFLAGS = $(AM_CPPFLAGS)
+libcollectdclient_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_builddir)/src/libcollectdclient/collectd -I$(top_srcdir)/src
 libcollectdclient_la_LDFLAGS = -version-info 1:0:0
 libcollectdclient_la_LIBADD = 
 if BUILD_WITH_LIBGCRYPT
index 0b34e1f49c25e53ebd060227dcac15982140ef46..acbe93f51c050093ea3214819058049074542298 100644 (file)
@@ -106,9 +106,11 @@ struct lcc_network_buffer_s
   char *username;
   char *password;
 
+#if HAVE_LIBGCRYPT
   gcry_cipher_hd_t encr_cypher;
   size_t encr_header_len;
   char encr_iv[16];
+#endif
 };
 
 #define SSTRNCPY(dst,src,sz) do { \
@@ -128,6 +130,7 @@ static _Bool have_gcrypt (void) /* {{{ */
     return (result);
   need_init = 0;
 
+#if HAVE_LIBGCRYPT
   gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
 
   if (!gcry_check_version (GCRYPT_VERSION))
@@ -138,6 +141,9 @@ static _Bool have_gcrypt (void) /* {{{ */
 
   result = 1;
   return (1);
+#else
+  return(0);
+#endif
 } /* }}} _Bool have_gcrypt */
 
 static uint64_t htonll (uint64_t val) /* {{{ */
@@ -494,6 +500,7 @@ static int nb_add_value_list (lcc_network_buffer_t *nb, /* {{{ */
   return (0);
 } /* }}} int nb_add_value_list */
 
+#if HAVE_LIBGCRYPT
 static int nb_add_signature (lcc_network_buffer_t *nb) /* {{{ */
 {
   char *buffer;
@@ -620,6 +627,7 @@ static int nb_add_encryption (lcc_network_buffer_t *nb) /* {{{ */
 
   return (0);
 } /* }}} int nb_add_encryption */
+#endif
 
 /*
  * Public functions
@@ -720,6 +728,7 @@ int lcc_network_buffer_initialize (lcc_network_buffer_t *nb) /* {{{ */
   nb->ptr = nb->buffer;
   nb->free = nb->size;
 
+#if HAVE_LIBGCRYPT
   if (nb->seclevel == SIGN)
   {
     size_t username_len;
@@ -765,6 +774,7 @@ int lcc_network_buffer_initialize (lcc_network_buffer_t *nb) /* {{{ */
     ADD_GENERIC (nb, hash, sizeof (hash));
     assert ((nb->encr_header_len + nb->free) == nb->size);
   }
+#endif
 
   return (0);
 } /* }}} int lcc_network_buffer_initialize */
@@ -774,10 +784,12 @@ int lcc_network_buffer_finalize (lcc_network_buffer_t *nb) /* {{{ */
   if (nb == NULL)
     return (EINVAL);
 
+#if HAVE_LIBGCRYPT
   if (nb->seclevel == SIGN)
     nb_add_signature (nb);
   else if (nb->seclevel == ENCRYPT)
     nb_add_encryption (nb);
+#endif
 
   return (0);
 } /* }}} int lcc_network_buffer_finalize */
index ded7732b00ce22fcc648cbb8ae2207c53f26db94..0f20f3ca117d912b9df8b4d5118b93ee9660ead0 100644 (file)
@@ -81,7 +81,7 @@ static void logfile_print (const char *msg, int severity,
                cdtime_t timestamp_time)
 {
        FILE *fh;
-       int do_close = 0;
+       _Bool do_close = 0;
        struct tm timestamp_tm;
        char timestamp_str[64];
        char level_str[16] = "";
@@ -151,8 +151,11 @@ static void logfile_print (const char *msg, int severity,
                else
                        fprintf (fh, "%s%s\n", level_str, msg);
 
-               if (do_close != 0)
+               if (do_close) {
                        fclose (fh);
+               } else {
+                       fflush(fh);
+               }
        }
 
        pthread_mutex_unlock (&file_lock);
index 3e162bacf0bf52be3ecfb6dc8d48e223df4e0a3e..b76f25b360ba6bf1771519f34f044c134ff98c32 100644 (file)
@@ -120,7 +120,7 @@ static int init (void)
     return (-1);
   }
 
-  curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1);
+  curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L);
   curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, nginx_curl_callback);
   curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
   curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, nginx_curl_error);
@@ -143,24 +143,24 @@ static int init (void)
     curl_easy_setopt (curl, CURLOPT_URL, url);
   }
 
-  curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1);
+  curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
 
   if ((verify_peer == NULL) || IS_TRUE (verify_peer))
   {
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1L);
   }
   else
   {
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L);
   }
 
   if ((verify_host == NULL) || IS_TRUE (verify_host))
   {
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2L);
   }
   else
   {
-    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0);
+    curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L);
   }
 
   if (cacert != NULL)
index da539a26ec4cd9f6b1026ed39f8903568f97e346..44f0c7bcdec158b3244ec6f7b0d9212b9cd652d5 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
 #include "plugin.h"
 #include "common.h"
 
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <net/if.h>
+#if HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+
 #include <net/pfvar.h>
-#include <paths.h>
-#include <err.h>
-#include <pwd.h>
+
+#ifndef FCNT_NAMES
+# if FCNT_MAX != 3
+#  error "Unexpected value for FCNT_MAX"
+# endif
+# define FCNT_NAMES {"search", "insert", "removals", NULL};
+#endif
+
+#ifndef SCNT_NAMES
+# if SCNT_MAX != 3
+#  error "Unexpected value for SCNT_MAX"
+# endif
+# define SCNT_NAMES {"search", "insert", "removals", NULL};
+#endif
 
 static char const *pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
 static char const *pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
 static char const *pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
-static char const *pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
+static char const *pf_scounters[SCNT_MAX+1] = SCNT_NAMES;
 
 static char const *pf_device = "/dev/pf";
 
@@ -86,7 +104,7 @@ static int pf_read (void)
        close (fd);
        fd = -1;
 
-       if (!status.running)
+       if (!state.running)
        {
                WARNING ("pf plugin: PF is not running.");
                return (-1);
index 15d4666b9eaf910c2d91f80ce2552291eb9d6e45..98ceb6d3dc78cec10bd7ed4966ee5d50a7204567 100644 (file)
@@ -170,14 +170,14 @@ static char *def_queries[] = {
 };
 static int def_queries_num = STATIC_ARRAY_SIZE (def_queries);
 
-static c_psql_database_t *databases     = NULL;
-static size_t             databases_num = 0;
+static c_psql_database_t **databases     = NULL;
+static size_t              databases_num = 0;
 
-static udb_query_t      **queries       = NULL;
-static size_t             queries_num   = 0;
+static udb_query_t       **queries       = NULL;
+static size_t              queries_num   = 0;
 
-static c_psql_writer_t   *writers       = NULL;
-static size_t             writers_num   = 0;
+static c_psql_writer_t    *writers       = NULL;
+static size_t              writers_num   = 0;
 
 static int c_psql_begin (c_psql_database_t *db)
 {
@@ -220,17 +220,25 @@ static int c_psql_commit (c_psql_database_t *db)
 
 static c_psql_database_t *c_psql_database_new (const char *name)
 {
-       c_psql_database_t *db;
+       c_psql_database_t **tmp;
+       c_psql_database_t  *db;
 
-       db = (c_psql_database_t *)realloc (databases,
-                       (databases_num + 1) * sizeof (*db));
+       db = (c_psql_database_t *)malloc (sizeof(*db));
        if (NULL == db) {
                log_err ("Out of memory.");
                return NULL;
        }
 
-       databases = db;
-       db = databases + databases_num;
+       tmp = (c_psql_database_t **)realloc (databases,
+                       (databases_num + 1) * sizeof (*databases));
+       if (NULL == tmp) {
+               log_err ("Out of memory.");
+               sfree (db);
+               return NULL;
+       }
+
+       databases = tmp;
+       databases[databases_num] = db;
        ++databases_num;
 
        db->conn = NULL;
@@ -324,7 +332,9 @@ static void c_psql_database_delete (void *data)
        sfree (db->service);
 
        /* don't care about freeing or reordering the 'databases' array
-        * this is done in 'shutdown' */
+        * this is done in 'shutdown'; also, don't free the database instance
+        * object just to make sure that in case anybody accesses it before
+        * shutdown won't segfault */
        return;
 } /* c_psql_database_delete */
 
@@ -900,10 +910,10 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
 
                if ((PGRES_COMMAND_OK != PQresultStatus (res))
                                && (PGRES_TUPLES_OK != PQresultStatus (res))) {
+                       PQclear (res);
+
                        if ((CONNECTION_OK != PQstatus (db->conn))
                                        && (0 == c_psql_check_connection (db))) {
-                               PQclear (res);
-
                                /* try again */
                                res = PQexecParams (db->conn, writer->statement,
                                                STATIC_ARRAY_SIZE (params), NULL,
@@ -912,6 +922,7 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
 
                                if ((PGRES_COMMAND_OK == PQresultStatus (res))
                                                || (PGRES_TUPLES_OK == PQresultStatus (res))) {
+                                       PQclear (res);
                                        success = 1;
                                        continue;
                                }
@@ -932,6 +943,8 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
                        pthread_mutex_unlock (&db->db_lock);
                        return -1;
                }
+
+               PQclear (res);
                success = 1;
        }
 
@@ -953,17 +966,17 @@ static int c_psql_flush (cdtime_t timeout,
                __attribute__((unused)) const char *ident,
                user_data_t *ud)
 {
-       c_psql_database_t *dbs = databases;
+       c_psql_database_t **dbs = databases;
        size_t dbs_num = databases_num;
        size_t i;
 
        if ((ud != NULL) && (ud->data != NULL)) {
-               dbs = ud->data;
+               dbs = (void *)&ud->data;
                dbs_num = 1;
        }
 
        for (i = 0; i < dbs_num; ++i) {
-               c_psql_database_t *db = dbs + i;
+               c_psql_database_t *db = dbs[i];
 
                /* don't commit if the timeout is larger than the regular commit
                 * interval as in that case all requested data has already been
@@ -983,7 +996,7 @@ static int c_psql_shutdown (void)
        plugin_unregister_read_group ("postgresql");
 
        for (i = 0; i < databases_num; ++i) {
-               c_psql_database_t *db = databases + i;
+               c_psql_database_t *db = databases[i];
 
                if (db->writers_num > 0) {
                        char cb_name[DATA_MAX_NAME_LEN];
@@ -998,6 +1011,8 @@ static int c_psql_shutdown (void)
                        plugin_unregister_flush (cb_name);
                        plugin_unregister_write (cb_name);
                }
+
+               sfree (db);
        }
 
        udb_query_free (queries, queries_num);
index 439cf4b8158501e2bd215228b0a369e9dcb32f52..85a8354629240553f7e60a65ae0c5cb72446ae29 100644 (file)
@@ -33,6 +33,7 @@
 #endif
 
 #define REDIS_DEF_HOST   "localhost"
+#define REDIS_DEF_PASSWD ""
 #define REDIS_DEF_PORT    6379
 #define REDIS_DEF_TIMEOUT 2000
 #define MAX_REDIS_NODE_NAME 64
@@ -229,8 +230,8 @@ static void redis_submit_d (char *plugin_instance,
 
 static int redis_init (void) /* {{{ */
 {
-  redis_node_t rn = { "default", REDIS_DEF_HOST, REDIS_DEF_PORT,
-    REDIS_DEF_TIMEOUT, /* next = */ NULL };
+  redis_node_t rn = { "default", REDIS_DEF_HOST, REDIS_DEF_PASSWD,
+    REDIS_DEF_PORT, REDIS_DEF_TIMEOUT, /* next = */ NULL };
 
   if (nodes_head == NULL)
     redis_node_add (&rn);
index 25f4d7ca534dcadb1627124d6a83b9c4e847cf17..0abab4bbf9a9564142fe98671458059c82ec0f45 100644 (file)
@@ -158,7 +158,7 @@ tcp_connections             value:GAUGE:0:4294967295
 temperature            value:GAUGE:-273.15:U
 threads                        value:GAUGE:0:U
 time_dispersion                value:GAUGE:-1000000:1000000
-timeleft               value:GAUGE:0:3600
+timeleft               value:GAUGE:0:U
 time_offset            value:GAUGE:-1000000:1000000
 total_bytes            value:DERIVE:0:U
 total_connections      value:DERIVE:0:U
index 328a6ab6077113cb562ad0ae57a5abffc05d4d01..c3752bc161e0b1b285d9f4780e3c31dd3ade2de0 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/utils_complain.c
- * Copyright (C) 2006-2007  Florian octo Forster
+ * Copyright (C) 2006-2013  Florian octo Forster
  * Copyright (C) 2008  Sebastian tokkee Harl
  *
  * This program is free software; you can redistribute it and/or modify it
 static int vcomplain (int level, c_complain_t *c,
                const char *format, va_list ap)
 {
-       time_t now;
+       cdtime_t now;
        char   message[512];
 
-       now = time (NULL);
+       now = cdtime ();
 
        if (c->last + c->interval > now)
                return 0;
@@ -44,8 +44,8 @@ static int vcomplain (int level, c_complain_t *c,
        else
                c->interval *= 2;
 
-       if (c->interval > 86400)
-               c->interval = 86400;
+       if (c->interval > TIME_T_TO_CDTIME_T (86400))
+               c->interval = TIME_T_TO_CDTIME_T (86400);
 
        vsnprintf (message, sizeof (message), format, ap);
        message[sizeof (message) - 1] = '\0';
@@ -58,12 +58,9 @@ void c_complain (int level, c_complain_t *c, const char *format, ...)
 {
        va_list ap;
 
-       /* reset the old interval */
-       if (c->interval < 0)
-               c->interval *= -1;
-
        va_start (ap, format);
-       vcomplain (level, c, format, ap);
+       if (vcomplain (level, c, format, ap))
+               c->complained_once = 1;
        va_end (ap);
 } /* c_complain */
 
@@ -71,12 +68,12 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...)
 {
        va_list ap;
 
-       if (c->interval < 0)
+       if (c->complained_once)
                return;
 
        va_start (ap, format);
        if (vcomplain (level, c, format, ap))
-               c->interval *= -1;
+               c->complained_once = 1;
        va_end (ap);
 } /* c_complain_once */
 
@@ -89,6 +86,7 @@ void c_do_release (int level, c_complain_t *c, const char *format, ...)
                return;
 
        c->interval = 0;
+       c->complained_once = 0;
 
        va_start (ap, format);
        vsnprintf (message, sizeof (message), format, ap);
index 09c43750b3979f2bdd7e67a50bd60a298895ca2f..028dda6fc236b10d01913624df76cc3d75820dbe 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/utils_complain.h
- * Copyright (C) 2006-2007  Florian octo Forster
+ * Copyright (C) 2006-2013  Florian octo Forster
  * Copyright (C) 2008  Sebastian tokkee Harl
  *
  * This program is free software; you can redistribute it and/or modify it
 #ifndef UTILS_COMPLAIN_H
 #define UTILS_COMPLAIN_H 1
 
-#include <time.h>
+#include "utils_time.h"
 
 typedef struct
 {
        /* time of the last report */
-       time_t last;
+       cdtime_t last;
 
-       /* how long to wait until reporting again
-        *   0 indicates that the complaint is no longer valid
-        * < 0 indicates that the complaint has been reported once
-        *     => c_complain_once will not report again
-        *     => c_complain uses the absolute value to reset the old value */
-       int interval;
+       /* How long to wait until reporting again.
+        * 0 indicates that the complaint is no longer valid. */
+       cdtime_t interval;
+
+       _Bool complained_once;
 } c_complain_t;
 
-#define C_COMPLAIN_INIT_STATIC { 0, 0 }
-#define C_COMPLAIN_INIT(c) do { (c)->last = 0; (c)->interval = 0; } while (0)
+#define C_COMPLAIN_INIT_STATIC { 0, 0, 0 }
+#define C_COMPLAIN_INIT(c) do { \
+       (c)->last = 0; \
+       (c)->interval = 0; \
+       (c)->complained_once = 0; \
+} while (0)
 
 /*
  * NAME
index 80a2ee577f7213c4182a57b70e5f220d6d4d92fa..655c61edf0764cc9911bab2a71e6556bc83405a0 100644 (file)
 #include "plugin.h"
 #include "common.h"
 
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP6_H
-# include <netinet/ip6.h>
-#endif
-#if HAVE_NETINET_IP_COMPAT_H
-# include <netinet/ip_compat.h>
-#endif
-#if HAVE_ARPA_INET_H
-# include <arpa/inet.h>
-#endif
 #if HAVE_SYS_SOCKET_H
 # include <sys/socket.h>
 #endif
 
-#if HAVE_ARPA_NAMESER_H
-# include <arpa/nameser.h>
-#endif
-#if HAVE_ARPA_NAMESER_COMPAT_H
-# include <arpa/nameser_compat.h>
-#endif
-
 #if HAVE_NET_IF_ARP_H
 # include <net/if_arp.h>
 #endif
 #if HAVE_NET_IF_H
 # include <net/if.h>
 #endif
-#if HAVE_NETINET_IF_ETHER_H
-# include <netinet/if_ether.h>
-#endif
 #if HAVE_NET_PPP_DEFS_H
 # include <net/ppp_defs.h>
 #endif
 # include <net/if_ppp.h>
 #endif
 
-#if HAVE_NETDB_H
-# include <netdb.h>
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP6_H
+# include <netinet/ip6.h>
+#endif
+#if HAVE_NETINET_IP_COMPAT_H
+# include <netinet/ip_compat.h>
+#endif
+#if HAVE_NETINET_IF_ETHER_H
+# include <netinet/if_ether.h>
 #endif
-
 #if HAVE_NETINET_IP_H
 # include <netinet/ip.h>
 #endif
 #ifdef HAVE_NETINET_IP_VAR_H
 # include <netinet/ip_var.h>
 #endif
-#if HAVE_NETINET_IP6_H
-# include <netinet/ip6.h>
-#endif
 #if HAVE_NETINET_UDP_H
 # include <netinet/udp.h>
 #endif
 
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+#if HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
+#if HAVE_ARPA_NAMESER_COMPAT_H
+# include <arpa/nameser_compat.h>
+#endif
+
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
+
 #if HAVE_PCAP_H
 # include <pcap.h>
 #endif
index b9b906fa373943b427e02d2b72f1fb39d3f21ed6..83512015898e22b27c527b431aa03bdcda5f2865 100644 (file)
@@ -25,8 +25,8 @@
 #include "plugin.h"
 #include "common.h"
 
+#include "utils_format_graphite.h"
 #include "utils_cache.h"
-#include "utils_format_json.h"
 #include "utils_parse_option.h"
 
 /* Utils functions to format data sets in graphite format.
@@ -108,11 +108,12 @@ static void gr_copy_escape_part (char *dst, const char *src, size_t dst_len,
 }
 
 static int gr_format_name (char *ret, int ret_len,
-        const value_list_t *vl,
-        const char *ds_name,
-        char *prefix,
-        char *postfix,
-        char escape_char)
+        value_list_t const *vl,
+        char const *ds_name,
+        char const *prefix,
+        char const *postfix,
+        char const escape_char,
+        unsigned int flags)
 {
     char n_host[DATA_MAX_NAME_LEN];
     char n_plugin[DATA_MAX_NAME_LEN];
@@ -143,7 +144,7 @@ static int gr_format_name (char *ret, int ret_len,
     if (n_plugin_instance[0] != '\0')
         ssnprintf (tmp_plugin, sizeof (tmp_plugin), "%s%c%s",
             n_plugin,
-            '-',
+            (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',
             n_plugin_instance);
     else
         sstrncpy (tmp_plugin, n_plugin, sizeof (tmp_plugin));
@@ -151,11 +152,13 @@ static int gr_format_name (char *ret, int ret_len,
     if (n_type_instance[0] != '\0')
         ssnprintf (tmp_type, sizeof (tmp_type), "%s%c%s",
             n_type,
-            '-',
+            (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',
             n_type_instance);
     else
         sstrncpy (tmp_type, n_type, sizeof (tmp_type));
 
+    /* Assert always_append_ds -> ds_name */
+    assert (!(flags & GRAPHITE_ALWAYS_APPEND_DS) || (ds_name != NULL));
     if (ds_name != NULL)
         ssnprintf (ret, ret_len, "%s%s%s.%s.%s.%s",
             prefix, n_host, postfix, tmp_plugin, tmp_type, ds_name);
@@ -167,31 +170,33 @@ static int gr_format_name (char *ret, int ret_len,
 }
 
 int format_graphite (char *buffer, size_t buffer_size,
-    const data_set_t *ds, const value_list_t *vl, char *prefix,
-    char *postfix, char escape_char,
-    _Bool store_rates)
+    data_set_t const *ds, value_list_t const *vl,
+    char const *prefix, char const *postfix, char const escape_char,
+    unsigned int flags)
 {
     int status = 0;
     int i;
     int buffer_pos = 0;
 
     gauge_t *rates = NULL;
-    if (store_rates)
+    if (flags & GRAPHITE_STORE_RATES)
       rates = uc_get_rate (ds, vl);
 
     for (i = 0; i < ds->ds_num; i++)
     {
-        const char *ds_name = NULL;
+        char const *ds_name = NULL;
         char        key[10*DATA_MAX_NAME_LEN];
         char        values[512];
         size_t      message_len;
         char        message[1024];
 
-        ds_name = ds->ds[i].name;
+        if ((flags & GRAPHITE_ALWAYS_APPEND_DS)
+            || (ds->ds_num > 1))
+          ds_name = ds->ds[i].name;
 
         /* Copy the identifier to `key' and escape it. */
         status = gr_format_name (key, sizeof (key), vl, ds_name,
-                    prefix, postfix, escape_char);
+                    prefix, postfix, escape_char, flags);
         if (status != 0)
         {
             ERROR ("format_graphite: error with gr_format_name");
index a7a05bbbadfea7f006801b6649beb7ed56656f85..398defbeabab0b31c8de7916df1ba2b9e86eca8c 100644 (file)
 #include "collectd.h"
 #include "plugin.h"
 
+#define GRAPHITE_STORE_RATES        0x01
+#define GRAPHITE_SEPARATE_INSTANCES 0x02
+#define GRAPHITE_ALWAYS_APPEND_DS   0x04
+
 int format_graphite (char *buffer,
     size_t buffer_size, const data_set_t *ds,
     const value_list_t *vl, const char *prefix,
     const char *postfix, const char escape_char,
-    _Bool store_rates);
+    unsigned int flags);
 
 #endif /* UTILS_FORMAT_GRAPHITE_H */
index 5b7551d3a18f4925cb0403f454350373c8c7c6e8..0b31262d630d0a4ec14826e8f0094bf6be54531a 100644 (file)
@@ -239,6 +239,7 @@ int cu_tail_read (cu_tail_t *obj, char *buf, int buflen, tailfunc_t *callback,
                        if (buf[len - 1] != '\n')
                                break;
                        buf[len - 1] = '\0';
+                       len--;
                }
 
                status = callback (data, buf, buflen);
index de60e39c7b21759f0fdefb062d3d74475df90fed..602f47af6231f59d40b51ccbd86800d1ca31bf3d 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * collectd - src/varnish.c
- * Copyright (C) 2010 Jérôme Renard
- * Copyright (C) 2010 Marc Fournier
- * Copyright (C) 2010 Florian Forster
+ * Copyright (C) 2010      Jérôme Renard
+ * Copyright (C) 2010      Marc Fournier
+ * Copyright (C) 2010-2012 Florian Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -20,7 +20,7 @@
  * Authors:
  *   Jérôme Renard <jerome.renard at gmail.com>
  *   Marc Fournier <marc.fournier at camptocamp.com>
- *   Florian octo Forster <octo at verplant.org>
+ *   Florian octo Forster <octo at collectd.org>
  **/
 
 /**
@@ -412,11 +412,21 @@ static int varnish_read (user_data_t *ud) /* {{{ */
 
        vd = VSM_New();
        VSC_Setup(vd);
-       if (VSM_n_Arg(vd, conf->instance) == -1)
+
+       if (conf->instance != NULL)
        {
-               ERROR ("Varnish plugin : unable to load statistics from instance");
-               return (-1);
+               int status;
+
+               status = VSM_n_Arg (vd, conf->instance);
+               if (status < 0)
+               {
+                       ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed "
+                                       "with status %i.",
+                                       conf->instance, status);
+                       return (-1);
+               }
        }
+
        if (VSC_Open (vd, /* diag = */ 1))
        {
                ERROR ("varnish plugin: Unable to load statistics.");
index 2ae30efe2ca179b0fd13cfafe5914f5a031b14ff..87befb6301e9bf35cc0593625d260fc313d110ff 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2011       Scott Sanders
  * Copyright (C) 2009       Paul Sadauskas
  * Copyright (C) 2009       Doug MacEachern
- * Copyright (C) 2007-2012  Florian octo Forster
+ * Copyright (C) 2007-2013  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -46,6 +46,7 @@
 #include "configfile.h"
 
 #include "utils_cache.h"
+#include "utils_complain.h"
 #include "utils_parse_option.h"
 #include "utils_format_graphite.h"
 
@@ -85,9 +86,7 @@ struct wg_callback
     char    *postfix;
     char     escape_char;
 
-    _Bool    store_rates;
-    _Bool    separate_instances;
-    _Bool    always_append_ds;
+    unsigned int format_flags;
 
     char     send_buf[WG_SEND_BUF_SIZE];
     size_t   send_buf_free;
@@ -95,6 +94,7 @@ struct wg_callback
     cdtime_t send_buf_init_time;
 
     pthread_mutex_t send_lock;
+    c_complain_t init_complaint;
 };
 
 
@@ -216,12 +216,19 @@ static int wg_callback_init (struct wg_callback *cb)
     if (cb->sock_fd < 0)
     {
         char errbuf[1024];
-        ERROR ("write_graphite plugin: Connecting to %s:%s failed. "
+        c_complain (LOG_ERR, &cb->init_complaint,
+                "write_graphite plugin: Connecting to %s:%s failed. "
                 "The last error was: %s", node, service,
                 sstrerror (errno, errbuf, sizeof (errbuf)));
         close (cb->sock_fd);
         return (-1);
     }
+    else
+    {
+        c_release (LOG_INFO, &cb->init_complaint,
+                "write_graphite plugin: Successfully connected to %s:%s.",
+                node, service);
+    }
 
     wg_reset_buffer (cb);
 
@@ -273,7 +280,7 @@ static int wg_flush (cdtime_t timeout,
         status = wg_callback_init (cb);
         if (status != 0)
         {
-            ERROR ("write_graphite plugin: wg_callback_init failed.");
+            /* An error message has already been printed. */
             pthread_mutex_unlock (&cb->send_lock);
             return (-1);
         }
@@ -299,7 +306,7 @@ static int wg_send_message (char const *message, struct wg_callback *cb)
         status = wg_callback_init (cb);
         if (status != 0)
         {
-            ERROR ("write_graphite plugin: wg_callback_init failed.");
+            /* An error message has already been printed. */
             pthread_mutex_unlock (&cb->send_lock);
             return (-1);
         }
@@ -340,7 +347,7 @@ static int wg_send_message (char const *message, struct wg_callback *cb)
 static int wg_write_messages (const data_set_t *ds, const value_list_t *vl,
         struct wg_callback *cb)
 {
-    char buffer[4096];
+    char buffer[WG_SEND_BUF_SIZE];
     int status;
 
     if (0 != strcmp (ds->type, vl->type))
@@ -352,15 +359,15 @@ static int wg_write_messages (const data_set_t *ds, const value_list_t *vl,
 
     memset (buffer, 0, sizeof (buffer));
     status = format_graphite (buffer, sizeof (buffer), ds, vl,
-            cb->prefix, cb->postfix, cb->escape_char, cb->store_rates);
+            cb->prefix, cb->postfix, cb->escape_char, cb->format_flags);
     if (status != 0) /* error message has been printed already. */
         return (status);
 
+    /* Send the message to graphite */
     wg_send_message (buffer, cb);
     if (status != 0)
     {
-        ERROR ("write_graphite plugin: wg_send_message failed "
-                "with status %i.", status);
+        /* An error message has already been printed. */
         return (status);
     }
 
@@ -434,9 +441,10 @@ static int wg_config_carbon (oconfig_item_t *ci)
     cb->prefix = NULL;
     cb->postfix = NULL;
     cb->escape_char = WG_DEFAULT_ESCAPE;
-    cb->store_rates = 1;
+    cb->format_flags = GRAPHITE_STORE_RATES;
 
     pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);
+    C_COMPLAIN_INIT (&cb->init_complaint);
 
     for (i = 0; i < ci->children_num; i++)
     {
@@ -451,11 +459,14 @@ static int wg_config_carbon (oconfig_item_t *ci)
         else if (strcasecmp ("Postfix", child->key) == 0)
             cf_util_get_string (child, &cb->postfix);
         else if (strcasecmp ("StoreRates", child->key) == 0)
-            cf_util_get_boolean (child, &cb->store_rates);
+            cf_util_get_flag (child, &cb->format_flags,
+                    GRAPHITE_STORE_RATES);
         else if (strcasecmp ("SeparateInstances", child->key) == 0)
-            cf_util_get_boolean (child, &cb->separate_instances);
+            cf_util_get_flag (child, &cb->format_flags,
+                    GRAPHITE_SEPARATE_INSTANCES);
         else if (strcasecmp ("AlwaysAppendDS", child->key) == 0)
-            cf_util_get_boolean (child, &cb->always_append_ds);
+            cf_util_get_flag (child, &cb->format_flags,
+                    GRAPHITE_ALWAYS_APPEND_DS);
         else if (strcasecmp ("EscapeCharacter", child->key) == 0)
             config_set_char (&cb->escape_char, child);
         else
index 3035e43a99611ec3daf9e3b5b99f2ec3a2d71316..6b1c64a7a48afbab11a6c1a2ff67b46efd10d789 100644 (file)
@@ -111,7 +111,7 @@ static int wh_callback_init (wh_callback_t *cb) /* {{{ */
                 return (-1);
         }
 
-        curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1);
+        curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1L);
         curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
 
         headers = NULL;
@@ -147,9 +147,9 @@ static int wh_callback_init (wh_callback_t *cb) /* {{{ */
                 curl_easy_setopt (cb->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
         }
 
-        curl_easy_setopt (cb->curl, CURLOPT_SSL_VERIFYPEER, cb->verify_peer);
+        curl_easy_setopt (cb->curl, CURLOPT_SSL_VERIFYPEER, (long) cb->verify_peer);
         curl_easy_setopt (cb->curl, CURLOPT_SSL_VERIFYHOST,
-                        cb->verify_host ? 2 : 0);
+                        cb->verify_host ? 2L : 0L);
         if (cb->cacert != NULL)
                 curl_easy_setopt (cb->curl, CURLOPT_CAINFO, cb->cacert);
 
index 046b7b02120953c65d66de9c27dd2ff5ac482e8c..aa900193b834e32b5d71c282f11663fe824a4e47 100644 (file)
@@ -128,7 +128,7 @@ static int za_read (void)
        za_read_derive (ksp, "stolen",   "cache_operation", "stolen");
 
         /* Issue indicators */
-        za_read_derive (ksp, "mutex_miss", "mutex_operation", "miss");
+        za_read_derive (ksp, "mutex_miss", "mutex_operations", "miss");
        za_read_derive (ksp, "hash_collisions", "hash_collisions", "");
        
         /* Evictions */
index 72458572b10948f0374208498080452bb420ae79..e3445412a4916077ef00e8b22a2fdf07c87990d0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-DEFAULT_VERSION="5.2.0.git"
+DEFAULT_VERSION="5.2.1.git"
 
 VERSION="`git describe 2> /dev/null | sed -e 's/^collectd-//'`"