Merge pull request #1592 from rpv-tomsk/mysql-plugin-sort
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 26 Mar 2016 20:24:13 +0000 (21:24 +0100)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 26 Mar 2016 20:24:13 +0000 (21:24 +0100)
mysql plugin: Split 'mysql_sort' type into several types.

100 files changed:
.travis.yml
CONTRIBUTING.md [new file with mode: 0644]
build.sh
configure.ac
contrib/redhat/collectd.spec
src/Makefile.am
src/apache.c
src/apcups.c
src/ascent.c
src/barometer.c
src/battery.c
src/bind.c
src/ceph.c
src/ceph_test.c
src/collectd-exec.pod
src/collectd-nagios.c
src/collectd.conf.in
src/collectd.conf.pod
src/collectdctl.c
src/collectdmon.c
src/curl_json.c
src/daemon/collectd.c
src/daemon/configfile.c
src/daemon/configfile.h
src/daemon/plugin.c
src/daemon/plugin.h
src/daemon/types_list.c
src/daemon/utils_avltree.c
src/daemon/utils_cache.c
src/daemon/utils_cache.h
src/daemon/utils_random.c
src/daemon/utils_subst.c
src/daemon/utils_subst.h
src/daemon/utils_subst_test.c
src/daemon/utils_time.c
src/email.c
src/interface.c
src/ipc.c
src/ipvs.c
src/liboconfig/oconfig.c
src/liboconfig/parser.y
src/logfile.c
src/mbmon.c
src/memcached.c
src/memory.c
src/modbus.c
src/mqtt.c
src/mysql.c
src/netlink.c
src/nfs.c
src/nginx.c
src/notify_email.c
src/ntpd.c
src/onewire.c
src/openvpn.c
src/perl.c
src/postgresql.c
src/powerdns.c
src/processes.c
src/python.c
src/pyvalues.c
src/redis.c
src/sensors.c
src/sigrok.c
src/smart.c
src/swap.c
src/syslog.c
src/tail.c
src/tcpconns.c
src/ted.c
src/testing.h
src/thermal.c
src/threshold.c
src/tokyotyrant.c
src/turbostat.c
src/types.db
src/unixsock.c
src/utils_cmd_flush.c
src/utils_cmd_getval.c
src/utils_cmd_putnotif.c
src/utils_cmd_putval.c
src/utils_db_query.c
src/utils_dns.c
src/utils_dns.h
src/utils_latency.c
src/utils_latency.h
src/utils_mount.c
src/utils_mount.h
src/utils_rrdcreate.c
src/virt.c
src/vserver.c
src/write_http.c
src/write_riemann.c
src/write_riemann_threshold.c
src/write_riemann_threshold.h [new file with mode: 0644]
src/write_sensu.c
src/write_tsdb.c
src/xmms.c
src/zfs_arc.c
src/zookeeper.c

index 435669b..03d9dde 100644 (file)
@@ -7,6 +7,7 @@ language: c
 before_install:
   - sudo apt-get update -qq
   - sudo apt-get install -qq --no-install-recommends
+      iptables-dev
       libatasmart-dev
       libcap-dev
       libcurl4-gnutls-dev
@@ -52,4 +53,4 @@ before_install:
       perl
       protobuf-c-compiler
       python-dev
-script: sh build.sh && ./configure && make distcheck
+script: sh build.sh && ./configure --with-python=/usr/bin/python && make distcheck DISTCHECK_CONFIGURE_FLAGS="--with-python=/usr/bin/python"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..befb76e
--- /dev/null
@@ -0,0 +1,38 @@
+# Thanks !
+
+Thanks for your feedback & contributions to the
+[collectd project](https://collectd.org/) !
+
+## Need help using collectd ?
+
+Please use the
+[collectd mailing list](http://mailman.verplant.org/listinfo/collectd) or the
+[#collectd IRC channel](https://webchat.freenode.net/?channels=#collectd).
+We'd like to keep the github issue tracker for bugreports and patch reviews.
+
+## Found a bug ?
+
+Please mention the exact collectd version you're using, how it was installed
+(built from source, or installed from packages. Where was it downloaded
+from). Which operating system/architecture, distribution and version are you
+running collectd on.
+
+If collectd crashes, try to get a
+[stack trace](https://collectd.org/wiki/index.php/Core_file).
+
+## Fixed a bug ? Want to add a feature ?
+
+Using git/github to submit changes is not mandatory. Sending patches to the
+[mailing-list](http://mailman.verplant.org/listinfo/collectd) is also fine.
+In both cases, take a quick look at the
+[submission guidelines](https://collectd.org/wiki/index.php/Submitting_patches)
+and the [coding style recommendations](https://collectd.org/wiki/index.php/Coding_style).
+
+Please try to submit **bugfixes** to the
+[oldest release branch](https://github.com/collectd/collectd/milestones) on
+which the bug is found, so that it gets included in every future **bugfix
+release**.
+
+Please try to submit **new features** to the master branch (which will become
+the next **feature release**).
+
index 20854b1..57f3d44 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -18,7 +18,7 @@ EOF
        done
 }
 
-check_for_application lex yacc autoheader aclocal automake autoconf
+check_for_application lex bison autoheader aclocal automake autoconf
 
 # Actually we don't need the pkg-config executable, but we need the M4 macros.
 # We check for `pkg-config' here and hope that M4 macros will then be
index fc1e11c..333f29a 100644 (file)
@@ -44,6 +44,7 @@ AC_SYS_LARGEFILE
 #
 AC_PROG_CC
 AC_PROG_CPP
+AC_PROG_EGREP
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
@@ -60,6 +61,18 @@ m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-conf
 
 PKG_PROG_PKG_CONFIG
 
+AC_CACHE_CHECK([if bison is the parser generator],
+       [collectd_cv_prog_bison],
+       [AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '],
+               [collectd_cv_prog_bison=yes], [collectd_cv_prog_bison=no]
+       )]
+)
+
+if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/src/liboconfig/parser.c"
+then
+       AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/src/liboconfig/parser.c. Please install bison])
+fi
+
 AC_CHECK_PROG([have_protoc_c], [protoc-c], [yes], [no])
 if test "x$have_protoc_c" = "xno"
 then
@@ -99,6 +112,10 @@ case $host_os in
        AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel])
        ac_system="OpenBSD"
        ;;
+       *netbsd*)
+       AC_DEFINE([KERNEL_NETBSD], 1, [True if program is to be compiled for a NetBSD kernel])
+       ac_system="NetBSD"
+       ;;
        *aix*)
        AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
        ac_system="AIX"
@@ -186,6 +203,19 @@ AC_HEADER_STDBOOL
 
 AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h)
 
+# For entropy plugin on newer NetBSD
+AC_CHECK_HEADERS(sys/rndio.h, [], [],
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
 # For ping library
 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
 [#if HAVE_STDINT_H
@@ -413,6 +443,22 @@ else
        AC_MSG_RESULT([no])
 fi
 
+AC_MSG_CHECKING([for sysctl kern.cp_time])
+if test -x /sbin/sysctl
+then
+       /sbin/sysctl kern.cp_time >/dev/null 2>&1
+       if test $? -eq 0
+       then
+               AC_MSG_RESULT([yes])
+               AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIME, 1,
+                       [Define if sysctl supports kern.cp_time])
+       else
+               AC_MSG_RESULT([no])
+       fi
+else
+       AC_MSG_RESULT([no])
+fi
+
 # For hddtemp module
 AC_CHECK_HEADERS(linux/major.h)
 
@@ -431,7 +477,7 @@ else
        have_linux_raid_md_u_h="no"
 fi
 
-# For the swap module
+# For the wireless module
 have_linux_wireless_h="no"
 if test "x$ac_system" = "xLinux"
 then
@@ -598,7 +644,35 @@ AC_CHECK_HEADERS(linux/un.h, [], [],
 #endif
 ])
 
-AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h sys/vmmeter.h kvm.h wordexp.h locale.h)
+AC_CHECK_HEADERS([ \
+  ctype.h \
+  fs_info.h \
+  fshelp.h \
+  grp.h \
+  kvm.h \
+  limits.h \
+  locale.h \
+  mntent.h \
+  mnttab.h \
+  paths.h \
+  pwd.h \
+  sys/fs_types.h \
+  sys/fstyp.h \
+  sys/mntent.h \
+  sys/mnttab.h \
+  sys/statfs.h \
+  sys/statvfs.h \
+  sys/un.h \
+  sys/vfs.h \
+  sys/vfstab.h \
+  sys/vmmeter.h \
+  wordexp.h \
+])
+
+AC_CHECK_HEADERS([xfs/xqm.h], [], [],
+[
+#define _GNU_SOURCE
+])
 
 # For the dns plugin
 AC_CHECK_HEADERS(arpa/nameser.h)
@@ -692,13 +766,9 @@ AC_CHECK_HEADERS(sys/capability.h)
 # Checks for typedefs, structures, and compiler characteristics.
 #
 AC_C_CONST
-AC_C_INLINE
-AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
-AC_TYPE_SSIZE_T
 AC_TYPE_UID_T
-AC_TYPE_UINT32_T
 AC_HEADER_TIME
 
 #
@@ -808,8 +878,6 @@ fi
 if test "x$have_clock_gettime" = "xyes"
 then
        AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
-else
-       AC_MSG_WARN(cannot find clock_gettime)
 fi
 
 nanosleep_needs_rt="no"
@@ -1437,6 +1505,24 @@ AC_CHECK_MEMBERS([struct kinfo_proc.p_pid, struct kinfo_proc.p_vm_rssize],
 #include <kvm.h>
        ])
 
+
+AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss],
+       [
+               AC_DEFINE(HAVE_STRUCT_KINFO_PROC2_NETBSD, 1,
+                       [Define if struct kinfo_proc2 exists in the NetBSD variant.])
+               have_struct_kinfo_proc2_netbsd="yes"
+       ],
+       [
+               have_struct_kinfo_proc2_netbsd="no"
+       ],
+       [
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <kvm.h>
+       ])
+
+
+
 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
 [#define _BSD_SOURCE
 #define _DEFAULT_SOURCE
@@ -4313,6 +4399,7 @@ fi
 if test "x$with_libstatgrab" = "xyes"
 then
   SAVE_CFLAGS="$CFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
   SAVE_LIBS="$LIBS"
 
   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
@@ -5369,6 +5456,14 @@ then
        plugin_tcpconns="yes"
 fi
 
+if test "x$ac_system" = "xNetBSD"
+then
+       plugin_entropy="yes"
+       plugin_irq="yes"
+       plugin_processes="yes"
+       plugin_disk="yes"
+fi
+
 # Mac OS X devices
 if test "x$with_libiokit" = "xyes"
 then
@@ -5615,6 +5710,11 @@ then
        plugin_swap="yes"
 fi
 
+if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes"
+then
+       plugin_swap="yes"
+fi
+
 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
 then
        plugin_tcpconns="yes"
index f0feb90..4d4e0aa 100644 (file)
 %{?el7:%global _has_lvm2app_h 1}
 %{?el7:%global _has_libudev 1}
 %{?el7:%global _has_recent_librrd 1}
-%{?el7:%global _has_broken_libmemcached 1}
 %{?el7:%global _has_iproute 1}
 %{?el7:%global _has_atasmart 1}
 %{?el7:%global _has_hiredis 1}
 %{?el7:%global _has_asm_msr_index 1}
 %{?el7:%global _has_libmosquitto 1}
+%{?el7:%global _has_libmodbus 1}
+%{?el7:%global _has_xmms 1}
 
 # plugins enabled by default
 %define with_aggregation 0%{!?_without_aggregation:1}
 %define with_madwifi 0%{!?_without_madwifi:1}
 %define with_mbmon 0%{!?_without_mbmon:1}
 %define with_md 0%{!?_without_md:1}
-%define with_memcachec 0%{!?_without_memcachec:0%{!?_has_broken_libmemcached:1}}
+%define with_memcachec 0%{!?_without_memcachec:1}
 %define with_memcached 0%{!?_without_memcached:1}
 %define with_memory 0%{!?_without_memory:1}
 %define with_multimeter 0%{!?_without_multimeter:1}
 %define with_write_riemann 0%{!?_without_write_riemann:1}
 %define with_write_sensu 0%{!?_without_write_sensu:1}
 %define with_write_tsdb 0%{!?_without_write_tsdb:1}
+%define with_xmms 0%{!?_without_xmms:0%{?_has_xmms}}
 %define with_zfs_arc 0%{!?_without_zfs_arc:1}
 %define with_zookeeper 0%{!?_without_zookeeper:1}
 
 %define with_write_kafka 0%{!?_without_write_kafka:0}
 # plugin write_mongodb disabled, requires libmongoc
 %define with_write_mongodb 0%{!?_without_write_mongodb:0}
-# plugin xmms disabled, requires xmms
-%define with_xmms 0%{!?_without_xmms:0}
 # plugin zone disabled, requires Solaris
 %define with_zone 0%{!?_without_zone:0}
 
@@ -789,6 +789,16 @@ BuildRequires:     protobuf-c-devel
 The riemann plugin submits values to Riemann, an event stream processor.
 %endif
 
+%if %{with_xmms}
+%package xmms
+Summary:       XMMS plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+BuildRequires: xmms-devel
+%description xmms
+The xmms plugin collects information from the XMMS music player.
+%endif
+
 %package collection3
 Summary:       Web-based viewer for collectd
 Group:         System Environment/Daemons
@@ -2093,9 +2103,9 @@ fi
 %{_includedir}/collectd/network_buffer.h
 %{_includedir}/collectd/lcc_features.h
 %{_libdir}/pkgconfig/libcollectdclient.pc
+%{_libdir}/libcollectdclient.so
 
 %files -n libcollectdclient
-%{_libdir}/libcollectdclient.so
 %{_libdir}/libcollectdclient.so.*
 
 %files -n collectd-utils
@@ -2366,6 +2376,11 @@ fi
 %{_libdir}/%{name}/write_riemann.so
 %endif
 
+%if %{with_xmms}
+%files xmms
+%{_libdir}/%{name}/xmms.so
+%endif
+
 %files collection3
 %{_localstatedir}/www/collection3
 %{_sysconfdir}/httpd/conf.d/collection3.conf
@@ -2395,11 +2410,12 @@ fi
 - Install collectdctl, collectd-tg and collectd-nagios in collectd-utils.rpm
 - Add build-dependency on libcap-devel
 
-* Mon Aug 19 2013 Marc Fournier <marc.fournier@camptocamp.com> 5.4.0-1
+* Mon Aug 19 2013 Marc Fournier <marc.fournier@camptocamp.com> 5.4.2-1
 - New upstream version
 - Build netlink plugin by default
 - Enable cgroups, lvm and statsd plugins
 - Enable (but don't build by default) mic, aquaero and sigrok plugins
+- Enable modbus, memcachec and xmms plugins on RHEL7
 
 * Tue Aug 06 2013 Marc Fournier <marc.fournier@camptocamp.com> 5.3.1-1
 - New upstream version
index bacbe75..3832bd2 100644 (file)
@@ -1260,7 +1260,7 @@ endif
 
 if BUILD_PLUGIN_WRITE_RIEMANN
 pkglib_LTLIBRARIES += write_riemann.la
-write_riemann_la_SOURCES = write_riemann.c write_riemann_threshold.c
+write_riemann_la_SOURCES = write_riemann.c write_riemann_threshold.c write_riemann_threshold.h
 nodist_write_riemann_la_SOURCES = riemann.pb-c.c riemann.pb-c.h
 write_riemann_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 write_riemann_la_LIBADD = -lprotobuf-c
index b306032..38035ca 100644 (file)
@@ -530,13 +530,16 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */
 
        st = user_data->data;
 
+       int status;
+
+       char *content_type;
+       static const char *text_plain = "text/plain";
+
        assert (st->url != NULL);
        /* (Assured by `config_add') */
 
        if (st->curl == NULL)
        {
-               int status;
-
                status = init_host (st);
                if (status != 0)
                        return (-1);
@@ -559,6 +562,16 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */
                st->server_type = APACHE;
        }
 
+       status = curl_easy_getinfo (st->curl, CURLINFO_CONTENT_TYPE, &content_type);
+       if ((status == CURLE_OK) && (content_type != NULL) &&
+           (strncasecmp (content_type, text_plain, strlen (text_plain)) != 0))
+       {
+               WARNING ("apache plugin: `Content-Type' response header is not `%s' "
+                       "(received: `%s'). Expecting unparseable data. Please check `URL' "
+                       "parameter (missing `?auto' suffix ?)",
+                       text_plain, content_type);
+       }
+
        ptr = st->apache_buffer;
        saveptr = NULL;
        while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL)
index 29d58c3..b4bc099 100644 (file)
@@ -220,7 +220,7 @@ static int net_recv (int *sockfd, char *buf, int buflen)
  * Returns zero on success
  * Returns non-zero on error
  */
-static int net_send (int *sockfd, char *buff, int len)
+static int net_send (int *sockfd, const char *buff, int len)
 {
        uint16_t packet_size;
 
@@ -401,7 +401,7 @@ static int apcups_config (oconfig_item_t *ci)
        return (0);
 } /* int apcups_config */
 
-static void apc_submit_generic (char *type, char *type_inst, double value)
+static void apc_submit_generic (const char *type, const char *type_inst, double value)
 {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
index 2ba3c77..d38e859 100644 (file)
@@ -32,7 +32,7 @@
 #include <curl/curl.h>
 #include <libxml/parser.h>
 
-static char *races_list[] = /* {{{ */
+static const char *races_list[] = /* {{{ */
 {
   NULL,
   "Human",    /*  1 */
@@ -49,7 +49,7 @@ static char *races_list[] = /* {{{ */
 }; /* }}} */
 #define RACES_LIST_LENGTH STATIC_ARRAY_SIZE (races_list)
 
-static char *classes_list[] = /* {{{ */
+static const char *classes_list[] = /* {{{ */
 {
   NULL,
   "Warrior", /*  1 */
@@ -66,7 +66,7 @@ static char *classes_list[] = /* {{{ */
 }; /* }}} */
 #define CLASSES_LIST_LENGTH STATIC_ARRAY_SIZE (classes_list)
 
-static char *genders_list[] = /* {{{ */
+static const char *genders_list[] = /* {{{ */
 {
   "Male",
   "Female"
index d60f588..0e8deaf 100644 (file)
@@ -1360,7 +1360,7 @@ static int BMP085_read(double * pressure, double * temperature)
  *
  * @return detected sensor type
  */
-enum Sensor_type Detect_sensor_type(void)
+static enum Sensor_type detect_sensor_type(void)
 {
     if(BMP085_detect())
         return Sensor_BMP085;
@@ -1802,7 +1802,7 @@ static int collectd_barometer_init (void)
     }
 
     /* detect sensor type - this will also set slave address */
-    sensor_type = Detect_sensor_type();
+    sensor_type = detect_sensor_type();
 
     /* init correct sensor type */
     switch(sensor_type)
index c4c050d..b87739a 100644 (file)
@@ -143,7 +143,7 @@ static void submit_capacity (char const *plugin_instance, /* {{{ */
 } /* }}} void submit_capacity */
 
 #if HAVE_IOKIT_PS_IOPOWERSOURCES_H || HAVE_IOKIT_IOKITLIB_H
-static double dict_get_double (CFDictionaryRef dict, char *key_string) /* {{{ */
+static double dict_get_double (CFDictionaryRef dict, const char *key_string) /* {{{ */
 {
        double      val_double;
        long long   val_int;
index dd49cb2..b9731ee 100644 (file)
@@ -836,8 +836,6 @@ static int bind_xml_stats_search_zones (int version, xmlDoc *doc, /* {{{ */
 
   for (i = 0; i < zone_nodes->nodesetval->nodeNr; i++)
   {
-    xmlNode *node;
-
     node = zone_nodes->nodesetval->nodeTab[i];
     assert (node != NULL);
 
index 2a85823..b1ca3b6 100644 (file)
@@ -96,7 +96,7 @@ enum ceph_dset_type_d
 };
 
 /** Valid types for ceph defined in types.db */
-const char * ceph_dset_types [CEPH_DSET_TYPES_NUM] =
+static const char * const ceph_dset_types [CEPH_DSET_TYPES_NUM] =
                                    {"ceph_latency", "ceph_bytes", "ceph_rate"};
 
 /******* ceph_daemon *******/
@@ -1096,7 +1096,7 @@ static int cconn_connect(struct cconn *io)
     fd = socket(PF_UNIX, SOCK_STREAM, 0);
     if(fd < 0)
     {
-        int err = -errno;
+        err = -errno;
         ERROR("ceph plugin: cconn_connect: socket(PF_UNIX, SOCK_STREAM, 0) "
             "failed: error %d", err);
         return err;
@@ -1545,7 +1545,7 @@ static int cconn_main_loop(uint32_t request_type)
             }
             else
             {
-                int ret = cconn_handle_event(io);
+                ret = cconn_handle_event(io);
                 if(ret)
                 {
                     WARNING("ceph plugin: cconn_handle_event(name=%s,"
index acab179..1141140 100644 (file)
@@ -24,8 +24,8 @@
 
 struct case_s
 {
-  char *key;
-  char *value;
+  const char *key;
+  const char *value;
 };
 typedef struct case_s case_t;
 
@@ -136,11 +136,11 @@ DEF_TEST(traverse_json)
   yajl_handle hndl;
 #if HAVE_YAJL_V2
   hndl = yajl_alloc (&callbacks, NULL, &ctx);
-  CHECK_ZERO (traverse_json ((unsigned char *) json, (uint32_t) strlen (json), hndl));
+  CHECK_ZERO (traverse_json ((const unsigned char *) json, (uint32_t) strlen (json), hndl));
   CHECK_ZERO (yajl_complete_parse (hndl));
 #else
   hndl = yajl_alloc (&callbacks, NULL, NULL, &ctx);
-  CHECK_ZERO (traverse_json ((unsigned char *) json, (uint32_t) strlen (json), hndl));
+  CHECK_ZERO (traverse_json ((const unsigned char *) json, (uint32_t) strlen (json), hndl));
   CHECK_ZERO (yajl_parse_complete (hndl));
 #endif
 
@@ -150,8 +150,8 @@ DEF_TEST(traverse_json)
 DEF_TEST(parse_keys)
 {
   struct {
-    char *str;
-    char *want;
+    const char *str;
+    const char *want;
   } cases[] = {
     {"WBThrottle.bytes_dirtied.description.bytes_wb.description.ios_dirtied.description.ios_wb.type", "WBThrottle.bytesDirtied.description.bytesWb.description.iosDirt"},
     {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
index 0e4cd53..654db40 100644 (file)
@@ -94,7 +94,7 @@ I<Valuelist> is a colon-separated list of the time and the values, each either
 an integer if the data-source is a counter, or a double if the data-source is
 of type "gauge". You can submit an undefined gauge-value by using B<U>. When
 submitting B<U> to a counter the behavior is undefined. The time is given as
-epoch (i.E<nbsp>e. standard UNIX time).
+epoch (i.E<nbsp>e. standard UNIX time) or B<N> to use the current time.
 
 You can mix options and values, but the order is important: Options only
 effect following values, so specifying an option as last field is allowed, but
index b17e47e..49e84f3 100644 (file)
@@ -245,6 +245,7 @@ static int match_range (range_t *range, double value)
        return (((ret - range->invert) == 0) ? 0 : 1);
 } /* int match_range */
 
+__attribute__((noreturn))
 static void usage (const char *name)
 {
        fprintf (stderr, "Usage: %s <-s socket> <-n value_spec> <-H hostname> [options]\n"
index 953b5e4..20b17b2 100644 (file)
@@ -84,7 +84,7 @@
 # Lines beginning with a single `#' belong to plugins which have been built  #
 # but are disabled by default.                                               #
 #                                                                            #
-# Lines begnning with `##' belong to plugins which have not been built due   #
+# Lines beginning with `##' belong to plugins which have not been built due  #
 # to missing dependencies or because they have been deactivated explicitly.  #
 ##############################################################################
 
 ##     None of the following option should be set manually
 ##     This plugin automatically detect most optimal options
 ##     Only set values here if:
-##     - The module ask you to
+##     - The module asks you to
 ##     - You want to disable the collection of some data
-##     - Your (intel) CPU is not supported (yet) by the module
-##     - The module generate a lot of errors 'MSR offset 0x... read failed'
+##     - Your (Intel) CPU is not supported (yet) by the module
+##     - The module generates a lot of errors 'MSR offset 0x... read failed'
 ##     In the last two cases, please open a bug request
 #
 #      TCCActivationTemp "100"
index 6a94edc..cf7ccd0 100644 (file)
@@ -38,7 +38,7 @@ i.e. a C<E<lt>PluginE<nbsp>...E<gt>> block.
 The syntax of this config file is similar to the config file of the famous
 I<Apache> webserver. Each line contains either an option (a key and a list of
 one or more values) or a section-start or -end. Empty lines and everything
-after a non-quoted hash-symbol (C<#>) is ignored. I<Keys> are unquoted
+after a non-quoted hash-symbol (C<#>) are ignored. I<Keys> are unquoted
 strings, consisting only of alphanumeric characters and the underscore (C<_>)
 character. Keys are handled case insensitive by I<collectd> itself and all
 plugins included with it. I<Values> can either be an I<unquoted string>, a
@@ -70,7 +70,7 @@ C<E<lt>B<Plugin> ...E<gt>> block.
 
 =item B<BaseDir> I<Directory>
 
-Sets the base directory. This is the directory beneath all RRD-files are
+Sets the base directory. This is the directory beneath which all RRD-files are
 created. Possibly more subdirectories are created. This is also the working
 directory for the daemon.
 
@@ -83,7 +83,7 @@ I<collectd> will be mostly useless.
 Only the first B<LoadPlugin> statement or block for a given plugin name has any
 effect. This is useful when you want to split up the configuration into smaller
 files and want each file to be "self contained", i.e. it contains a B<Plugin>
-block I<and> then appropriate B<LoadPlugin> statement. The downside is that if
+block I<and> the appropriate B<LoadPlugin> statement. The downside is that if
 you have multiple conflicting B<LoadPlugin> blocks, e.g. when they specify
 different intervals, only one of them (the first one encountered) will take
 effect and all others will be silently ignored.
@@ -127,13 +127,13 @@ the average user from ever having to deal with this low level linking stuff.
 =item B<Interval> I<Seconds>
 
 Sets a plugin-specific interval for collecting metrics. This overrides the
-global B<Interval> setting. If a plugin provides own support for specifying an
-interval, that setting will take precedence.
+global B<Interval> setting. If a plugin provides its own support for specifying
+an interval, that setting will take precedence.
 
 =item B<FlushInterval> I<Seconds>
 
-Specifies the the interval, in seconds, to call the flush callback if it's
-defined in this plugin. By default, this is disabled
+Specifies the interval, in seconds, to call the flush callback if it's
+defined in this plugin. By default, this is disabled.
 
 =item B<FlushTimeout> I<Seconds>
 
@@ -214,7 +214,7 @@ matching C<*.conf> in any subdirectory of C</etc/collectd.d>:
 
 =back
 
-If more than one files are included by a single B<Include> option, the files
+If more than one file is included by a single B<Include> option, the files
 will be included in lexicographical order (as defined by the C<strcmp>
 function). Thus, you can e.E<nbsp>g. use numbered prefixes to specify the
 order in which the files are loaded.
@@ -255,7 +255,7 @@ magic! (Assuming you're using the I<RRDtool> or I<RRDCacheD> plugin.)
 
 =item B<MaxReadInterval> I<Seconds>
 
-Read plugin doubles interval between queries after each failed attempt
+A read plugin doubles the interval between queries after each failed attempt
 to get data.
 
 This options limits the maximum value of the interval. The default value is
@@ -2531,7 +2531,7 @@ a more detailed description see B<IgnoreSelected> below.
 
 =item B<IgnoreSelected> I<true>|I<false>
 
-If no configuration if given, the B<traffic>-plugin will collect data from
+If no configuration if given, the B<interface>-plugin will collect data from
 all interfaces. This may not be practical, especially for loopback- and
 similar interfaces. Thus, you can use the B<Interface>-option to pick the
 interfaces you're interested in. Sometimes, however, it's easier/preferred
index febc998..7d3cbce 100644 (file)
@@ -72,6 +72,7 @@
 extern char *optarg;
 extern int   optind;
 
+__attribute__((noreturn))
 static void exit_usage (const char *name, int status) {
   fprintf ((status == 0) ? stdout : stderr,
       "Usage: %s [options] <command> [cmd options]\n\n"
index 65271dd..2c1d589 100644 (file)
 static int loop    = 0;
 static int restart = 0;
 
-static char  *pidfile      = NULL;
-static pid_t  collectd_pid = 0;
+static const char *pidfile      = NULL;
+static pid_t       collectd_pid = 0;
 
-static void exit_usage (char *name)
+__attribute__((noreturn))
+static void exit_usage (const char *name)
 {
        printf ("Usage: %s <options> [-- <collectd options>]\n"
 
index 556263f..45898c3 100644 (file)
@@ -861,7 +861,7 @@ static void cj_submit (cj_t *db, cj_key_t *key, value_t *value) /* {{{ */
 static int cj_sock_perform (cj_t *db) /* {{{ */
 {
   char errbuf[1024];
-  struct sockaddr_un sa_unix = {};
+  struct sockaddr_un sa_unix = { 0 };
   sa_unix.sun_family = AF_UNIX;
   sstrncpy (sa_unix.sun_path, db->sock, sizeof (sa_unix.sun_path));
 
index 7b324e1..6f29917 100644 (file)
@@ -269,6 +269,7 @@ static void update_kstat (void)
 /* TODO
  * Remove all settings but `-f' and `-C'
  */
+__attribute__((noreturn))
 static void exit_usage (int status)
 {
        printf ("Usage: "PACKAGE_NAME" [OPTIONS]\n\n"
@@ -422,7 +423,7 @@ static int pidfile_remove (void)
 #endif /* COLLECT_DAEMON */
 
 #ifdef KERNEL_LINUX
-int notify_upstart (void)
+static int notify_upstart (void)
 {
     char const *upstart_job = getenv("UPSTART_JOB");
 
@@ -442,7 +443,7 @@ int notify_upstart (void)
     return 1;
 }
 
-int notify_systemd (void)
+static int notify_systemd (void)
 {
     int                  fd;
     const char          *notifysocket;
@@ -518,7 +519,7 @@ int main (int argc, char **argv)
        struct sigaction sig_term_action;
        struct sigaction sig_usr1_action;
        struct sigaction sig_pipe_action;
-       char *configfile = CONFIGFILE;
+       const char *configfile = CONFIGFILE;
        int test_config  = 0;
        int test_readall = 0;
        const char *basedir;
index 89b0be0..8a7621d 100644 (file)
@@ -72,15 +72,15 @@ typedef struct cf_complex_callback_s
 
 typedef struct cf_value_map_s
 {
-       char *key;
+       const char *key;
        int (*func) (oconfig_item_t *);
 } cf_value_map_t;
 
 typedef struct cf_global_option_s
 {
-       char *key;
+       const char *key;
        char *value;
-       char *def;
+       const char *def;
 } cf_global_option_t;
 
 /*
@@ -381,7 +381,7 @@ static int dispatch_value (oconfig_item_t *ci)
 static int dispatch_block_plugin (oconfig_item_t *ci)
 {
        int i;
-       char *name;
+       const char *name;
 
        cf_complex_callback_t *cb;
 
@@ -1115,7 +1115,7 @@ int cf_register_complex (const char *type, int (*callback) (oconfig_item_t *))
        return (0);
 } /* int cf_register_complex */
 
-int cf_read (char *filename)
+int cf_read (const char *filename)
 {
        oconfig_item_t *conf;
        int i;
index 5bc9b30..648246b 100644 (file)
@@ -87,7 +87,7 @@ int cf_register_complex (const char *type, int (*callback) (oconfig_item_t *));
  *  Returns zero upon success and non-zero otherwise. A error-message will have
  *  been printed in this case.
  */
-int cf_read (char *filename);
+int cf_read (const char *filename);
 
 int global_option_set (const char *option, const char *value);
 const char *global_option_get (const char *option);
index e5e0a45..e7993f1 100644 (file)
@@ -998,7 +998,7 @@ static int plugin_mark_loaded (char const *name)
        return (status);
 }
 
-static void plugin_free_loaded ()
+static void plugin_free_loaded (void)
 {
        void *key;
        void *value;
@@ -1343,7 +1343,7 @@ static void plugin_flush_timeout_callback_free (void *data)
 
 static char *plugin_flush_callback_name (const char *name)
 {
-       char *flush_prefix = "flush/";
+       const char *flush_prefix = "flush/";
        size_t prefix_size;
        char *flush_name;
        size_t name_size;
@@ -1378,7 +1378,6 @@ int plugin_register_flush (const char *name,
        if (ctx.flush_interval != 0)
        {
                char *flush_name;
-               user_data_t ud;
                flush_callback_t *cb;
 
                flush_name = plugin_flush_callback_name (name);
@@ -1403,15 +1402,15 @@ int plugin_register_flush (const char *name,
                }
                cb->timeout = ctx.flush_timeout;
 
-               ud.data = cb;
-               ud.free_func = plugin_flush_timeout_callback_free;
+               ud->data = cb;
+               ud->free_func = plugin_flush_timeout_callback_free;
 
                status = plugin_register_complex_read (
                        /* group     = */ "flush",
                        /* name      = */ flush_name,
                        /* callback  = */ plugin_flush_timeout_callback,
                        /* interval  = */ ctx.flush_interval,
-                       /* user data = */ &ud);
+                       /* user data = */ ud);
 
                sfree (flush_name);
                if (status != 0)
@@ -1697,7 +1696,6 @@ int plugin_unregister_notification (const char *name)
 void plugin_init_all (void)
 {
        char const *chain_name;
-       long write_threads_num;
        llentry_t *le;
        int status;
 
index b1adb52..a63f5cd 100644 (file)
@@ -334,7 +334,7 @@ int plugin_unregister_notification (const char *name);
  *  Since some writers dynamically build their name it can be hard for
  *  the configuring person to know it. This function will fill this gap.
  */
-void plugin_log_available_writers ();
+void plugin_log_available_writers (void);
 
 /*
  * NAME
@@ -459,4 +459,10 @@ cdtime_t plugin_get_interval (void);
 int plugin_thread_create (pthread_t *thread, const pthread_attr_t *attr,
                void *(*start_routine) (void *), void *arg);
 
+/*
+ * Plugins need to implement this
+ */
+
+void module_register (void);
+
 #endif /* PLUGIN_H */
index cf28c2e..eb50bb8 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "plugin.h"
 #include "configfile.h"
+#include "types_list.h"
 
 static int parse_ds (data_source_t *dsrc, char *buf, size_t buf_len)
 {
index 58b8b84..fcfbb94 100644 (file)
@@ -245,7 +245,7 @@ static void rebalance (c_avl_tree_t *t, c_avl_node_t *n)
                {
                        assert (n->right != NULL);
                        b_bottom = BALANCE (n->right);
-                       assert ((b_bottom >= -1) || (b_bottom <= 1));
+                       assert ((b_bottom >= -1) && (b_bottom <= 1));
                        if (b_bottom == 1)
                                n = rotate_right_left (t, n);
                        else
@@ -255,7 +255,7 @@ static void rebalance (c_avl_tree_t *t, c_avl_node_t *n)
                {
                        assert (n->left != NULL);
                        b_bottom = BALANCE (n->left);
-                       assert ((b_bottom >= -1) || (b_bottom <= 1));
+                       assert ((b_bottom >= -1) && (b_bottom <= 1));
                        if (b_bottom == -1)
                                n = rotate_left_right (t, n);
                        else
index e2c6426..0756807 100644 (file)
@@ -559,7 +559,7 @@ gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl)
   return (ret);
 } /* gauge_t *uc_get_rate */
 
-size_t uc_get_size() {
+size_t uc_get_size (void) {
   size_t size_arrays = 0;
 
   pthread_mutex_lock (&cache_lock);
@@ -736,7 +736,6 @@ int uc_get_history_by_name (const char *name,
   if (ce->history_length < num_steps)
   {
     gauge_t *tmp;
-    size_t i;
 
     tmp = realloc (ce->history, sizeof (*ce->history)
        * num_steps * ce->values_num);
index ea3eb2f..75bfc42 100644 (file)
@@ -40,7 +40,7 @@ int uc_update (const data_set_t *ds, const value_list_t *vl);
 int uc_get_rate_by_name (const char *name, gauge_t **ret_values, size_t *ret_values_num);
 gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl);
 
-size_t uc_get_size();
+size_t uc_get_size (void);
 int uc_get_names (char ***ret_names, cdtime_t **ret_times, size_t *ret_number);
 
 int uc_get_state (const data_set_t *ds, const value_list_t *vl);
index b873845..fee0871 100644 (file)
 
 #include "collectd.h"
 #include "utils_time.h"
+#include "utils_random.h"
 
 #include <pthread.h>
 
+
 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
 static _Bool have_seed = 0;
 static unsigned short seed[3];
index 43634df..cfa1c76 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "collectd.h"
 #include "common.h"
+#include "utils_subst.h"
 
 char *subst (char *buf, size_t buflen, const char *string, size_t off1, size_t off2,
                const char *replacement)
index 9085286..50df9c7 100644 (file)
@@ -66,7 +66,7 @@
  *
  * The function returns 'buf' on success, NULL else.
  */
-char *subst (char *buf, size_t buflen, const char *string, int off1, int off2,
+char *subst (char *buf, size_t buflen, const char *string, size_t off1, size_t off2,
                const char *replacement);
 
 /*
index ec2e351..953ccc4 100644 (file)
@@ -36,11 +36,11 @@ kstat_ctl_t *kc;
 DEF_TEST(subst)
 {
   struct {
-    char *str;
+    const char *str;
     int off1;
     int off2;
-    char *rplmt;
-    char *want;
+    const char *rplmt;
+    const char *want;
   } cases[] = {
     {"foo_____bar", 3, 8, " - ", "foo - bar"}, /* documentation example */
     {"foo bar", 0, 2, "m",     "mo bar"},    /* beginning, shorten */
@@ -95,7 +95,10 @@ DEF_TEST(subst)
 DEF_TEST(subst_string)
 {
   struct {
-    char *str;          char *srch; char *rplmt; char *want;
+    const char *str;
+    const char *srch;
+    const char *rplmt;
+    const char *want;
   } cases[] = {
     {"Hello %{name}",    "%{name}", "world", "Hello world"},
     {"abcccccc",         "abc",     "cab",   "ccccccab"},
index 47ed6d3..56c250c 100644 (file)
@@ -127,7 +127,7 @@ static int format_rfc3339 (char *buffer, size_t buffer_size, cdtime_t t, _Bool p
 
   if (localtime_r (&t_spec.tv_sec, &t_tm) == NULL) {
     char errbuf[1024];
-    int status = errno;
+    status = errno;
     ERROR ("format_rfc3339: localtime_r failed: %s",
         sstrerror (status, errbuf, sizeof (errbuf)));
     return (status);
index 63b6a56..81ae29c 100644 (file)
@@ -389,8 +389,8 @@ static void *open_connection (void __attribute__((unused)) *arg)
 {
        struct sockaddr_un addr;
 
-       char *path  = (NULL == sock_file) ? SOCK_PATH : sock_file;
-       char *group = (NULL == sock_group) ? COLLECTD_GRP_NAME : sock_group;
+       const char *path  = (NULL == sock_file) ? SOCK_PATH : sock_file;
+       const char *group = (NULL == sock_group) ? COLLECTD_GRP_NAME : sock_group;
 
        /* create UNIX socket */
        errno = 0;
index 1c01f6f..90dc139 100644 (file)
@@ -190,7 +190,7 @@ static int interface_read (void)
        struct ifaddrs *if_list;
        struct ifaddrs *if_ptr;
 
-/* Darin/Mac OS X and possible other *BSDs */
+/* Darwin/Mac OS X and possible other *BSDs */
 #if HAVE_STRUCT_IF_DATA
 #  define IFA_DATA if_data
 #  define IFA_RX_BYTES ifi_ibytes
@@ -286,6 +286,10 @@ static int interface_read (void)
                incoming = atoll (fields[2]);
                outgoing = atoll (fields[10]);
                if_submit (device, "if_errors", incoming, outgoing);
+
+               incoming = atoll (fields[3]);
+               outgoing = atoll (fields[11]);
+               if_submit (device, "if_dropped", incoming, outgoing);
        }
 
        fclose (fh);
index b403847..645d4b0 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -298,7 +298,7 @@ static int ipc_read_msg (void) /* {{{ */
     msg_alloc_queues++;
     msg_used_space += ipcinfo_msg[i].msg_cbytes;
     msg_qnum += ipcinfo_msg[i].msg_qnum;
-
+  }
   free(ipcinfo_msg);
 
   ipc_submit_g("msg", "count", "queues", msg_alloc_queues);
index 4345a46..760aa3c 100644 (file)
@@ -224,7 +224,8 @@ static int get_ti (struct ip_vs_dest_entry *de, char *ti, size_t size)
        return 0;
 } /* get_ti */
 
-static void cipvs_submit_connections (char *pi, char *ti, derive_t value)
+static void cipvs_submit_connections (const char *pi, const char *ti,
+               derive_t value)
 {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
@@ -245,7 +246,7 @@ static void cipvs_submit_connections (char *pi, char *ti, derive_t value)
        return;
 } /* cipvs_submit_connections */
 
-static void cipvs_submit_if (char *pi, char *t, char *ti,
+static void cipvs_submit_if (const char *pi, const char *t, const char *ti,
                derive_t rx, derive_t tx)
 {
        value_t values[2];
@@ -268,7 +269,8 @@ static void cipvs_submit_if (char *pi, char *t, char *ti,
        return;
 } /* cipvs_submit_if */
 
-static void cipvs_submit_dest (char *pi, struct ip_vs_dest_entry *de) {
+static void cipvs_submit_dest (const char *pi, struct ip_vs_dest_entry *de)
+{
        struct ip_vs_stats_user stats = de->stats;
 
        char ti[DATA_MAX_NAME_LEN];
index d01c79d..89ccdec 100644 (file)
@@ -193,7 +193,7 @@ oconfig_item_t *oconfig_clone (const oconfig_item_t *ci_orig)
   return (ci_copy);
 } /* oconfig_item_t *oconfig_clone */
 
-void oconfig_free_all (oconfig_item_t *ci)
+static void oconfig_free_all (oconfig_item_t *ci)
 {
   int i;
 
index f0e886c..803eec2 100644 (file)
@@ -225,7 +225,7 @@ entire_file:
 %%
 static int yyerror (const char *s)
 {
-       char *text;
+       const char *text;
 
        if (*yytext == '\n')
                text = "<newline>";
index b75ecb8..1179718 100644 (file)
@@ -201,7 +201,7 @@ static int logfile_notification (const notification_t *n,
 
 #define APPEND(bufptr, buflen, key, value) \
        if ((buflen > 0) && (strlen (value) > 0)) { \
-               int status = ssnprintf (bufptr, buflen, ", %s = %s", key, value); \
+               status = ssnprintf (bufptr, buflen, ", %s = %s", key, value); \
                if (status > 0) { \
                        bufptr += status; \
                        buflen -= status; \
index 5e87f00..2d6d77e 100644 (file)
@@ -260,8 +260,8 @@ static int mbmon_read (void)
                double value;
                char *nextc;
 
-               char *type;
-               char *inst;
+               const char *type;
+               const char *inst;
 
                *t++ = '\0';
                trim_spaces (s);
index d7578b6..2c01a57 100644 (file)
@@ -98,8 +98,8 @@ static int memcached_connect_unix (memcached_t *st)
 
 static int memcached_connect_inet (memcached_t *st)
 {
-  char *host;
-  char *port;
+  const char *host;
+  const char *port;
 
   struct addrinfo  ai_hints;
   struct addrinfo *ai_list, *ai_ptr;
index ea16ce3..3d8a867 100644 (file)
@@ -237,7 +237,7 @@ static int memory_read_internal (value_list_t *vl)
         * vm.stats.vm.v_inactive_count: 113730
         * vm.stats.vm.v_cache_count: 10809
         */
-       char *sysctl_keys[8] =
+       const char *sysctl_keys[8] =
        {
                "vm.stats.vm.v_page_size",
                "vm.stats.vm.v_page_count",
index d2b0a53..d538fb3 100644 (file)
@@ -310,7 +310,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */
   if (host == NULL)
     return (EINVAL);
 
+#if COLLECT_DEBUG
   modbus_set_debug (&host->connection, 1);
+#endif
 
   /* We'll do the error handling ourselves. */
   modbus_set_error_handling (&host->connection, NOP_ON_ERROR);
@@ -390,7 +392,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */
     }
   }
 
+#if COLLECT_DEBUG
   modbus_set_debug (host->connection, 1);
+#endif
 
   /* We'll do the error handling ourselves. */
   modbus_set_error_recovery (host->connection, 0);
index 8bc412c..4977f68 100644 (file)
@@ -700,11 +700,11 @@ static int mqtt_config_subscriber (oconfig_item_t *ci)
             cf_util_get_string (child, &conf->host);
         else if (strcasecmp ("Port", child->key) == 0)
         {
-            int tmp = cf_util_get_port_number (child);
-            if (tmp < 0)
+            status = cf_util_get_port_number (child);
+            if (status < 0)
                 ERROR ("mqtt plugin: Invalid port number.");
             else
-                conf->port = tmp;
+                conf->port = status;
         }
         else if (strcasecmp ("ClientId", child->key) == 0)
             cf_util_get_string (child, &conf->client_id);
@@ -714,12 +714,12 @@ static int mqtt_config_subscriber (oconfig_item_t *ci)
             cf_util_get_string (child, &conf->password);
         else if (strcasecmp ("QoS", child->key) == 0)
         {
-            int tmp = -1;
-            status = cf_util_get_int (child, &tmp);
-            if ((status != 0) || (tmp < 0) || (tmp > 2))
+            int qos = -1;
+            status = cf_util_get_int (child, &qos);
+            if ((status != 0) || (qos < 0) || (qos > 2))
                 ERROR ("mqtt plugin: Not a valid QoS setting.");
             else
-                conf->qos = tmp;
+                conf->qos = qos;
         }
         else if (strcasecmp ("Topic", child->key) == 0)
             cf_util_get_string (child, &conf->topic);
index 88a56dc..3850745 100644 (file)
@@ -65,9 +65,6 @@ typedef struct mysql_database_s mysql_database_t; /* }}} */
 
 static int mysql_read (user_data_t *ud);
 
-void mysql_read_default_options(struct st_mysql_options *options,
-               const char *filename,const char *group);
-
 static void mysql_database_free (void *arg) /* {{{ */
 {
        mysql_database_t *db;
@@ -403,8 +400,8 @@ static int mysql_read_master_stats (mysql_database_t *db, MYSQL *con)
        MYSQL_RES *res;
        MYSQL_ROW  row;
 
-       char *query;
-       int   field_num;
+       const char *query;
+       int         field_num;
        unsigned long long position;
 
        query = "SHOW MASTER STATUS";
@@ -449,8 +446,8 @@ static int mysql_read_slave_stats (mysql_database_t *db, MYSQL *con)
        MYSQL_RES *res;
        MYSQL_ROW  row;
 
-       char *query;
-       int   field_num;
+       const char *query;
+       int         field_num;
 
        /* WTF? libmysqlclient does not seem to provide any means to
         * translate a column name to a column index ... :-/ */
@@ -572,84 +569,84 @@ static int mysql_read_innodb_stats (mysql_database_t *db, MYSQL *con)
        MYSQL_RES *res;
        MYSQL_ROW  row;
 
-       char *query;
-    struct {
-        char *key;
-        char *type;
-        int ds_type;
-    } metrics[] = {
-        { "metadata_mem_pool_size",         "bytes",        DS_TYPE_GAUGE },
-        { "lock_deadlocks",                 "mysql_locks",  DS_TYPE_DERIVE },
-        { "lock_timeouts",                  "mysql_locks",  DS_TYPE_DERIVE },
-        { "lock_row_lock_current_waits",    "mysql_locks",  DS_TYPE_DERIVE },
-        { "buffer_pool_size",               "bytes",        DS_TYPE_GAUGE },
-
-        { "buffer_pool_reads",              "operations",   DS_TYPE_DERIVE },
-        { "buffer_pool_read_requests",      "operations",   DS_TYPE_DERIVE },
-        { "buffer_pool_write_requests",     "operations",   DS_TYPE_DERIVE },
-        { "buffer_pool_wait_free",          "operations",   DS_TYPE_DERIVE },
-        { "buffer_pool_read_ahead",         "operations",   DS_TYPE_DERIVE },
-        { "buffer_pool_read_ahead_evicted", "operations",   DS_TYPE_DERIVE },
-
-        { "buffer_pool_pages_total",        "gauge",        DS_TYPE_GAUGE },
-        { "buffer_pool_pages_misc",         "gauge",        DS_TYPE_GAUGE },
-        { "buffer_pool_pages_data",         "gauge",        DS_TYPE_GAUGE },
-        { "buffer_pool_bytes_data",         "gauge",        DS_TYPE_GAUGE },
-        { "buffer_pool_pages_dirty",        "gauge",        DS_TYPE_GAUGE },
-        { "buffer_pool_bytes_dirty",        "gauge",        DS_TYPE_GAUGE },
-        { "buffer_pool_pages_free",         "gauge",        DS_TYPE_GAUGE },
-
-        { "buffer_pages_created",           "operations",   DS_TYPE_DERIVE },
-        { "buffer_pages_written",           "operations",   DS_TYPE_DERIVE },
-        { "buffer_pages_read",              "operations",   DS_TYPE_DERIVE },
-        { "buffer_data_reads",              "operations",   DS_TYPE_DERIVE },
-        { "buffer_data_written",            "operations",   DS_TYPE_DERIVE },
-
-        { "os_data_reads",                  "operations",   DS_TYPE_DERIVE },
-        { "os_data_writes",                 "operations",   DS_TYPE_DERIVE },
-        { "os_data_fsyncs",                 "operations",   DS_TYPE_DERIVE },
-        { "os_log_bytes_written",           "operations",   DS_TYPE_DERIVE },
-        { "os_log_fsyncs",                  "operations",   DS_TYPE_DERIVE },
-        { "os_log_pending_fsyncs",          "operations",   DS_TYPE_DERIVE },
-        { "os_log_pending_writes",          "operations",   DS_TYPE_DERIVE },
-
-        { "trx_rseg_history_len",           "gauge",        DS_TYPE_GAUGE },
-
-        { "log_waits",                      "operations",   DS_TYPE_DERIVE },
-        { "log_write_requests",             "operations",   DS_TYPE_DERIVE },
-        { "log_writes",                     "operations",   DS_TYPE_DERIVE },
-        { "adaptive_hash_searches",         "operations",   DS_TYPE_DERIVE },
-
-        { "file_num_open_files",            "gauge",        DS_TYPE_GAUGE },
-
-        { "ibuf_merges_insert",             "operations",   DS_TYPE_DERIVE },
-        { "ibuf_merges_delete_mark",        "operations",   DS_TYPE_DERIVE },
-        { "ibuf_merges_delete",             "operations",   DS_TYPE_DERIVE },
-        { "ibuf_merges_discard_insert",     "operations",   DS_TYPE_DERIVE },
-        { "ibuf_merges_discard_delete_mark","operations",   DS_TYPE_DERIVE },
-        { "ibuf_merges_discard_delete",     "operations",   DS_TYPE_DERIVE },
-        { "ibuf_merges_discard_merges",     "operations",   DS_TYPE_DERIVE },
-        { "ibuf_size",                      "bytes",        DS_TYPE_GAUGE },
-
-        { "innodb_activity_count",          "gauge",        DS_TYPE_GAUGE },
-        { "innodb_dblwr_writes",            "operations",   DS_TYPE_DERIVE },
-        { "innodb_dblwr_pages_written",     "operations",   DS_TYPE_DERIVE },
-        { "innodb_dblwr_page_size",         "gauge",        DS_TYPE_GAUGE },
-
-        { "innodb_rwlock_s_spin_waits",     "operations",   DS_TYPE_DERIVE },
-        { "innodb_rwlock_x_spin_waits",     "operations",   DS_TYPE_DERIVE },
-        { "innodb_rwlock_s_spin_rounds",    "operations",   DS_TYPE_DERIVE },
-        { "innodb_rwlock_x_spin_rounds",    "operations",   DS_TYPE_DERIVE },
-        { "innodb_rwlock_s_os_waits",       "operations",   DS_TYPE_DERIVE },
-        { "innodb_rwlock_x_os_waits",       "operations",   DS_TYPE_DERIVE },
-
-        { "dml_reads",                      "operations",   DS_TYPE_DERIVE },
-        { "dml_inserts",                    "operations",   DS_TYPE_DERIVE },
-        { "dml_deletes",                    "operations",   DS_TYPE_DERIVE },
-        { "dml_updates",                    "operations",   DS_TYPE_DERIVE },
-
-        { NULL,                     NULL,           0}
-    };
+       const char *query;
+       struct {
+               const char *key;
+               const char *type;
+               int ds_type;
+       } metrics[] = {
+               { "metadata_mem_pool_size",          "bytes",        DS_TYPE_GAUGE },
+               { "lock_deadlocks",                  "mysql_locks",  DS_TYPE_DERIVE },
+               { "lock_timeouts",                   "mysql_locks",  DS_TYPE_DERIVE },
+               { "lock_row_lock_current_waits",     "mysql_locks",  DS_TYPE_DERIVE },
+               { "buffer_pool_size",                "bytes",        DS_TYPE_GAUGE },
+
+               { "buffer_pool_reads",               "operations",   DS_TYPE_DERIVE },
+               { "buffer_pool_read_requests",       "operations",   DS_TYPE_DERIVE },
+               { "buffer_pool_write_requests",      "operations",   DS_TYPE_DERIVE },
+               { "buffer_pool_wait_free",           "operations",   DS_TYPE_DERIVE },
+               { "buffer_pool_read_ahead",          "operations",   DS_TYPE_DERIVE },
+               { "buffer_pool_read_ahead_evicted",  "operations",   DS_TYPE_DERIVE },
+
+               { "buffer_pool_pages_total",         "gauge",        DS_TYPE_GAUGE },
+               { "buffer_pool_pages_misc",          "gauge",        DS_TYPE_GAUGE },
+               { "buffer_pool_pages_data",          "gauge",        DS_TYPE_GAUGE },
+               { "buffer_pool_bytes_data",          "gauge",        DS_TYPE_GAUGE },
+               { "buffer_pool_pages_dirty",         "gauge",        DS_TYPE_GAUGE },
+               { "buffer_pool_bytes_dirty",         "gauge",        DS_TYPE_GAUGE },
+               { "buffer_pool_pages_free",          "gauge",        DS_TYPE_GAUGE },
+
+               { "buffer_pages_created",            "operations",   DS_TYPE_DERIVE },
+               { "buffer_pages_written",            "operations",   DS_TYPE_DERIVE },
+               { "buffer_pages_read",               "operations",   DS_TYPE_DERIVE },
+               { "buffer_data_reads",               "operations",   DS_TYPE_DERIVE },
+               { "buffer_data_written",             "operations",   DS_TYPE_DERIVE },
+
+               { "os_data_reads",                   "operations",   DS_TYPE_DERIVE },
+               { "os_data_writes",                  "operations",   DS_TYPE_DERIVE },
+               { "os_data_fsyncs",                  "operations",   DS_TYPE_DERIVE },
+               { "os_log_bytes_written",            "operations",   DS_TYPE_DERIVE },
+               { "os_log_fsyncs",                   "operations",   DS_TYPE_DERIVE },
+               { "os_log_pending_fsyncs",           "operations",   DS_TYPE_DERIVE },
+               { "os_log_pending_writes",           "operations",   DS_TYPE_DERIVE },
+
+               { "trx_rseg_history_len",            "gauge",        DS_TYPE_GAUGE },
+
+               { "log_waits",                       "operations",   DS_TYPE_DERIVE },
+               { "log_write_requests",              "operations",   DS_TYPE_DERIVE },
+               { "log_writes",                      "operations",   DS_TYPE_DERIVE },
+               { "adaptive_hash_searches",          "operations",   DS_TYPE_DERIVE },
+
+               { "file_num_open_files",             "gauge",        DS_TYPE_GAUGE },
+
+               { "ibuf_merges_insert",              "operations",   DS_TYPE_DERIVE },
+               { "ibuf_merges_delete_mark",         "operations",   DS_TYPE_DERIVE },
+               { "ibuf_merges_delete",              "operations",   DS_TYPE_DERIVE },
+               { "ibuf_merges_discard_insert",      "operations",   DS_TYPE_DERIVE },
+               { "ibuf_merges_discard_delete_mark", "operations",   DS_TYPE_DERIVE },
+               { "ibuf_merges_discard_delete",      "operations",   DS_TYPE_DERIVE },
+               { "ibuf_merges_discard_merges",      "operations",   DS_TYPE_DERIVE },
+               { "ibuf_size",                       "bytes",        DS_TYPE_GAUGE },
+
+               { "innodb_activity_count",           "gauge",        DS_TYPE_GAUGE },
+               { "innodb_dblwr_writes",             "operations",   DS_TYPE_DERIVE },
+               { "innodb_dblwr_pages_written",      "operations",   DS_TYPE_DERIVE },
+               { "innodb_dblwr_page_size",          "gauge",        DS_TYPE_GAUGE },
+
+               { "innodb_rwlock_s_spin_waits",      "operations",   DS_TYPE_DERIVE },
+               { "innodb_rwlock_x_spin_waits",      "operations",   DS_TYPE_DERIVE },
+               { "innodb_rwlock_s_spin_rounds",     "operations",   DS_TYPE_DERIVE },
+               { "innodb_rwlock_x_spin_rounds",     "operations",   DS_TYPE_DERIVE },
+               { "innodb_rwlock_s_os_waits",        "operations",   DS_TYPE_DERIVE },
+               { "innodb_rwlock_x_os_waits",        "operations",   DS_TYPE_DERIVE },
+
+               { "dml_reads",                       "operations",   DS_TYPE_DERIVE },
+               { "dml_inserts",                     "operations",   DS_TYPE_DERIVE },
+               { "dml_deletes",                     "operations",   DS_TYPE_DERIVE },
+               { "dml_updates",                     "operations",   DS_TYPE_DERIVE },
+
+               { NULL,                              NULL,           0}
+       };
 
        query = "SELECT name, count, type FROM information_schema.innodb_metrics WHERE status = 'enabled'";
 
@@ -659,45 +656,43 @@ static int mysql_read_innodb_stats (mysql_database_t *db, MYSQL *con)
 
        while ((row = mysql_fetch_row (res)))
        {
-        int i;
+               int i;
                char *key;
                unsigned long long val;
 
                key = row[0];
                val = atoll (row[1]);
 
-        for (i = 0;
-             metrics[i].key != NULL && strcmp(metrics[i].key, key) != 0;
-             i++)
-            ;
-
-        if (metrics[i].key == NULL)
-            continue;
-
-        switch (metrics[i].ds_type) {
-        case DS_TYPE_COUNTER:
-            counter_submit(metrics[i].type, key, (counter_t)val, db);
-            break;
-        case DS_TYPE_GAUGE:
-            gauge_submit(metrics[i].type, key, (gauge_t)val, db);
-            break;
-        case DS_TYPE_DERIVE:
-            derive_submit(metrics[i].type, key, (derive_t)val, db);
-            break;
-        }
-    }
-
-    mysql_free_result(res);
-    return (0);
+               for (i = 0; metrics[i].key != NULL && strcmp(metrics[i].key, key) != 0; i++)
+                       ;
+
+               if (metrics[i].key == NULL)
+                       continue;
+
+               switch (metrics[i].ds_type) {
+                       case DS_TYPE_COUNTER:
+                               counter_submit(metrics[i].type, key, (counter_t)val, db);
+                               break;
+                       case DS_TYPE_GAUGE:
+                               gauge_submit(metrics[i].type, key, (gauge_t)val, db);
+                               break;
+                       case DS_TYPE_DERIVE:
+                               derive_submit(metrics[i].type, key, (derive_t)val, db);
+                               break;
+               }
+       }
+
+       mysql_free_result(res);
+       return (0);
 }
 
 static int mysql_read (user_data_t *ud)
 {
        mysql_database_t *db;
-       MYSQL     *con;
-       MYSQL_RES *res;
-       MYSQL_ROW  row;
-       char      *query;
+       MYSQL      *con;
+       MYSQL_RES  *res;
+       MYSQL_ROW   row;
+       const char *query;
 
        derive_t qcache_hits          = 0;
        derive_t qcache_inserts       = 0;
@@ -712,7 +707,7 @@ static int mysql_read (user_data_t *ud)
 
        unsigned long long traffic_incoming = 0ULL;
        unsigned long long traffic_outgoing = 0ULL;
-    unsigned long mysql_version = 0ULL;
+       unsigned long mysql_version = 0ULL;
 
        if ((ud == NULL) || (ud->data == NULL))
        {
@@ -726,7 +721,7 @@ static int mysql_read (user_data_t *ud)
        if ((con = getconnection (db)) == NULL)
                return (-1);
 
-  mysql_version = mysql_get_server_version(con);
+       mysql_version = mysql_get_server_version(con);
 
        query = "SHOW STATUS";
        if (mysql_version >= 50002)
@@ -947,7 +942,7 @@ static int mysql_read (user_data_t *ud)
        traffic_submit  (traffic_incoming, traffic_outgoing, db);
 
        if (mysql_version >= 50600 && db->innodb_stats)
-        mysql_read_innodb_stats (db, con);
+               mysql_read_innodb_stats (db, con);
 
        if (db->master_stats)
                mysql_read_master_stats (db, con);
index e1f378d..d4661ce 100644 (file)
@@ -470,7 +470,7 @@ static int qos_filter_cb (const struct nlmsghdr *nlh, void *args)
   const char *kind = NULL;
 
   /* char *type_instance; */
-  char *tc_type;
+  const char *tc_type;
   char tc_inst[DATA_MAX_NAME_LEN];
 
   _Bool stats_submitted = 0;
index be82372..a921a17 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
@@ -554,7 +554,7 @@ static int nfs_submit_nfs4_client (const char *instance, char **fields,
        return (0);
 }
 
-static void nfs_read_linux (FILE *fh, char *inst)
+static void nfs_read_linux (FILE *fh, const char *inst)
 {
        char buffer[1024];
 
@@ -603,7 +603,7 @@ static void nfs_read_linux (FILE *fh, char *inst)
 #endif /* KERNEL_LINUX */
 
 #if HAVE_LIBKSTAT
-static int nfs_read_kstat (kstat_t *ksp, int nfs_version, char *inst,
+static int nfs_read_kstat (kstat_t *ksp, int nfs_version, const char *inst,
                char const **proc_names, size_t proc_names_num)
 {
        char plugin_instance[DATA_MAX_NAME_LEN];
index 69ec06d..e493cc9 100644 (file)
@@ -195,7 +195,7 @@ static int init (void)
   return (0);
 } /* void init */
 
-static void submit (char *type, char *inst, long long value)
+static void submit (const char *type, const char *inst, long long value)
 {
   value_t values[1];
   value_list_t vl = VALUE_LIST_INIT;
index 24c66ec..76d48d4 100644 (file)
@@ -293,7 +293,6 @@ static int notify_email_notification (const notification_t *n,
 
   /* Initiate a connection to the SMTP server and transfer the message. */
   if (!smtp_start_session (session)) {
-    char buf[MAXSTRING];
     ERROR ("notify_email plugin: SMTP server problem: %s",
         smtp_strerror (smtp_errno (), buf, sizeof buf));
     pthread_mutex_unlock (&session_lock);
index ee2c048..4a31e45 100644 (file)
@@ -163,16 +163,16 @@ struct resp_pkt
 /* l_fp to double */
 #define M_LFPTOD(r_i, r_uf, d) \
        do { \
-               register int32_t  i; \
-               register uint32_t f; \
+               register int32_t  ri; \
+               register uint32_t rf; \
                \
-               i = (r_i); \
-               f = (r_uf); \
-               if (i < 0) { \
-                       M_NEG(i, f); \
-                       (d) = -((double) i + ((double) f) / 4294967296.0); \
+               ri = (r_i); \
+               rf = (r_uf); \
+               if (ri < 0) { \
+                       M_NEG(ri, rf); \
+                       (d) = -((double) ri + ((double) rf) / 4294967296.0); \
                } else { \
-                       (d) = (double) i + ((double) f) / 4294967296.0; \
+                       (d) = (double) ri + ((double) rf) / 4294967296.0; \
                } \
        } while (0)
 
@@ -247,7 +247,7 @@ struct info_kernel
 };
 
 /* List of reference clock names */
-static char *refclock_names[] =
+static const char *refclock_names[] =
 {
        "UNKNOWN",    "LOCAL",        "GPS_TRAK",   "WWV_PST",     /*  0- 3 */
        "SPECTRACOM", "TRUETIME",     "IRIG_AUDIO", "CHU_AUDIO",   /*  4- 7 */
@@ -307,7 +307,7 @@ static int ntpd_config (const char *key, const char *value)
        return (0);
 }
 
-static void ntpd_submit (char *type, char *type_inst, gauge_t value)
+static void ntpd_submit (const char *type, const char *type_inst, gauge_t value)
 {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
@@ -328,8 +328,8 @@ static void ntpd_submit (char *type, char *type_inst, gauge_t value)
 /* Each time a peer is polled, ntpd shifts the reach register to the left and
  * sets the LSB based on whether the peer was reachable. If the LSB is zero,
  * the values are out of date. */
-static void ntpd_submit_reach (char *type, char *type_inst, uint8_t reach,
-               gauge_t value)
+static void ntpd_submit_reach (const char *type, const char *type_inst,
+               uint8_t reach, gauge_t value)
 {
        if (!(reach & 1))
                value = NAN;
@@ -339,8 +339,8 @@ static void ntpd_submit_reach (char *type, char *type_inst, uint8_t reach,
 
 static int ntpd_connect (void)
 {
-       char *host;
-       char *port;
+       const char *host;
+       const char *port;
 
        struct addrinfo  ai_hints;
        struct addrinfo *ai_list;
index 58c35e1..3c441ec 100644 (file)
@@ -415,11 +415,11 @@ static int cow_read_ds2409 (const char *path)
   int status;
 
   status = ssnprintf (subpath, sizeof (subpath), "%s/main", path);
-  if ((status > 0) && (status < sizeof (subpath)))
+  if ((status > 0) && (status < (int) sizeof (subpath)))
     cow_read_bus (subpath);
 
   status = ssnprintf (subpath, sizeof (subpath), "%s/aux", path);
-  if ((status > 0) && (status < sizeof (subpath)))
+  if ((status > 0) && (status < (int) sizeof (subpath)))
     cow_read_bus (subpath);
 
   return (0);
@@ -459,7 +459,7 @@ static int cow_read_bus (const char *path)
     else
       status = ssnprintf (subpath, sizeof (subpath), "%s/%s",
           path, buffer_ptr);
-    if ((status <= 0) || (status >= sizeof (subpath)))
+    if ((status <= 0) || (status >= (int) sizeof (subpath)))
       continue;
 
     for (i = 0; i < ow_family_features_num; i++)
index 93c8f1b..8bccce3 100644 (file)
@@ -95,7 +95,8 @@ static int openvpn_strsplit (char *string, char **fields, size_t size)
 } /* int openvpn_strsplit */
 
 /* dispatches number of users */
-static void numusers_submit (char *pinst, char *tinst, gauge_t value)
+static void numusers_submit (const char *pinst, const char *tinst,
+               gauge_t value)
 {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
@@ -115,8 +116,10 @@ static void numusers_submit (char *pinst, char *tinst, gauge_t value)
        plugin_dispatch_values (&vl);
 } /* void numusers_submit */
 
-/* dispatches stats about traffic (TCP or UDP) generated by the tunnel per single endpoint */
-static void iostats_submit (char *pinst, char *tinst, derive_t rx, derive_t tx)
+/* dispatches stats about traffic (TCP or UDP) generated by the tunnel
+ * per single endpoint */
+static void iostats_submit (const char *pinst, const char *tinst,
+               derive_t rx, derive_t tx)
 {
        value_t values[2];
        value_list_t vl = VALUE_LIST_INIT;
@@ -145,7 +148,7 @@ static void iostats_submit (char *pinst, char *tinst, derive_t rx, derive_t tx)
 } /* void traffic_submit */
 
 /* dispatches stats about data compression shown when in single mode */
-static void compression_submit (char *pinst, char *tinst,
+static void compression_submit (const char *pinst, const char *tinst,
                derive_t uncompressed, derive_t compressed)
 {
        value_t values[2];
@@ -168,7 +171,7 @@ static void compression_submit (char *pinst, char *tinst,
        plugin_dispatch_values (&vl);
 } /* void compression_submit */
 
-static int single_read (char *name, FILE *fh)
+static int single_read (const char *name, FILE *fh)
 {
        char buffer[1024];
        char *fields[4];
@@ -261,7 +264,7 @@ static int single_read (char *name, FILE *fh)
 } /* int single_read */
 
 /* for reading status version 1 */
-static int multi1_read (char *name, FILE *fh)
+static int multi1_read (const char *name, FILE *fh)
 {
        char buffer[1024];
        char *fields[10];
@@ -324,7 +327,7 @@ static int multi1_read (char *name, FILE *fh)
 } /* int multi1_read */
 
 /* for reading status version 2 */
-static int multi2_read (char *name, FILE *fh)
+static int multi2_read (const char *name, FILE *fh)
 {
        char buffer[1024];
        char *fields[10];
@@ -386,7 +389,7 @@ static int multi2_read (char *name, FILE *fh)
 } /* int multi2_read */
 
 /* for reading status version 3 */
-static int multi3_read (char *name, FILE *fh)
+static int multi3_read (const char *name, FILE *fh)
 {
        char buffer[1024];
        char *fields[15];
@@ -451,7 +454,7 @@ static int multi3_read (char *name, FILE *fh)
 } /* int multi3_read */
 
 /* for reading status version 4 */
-static int multi4_read (char *name, FILE *fh)
+static int multi4_read (const char *name, FILE *fh)
 {
        char buffer[1024];
        char *fields[11];
index 0c5ee0c..c25bfe8 100644 (file)
@@ -2076,7 +2076,7 @@ static int perl_shutdown (void)
                return 0;
 
        if (NULL == aTHX) {
-               c_ithread_t *t = NULL;
+               t = NULL;
 
                pthread_mutex_lock (&perl_threads->mutex);
                t = c_ithread_create (perl_threads->head->interp);
index 87a56b7..7922683 100644 (file)
@@ -154,7 +154,7 @@ typedef struct {
        int ref_cnt;
 } c_psql_database_t;
 
-static char *def_queries[] = {
+static const char *const def_queries[] = {
        "backends",
        "transactions",
        "queries",
@@ -429,9 +429,9 @@ static PGresult *c_psql_exec_query_noparams (c_psql_database_t *db,
 static PGresult *c_psql_exec_query_params (c_psql_database_t *db,
                udb_query_t *q, c_psql_user_data_t *data)
 {
-       char *params[db->max_params_num];
-       char  interval[64];
-       int   i;
+       const char *params[db->max_params_num];
+       char        interval[64];
+       int         i;
 
        if ((data == NULL) || (data->params_num == 0))
                return (c_psql_exec_query_noparams (db, q));
index 0400f3d..ab62dcf 100644 (file)
@@ -75,9 +75,9 @@ struct list_item_s
 
 struct statname_lookup_s
 {
-  char *name;
-  char *type;
-  char *type_instance;
+  const char *name;
+  const char *type;
+  const char *type_instance;
 };
 typedef struct statname_lookup_s statname_lookup_t;
 
@@ -143,7 +143,7 @@ uptime                number of seconds process has been running (since 3.1.5)
 user-msec             number of CPU milliseconds spent in 'user' mode
 }}} */
 
-const char* const default_server_fields[] = /* {{{ */
+static const char* const default_server_fields[] = /* {{{ */
 {
   "latency",
   "packetcache-hit",
@@ -158,9 +158,9 @@ const char* const default_server_fields[] = /* {{{ */
   "udp-answers",
   "udp-queries",
 }; /* }}} */
-int default_server_fields_num = STATIC_ARRAY_SIZE (default_server_fields);
+static int default_server_fields_num = STATIC_ARRAY_SIZE (default_server_fields);
 
-statname_lookup_t lookup_table[] = /* {{{ */
+static statname_lookup_t lookup_table[] = /* {{{ */
 {
   /*********************
    * Server statistics *
@@ -285,7 +285,7 @@ statname_lookup_t lookup_table[] = /* {{{ */
   {"unexpected-packets",   "dns_answer",   "unexpected"},
   {"uptime",               "uptime",       NULL}
 }; /* }}} */
-int lookup_table_length = STATIC_ARRAY_SIZE (lookup_table);
+static int lookup_table_length = STATIC_ARRAY_SIZE (lookup_table);
 
 static llist_t *list = NULL;
 
index a53d276..d0d7361 100644 (file)
@@ -792,7 +792,7 @@ static void ps_submit_fork_rate (derive_t value)
 
 /* ------- additional functions for KERNEL_LINUX/HAVE_THREAD_INFO ------- */
 #if KERNEL_LINUX
-static procstat_t *ps_read_tasks_status (int pid, procstat_t *ps)
+static procstat_t *ps_read_tasks_status (long pid, procstat_t *ps)
 {
        char           dirname[64];
        DIR           *dh;
@@ -805,7 +805,7 @@ static procstat_t *ps_read_tasks_status (int pid, procstat_t *ps)
        char *fields[8];
        int numfields;
 
-       ssnprintf (dirname, sizeof (dirname), "/proc/%i/task", pid);
+       ssnprintf (dirname, sizeof (dirname), "/proc/%li/task", pid);
 
        if ((dh = opendir (dirname)) == NULL)
        {
@@ -822,7 +822,7 @@ static procstat_t *ps_read_tasks_status (int pid, procstat_t *ps)
 
                tpid = ent->d_name;
 
-               ssnprintf (filename, sizeof (filename), "/proc/%i/task/%s/status", pid, tpid);
+               ssnprintf (filename, sizeof (filename), "/proc/%li/task/%s/status", pid, tpid);
                if ((fh = fopen (filename, "r")) == NULL)
                {
                        DEBUG ("Failed to open file `%s'", filename);
@@ -876,7 +876,7 @@ static procstat_t *ps_read_tasks_status (int pid, procstat_t *ps)
 } /* int *ps_read_tasks_status */
 
 /* Read data from /proc/pid/status */
-static procstat_t *ps_read_status (int pid, procstat_t *ps)
+static procstat_t *ps_read_status (long pid, procstat_t *ps)
 {
        FILE *fh;
        char buffer[1024];
@@ -888,7 +888,7 @@ static procstat_t *ps_read_status (int pid, procstat_t *ps)
        char *fields[8];
        int numfields;
 
-       ssnprintf (filename, sizeof (filename), "/proc/%i/status", pid);
+       ssnprintf (filename, sizeof (filename), "/proc/%li/status", pid);
        if ((fh = fopen (filename, "r")) == NULL)
                return (NULL);
 
@@ -946,7 +946,7 @@ static procstat_t *ps_read_status (int pid, procstat_t *ps)
        return (ps);
 } /* procstat_t *ps_read_vmem */
 
-static procstat_t *ps_read_io (int pid, procstat_t *ps)
+static procstat_t *ps_read_io (long pid, procstat_t *ps)
 {
        FILE *fh;
        char buffer[1024];
@@ -955,7 +955,7 @@ static procstat_t *ps_read_io (int pid, procstat_t *ps)
        char *fields[8];
        int numfields;
 
-       ssnprintf (filename, sizeof (filename), "/proc/%i/io", pid);
+       ssnprintf (filename, sizeof (filename), "/proc/%li/io", pid);
        if ((fh = fopen (filename, "r")) == NULL)
                return (NULL);
 
@@ -1001,7 +1001,7 @@ static procstat_t *ps_read_io (int pid, procstat_t *ps)
        return (ps);
 } /* procstat_t *ps_read_io */
 
-int ps_read_process (int pid, procstat_t *ps, char *state)
+static int ps_read_process (long pid, procstat_t *ps, char *state)
 {
        char  filename[64];
        char  buffer[1024];
@@ -1026,7 +1026,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
 
        memset (ps, 0, sizeof (procstat_t));
 
-       ssnprintf (filename, sizeof (filename), "/proc/%i/stat", pid);
+       ssnprintf (filename, sizeof (filename), "/proc/%li/stat", pid);
 
        status = read_file_contents (filename, buffer, sizeof(buffer) - 1);
        if (status <= 0)
@@ -1071,9 +1071,9 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
        fields_len = strsplit (buffer_ptr, fields, STATIC_ARRAY_SIZE (fields));
        if (fields_len < 22)
        {
-               DEBUG ("processes plugin: ps_read_process (pid = %i):"
+               DEBUG ("processes plugin: ps_read_process (pid = %li):"
                                " `%s' has only %i fields..",
-                               (int) pid, filename, fields_len);
+                               pid, filename, fields_len);
                return (-1);
        }
 
@@ -1092,7 +1092,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
                        /* No VMem data */
                        ps->vmem_data = -1;
                        ps->vmem_code = -1;
-                       DEBUG("ps_read_process: did not get vmem data for pid %i",pid);
+                       DEBUG("ps_read_process: did not get vmem data for pid %li", pid);
                }
                if (ps->num_lwp <= 0)
                        ps->num_lwp = 1;
@@ -1102,7 +1102,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
        /* Leave the rest at zero if this is only a zombi */
        if (ps->num_proc == 0)
        {
-               DEBUG ("processes plugin: This is only a zombie: pid = %i; "
+               DEBUG ("processes plugin: This is only a zombie: pid = %li; "
                                "name = %s;", pid, ps->name);
                return (0);
        }
@@ -1142,7 +1142,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
                ps->io_syscr = -1;
                ps->io_syscw = -1;
 
-               DEBUG("ps_read_process: not get io data for pid %i",pid);
+               DEBUG("ps_read_process: not get io data for pid %li", pid);
        }
 
        if ( report_ctx_switch )
@@ -1153,7 +1153,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
                        ps->cswitch_invol = -1;
 
                        DEBUG("ps_read_tasks_status: not get context "
-                                       "switch data for pid %i",pid);
+                                       "switch data for pid %li", pid);
                }
        }
 
@@ -1161,7 +1161,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
        return (0);
 } /* int ps_read_process (...) */
 
-static char *ps_get_cmdline (pid_t pid, char *name, char *buf, size_t buf_len)
+static char *ps_get_cmdline (long pid, char *name, char *buf, size_t buf_len)
 {
        char  *buf_ptr;
        size_t len;
@@ -1174,8 +1174,7 @@ static char *ps_get_cmdline (pid_t pid, char *name, char *buf, size_t buf_len)
        if ((pid < 1) || (NULL == buf) || (buf_len < 2))
                return NULL;
 
-       ssnprintf (file, sizeof (file), "/proc/%u/cmdline",
-                       (unsigned int) pid);
+       ssnprintf (file, sizeof (file), "/proc/%li/cmdline", pid);
 
        errno = 0;
        fd = open (file, O_RDONLY);
@@ -1256,7 +1255,7 @@ static char *ps_get_cmdline (pid_t pid, char *name, char *buf, size_t buf_len)
        return buf;
 } /* char *ps_get_cmdline (...) */
 
-static int read_fork_rate ()
+static int read_fork_rate (void)
 {
        FILE *proc_stat;
        char buffer[1024];
@@ -1303,7 +1302,7 @@ static int read_fork_rate ()
 #endif /*KERNEL_LINUX */
 
 #if KERNEL_SOLARIS
-static char *ps_get_cmdline (pid_t pid, char *name __attribute__((unused)), /* {{{ */
+static char *ps_get_cmdline (long pid, char *name __attribute__((unused)), /* {{{ */
     char *buffer, size_t buffer_size)
 {
        char path[PATH_MAX];
@@ -1451,7 +1450,7 @@ static int ps_read_process(long pid, procstat_t *ps, char *state)
  * are retrieved from kstat (module cpu, name sys, class misc, stat nthreads).
  * The result is the sum for all the threads created on each cpu
  */
-static int read_fork_rate()
+static int read_fork_rate (void)
 {
        extern kstat_ctl_t *kc;
        kstat_t *ksp_chain = NULL;
@@ -1802,7 +1801,7 @@ static int ps_read (void)
 
        struct dirent *ent;
        DIR           *proc;
-       int            pid;
+       long           pid;
 
        char cmdline[CMDLINE_BUFFER_SIZE];
 
@@ -1829,7 +1828,7 @@ static int ps_read (void)
                if (!isdigit (ent->d_name[0]))
                        continue;
 
-               if ((pid = atoi (ent->d_name)) < 1)
+               if ((pid = atol (ent->d_name)) < 1)
                        continue;
 
                status = ps_read_process (pid, &ps, &state);
index 1897b6d..b909024 100644 (file)
@@ -390,7 +390,7 @@ static int cpy_write_callback(const data_set_t *ds, const value_list_t *value_li
                }
                dict = PyDict_New();  /* New reference. */
                if (value_list->meta) {
-                       int i, num;
+                       int num;
                        char **table;
                        meta_data_t *meta = value_list->meta;
 
@@ -1050,7 +1050,7 @@ PyMODINIT_FUNC PyInit_collectd(void) {
 }
 #endif
 
-static int cpy_init_python() {
+static int cpy_init_python(void) {
        PyObject *sys;
        PyObject *module;
 
index 4417601..1097f7f 100644 (file)
@@ -106,19 +106,19 @@ static PyObject *cpy_common_repr(PyObject *s) {
        return ret;
 }
 
-static char time_doc[] = "This is the Unix timestap of the time this value was read.\n"
+static char time_doc[] = "This is the Unix timestamp of the time this value was read.\n"
                "For dispatching values this can be set to 0 which means \"now\".\n"
                "This means the time the value is actually dispatched, not the time\n"
                "it was set to 0.";
 
 static char host_doc[] = "The hostname of the host this value was read from.\n"
                "For dispatching this can be set to an empty string which means\n"
-               "the local hostname as defined in the collectd.conf.";
+               "the local hostname as defined in collectd.conf.";
 
 static char type_doc[] = "The type of this value. This type has to be defined\n"
-               "in your types.db. Attempting to set it to any other value will\n"
-               "raise a TypeError exception.\n"
-               "Assigning a type is mandetory, calling dispatch without doing\n"
+               "in the types.db file. Attempting to set it to any other value\n"
+               "will raise a TypeError exception.\n"
+               "Assigning a type is mandatory, calling dispatch without doing\n"
                "so will raise a RuntimeError exception.";
 
 static char type_instance_doc[] = "";
@@ -129,7 +129,7 @@ static char plugin_doc[] = "The name of the plugin that read the data. Setting t
 static char plugin_instance_doc[] = "";
 
 static char PluginData_doc[] = "This is an internal class that is the base for Values\n"
-               "and Notification. It is pretty useless by itself and was therefore not\n"
+               "and Notification. It is pretty useless by itself and is therefore not\n"
                "exported to the collectd module.";
 
 static PyObject *PluginData_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
@@ -312,8 +312,8 @@ static char interval_doc[] = "The interval is the timespan in seconds between tw
 static char values_doc[] = "These are the actual values that get dispatched to collectd.\n"
                "It has to be a sequence (a tuple or list) of numbers.\n"
                "The size of the sequence and the type of its content depend on the type\n"
-               "member your types.db file. For more information on this read the types.db\n"
-               "man page.\n"
+               "member in the types.db file. For more information on this read the\n"
+               "types.db man page.\n"
                "\n"
                "If the sequence does not have the correct size upon dispatch a RuntimeError\n"
                "exception will be raised. If the content of the sequence is not a number,\n"
@@ -322,7 +322,7 @@ static char values_doc[] = "These are the actual values that get dispatched to c
 static char meta_doc[] = "These are the meta data for this Value object.\n"
                "It has to be a dictionary of numbers, strings or bools. All keys must be\n"
                "strings. int and long objects will be dispatched as signed integers unless\n"
-               "they are between 2**63 and 2**64-1, which will result in a unsigned integer.\n"
+               "they are between 2**63 and 2**64-1, which will result in an unsigned integer.\n"
                "You can force one of these storage classes by using the classes\n"
                "collectd.Signed and collectd.Unsigned. A meta object received by a write\n"
                "callback will always contain Signed or Unsigned objects.";
@@ -340,7 +340,7 @@ static char dispatch_doc[] = "dispatch([type][, values][, plugin_instance][, typ
 static char write_doc[] = "write([destination][, type][, values][, plugin_instance][, type_instance]"
                "[, plugin][, host][, time][, interval]) -> None.  Dispatch a value list.\n"
                "\n"
-               "Write this instance to a single plugin or all plugins if 'destination' is obmitted.\n"
+               "Write this instance to a single plugin or all plugins if 'destination' is omitted.\n"
                "This will bypass the main collectd process and all filtering and caching.\n"
                "Other than that it works similar to 'dispatch'. In most cases 'dispatch' should be\n"
                "used instead of 'write'.\n";
index 9282e19..4e3de56 100644 (file)
@@ -294,7 +294,7 @@ static int redis_init (void) /* {{{ */
   return (0);
 } /* }}} int redis_init */
 
-int redis_handle_info (char *node, char const *info_line, char const *type, char const *type_instance, char const *field_name, int ds_type) /* {{{ */
+static int redis_handle_info (char *node, char const *info_line, char const *type, char const *type_instance, char const *field_name, int ds_type) /* {{{ */
 {
   char *str = strstr (info_line, field_name);
   static char buf[MAX_REDIS_VAL_SIZE];
@@ -321,7 +321,7 @@ int redis_handle_info (char *node, char const *info_line, char const *type, char
 
 } /* }}} int redis_handle_info */
 
-int redis_handle_query (redisContext *rh, redis_node_t *rn, redis_query_t *rq) /* {{{ */
+static int redis_handle_query (redisContext *rh, redis_node_t *rn, redis_query_t *rq) /* {{{ */
 {
     redisReply *rr;
     const data_set_t *ds;
@@ -376,7 +376,7 @@ int redis_handle_query (redisContext *rh, redis_node_t *rn, redis_query_t *rq) /
     redis_submit(rn->name, rq->type, (strlen(rq->instance) >0)?rq->instance:NULL, val);
     freeReplyObject (rr);
     return 0;
-} /* }}} int redis_handle_info */
+} /* }}} int redis_handle_query */
 
 static int redis_read (void) /* {{{ */
 {
@@ -399,25 +399,27 @@ static int redis_read (void) /* {{{ */
 
     if (strlen (rn->passwd) > 0)
     {
-      DEBUG ("redis plugin: authenticanting node `%s' passwd(%s).", rn->name, rn->passwd);
-      rr = redisCommand (rh, "AUTH %s", rn->passwd);
+      DEBUG ("redis plugin: authenticating node `%s' passwd(%s).", rn->name, rn->passwd);
 
-      if (rr == NULL || rr->type != REDIS_REPLY_STATUS)
+      if ((rr = redisCommand (rh, "AUTH %s", rn->passwd)) == NULL)
       {
         WARNING ("redis plugin: unable to authenticate on node `%s'.", rn->name);
-        if (rr != NULL)
-          freeReplyObject (rr);
+        goto redis_fail;
+      }
 
-        redisFree (rh);
-        continue;
+      if (rr->type != REDIS_REPLY_STATUS)
+      {
+        WARNING ("redis plugin: invalid authentication on node `%s'.", rn->name);
+        goto redis_fail;
       }
+
+      freeReplyObject (rr);
     }
 
     if ((rr = redisCommand(rh, "INFO")) == NULL)
     {
-      WARNING ("redis plugin: unable to connect to node `%s'.", rn->name);
-      redisFree (rh);
-      continue;
+      WARNING ("redis plugin: unable to get info from node `%s'.", rn->name);
+      goto redis_fail;
     }
 
     redis_handle_info (rn->name, rr->str, "uptime", NULL, "uptime_in_seconds", DS_TYPE_GAUGE);
@@ -429,16 +431,22 @@ static int redis_read (void) /* {{{ */
     redis_handle_info (rn->name, rr->str, "volatile_changes", NULL, "changes_since_last_save", DS_TYPE_GAUGE);
     redis_handle_info (rn->name, rr->str, "total_connections", NULL, "total_connections_received", DS_TYPE_DERIVE);
     redis_handle_info (rn->name, rr->str, "total_operations", NULL, "total_commands_processed", DS_TYPE_DERIVE);
-    redis_handle_info (rn->name, rr->str, "expired_keys", NULL, "expired_keys", DS_TYPE_GAUGE);
+    redis_handle_info (rn->name, rr->str, "expired_keys", NULL, "expired_keys", DS_TYPE_DERIVE);
+    redis_handle_info (rn->name, rr->str, "evicted_keys", NULL, "evicted_keys", DS_TYPE_DERIVE);
     redis_handle_info (rn->name, rr->str, "pubsub", "channels", "pubsub_channels", DS_TYPE_GAUGE);
     redis_handle_info (rn->name, rr->str, "pubsub", "patterns", "pubsub_patterns", DS_TYPE_GAUGE);
     redis_handle_info (rn->name, rr->str, "current_connections", "slaves", "connected_slaves", DS_TYPE_GAUGE);
-
-    freeReplyObject (rr);
+    redis_handle_info (rn->name, rr->str, "cache_result", "hits", "keyspace_hits", DS_TYPE_DERIVE);
+    redis_handle_info (rn->name, rr->str, "cache_result", "misses", "keyspace_misses", DS_TYPE_DERIVE);
+    redis_handle_info (rn->name, rr->str, "total_bytes", "input", "total_net_input_bytes", DS_TYPE_DERIVE);
+    redis_handle_info (rn->name, rr->str, "total_bytes", "output", "total_net_output_bytes", DS_TYPE_DERIVE);
 
     for (rq = rn->queries; rq != NULL; rq = rq->next)
         redis_handle_query(rh, rn, rq);
 
+redis_fail:
+    if (rr != NULL)
+      freeReplyObject (rr);
     redisFree (rh);
   }
 
index f5b09bd..c678dec 100644 (file)
@@ -176,7 +176,7 @@ static char *conffile = NULL;
        "as bug."
 #endif
 
-featurelist_t *first_feature = NULL;
+static featurelist_t *first_feature = NULL;
 static ignorelist_t *sensor_list;
 
 #if SENSORS_API_VERSION < 0x400
@@ -265,7 +265,7 @@ static int sensors_config (const char *key, const char *value)
        return (0);
 }
 
-void sensors_free_features (void)
+static void sensors_free_features (void)
 {
        featurelist_t *thisft;
        featurelist_t *nextft;
index 487f31a..ad5c70c 100644 (file)
@@ -136,9 +136,9 @@ static int sigrok_config(oconfig_item_t *ci)
        return 0;
 }
 
-static char *sigrok_value_type(const struct sr_datafeed_analog *analog)
+static const char *sigrok_value_type(const struct sr_datafeed_analog *analog)
 {
-       char *s;
+       const char *s;
 
        if (analog->mq == SR_MQ_VOLTAGE)
                s = "voltage";
index 2207bd6..7b39aae 100644 (file)
@@ -68,7 +68,8 @@ static int smart_config (const char *key, const char *value)
   return (0);
 } /* int smart_config */
 
-static void smart_submit (const char *dev, char *type, char *type_inst, double value)
+static void smart_submit (const char *dev, const char *type,
+               const char *type_inst, double value)
 {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
index e4c5d24..d714b5f 100644 (file)
@@ -82,6 +82,10 @@ static derive_t pagesize;
 static _Bool report_by_device = 0;
 /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */
 
+#elif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS
+/* No global variables */
+/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
+
 #elif defined(VM_SWAPUSAGE)
 /* No global variables */
 /* #endif defined(VM_SWAPUSAGE) */
index 3f73178..849f7d1 100644 (file)
@@ -90,7 +90,7 @@ static int sl_notification (const notification_t *n,
        char  buf[1024] = "";
        size_t offset = 0;
        int log_severity;
-       char *severity_string;
+       const char *severity_string;
        int status;
 
        if (n->severity > notif_severity)
index 5c74e3d..ffdba8a 100644 (file)
@@ -56,9 +56,9 @@ struct ctail_config_match_s
 };
 typedef struct ctail_config_match_s ctail_config_match_t;
 
-cu_tail_match_t **tail_match_list = NULL;
-size_t tail_match_list_num = 0;
-cdtime_t tail_match_list_intervals[255];
+static cu_tail_match_t **tail_match_list = NULL;
+static size_t tail_match_list_num = 0;
+static cdtime_t tail_match_list_intervals[255];
 
 static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
     oconfig_item_t *ci)
index 8f40be6..5b47ff5 100644 (file)
@@ -283,7 +283,7 @@ static uint32_t count_total[TCP_STATE_MAX + 1];
 static uint32_t sequence_number = 0;
 #endif
 
-enum
+static enum
 {
   SRC_DUNNO,
   SRC_NETLINK,
index e76b3c9..37ab85d 100644 (file)
--- a/src/ted.c
+++ b/src/ted.c
@@ -263,7 +263,7 @@ static int ted_open_device (void)
     return (0);
 } /* int ted_open_device */
 
-static void ted_submit (char *type, double value)
+static void ted_submit (const char *type, double value)
 {
     value_t values[1];
     value_list_t vl = VALUE_LIST_INIT;
index c0a9e88..2e4bf05 100644 (file)
@@ -36,7 +36,7 @@ static int check_count__ = 0;
 # define DBL_PRECISION 1e-12
 #endif
 
-#define DEF_TEST(func) static int test_##func ()
+#define DEF_TEST(func) static int test_##func (void)
 
 #define RUN_TEST(func) do { \
   int status; \
index 27c92bc..54311a6 100644 (file)
@@ -35,8 +35,8 @@ static const char *config_keys[] = {
        "ForceUseProcfs"
 };
 
-const char *const dirname_sysfs = "/sys/class/thermal";
-const char *const dirname_procfs = "/proc/acpi/thermal_zone";
+static const char *const dirname_sysfs = "/sys/class/thermal";
+static const char *const dirname_procfs = "/proc/acpi/thermal_zone";
 
 static _Bool force_procfs = 0;
 static ignorelist_t *device_list;
index b753d37..ed83129 100644 (file)
@@ -868,7 +868,7 @@ static int ut_missing (const value_list_t *vl,
   return (0);
 } /* }}} int ut_missing */
 
-int ut_config (oconfig_item_t *ci)
+static int ut_config (oconfig_item_t *ci)
 { /* {{{ */
   int i;
   int status = 0;
index 7fa621b..befbd50 100644 (file)
@@ -78,7 +78,7 @@ static int tt_config (const char *key, const char *value)
        return (0);
 }
 
-static void printerr()
+static void printerr (void)
 {
        int ecode = tcrdbecode(rdb);
        ERROR ("tokyotyrant plugin: error: %d, %s",
@@ -106,8 +106,8 @@ static void tt_submit (gauge_t val, const char* type)
 
 static void tt_open_db (void)
 {
-       char* host = NULL;
-       int   port = DEFAULT_PORT;
+       const char *host;
+       int         port = DEFAULT_PORT;
 
        if (rdb != NULL)
                return;
index 14ce29f..fc1b5dc 100644 (file)
@@ -457,7 +457,7 @@ delta_core(struct core_data *delta, const struct core_data *new, const struct co
  */
 static inline int __attribute__((warn_unused_result))
 delta_thread(struct thread_data *delta, const struct thread_data *new, const struct thread_data *old,
-       const struct core_data *core_delta)
+       const struct core_data *cdelta)
 {
        delta->tsc = new->tsc - old->tsc;
 
@@ -491,12 +491,12 @@ delta_thread(struct thread_data *delta, const struct thread_data *new, const str
         * it is possible for mperf's non-halted cycles + idle states
         * to exceed TSC's all cycles: show c1 = 0% in that case.
         */
-       if ((delta->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > delta->tsc)
+       if ((delta->mperf + cdelta->c3 + cdelta->c6 + cdelta->c7) > delta->tsc)
                delta->c1 = 0;
        else {
                /* normal case, derive c1 */
-               delta->c1 = delta->tsc - delta->mperf - core_delta->c3
-                       - core_delta->c6 - core_delta->c7;
+               delta->c1 = delta->tsc - delta->mperf - cdelta->c3
+                       - cdelta->c6 - cdelta->c7;
        }
 
        if (delta->mperf == 0) {
@@ -805,7 +805,7 @@ guess:
  * Identify the functionality of the CPU
  */
 static int __attribute__((warn_unused_result))
-probe_cpu()
+probe_cpu(void)
 {
        unsigned int eax, ebx, ecx, edx, max_level;
        unsigned int fms, family, model;
@@ -1147,7 +1147,7 @@ allocate_cpu_set(cpu_set_t ** set, size_t * size) {
  * Build a local representation of the cpu distribution
  */
 static int __attribute__((warn_unused_result))
-topology_probe()
+topology_probe(void)
 {
        unsigned int i;
        int ret;
index e2c3e6d..0d81524 100644 (file)
@@ -67,7 +67,8 @@ email_check           value:GAUGE:0:U
 email_count            value:GAUGE:0:U
 email_size             value:GAUGE:0:U
 entropy                        value:GAUGE:0:4294967295
-expired_keys    value:GAUGE:0:U
+expired_keys    value:DERIVE:0:U
+evicted_keys    value:DERIVE:0:U
 fanspeed               value:GAUGE:0:U
 file_handles           value:GAUGE:0:U
 file_size              value:GAUGE:0:U
index 54a1e20..795f7ab 100644 (file)
@@ -151,7 +151,7 @@ static int us_open_socket (void)
 
        do
        {
-               char *grpname;
+               const char *grpname;
                struct group *g;
                struct group sg;
                char grbuf[2048];
index 8b34a75..4106166 100644 (file)
@@ -30,6 +30,7 @@
 #include "common.h"
 #include "plugin.h"
 #include "utils_parse_option.h"
+#include "utils_cmd_flush.h"
 
 int handle_flush (FILE *fh, char *buffer)
 {
index 8cbb9b2..4d679f0 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "utils_cache.h"
 #include "utils_parse_option.h"
+#include "utils_cmd_getval.h"
 
 #define print_to_socket(fh, ...) \
   do { \
index 530d153..145cd10 100644 (file)
@@ -29,6 +29,7 @@
 #include "plugin.h"
 
 #include "utils_parse_option.h"
+#include "utils_cmd_putnotif.h"
 
 #define print_to_socket(fh, ...) \
   do { \
index 7b0258c..43244f6 100644 (file)
@@ -29,6 +29,7 @@
 #include "plugin.h"
 
 #include "utils_parse_option.h"
+#include "utils_cmd_putval.h"
 
 #define print_to_socket(fh, ...) \
     do { \
index d2b8117..c7be9f0 100644 (file)
@@ -638,7 +638,7 @@ static int udb_result_create (const char *query_name, /* {{{ */
 /*
  * Query private functions
  */
-void udb_query_free_one (udb_query_t *q) /* {{{ */
+static void udb_query_free_one (udb_query_t *q) /* {{{ */
 {
   if (q == NULL)
     return;
index 71a14d8..2c7a59d 100644 (file)
@@ -156,9 +156,6 @@ typedef int (printer)(const char *, ...);
 /*
  * Global variables
  */
-int qtype_counts[T_MAX];
-int opcode_counts[OP_MAX];
-int qclass_counts[C_MAX];
 
 #if HAVE_PCAP_H
 static pcap_t *pcap_obj = NULL;
@@ -418,11 +415,6 @@ handle_dns(const char *buf, int len)
 
     qh.length = (uint16_t) len;
 
-    /* gather stats */
-    qtype_counts[qh.qtype]++;
-    qclass_counts[qh.qclass]++;
-    opcode_counts[qh.opcode]++;
-
     if (Callback != NULL)
            Callback (&qh);
 
index 83f0ea4..ef7de0a 100644 (file)
@@ -48,8 +48,6 @@
 #define DNS_MSG_HDR_SZ 12
 
 #define T_MAX 65536
-#define OP_MAX 16
-#define C_MAX 65536
 #define MAX_QNAME_SZ 512
 
 struct rfc1035_header_s {
@@ -75,10 +73,6 @@ struct rfc1035_header_s {
 };
 typedef struct rfc1035_header_s rfc1035_header_t;
 
-extern int qtype_counts[T_MAX];
-extern int opcode_counts[OP_MAX];
-extern int qclass_counts[C_MAX];
-
 #if HAVE_PCAP_H
 void dnstop_set_pcap_obj (pcap_t *po);
 #endif
index 12fc9b8..ca7d5fa 100644 (file)
@@ -76,7 +76,7 @@ struct latency_counter_s
 * So, if the required bin width is 300, then new bin width will be 512 as it is
 * the next nearest power of 2.
 */
-void change_bin_width (latency_counter_t *lc, cdtime_t latency) /* {{{ */
+static void change_bin_width (latency_counter_t *lc, cdtime_t latency) /* {{{ */
 {
   /* This function is called because the new value is above histogram's range.
    * First find the required bin width:
@@ -117,7 +117,7 @@ void change_bin_width (latency_counter_t *lc, cdtime_t latency) /* {{{ */
       CDTIME_T_TO_DOUBLE (new_bin_width));
 } /* }}} void change_bin_width */
 
-latency_counter_t *latency_counter_create () /* {{{ */
+latency_counter_t *latency_counter_create (void) /* {{{ */
 {
   latency_counter_t *lc;
 
index 9930b72..2cfa71b 100644 (file)
@@ -30,7 +30,7 @@
 struct latency_counter_s;
 typedef struct latency_counter_s latency_counter_t;
 
-latency_counter_t *latency_counter_create ();
+latency_counter_t *latency_counter_create (void);
 void latency_counter_destroy (latency_counter_t *lc);
 
 void latency_counter_add (latency_counter_t *lc, cdtime_t latency);
index 36d8d64..752d2e1 100644 (file)
  *   Niki W. Waibel <niki.waibel@gmx.net>
 **/
 
-#include "collectd.h"
-#include "utils_mount.h"
-
-#include "common.h" /* sstrncpy() et alii */
-#include "plugin.h" /* ERROR() macro */
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #if HAVE_XFS_XQM_H
+# define _GNU_SOURCE
 # include <xfs/xqm.h>
 #define XFS_SUPER_MAGIC_STR "XFSB"
 #define XFS_SUPER_MAGIC2_STR "BSFX"
 #endif
 
+#include "collectd.h"
+#include "utils_mount.h"
+
+#include "common.h" /* sstrncpy() et alii */
+#include "plugin.h" /* ERROR() macro */
+
+
 #if HAVE_GETVFSSTAT
 #  if HAVE_SYS_TYPES_H
 #    include <sys/types.h>
@@ -429,16 +435,16 @@ static cu_mount_t *cu_mount_listmntent (void)
 #elif HAVE_GETVFSSTAT || HAVE_GETFSSTAT
 static cu_mount_t *cu_mount_getfsstat (void)
 {
-#if HAVE_GETVFSSTAT
-#  define STRUCT_STATFS struct statvfs
-#  define CMD_STATFS    getvfsstat
-#  define FLAGS_STATFS  ST_NOWAIT
-/* #endif HAVE_GETVFSSTAT */
-#elif HAVE_GETFSSTAT
+#if HAVE_GETFSSTAT
 #  define STRUCT_STATFS struct statfs
 #  define CMD_STATFS    getfsstat
 #  define FLAGS_STATFS  MNT_NOWAIT
-#endif /* HAVE_GETFSSTAT */
+/* #endif HAVE_GETFSSTAT */
+#elif HAVE_GETVFSSTAT
+#  define STRUCT_STATFS struct statvfs
+#  define CMD_STATFS    getvfsstat
+#  define FLAGS_STATFS  ST_NOWAIT
+#endif /* HAVE_GETVFSSTAT */
 
        int bufsize;
        STRUCT_STATFS *buf;
@@ -757,7 +763,7 @@ void cu_mount_freelist (cu_mount_t *list)
 } /* void cu_mount_freelist(cu_mount_t *list) */
 
 char *
-cu_mount_checkoption(char *line, char *keyword, int full)
+cu_mount_checkoption(char *line, const char *keyword, int full)
 {
        char *line2, *l2, *p1, *p2;
        int l;
@@ -798,7 +804,7 @@ cu_mount_checkoption(char *line, char *keyword, int full)
 } /* char *cu_mount_checkoption(char *line, char *keyword, int full) */
 
 char *
-cu_mount_getoptionvalue(char *line, char *keyword)
+cu_mount_getoptionvalue(char *line, const char *keyword)
 {
        char *r;
 
@@ -820,7 +826,7 @@ cu_mount_getoptionvalue(char *line, char *keyword)
                }
        }
        return r;
-} /* char *cu_mount_getoptionvalue(char *line, char *keyword) */
+} /* char *cu_mount_getoptionvalue(char *line, const char *keyword) */
 
 int
 cu_mount_type(const char *type)
index 7518188..0a5c980 100644 (file)
@@ -113,7 +113,7 @@ void cu_mount_freelist(cu_mount_t *list);
        allocated by *list and *list itself as well.
 */
 
-char *cu_mount_checkoption(char *line, char *keyword, int full);
+char *cu_mount_checkoption(char *line, const char *keyword, int full);
 /*
   DESCRIPTION
        The cu_mount_checkoption() function is a replacement of
@@ -153,7 +153,7 @@ char *cu_mount_checkoption(char *line, char *keyword, int full);
        maybe you might want to try cu_mount_getoptionvalue()...
 */
 
-char *cu_mount_getoptionvalue(char *line, char *keyword);
+char *cu_mount_getoptionvalue(char *line, const char *keyword);
 /*
   DESCRIPTION
        The cu_mount_getoptionvalue() function can be used to grab
index 39f42b2..06e4f21 100644 (file)
@@ -62,7 +62,7 @@ static int rra_timespans[] =
 };
 static int rra_timespans_num = STATIC_ARRAY_SIZE (rra_timespans);
 
-static char *rra_types[] =
+static const char *const rra_types[] =
 {
   "AVERAGE",
   "MIN",
@@ -305,7 +305,7 @@ static int ds_get (char ***ret, /* {{{ */
   for (ds_num = 0; ds_num < ds->ds_num; ds_num++)
   {
     data_source_t *d = ds->ds + ds_num;
-    char *type;
+    const char *type;
     int status;
 
     ds_def[ds_num] = NULL;
index b9da68e..79d4682 100644 (file)
@@ -833,7 +833,7 @@ refresh_lists (void)
 }
 
 static void
-free_domains ()
+free_domains (void)
 {
     int i;
 
@@ -866,7 +866,7 @@ add_domain (virDomainPtr dom)
 }
 
 static void
-free_block_devices ()
+free_block_devices (void)
 {
     int i;
 
@@ -906,7 +906,7 @@ add_block_device (virDomainPtr dom, const char *path)
 }
 
 static void
-free_interface_devices ()
+free_interface_devices (void)
 {
     int i;
 
index bd2e867..6c09f43 100644 (file)
@@ -215,7 +215,7 @@ static int vserver_read (void)
                {
                        derive_t rx;
                        derive_t tx;
-                       char *type_instance;
+                       const char *type_instance;
 
                        if (strsplit (buffer, cols, 4) < 4)
                                continue;
@@ -265,7 +265,7 @@ static int vserver_read (void)
 
                        if (2 == n)
                        {
-                               char   *type_instance;
+                               const char *type_instance;
                                gauge_t value;
 
                                if (0 == strcmp (cols[0], "nr_threads:"))
@@ -314,8 +314,8 @@ static int vserver_read (void)
 
                while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
                {
-                       char *type = "vs_memory";
-                       char *type_instance;
+                       const char *type = "vs_memory";
+                       const char *type_instance;
                        gauge_t value;
 
                        if (strsplit (buffer, cols, 2) < 2)
index 361c39e..ec3a01c 100644 (file)
@@ -69,6 +69,7 @@ struct wh_callback_s
         int format;
 
         CURL *curl;
+        struct curl_slist *headers;
         char curl_errbuf[CURL_ERROR_SIZE];
 
         char  *send_buffer;
@@ -129,8 +130,6 @@ static int wh_send_buffer (wh_callback_t *cb) /* {{{ */
 
 static int wh_callback_init (wh_callback_t *cb) /* {{{ */
 {
-        struct curl_slist *headers;
-
         if (cb->curl != NULL)
                 return (0);
 
@@ -157,14 +156,14 @@ static int wh_callback_init (wh_callback_t *cb) /* {{{ */
         curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1L);
         curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
 
-        headers = NULL;
-        headers = curl_slist_append (headers, "Accept:  */*");
+        cb->headers = NULL;
+        cb->headers = curl_slist_append (cb->headers, "Accept:  */*");
         if (cb->format == WH_FORMAT_JSON)
-                headers = curl_slist_append (headers, "Content-Type: application/json");
+                cb->headers = curl_slist_append (cb->headers, "Content-Type: application/json");
         else
-                headers = curl_slist_append (headers, "Content-Type: text/plain");
-        headers = curl_slist_append (headers, "Expect:");
-        curl_easy_setopt (cb->curl, CURLOPT_HTTPHEADER, headers);
+                cb->headers = curl_slist_append (cb->headers, "Content-Type: text/plain");
+        cb->headers = curl_slist_append (cb->headers, "Expect:");
+        curl_easy_setopt (cb->curl, CURLOPT_HTTPHEADER, cb->headers);
 
         curl_easy_setopt (cb->curl, CURLOPT_ERRORBUFFER, cb->curl_errbuf);
         curl_easy_setopt (cb->curl, CURLOPT_URL, cb->location);
@@ -331,6 +330,13 @@ static void wh_callback_free (void *data) /* {{{ */
                 curl_easy_cleanup (cb->curl);
                 cb->curl = NULL;
         }
+
+        if (cb->headers != NULL)
+        {
+                curl_slist_free_all (cb->headers);
+                cb->headers = NULL;
+        }
+
         sfree (cb->name);
         sfree (cb->location);
         sfree (cb->user);
@@ -557,6 +563,8 @@ static int wh_config_node (oconfig_item_t *ci) /* {{{ */
         cb->low_speed_limit = 0;
         cb->timeout = 0;
         cb->log_http_error = 0;
+        cb->headers = NULL;
+
 
         pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);
 
index 5c59c92..6a47ba3 100644 (file)
  *   Florian octo Forster <octo at collectd.org>
  */
 
+#include <arpa/inet.h>
+#include <errno.h>
+#include <netdb.h>
+#include <inttypes.h>
+#include <pthread.h>
+
 #include "collectd.h"
 #include "plugin.h"
 #include "common.h"
 #include "configfile.h"
 #include "utils_cache.h"
 #include "riemann.pb-c.h"
-
-#include <arpa/inet.h>
-#include <errno.h>
-#include <netdb.h>
-#include <inttypes.h>
-#include <pthread.h>
+#include "write_riemann_threshold.h"
 
 #define RIEMANN_HOST           "localhost"
 #define RIEMANN_PORT           "5555"
 #define RIEMANN_TTL_FACTOR      2.0
 #define RIEMANN_BATCH_MAX      8192
 
-int write_riemann_threshold_check(const data_set_t *, const value_list_t *, int *);
-
 struct riemann_host {
        char                    *name;
        char                    *event_service_prefix;
index f001ee5..8567288 100644 (file)
  *   Andrés J. Díaz <ajdiaz at connectical.com>
  **/
 
+#include <assert.h>
+#include <ltdl.h>
+#include <pthread.h>
+
 #include "collectd.h"
 #include "common.h"
 #include "plugin.h"
 #include "utils_avltree.h"
 #include "utils_cache.h"
 #include "utils_threshold.h"
-
-#include <assert.h>
-#include <pthread.h>
+#include "write_riemann_threshold.h"
 
 /*
  * Threshold management
diff --git a/src/write_riemann_threshold.h b/src/write_riemann_threshold.h
new file mode 100644 (file)
index 0000000..d3b3fe9
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef WRITE_RIEMANN_THRESHOLD_H
+#define WRITE_RIEMANN_THRESHOLD_H
+
+int write_riemann_threshold_check(const data_set_t *, const value_list_t *, int *);
+
+#endif
index b09dcc8..aae5d8b 100644 (file)
@@ -24,6 +24,8 @@
  *   Fabrice A. Marie <fabrice at kibinlabs.com>
  */
 
+#define _GNU_SOURCE
+
 #include "collectd.h"
 #include "plugin.h"
 #include "common.h"
 #include <stddef.h>
 
 #include <stdlib.h>
-#ifndef HAVE_ASPRINTF
-/*
- * Uses asprintf() portable implementation from
- * https://github.com/littlstar/asprintf.c/blob/master/
- * copyright (c) 2014 joseph werle <joseph.werle@gmail.com> under MIT license.
- */
-#include <stdio.h>
-#include <stdarg.h>
-
-int vasprintf(char **str, const char *fmt, va_list args) {
-       int size = 0;
-       va_list tmpa;
-       // copy
-       va_copy(tmpa, args);
-       // apply variadic arguments to
-       // sprintf with format to get size
-       size = vsnprintf(NULL, size, fmt, tmpa);
-       // toss args
-       va_end(tmpa);
-       // return -1 to be compliant if
-       // size is less than 0
-       if (size < 0) { return -1; }
-       // alloc with size plus 1 for `\0'
-       *str = (char *) malloc(size + 1);
-       // return -1 to be compliant
-       // if pointer is `NULL'
-       if (NULL == *str) { return -1; }
-       // format string with original
-       // variadic arguments and set new size
-       size = vsprintf(*str, fmt, args);
-       return size;
-}
-
-int asprintf(char **str, const char *fmt, ...) {
-       int size = 0;
-       va_list args;
-       // init variadic argumens
-       va_start(args, fmt);
-       // format and get size
-       size = vasprintf(str, fmt, args);
-       // toss args
-       va_end(args);
-       return size;
-}
-
-#endif
-
 #define SENSU_HOST             "localhost"
 #define SENSU_PORT             "3030"
 
@@ -258,7 +213,7 @@ static char *build_json_str_list(const char *tag, struct str_list const *list) /
        return ret_str;
 } /* }}} char *build_json_str_list*/
 
-int sensu_format_name2(char *ret, int ret_len,
+static int sensu_format_name2(char *ret, int ret_len,
                const char *hostname,
                const char *plugin, const char *plugin_instance,
                const char *type, const char *type_instance,
@@ -550,7 +505,7 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */
  * http://creativeandcritical.net/str-replace-c/
  * copyright (c) Laird Shaw, under public domain.
  */
-char *replace_str(const char *str, const char *old, /* {{{ */
+static char *replace_str(const char *str, const char *old, /* {{{ */
                const char *new)
 {
        char *ret, *r;
index 2ed4389..c562596 100644 (file)
@@ -346,7 +346,7 @@ static int wt_format_name(char *ret, int ret_len,
 {
     int status;
     char *temp = NULL;
-    char *prefix = "";
+    const char *prefix = "";
     const char *meta_prefix = "tsdb_prefix";
 
     if (vl->meta) {
@@ -411,9 +411,9 @@ static int wt_send_message (const char* key, const char* value,
     int status;
     size_t message_len;
     char *temp = NULL;
-    char *tags = "";
+    const char *tags = "";
     char message[1024];
-    char *host_tags = cb->host_tags ? cb->host_tags : "";
+    const char *host_tags = cb->host_tags ? cb->host_tags : "";
     const char *meta_tsdb = "tsdb_tags";
 
     /* skip if value is NaN */
index a423bb6..29f2acd 100644 (file)
@@ -48,7 +48,7 @@ static void cxmms_submit (const char *type, gauge_t value)
        plugin_dispatch_values (&vl);
 } /* void cxmms_submit */
 
-int cxmms_read (void)
+static int cxmms_read (void)
 {
   gint rate;
   gint freq;
index 1a7613c..e1c3937 100644 (file)
@@ -71,7 +71,7 @@ static int put_zfs_value (kstat_t *ksp, char const *k, value_t v)
        return 0;
 }
 
-static long long get_zfs_value(kstat_t *ksp, char *key)
+static long long get_zfs_value(kstat_t *ksp, const char *key)
 {
        llentry_t *e;
        value_t *v;
@@ -286,8 +286,11 @@ static int za_read (void)
        za_read_derive (ksp, "deleted",  "cache_operation", "deleted");
 #if __FreeBSD__
        za_read_derive (ksp, "allocated","cache_operation", "allocated");
+#if defined(__FreeBSD_version) && (__FreeBSD_version < 1002501)
+       /* stolen removed from sysctl kstat.zfs.misc.arcstats on FreeBSD 10.2+ */
        za_read_derive (ksp, "stolen",   "cache_operation", "stolen");
 #endif
+#endif
 
        /* Issue indicators */
        za_read_derive (ksp, "mutex_miss", "mutex_operations", "miss");
index 539795c..1eed1fb 100644 (file)
@@ -108,8 +108,8 @@ static int zookeeper_connect (void)
        struct addrinfo ai_hints;
        struct addrinfo *ai;
        struct addrinfo *ai_list;
-       char *host;
-       char *port;
+       const char *host;
+       const char *port;
 
        memset ((void *) &ai_hints, '\0', sizeof (ai_hints));
        ai_hints.ai_family   = AF_UNSPEC;