summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorfhajny <fhajny>2016-12-07 17:28:39 +0000
committerfhajny <fhajny>2016-12-07 17:28:39 +0000
commitbf9f6f2dfac3102dfca21e989078ec4d75559987 (patch)
tree17e43a141443eb62d51a82c33e873d5af5041363 /sysutils
parentddd88059245612cf13184dd4bf041141bdf534a9 (diff)
downloadpkgsrc-bf9f6f2dfac3102dfca21e989078ec4d75559987.tar.gz
Update sysutils/collectd to 5.6.2.
Most of the NetBSD specific patches were re-applied due to code syntax changes. Upstream changes in 5.6.2: - collectd: A compile error on AIX has been fixed: "MSG_DONTWAIT" is not available on AIX. - collectd: The capability checking has been rewritten to be more portable. - collectd.conf(5): Various typos have been fixed. - collectd-tg: Incorrect usage of "nanosleep()" has been fixed which caused the tool to sleep (almost) indefinitely. - Build system: Detection of the Java environment has been made deterministic to allow for reproducible builds. - Build system: Detection of the Lua headers has been improved. - APC UPS plugin: Unavailable metrics are now skipped instead of reported as 0 (zero). - Modbus plugin: Build issues on FreeBSD have been fixed. - OpenVPN plugin: Gracefully handle empty configurations. - PowerDNS plugin: The "recursor command" has been fixed so PowerDNS can correctly parse all requested fields. - Write Graphite and AMQP plugins: A bug that could lead to a missing null-termination has been fixed. - Write HTTP plugin: A logic error when checking the correctness of the data set has been fixed. - Write Kafka plugin: The "Key Random" config option has been fixed. - Write Kafka plugin: Support for librdkafka 0.9.0 has been added. - Write Riemann plugin: Build issues on Solaris have been fixed. - ZFS ARC plugin: A duplicate metric has been removed.
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/collectd/Makefile.common4
-rw-r--r--sysutils/collectd/distinfo34
-rw-r--r--sysutils/collectd/patches/patch-src_cpu.c68
-rw-r--r--sysutils/collectd/patches/patch-src_df.c10
-rw-r--r--sysutils/collectd/patches/patch-src_disk.c329
-rw-r--r--sysutils/collectd/patches/patch-src_entropy.c107
-rw-r--r--sysutils/collectd/patches/patch-src_irq.c114
-rw-r--r--sysutils/collectd/patches/patch-src_libcollectclient_network__buffer.c20
-rw-r--r--sysutils/collectd/patches/patch-src_memory.c110
-rw-r--r--sysutils/collectd/patches/patch-src_processes.c440
-rw-r--r--sysutils/collectd/patches/patch-src_swap.c175
-rw-r--r--sysutils/collectd/patches/patch-src_tcpconns.c22
-rw-r--r--sysutils/collectd/patches/patch-src_utils__dns.c8
-rw-r--r--sysutils/collectd/patches/patch-src_utils__format__kairosdb.c26
14 files changed, 737 insertions, 730 deletions
diff --git a/sysutils/collectd/Makefile.common b/sysutils/collectd/Makefile.common
index 32c0c5e9875..ebab6b27564 100644
--- a/sysutils/collectd/Makefile.common
+++ b/sysutils/collectd/Makefile.common
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.common,v 1.12 2016/10/13 15:17:28 fhajny Exp $
+# $NetBSD: Makefile.common,v 1.13 2016/12/07 17:28:39 fhajny Exp $
#
# used by sysutils/collectd/Makefile
# used by sysutils/collectd-amqp/Makefile
@@ -16,7 +16,7 @@
# used by sysutils/p5-collectd/Makefile
# used by sysutils/py-collectd/Makefile
-DISTNAME= collectd-5.6.1
+DISTNAME= collectd-5.6.2
MASTER_SITES= http://collectd.org/files/
CATEGORIES= sysutils
EXTRACT_SUFX= .tar.bz2
diff --git a/sysutils/collectd/distinfo b/sysutils/collectd/distinfo
index cfff06953bc..d78c0ed5710 100644
--- a/sysutils/collectd/distinfo
+++ b/sysutils/collectd/distinfo
@@ -1,24 +1,24 @@
-$NetBSD: distinfo,v 1.29 2016/11/20 22:11:28 joerg Exp $
+$NetBSD: distinfo,v 1.30 2016/12/07 17:28:39 fhajny Exp $
-SHA1 (collectd-5.6.1.tar.bz2) = 20b773928743b346e0962fc1dc37167390a16d80
-RMD160 (collectd-5.6.1.tar.bz2) = 5247f6b4a0936ac9715189e16afe6f65bee94788
-SHA512 (collectd-5.6.1.tar.bz2) = da25f1a9cbaf47533f5a4d2f5f78b966317d4f21865c5a714954ad9d7d02b4798a3e0471ce52199dc80e01dc2808376cb10a7e19c402aafc984bf595f09951a6
-Size (collectd-5.6.1.tar.bz2) = 1903962 bytes
+SHA1 (collectd-5.6.2.tar.bz2) = 358b53ac5e0b00532d74bd40eb2658c6772d1458
+RMD160 (collectd-5.6.2.tar.bz2) = 81818c24db06f7a8922dc24e7be8cbf5d86e050c
+SHA512 (collectd-5.6.2.tar.bz2) = 81438e2e653649cf8a447f475b41844b7adb8ec436b43fb395ba9cf8b09b56a068633fe4b6c802d5cde3909d85a3af2542f5804005b3843f7936a37553911d61
+Size (collectd-5.6.2.tar.bz2) = 1806969 bytes
SHA1 (patch-Makefile.am) = ed45b75293a4ea2dd577d04eeb3b9017b8f47319
SHA1 (patch-configure.ac) = f450d6b00e5c7c37214b4d90ca057c515ed08fa1
SHA1 (patch-src_Makefile.am) = 1d5cc2f58ce776df04feab2afc937f12ee7b0765
SHA1 (patch-src_collectd.conf.in) = f0b35085cf0ddfd766e140b145177ab1f1326f5f
-SHA1 (patch-src_cpu.c) = 32af60d7e49edf9d16481b705bc1ea429c90c82b
+SHA1 (patch-src_cpu.c) = e645ae6b05c051c3c878f88a493fbbd7d548bb66
SHA1 (patch-src_daemon_Makefile.am) = e38d465faf8bdd750fd9cb7f0bd9f041fcc8f83c
-SHA1 (patch-src_df.c) = 7e75dfbc72ecad48eb0eb7427a19329daf6b9a60
-SHA1 (patch-src_disk.c) = 159862e8ca1e841e3c4013c03ba03f059fdbbab5
-SHA1 (patch-src_entropy.c) = 4fa683654936f57fb7366faebb93d572af08db9c
-SHA1 (patch-src_irq.c) = 6e414b6fd664e784edd5aa9f907c8cfa80a0cd48
-SHA1 (patch-src_libcollectclient_network__buffer.c) = 76c94284b4078259985b70168342ac306b4505b7
-SHA1 (patch-src_memory.c) = b15225915ff23beed0b75c45be2eb3940d3717fd
+SHA1 (patch-src_df.c) = 5c6549cd9ec72efed5cdb7d8dd9297c50491426e
+SHA1 (patch-src_disk.c) = 1d458db9753be9c8ad1ae5edb3468acf7419a66b
+SHA1 (patch-src_entropy.c) = 86e4a1a2160ae5967c8a6d242aefcc298eeb8cbf
+SHA1 (patch-src_irq.c) = 78f1757ff2ed6db9fb1d0e773c2a01eb190d53a0
+SHA1 (patch-src_libcollectclient_network__buffer.c) = 62924943831e6d0585b103e567888f9af5c46f9e
+SHA1 (patch-src_memory.c) = 2934cd50e454fc14d0ec952854c88b0a830fa9a7
SHA1 (patch-src_netstat__udp.c) = 30cb12d25f56c60959658dbd181783212e00cc61
-SHA1 (patch-src_processes.c) = e00d2edf6b4e6bfe3663e34fffb05f40652affe5
-SHA1 (patch-src_swap.c) = 304a25324099495fb875127221ed5fc95173a164
-SHA1 (patch-src_tcpconns.c) = 712af1b821d62217283df884dd283d5b1218ab7c
-SHA1 (patch-src_utils__dns.c) = c3782dc9127f42da30e3142b853aa2cb2259af94
-SHA1 (patch-src_utils__format__kairosdb.c) = 4fd05adcf0bf47ed94ce60aad5d7332279b06224
+SHA1 (patch-src_processes.c) = 9a1a7a6943ea05d1a38cedf26e7aab8508df7ff1
+SHA1 (patch-src_swap.c) = 24da6e04e3006639311e8111f26f72e4fab4054a
+SHA1 (patch-src_tcpconns.c) = b85de1d0eb03989df12d9688b38d61733a13c028
+SHA1 (patch-src_utils__dns.c) = 138a3168dc109d785412ffd068edab3b4dacca36
+SHA1 (patch-src_utils__format__kairosdb.c) = 1b82ee092f8188a27645bcd67c811f0d31d54b70
diff --git a/sysutils/collectd/patches/patch-src_cpu.c b/sysutils/collectd/patches/patch-src_cpu.c
index 37836cff7b6..8773e6c7354 100644
--- a/sysutils/collectd/patches/patch-src_cpu.c
+++ b/sysutils/collectd/patches/patch-src_cpu.c
@@ -1,50 +1,48 @@
-$NetBSD: patch-src_cpu.c,v 1.2 2016/10/13 15:17:28 fhajny Exp $
+$NetBSD: patch-src_cpu.c,v 1.3 2016/12/07 17:28:39 fhajny Exp $
Port this too to NetBSD.
---- src/cpu.c.orig 2016-09-11 08:10:25.255038733 +0000
+--- src/cpu.c.orig 2016-11-30 08:52:01.308911943 +0000
+++ src/cpu.c
-@@ -80,7 +80,9 @@
+@@ -81,7 +81,7 @@
#if HAVE_SYSCTL
- # if defined(CTL_HW) && defined(HW_NCPU) \
-- && defined(CTL_KERN) && defined(KERN_CPTIME) && defined(CPUSTATES)
-+ && defined(CTL_KERN) \
-+ && (defined(KERN_CPTIME) || defined(KERN_CP_TIME)) \
-+ && defined(CPUSTATES)
- # define CAN_USE_SYSCTL 1
- # else
- # define CAN_USE_SYSCTL 0
-@@ -696,6 +698,24 @@ static int cpu_read (void)
+ #if defined(CTL_HW) && defined(HW_NCPU) && defined(CTL_KERN) && \
+- defined(KERN_CPTIME) && defined(CPUSTATES)
++ (defined(KERN_CPTIME) || defined(KERN_CP_TIME)) && defined(CPUSTATES)
+ #define CAN_USE_SYSCTL 1
+ #else
+ #define CAN_USE_SYSCTL 0
+@@ -673,6 +673,24 @@ static int cpu_read(void) {
- memset (cpuinfo, 0, sizeof (cpuinfo));
+ memset(cpuinfo, 0, sizeof(cpuinfo));
+#if defined(KERN_CP_TIME) && defined(KERNEL_NETBSD)
-+ {
-+ int mib[] = {CTL_KERN, KERN_CP_TIME};
++ {
++ int mib[] = {CTL_KERN, KERN_CP_TIME};
+
-+ cpuinfo_size = sizeof(cpuinfo[0]) * numcpu * CPUSTATES;
-+ status = sysctl(mib, 2, cpuinfo, &cpuinfo_size, NULL, 0);
-+ if (status == -1) {
-+ char errbuf[1024];
++ cpuinfo_size = sizeof(cpuinfo[0]) * numcpu * CPUSTATES;
++ status = sysctl(mib, 2, cpuinfo, &cpuinfo_size, NULL, 0);
++ if (status == -1) {
++ char errbuf[1024];
+
-+ ERROR ("cpu plugin: sysctl failed: %s.",
-+ sstrerror (errno, errbuf, sizeof (errbuf)));
-+ return -1;
-+ }
-+ if (cpuinfo_size == (sizeof(cpuinfo[0]) * CPUSTATES)) {
-+ numcpu = 1;
-+ }
-+ }
++ ERROR ("cpu plugin: sysctl failed: %s.",
++ sstrerror (errno, errbuf, sizeof (errbuf)));
++ return -1;
++ }
++ if (cpuinfo_size == (sizeof(cpuinfo[0]) * CPUSTATES)) {
++ numcpu = 1;
++ }
++ }
+#else /* defined(KERN_CP_TIME) && defined(KERNEL_NETBSD) */
#if defined(KERN_CPTIME2)
- if (numcpu > 1) {
- for (int i = 0; i < numcpu; i++) {
-@@ -735,6 +755,7 @@ static int cpu_read (void)
- cpuinfo[0][i] = cpuinfo_tmp[i];
- }
- }
+ if (numcpu > 1) {
+ for (int i = 0; i < numcpu; i++) {
+@@ -710,6 +728,7 @@ static int cpu_read(void) {
+ cpuinfo[0][i] = cpuinfo_tmp[i];
+ }
+ }
+#endif /* defined(KERN_CP_TIME) && defined(KERNEL_NETBSD) */
- for (int i = 0; i < numcpu; i++) {
- cpu_stage (i, COLLECTD_CPU_STATE_USER, (derive_t) cpuinfo[i][CP_USER], now);
+ for (int i = 0; i < numcpu; i++) {
+ cpu_stage(i, COLLECTD_CPU_STATE_USER, (derive_t)cpuinfo[i][CP_USER], now);
diff --git a/sysutils/collectd/patches/patch-src_df.c b/sysutils/collectd/patches/patch-src_df.c
index 7c0c65c5c6d..d2dcc3c169b 100644
--- a/sysutils/collectd/patches/patch-src_df.c
+++ b/sysutils/collectd/patches/patch-src_df.c
@@ -1,12 +1,12 @@
-$NetBSD: patch-src_df.c,v 1.4 2015/08/18 07:52:20 he Exp $
+$NetBSD: patch-src_df.c,v 1.5 2016/12/07 17:28:39 fhajny Exp $
Older NetBSD doesn't have float_t.
---- src/df.c.orig 2015-03-10 14:14:45.000000000 +0000
+--- src/df.c.orig 2016-11-30 08:52:01.312911569 +0000
+++ src/df.c
@@ -28,6 +28,14 @@
- #include "utils_mount.h"
#include "utils_ignorelist.h"
+ #include "utils_mount.h"
+#if defined(__NetBSD__)
+#include <sys/param.h>
@@ -17,5 +17,5 @@ Older NetBSD doesn't have float_t.
+#endif
+
#if HAVE_STATVFS
- # if HAVE_SYS_STATVFS_H
- # include <sys/statvfs.h>
+ #if HAVE_SYS_STATVFS_H
+ #include <sys/statvfs.h>
diff --git a/sysutils/collectd/patches/patch-src_disk.c b/sysutils/collectd/patches/patch-src_disk.c
index aabff0e4754..ff44eaefe48 100644
--- a/sysutils/collectd/patches/patch-src_disk.c
+++ b/sysutils/collectd/patches/patch-src_disk.c
@@ -1,10 +1,10 @@
-$NetBSD: patch-src_disk.c,v 1.1 2015/08/11 13:19:21 he Exp $
+$NetBSD: patch-src_disk.c,v 1.2 2016/12/07 17:28:39 fhajny Exp $
Provide a port to NetBSD.
---- src/disk.c.orig 2015-03-10 14:14:45.000000000 +0000
+--- src/disk.c.orig 2016-11-30 08:52:01.312911569 +0000
+++ src/disk.c
-@@ -124,6 +124,35 @@ static int numdisk;
+@@ -135,6 +135,35 @@ static int numdisk;
static int pnumdisk;
/* #endif HAVE_PERFSTAT */
@@ -14,21 +14,21 @@ Provide a port to NetBSD.
+#include <sys/iostat.h>
+
+typedef struct diskstats {
-+ char *name;
++ char *name;
+
-+ u_int poll_count;
++ u_int poll_count;
+
-+ derive_t read_ops;
-+ derive_t write_ops;
++ derive_t read_ops;
++ derive_t write_ops;
+
-+ derive_t read_bytes;
-+ derive_t write_bytes;
++ derive_t read_bytes;
++ derive_t write_bytes;
+
-+ derive_t avg_io_time;
++ derive_t avg_io_time;
+
-+ struct io_sysctl stats;
++ struct io_sysctl stats;
+
-+ struct diskstats *next;
++ struct diskstats *next;
+} diskstats_t;
+
+static diskstats_t *disklist;
@@ -38,172 +38,171 @@ Provide a port to NetBSD.
+/* #endif HAVE_SYSCTL && KERNEL_NETBSD */
+
#else
- # error "No applicable input method."
+ #error "No applicable input method."
#endif
-@@ -241,7 +270,34 @@ static int disk_init (void)
- continue;
- ksp[numdisk++] = ksp_chain;
- }
+@@ -253,7 +282,33 @@ static int disk_init(void) {
+ continue;
+ ksp[numdisk++] = ksp_chain;
+ }
-#endif /* HAVE_LIBKSTAT */
+/* #endif HAVE_LIBKSTAT */
+
+#elif HAVE_SYSCTL && KERNEL_NETBSD
-+ int mib[3];
-+ size_t size;
-+
-+ /* figure out number of drives */
-+ mib[0] = CTL_HW;
-+ mib[1] = HW_IOSTATS;
-+ mib[2] = sizeof(struct io_sysctl);
-+ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1) {
-+ ERROR ("disk plugin: sysctl for ndrives failed");
-+ return -1;
-+ }
-+ ndrive = size / sizeof(struct io_sysctl);
-+
-+ if (size == 0 ) {
-+ ERROR ("disk plugin: no drives found");
-+ return -1;
-+ }
-+ drives = (struct io_sysctl *)malloc(size);
-+ if (drives == NULL) {
-+ ERROR ("disk plugin: memory allocation failure");
-+ return -1;
-+ }
-+
-+#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
++ int mib[3];
++ size_t size;
++
++ /* figure out number of drives */
++ mib[0] = CTL_HW;
++ mib[1] = HW_IOSTATS;
++ mib[2] = sizeof(struct io_sysctl);
++ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1) {
++ ERROR ("disk plugin: sysctl for ndrives failed");
++ return -1;
++ }
++ ndrive = size / sizeof(struct io_sysctl);
++
++ if (size == 0 ) {
++ ERROR ("disk plugin: no drives found");
++ return -1;
++ }
++ drives = (struct io_sysctl *)malloc(size);
++ if (drives == NULL) {
++ ERROR ("disk plugin: memory allocation failure");
++ return -1;
++ }
+
++#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
- return (0);
+ return (0);
} /* int disk_init */
-@@ -929,7 +985,129 @@ static int disk_read (void)
- write_time *= ((double)(_system_configuration.Xint)/(double)(_system_configuration.Xfrac)) / 1000000.0;
- disk_submit (stat_disk[i].name, "disk_time", read_time, write_time);
- }
+@@ -1026,7 +1081,129 @@ static int disk_read(void) {
+ 1000000.0;
+ disk_submit(stat_disk[i].name, "disk_time", read_time, write_time);
+ }
-#endif /* defined(HAVE_PERFSTAT) */
+/* #endif defined(HAVE_PERFSTAT) */
+
+#elif HAVE_SYSCTL && KERNEL_NETBSD
-+ int mib[3];
-+ size_t size, i, nndrive;
-+ diskstats_t *ds, *pre_ds;
-+ char *output_name;
-+
-+ u_int64_t ops;
-+ u_int64_t delta_t;
-+
-+ /* figure out number of drives */
-+ mib[0] = CTL_HW;
-+ mib[1] = HW_IOSTATS;
-+ mib[2] = sizeof(struct io_sysctl);
-+ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1) {
-+ ERROR ("disk plugin: sysctl for ndrives failed");
-+ return -1;
-+ }
-+ nndrive = size / sizeof(struct io_sysctl);
-+
-+ if (size == 0 ) {
-+ ERROR ("disk plugin: no drives found");
-+ return -1;
-+ }
-+ /* number of drives changed, reallocate buffer */
-+ if (nndrive != ndrive) {
-+ drives = (struct io_sysctl *)realloc(drives, size);
-+ if (drives == NULL) {
-+ ERROR ("disk plugin: memory allocation failure");
-+ return -1;
-+ }
-+ ndrive = nndrive;
-+ }
-+
-+ /* get stats for all drives */
-+ mib[0] = CTL_HW;
-+ mib[1] = HW_IOSTATS;
-+ mib[2] = sizeof(struct io_sysctl);
-+ if (sysctl(mib, 3, drives, &size, NULL, 0) == -1) {
-+ ERROR ("disk plugin: sysctl for drive stats failed");
-+ return -1;
-+ }
-+
-+ for (i = 0; i < ndrive; i++) {
-+
-+ if (drives[i].type != IOSTAT_DISK)
-+ continue;
-+
-+ /* find drive stats, if present */
-+ for (ds = disklist, pre_ds = disklist;
-+ ds != NULL;
-+ pre_ds = ds, ds = ds->next) {
-+ if (strcmp (drives[i].name, ds->name) == 0)
-+ break;
-+ }
-+ if (ds == NULL) { /* not found; allocate & link in */
-+ if ((ds = calloc(1, sizeof(diskstats_t))) == NULL)
-+ continue;
-+ if ((ds->name = strdup(drives[i].name)) == NULL) {
-+ free(ds);
-+ continue;
-+ }
-+ if (pre_ds == NULL)
-+ disklist = ds;
-+ else
-+ pre_ds->next = ds;
-+ }
-+
-+ ds->poll_count++;
-+ if (ds->poll_count <= 2)
-+ {
-+ DEBUG ("disk plugin: (ds->poll_count = %i) <= "
-+ "(min_poll_count = 2); => Not writing.",
-+ ds->poll_count);
-+ ds->stats = drives[i]; /* but save base values */
-+ continue;
-+ }
-+ ds->read_ops = drives[i].rxfer - ds->stats.rxfer;
-+ ds->write_ops = drives[i].wxfer - ds->stats.wxfer;
-+ ds->read_bytes = drives[i].rbytes - ds->stats.rbytes;
-+ ds->write_bytes = drives[i].wbytes - ds->stats.wbytes;
-+
-+ /* Need this dance because of unsigned values... */
-+ if (drives[i].time_usec < ds->stats.time_usec) {
-+ delta_t = ((drives[i].time_sec - 1 -
-+ ds->stats.time_sec) * 1000) +
-+ ((drives[i].time_usec + 1000000 -
-+ ds->stats.time_usec) / 1000);
-+ } else {
-+ delta_t = ((drives[i].time_sec -
-+ ds->stats.time_sec) * 1000) +
-+ ((drives[i].time_usec -
-+ ds->stats.time_usec) / 1000);
-+ }
-+
-+ ops = ds->read_ops + ds->write_ops;
-+ if (ops == 0) {
-+ DEBUG ("disk plugin: read + write ops == 0, "
-+ "not writing");
-+ continue;
-+ }
-+
-+ ds->avg_io_time = delta_t / ops;
-+
-+ output_name = drives[i].name;
-+
-+ if ((ds->read_bytes != 0) || (ds->write_bytes != 0))
-+ disk_submit (output_name, "disk_octets",
-+ ds->read_bytes, ds->write_bytes);
-+
-+ if ((ds->read_ops != 0) || (ds->write_ops != 0))
-+ disk_submit (output_name, "disk_ops",
-+ ds->read_ops, ds->write_ops);
-+
-+ if (ds->avg_io_time != 0)
-+ disk_submit (output_name, "disk_time",
-+ ds->avg_io_time, ds->avg_io_time);
-+
-+ ds->stats = drives[i];
-+ }
++ int mib[3];
++ size_t size, i, nndrive;
++ diskstats_t *ds, *pre_ds;
++ char *output_name;
++
++ u_int64_t ops;
++ u_int64_t delta_t;
++
++ /* figure out number of drives */
++ mib[0] = CTL_HW;
++ mib[1] = HW_IOSTATS;
++ mib[2] = sizeof(struct io_sysctl);
++ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1) {
++ ERROR ("disk plugin: sysctl for ndrives failed");
++ return -1;
++ }
++ nndrive = size / sizeof(struct io_sysctl);
++
++ if (size == 0 ) {
++ ERROR ("disk plugin: no drives found");
++ return -1;
++ }
++ /* number of drives changed, reallocate buffer */
++ if (nndrive != ndrive) {
++ drives = (struct io_sysctl *)realloc(drives, size);
++ if (drives == NULL) {
++ ERROR ("disk plugin: memory allocation failure");
++ return -1;
++ }
++ ndrive = nndrive;
++ }
++
++ /* get stats for all drives */
++ mib[0] = CTL_HW;
++ mib[1] = HW_IOSTATS;
++ mib[2] = sizeof(struct io_sysctl);
++ if (sysctl(mib, 3, drives, &size, NULL, 0) == -1) {
++ ERROR ("disk plugin: sysctl for drive stats failed");
++ return -1;
++ }
++
++ for (i = 0; i < ndrive; i++) {
++
++ if (drives[i].type != IOSTAT_DISK)
++ continue;
++
++ /* find drive stats, if present */
++ for (ds = disklist, pre_ds = disklist;
++ ds != NULL;
++ pre_ds = ds, ds = ds->next) {
++ if (strcmp (drives[i].name, ds->name) == 0)
++ break;
++ }
++ if (ds == NULL) { /* not found; allocate & link in */
++ if ((ds = calloc(1, sizeof(diskstats_t))) == NULL)
++ continue;
++ if ((ds->name = strdup(drives[i].name)) == NULL) {
++ free(ds);
++ continue;
++ }
++ if (pre_ds == NULL)
++ disklist = ds;
++ else
++ pre_ds->next = ds;
++ }
++
++ ds->poll_count++;
++ if (ds->poll_count <= 2)
++ {
++ DEBUG ("disk plugin: (ds->poll_count = %i) <= "
++ "(min_poll_count = 2); => Not writing.",
++ ds->poll_count);
++ ds->stats = drives[i]; /* but save base values */
++ continue;
++ }
++ ds->read_ops = drives[i].rxfer - ds->stats.rxfer;
++ ds->write_ops = drives[i].wxfer - ds->stats.wxfer;
++ ds->read_bytes = drives[i].rbytes - ds->stats.rbytes;
++ ds->write_bytes = drives[i].wbytes - ds->stats.wbytes;
++
++ /* Need this dance because of unsigned values... */
++ if (drives[i].time_usec < ds->stats.time_usec) {
++ delta_t = ((drives[i].time_sec - 1 -
++ ds->stats.time_sec) * 1000) +
++ ((drives[i].time_usec + 1000000 -
++ ds->stats.time_usec) / 1000);
++ } else {
++ delta_t = ((drives[i].time_sec -
++ ds->stats.time_sec) * 1000) +
++ ((drives[i].time_usec -
++ ds->stats.time_usec) / 1000);
++ }
++
++ ops = ds->read_ops + ds->write_ops;
++ if (ops == 0) {
++ DEBUG ("disk plugin: read + write ops == 0, "
++ "not writing");
++ continue;
++ }
++
++ ds->avg_io_time = delta_t / ops;
++
++ output_name = drives[i].name;
++
++ if ((ds->read_bytes != 0) || (ds->write_bytes != 0))
++ disk_submit (output_name, "disk_octets",
++ ds->read_bytes, ds->write_bytes);
++
++ if ((ds->read_ops != 0) || (ds->write_ops != 0))
++ disk_submit (output_name, "disk_ops",
++ ds->read_ops, ds->write_ops);
++
++ if (ds->avg_io_time != 0)
++ disk_submit (output_name, "disk_time",
++ ds->avg_io_time, ds->avg_io_time);
++
++ ds->stats = drives[i];
++ }
+
+#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
- return (0);
+ return (0);
} /* int disk_read */
diff --git a/sysutils/collectd/patches/patch-src_entropy.c b/sysutils/collectd/patches/patch-src_entropy.c
index b6dfa2fc43f..77a3ea43579 100644
--- a/sysutils/collectd/patches/patch-src_entropy.c
+++ b/sysutils/collectd/patches/patch-src_entropy.c
@@ -1,50 +1,49 @@
-$NetBSD: patch-src_entropy.c,v 1.6 2015/12/12 22:23:32 he Exp $
+$NetBSD: patch-src_entropy.c,v 1.7 2016/12/07 17:28:39 fhajny Exp $
Provide a NetBSD implementation for graphing available entropy.
This version tries to keep /dev/urandom open (for repeated use),
instead of constantly re-opening/closing it, since the latter will
needlessly reduce the kernel's entropy estimate.
---- src/entropy.c.orig 2015-03-10 14:14:45.000000000 +0000
+--- src/entropy.c.orig 2016-11-30 08:52:01.312911569 +0000
+++ src/entropy.c
-@@ -28,27 +28,16 @@
+@@ -29,27 +29,16 @@
#include "common.h"
#include "plugin.h"
-#if !KERNEL_LINUX
--# error "No applicable input method."
--#endif
--
--#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail"
--
--static void entropy_submit (double entropy)
--{
-- value_t values[1];
-- value_list_t vl = VALUE_LIST_INIT;
+-#error "No applicable input method."
+static void entropy_submit (double);
+static int entropy_read (void);
-
-- values[0].gauge = entropy;
++
+#if !KERNEL_LINUX && !KERNEL_NETBSD
+# error "No applicable input method."
-+#endif
+ #endif
-- vl.values = values;
-- vl.values_len = 1;
-- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
-- sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin));
-- sstrncpy (vl.type, "entropy", sizeof (vl.type));
+#if KERNEL_LINUX
+ #define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail"
-- plugin_dispatch_values (&vl);
+-static void entropy_submit(double entropy) {
+- value_t values[1];
+- value_list_t vl = VALUE_LIST_INIT;
+-
+- values[0].gauge = entropy;
+-
+- vl.values = values;
+- vl.values_len = 1;
+- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
+- sstrncpy(vl.plugin, "entropy", sizeof(vl.plugin));
+- sstrncpy(vl.type, "entropy", sizeof(vl.type));
+-
+- plugin_dispatch_values(&vl);
-}
-+#define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail"
-
- static int entropy_read (void)
- {
-@@ -74,6 +63,68 @@ static int entropy_read (void)
+-
+ static int entropy_read(void) {
+ double entropy;
+ FILE *fh;
+@@ -72,6 +61,68 @@ static int entropy_read(void) {
- return (0);
+ return (0);
}
+#endif /* KERNEL_LINUX */
+
@@ -69,45 +68,45 @@ needlessly reduce the kernel's entropy estimate.
+static int
+entropy_read (void)
+{
-+ rndpoolstat_t rs;
-+ static int fd;
++ rndpoolstat_t rs;
++ static int fd;
+
-+ if (fd == 0) {
-+ fd = open(_PATH_URANDOM, O_RDONLY, 0644);
-+ if (fd < 0) {
-+ fd = 0;
-+ return -1;
-+ }
-+ }
++ if (fd == 0) {
++ fd = open(_PATH_URANDOM, O_RDONLY, 0644);
++ if (fd < 0) {
++ fd = 0;
++ return -1;
++ }
++ }
+
-+ if (ioctl(fd, RNDGETPOOLSTAT, &rs) < 0) {
-+ (void) close(fd);
-+ fd = 0; /* signal a reopening on next attempt */
-+ return -1;
-+ }
++ if (ioctl(fd, RNDGETPOOLSTAT, &rs) < 0) {
++ (void) close(fd);
++ fd = 0; /* signal a reopening on next attempt */
++ return -1;
++ }
+
-+ entropy_submit (rs.curentropy);
++ entropy_submit (rs.curentropy);
+
-+ return 0;
++ return 0;
+}
+
+#endif /* KERNEL_NETBSD */
+
+static void entropy_submit (double entropy)
+{
-+ value_t values[1];
-+ value_list_t vl = VALUE_LIST_INIT;
++ value_t values[1];
++ value_list_t vl = VALUE_LIST_INIT;
+
-+ values[0].gauge = entropy;
++ values[0].gauge = entropy;
+
-+ vl.values = values;
-+ vl.values_len = 1;
-+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
-+ sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin));
-+ sstrncpy (vl.type, "entropy", sizeof (vl.type));
++ vl.values = values;
++ vl.values_len = 1;
++ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
++ sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin));
++ sstrncpy (vl.type, "entropy", sizeof (vl.type));
+
-+ plugin_dispatch_values (&vl);
++ plugin_dispatch_values (&vl);
+}
- void module_register (void)
- {
+ void module_register(void) {
+ plugin_register_read("entropy", entropy_read);
diff --git a/sysutils/collectd/patches/patch-src_irq.c b/sysutils/collectd/patches/patch-src_irq.c
index e6137c418e7..1dc8bd3ce77 100644
--- a/sysutils/collectd/patches/patch-src_irq.c
+++ b/sysutils/collectd/patches/patch-src_irq.c
@@ -1,8 +1,8 @@
-$NetBSD: patch-src_irq.c,v 1.3 2016/10/13 15:17:28 fhajny Exp $
+$NetBSD: patch-src_irq.c,v 1.4 2016/12/07 17:28:39 fhajny Exp $
Provide a port to NetBSD.
---- src/irq.c.orig 2016-09-11 08:10:25.263038721 +0000
+--- src/irq.c.orig 2016-11-30 08:52:01.316911197 +0000
+++ src/irq.c
@@ -27,10 +27,20 @@
#include "plugin.h"
@@ -10,7 +10,7 @@ Provide a port to NetBSD.
-#if !KERNEL_LINUX
+#if !KERNEL_LINUX && !KERNEL_NETBSD
- # error "No applicable input method."
+ #error "No applicable input method."
#endif
+#if KERNEL_NETBSD
@@ -26,17 +26,17 @@ Provide a port to NetBSD.
/*
* (Module-)Global variables
*/
-@@ -90,6 +100,7 @@ static void irq_submit (const char *irq_
- plugin_dispatch_values (&vl);
+@@ -79,6 +89,7 @@ static void irq_submit(const char *irq_n
+ plugin_dispatch_values(&vl);
} /* void irq_submit */
+#if KERNEL_LINUX
- static int irq_read (void)
- {
- FILE *fh;
-@@ -188,6 +199,64 @@ static int irq_read (void)
+ static int irq_read(void) {
+ FILE *fh;
+ char buffer[1024];
+@@ -171,6 +182,64 @@ static int irq_read(void) {
- return (0);
+ return (0);
} /* int irq_read */
+#endif /* KERNEL_LINUX */
+
@@ -44,58 +44,58 @@ Provide a port to NetBSD.
+static int
+irq_read (void)
+{
-+ const int mib[4] = {
-+ CTL_KERN,
-+ KERN_EVCNT,
-+ EVCNT_TYPE_INTR,
-+ KERN_EVCNT_COUNT_NONZERO
-+ };
-+ size_t buflen = 0;
-+ void *buf = NULL;
-+ const struct evcnt_sysctl *evs, *last_evs;
++ const int mib[4] = {
++ CTL_KERN,
++ KERN_EVCNT,
++ EVCNT_TYPE_INTR,
++ KERN_EVCNT_COUNT_NONZERO
++ };
++ size_t buflen = 0;
++ void *buf = NULL;
++ const struct evcnt_sysctl *evs, *last_evs;
+
-+ for (;;) {
-+ size_t newlen;
-+ int error;
++ for (;;) {
++ size_t newlen;
++ int error;
+
-+ newlen = buflen;
-+ if (buflen)
-+ buf = malloc(buflen);
-+ error = sysctl(mib, __arraycount(mib),
-+ buf, &newlen, NULL, 0);
-+ if (error) {
-+ ERROR("irq plugin: failed to get event count");
-+ return -1;
-+ }
-+ if (newlen <= buflen) {
-+ buflen = newlen;
-+ break;
-+ }
-+ if (buf)
-+ free(buf);
-+ buflen = newlen;
-+ }
-+ evs = buf;
-+ last_evs = (void*)((char *)buf + buflen);
-+ buflen /= sizeof(uint64_t);
-+ while(evs < last_evs
-+ && buflen > sizeof(*evs) / sizeof(uint64_t)
-+ && buflen >= evs->ev_len)
-+ {
-+ char irqname[80];
++ newlen = buflen;
++ if (buflen)
++ buf = malloc(buflen);
++ error = sysctl(mib, __arraycount(mib),
++ buf, &newlen, NULL, 0);
++ if (error) {
++ ERROR("irq plugin: failed to get event count");
++ return -1;
++ }
++ if (newlen <= buflen) {
++ buflen = newlen;
++ break;
++ }
++ if (buf)
++ free(buf);
++ buflen = newlen;
++ }
++ evs = buf;
++ last_evs = (void*)((char *)buf + buflen);
++ buflen /= sizeof(uint64_t);
++ while(evs < last_evs
++ && buflen > sizeof(*evs) / sizeof(uint64_t)
++ && buflen >= evs->ev_len)
++ {
++ char irqname[80];
+
-+ snprintf(irqname, 80, "%s-%s", evs->ev_strings,
-+ evs->ev_strings + evs->ev_grouplen + 1);
++ snprintf(irqname, 80, "%s-%s", evs->ev_strings,
++ evs->ev_strings + evs->ev_grouplen + 1);
+
-+ irq_submit(irqname, evs->ev_count);
++ irq_submit(irqname, evs->ev_count);
+
-+ buflen -= evs->ev_len;
-+ evs =(const void*)((const uint64_t *)evs + evs->ev_len);
-+ }
-+ free(buf);
-+ return 0;
++ buflen -= evs->ev_len;
++ evs =(const void*)((const uint64_t *)evs + evs->ev_len);
++ }
++ free(buf);
++ return 0;
+}
+#endif /* KERNEL_NETBSD */
- void module_register (void)
- {
+ void module_register(void) {
+ plugin_register_config("irq", irq_config, config_keys, config_keys_num);
diff --git a/sysutils/collectd/patches/patch-src_libcollectclient_network__buffer.c b/sysutils/collectd/patches/patch-src_libcollectclient_network__buffer.c
index 1bf5bce531f..f5547a62f9b 100644
--- a/sysutils/collectd/patches/patch-src_libcollectclient_network__buffer.c
+++ b/sysutils/collectd/patches/patch-src_libcollectclient_network__buffer.c
@@ -1,23 +1,23 @@
-$NetBSD: patch-src_libcollectclient_network__buffer.c,v 1.2 2016/10/13 15:17:28 fhajny Exp $
+$NetBSD: patch-src_libcollectclient_network__buffer.c,v 1.3 2016/12/07 17:28:39 fhajny Exp $
Need the workaround on at least SunOS too.
---- src/libcollectdclient/network_buffer.c.orig 2016-09-11 08:10:25.263038721 +0000
+--- src/libcollectdclient/network_buffer.c.orig 2016-11-30 08:52:01.316911197 +0000
+++ src/libcollectdclient/network_buffer.c
@@ -36,7 +36,7 @@
#include <pthread.h>
#if HAVE_LIBGCRYPT
--# if defined __APPLE__
-+# if defined __APPLE__ || defined(__sun)
+-#if defined __APPLE__
++#if defined __APPLE__ || defined(__sun)
/* default xcode compiler throws warnings even when deprecated functionality
* is not used. -Werror breaks the build because of erroneous warnings.
* http://stackoverflow.com/questions/10556299/compiler-warnings-with-libgcrypt-v1-5-0/12830209#12830209
@@ -49,7 +49,7 @@
*/
- # define GCRYPT_NO_DEPRECATED
- # include <gcrypt.h>
--# if defined __APPLE__
-+# if defined(__APPLE__) || defined(__sun)
+ #define GCRYPT_NO_DEPRECATED
+ #include <gcrypt.h>
+-#if defined __APPLE__
++#if defined __APPLE__ || defined(__sun)
/* Re enable deprecation warnings */
- # pragma GCC diagnostic warning "-Wdeprecated-declarations"
- # endif
+ #pragma GCC diagnostic warning "-Wdeprecated-declarations"
+ #endif
diff --git a/sysutils/collectd/patches/patch-src_memory.c b/sysutils/collectd/patches/patch-src_memory.c
index c3b70063a0b..2e0f27f65f0 100644
--- a/sysutils/collectd/patches/patch-src_memory.c
+++ b/sysutils/collectd/patches/patch-src_memory.c
@@ -1,9 +1,9 @@
-$NetBSD: patch-src_memory.c,v 1.3 2016/10/13 15:17:28 fhajny Exp $
+$NetBSD: patch-src_memory.c,v 1.4 2016/12/07 17:28:39 fhajny Exp $
Add a port for NetBSD using VM_UVMEXP2, and preferring
sysctl over sysctlbyname.
---- src/memory.c.orig 2016-09-11 08:10:25.267038716 +0000
+--- src/memory.c.orig 2016-11-30 08:52:01.316911197 +0000
+++ src/memory.c
@@ -66,6 +66,10 @@ static mach_port_t port_host;
static vm_size_t pagesize;
@@ -28,7 +28,7 @@ sysctl over sysctlbyname.
/* no global variables */
/* endif HAVE_LIBSTATGRAB */
@@ -94,6 +94,10 @@ static int pagesize;
- # error "No applicable input method."
+ #error "No applicable input method."
#endif
+#if KERNEL_NETBSD
@@ -38,89 +38,87 @@ sysctl over sysctlbyname.
static _Bool values_absolute = 1;
static _Bool values_percentage = 0;
-@@ -121,6 +125,15 @@ static int memory_init (void)
- host_page_size (port_host, &pagesize);
+@@ -120,6 +124,14 @@ static int memory_init(void) {
+ host_page_size(port_host, &pagesize);
/* #endif HAVE_HOST_STATISTICS */
+#elif HAVE_SYSCTL
-+ pagesize = getpagesize ();
-+ if (pagesize <= 0)
-+ {
-+ ERROR ("memory plugin: Invalid pagesize: %i", pagesize);
-+ return (-1);
-+ }
++ pagesize = getpagesize();
++ if (pagesize <= 0) {
++ ERROR("memory plugin: Invalid pagesize: %i", pagesize);
++ return (-1);
++ }
+/* #endif HAVE_SYSCTL */
+
#elif HAVE_SYSCTLBYNAME
/* no init stuff */
/* #endif HAVE_SYSCTLBYNAME */
-@@ -145,15 +158,6 @@ static int memory_init (void)
+@@ -142,14 +154,6 @@ static int memory_init(void) {
/* #endif HAVE_LIBKSTAT */
-#elif HAVE_SYSCTL
-- pagesize = getpagesize ();
-- if (pagesize <= 0)
-- {
-- ERROR ("memory plugin: Invalid pagesize: %i", pagesize);
-- return (-1);
-- }
+- pagesize = getpagesize();
+- if (pagesize <= 0) {
+- ERROR("memory plugin: Invalid pagesize: %i", pagesize);
+- return (-1);
+- }
-/* #endif HAVE_SYSCTL */
-
#elif HAVE_LIBSTATGRAB
/* no init stuff */
/* #endif HAVE_LIBSTATGRAB */
-@@ -227,6 +231,46 @@ static int memory_read_internal (value_l
+@@ -221,6 +225,46 @@ static int memory_read_internal(value_li
/* #endif HAVE_HOST_STATISTICS */
#elif HAVE_SYSCTLBYNAME
+
+#if HAVE_SYSCTL && defined(KERNEL_NETBSD)
-+ int mib[] = {CTL_VM, VM_UVMEXP2};
-+ struct uvmexp_sysctl uvmexp;
-+ gauge_t mem_active;
-+ gauge_t mem_inactive;
-+ gauge_t mem_free;
-+ gauge_t mem_wired;
-+ gauge_t mem_kernel;
-+ size_t size;
++ int mib[] = {CTL_VM, VM_UVMEXP2};
++ struct uvmexp_sysctl uvmexp;
++ gauge_t mem_active;
++ gauge_t mem_inactive;
++ gauge_t mem_free;
++ gauge_t mem_wired;
++ gauge_t mem_kernel;
++ size_t size;
+
-+ memset (&uvmexp, 0, sizeof (uvmexp));
-+ size = sizeof (uvmexp);
++ memset (&uvmexp, 0, sizeof (uvmexp));
++ size = sizeof (uvmexp);
+
-+ if (sysctl (mib, 2, &uvmexp, &size, NULL, 0) < 0) {
-+ char errbuf[1024];
-+ WARNING ("memory plugin: sysctl failed: %s",
-+ sstrerror (errno, errbuf, sizeof (errbuf)));
-+ return (-1);
-+ }
++ if (sysctl (mib, 2, &uvmexp, &size, NULL, 0) < 0) {
++ char errbuf[1024];
++ WARNING ("memory plugin: sysctl failed: %s",
++ sstrerror (errno, errbuf, sizeof (errbuf)));
++ return (-1);
++ }
+
-+ assert (pagesize > 0);
-+ mem_active = (gauge_t) (uvmexp.active * pagesize);
-+ mem_inactive = (gauge_t) (uvmexp.inactive * pagesize);
-+ mem_free = (gauge_t) (uvmexp.free * pagesize);
-+ mem_wired = (gauge_t) (uvmexp.wired * pagesize);
-+ mem_kernel = (gauge_t) ((uvmexp.npages - (
-+ uvmexp.active + uvmexp.inactive +
-+ uvmexp.free + uvmexp.wired
-+ )) * pagesize);
++ assert (pagesize > 0);
++ mem_active = (gauge_t) (uvmexp.active * pagesize);
++ mem_inactive = (gauge_t) (uvmexp.inactive * pagesize);
++ mem_free = (gauge_t) (uvmexp.free * pagesize);
++ mem_wired = (gauge_t) (uvmexp.wired * pagesize);
++ mem_kernel = (gauge_t) ((uvmexp.npages - (
++ uvmexp.active + uvmexp.inactive +
++ uvmexp.free + uvmexp.wired
++ )) * pagesize);
+
-+ MEMORY_SUBMIT ("active", mem_active,
-+ "inactive", mem_inactive,
-+ "free", mem_free,
-+ "wired", mem_wired,
-+ "kernel", mem_kernel);
++ MEMORY_SUBMIT ("active", mem_active,
++ "inactive", mem_inactive,
++ "free", mem_free,
++ "wired", mem_wired,
++ "kernel", mem_kernel);
+/* #endif HAVE_SYSCTL && defined(KERNEL_NETBSD) */
+
+#else /* Other HAVE_SYSCTLBYNAME providers */
+
- /*
- * vm.stats.vm.v_page_size: 4096
- * vm.stats.vm.v_page_count: 246178
-@@ -276,6 +320,8 @@ static int memory_read_internal (value_l
- "active", (gauge_t) sysctl_vals[4],
- "inactive", (gauge_t) sysctl_vals[5],
- "cache", (gauge_t) sysctl_vals[6]);
+ /*
+ * vm.stats.vm.v_page_size: 4096
+ * vm.stats.vm.v_page_count: 246178
+@@ -259,6 +303,8 @@ static int memory_read_internal(value_li
+ (gauge_t)sysctl_vals[3], "active", (gauge_t)sysctl_vals[4],
+ "inactive", (gauge_t)sysctl_vals[5], "cache",
+ (gauge_t)sysctl_vals[6]);
+
+#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
/* #endif HAVE_SYSCTLBYNAME */
diff --git a/sysutils/collectd/patches/patch-src_processes.c b/sysutils/collectd/patches/patch-src_processes.c
index 090a1ce04cf..245bcb2e6bc 100644
--- a/sysutils/collectd/patches/patch-src_processes.c
+++ b/sysutils/collectd/patches/patch-src_processes.c
@@ -1,249 +1,253 @@
-$NetBSD: patch-src_processes.c,v 1.3 2015/09/01 09:00:04 he Exp $
+$NetBSD: patch-src_processes.c,v 1.4 2016/12/07 17:28:39 fhajny Exp $
Add a port to NetBSD.
---- src/processes.c.orig 2015-05-20 12:04:47.000000000 +0000
+--- src/processes.c.orig 2016-11-30 08:52:01.324910450 +0000
+++ src/processes.c
-@@ -94,13 +94,13 @@
- # endif
+@@ -95,14 +95,14 @@
/* #endif KERNEL_LINUX */
--#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
-+#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
- # include <kvm.h>
- # include <sys/param.h>
- # include <sys/sysctl.h>
- # include <sys/user.h>
- # include <sys/proc.h>
--/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
-+/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
+ #elif HAVE_LIBKVM_GETPROCS && \
+- (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++ (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
+ #include <kvm.h>
+ #include <sys/param.h>
+ #include <sys/proc.h>
+ #include <sys/sysctl.h>
+ #include <sys/user.h>
+ /* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD ||
+- * HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++ * HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
#elif HAVE_PROCINFO_H
- # include <procinfo.h>
-@@ -229,9 +229,14 @@ static mach_msg_type_number_t pset_l
- static long pagesize_g;
+ #include <procinfo.h>
+@@ -244,10 +244,15 @@ static long pagesize_g;
/* #endif KERNEL_LINUX */
--#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
-+#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
+ #elif HAVE_LIBKVM_GETPROCS && \
+- (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++ (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
static int pagesize;
--/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
+
+#if KERNEL_NETBSD
+int maxslp;
+#endif
+
-+/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
+ /* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD ||
+- * HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++ * HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
#elif HAVE_PROCINFO_H
- static struct procentry64 procentry[MAXPROCENTRY];
-@@ -638,9 +643,20 @@ static int ps_init (void)
- pagesize_g, CONFIG_HZ);
+ static struct procentry64 procentry[MAXPROCENTRY];
+@@ -607,10 +612,21 @@ static int ps_init(void) {
/* #endif KERNEL_LINUX */
--#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
-+#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
+ #elif HAVE_LIBKVM_GETPROCS && \
+- (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++ (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
+#if KERNEL_NETBSD
-+ int mib[2];
-+ size_t size;
-+
-+ mib[0] = CTL_VM;
-+ mib[1] = VM_MAXSLP;
-+ size = sizeof(maxslp);
-+ if (sysctl(mib, 2, &maxslp, &size, NULL, 0) == -1)
-+ maxslp = 20; /* reasonable default? */
++ int mib[2];
++ size_t size;
++
++ mib[0] = CTL_VM;
++ mib[1] = VM_MAXSLP;
++ size = sizeof(maxslp);
++ if (sysctl(mib, 2, &maxslp, &size, NULL, 0) == -1)
++ maxslp = 20; /* reasonable default? */
+#endif
+
- pagesize = getpagesize();
--/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
-+/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
+ pagesize = getpagesize();
+ /* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD ||
+- * HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++ * HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
#elif HAVE_PROCINFO_H
- pagesize = getpagesize();
-@@ -1940,6 +1956,186 @@ static int ps_read (void)
- ps_submit_proc_list (ps_ptr);
+ pagesize = getpagesize();
+@@ -1917,6 +1933,187 @@ static int ps_read(void) {
+ ps_submit_proc_list(ps_ptr);
/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
+#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC2_NETBSD
-+ int running = 0;
-+ int sleeping = 0;
-+ int zombies = 0;
-+ int stopped = 0;
-+ int blocked = 0;
-+ int idle = 0;
-+ int wait = 0;
-+
-+ kvm_t *kd;
-+ char errbuf[_POSIX2_LINE_MAX];
-+ struct kinfo_proc2 *procs; /* array of processes */
-+ struct kinfo_proc2 *proc_ptr = NULL;
-+ struct kinfo_proc2 *p;
-+ int count; /* returns number of processes */
-+ int i;
-+ int l, nlwps;
-+ struct kinfo_lwp *kl;
-+
-+ procstat_t *ps_ptr;
-+ procstat_entry_t pse;
-+
-+ ps_list_reset ();
-+
-+ /* Open the kvm interface, get a descriptor */
-+ kd = kvm_openfiles (NULL, NULL, NULL, KVM_NO_FILES, errbuf);
-+ if (kd == NULL)
-+ {
-+ ERROR ("processes plugin: Cannot open kvm interface: %s",
-+ errbuf);
-+ return (0);
-+ }
-+
-+ /* Get the list of processes. */
-+ procs = kvm_getproc2(kd, KERN_PROC_ALL, 0,
-+ sizeof(struct kinfo_proc2), &count);
-+ if (procs == NULL)
-+ {
-+ ERROR ("processes plugin: Cannot get kvm processes list: %s",
-+ kvm_geterr(kd));
-+ kvm_close (kd);
-+ return (0);
-+ }
-+
-+ /* Iterate through the processes in kinfo_proc */
-+ for (i = 0; i < count; i++)
-+ {
-+ /* Create only one process list entry per _process_, i.e.
-+ * filter out threads (duplicate PID entries). */
-+ if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid))
-+ {
-+ char cmdline[CMDLINE_BUFFER_SIZE] = "";
-+ _Bool have_cmdline = 0;
-+
-+ proc_ptr = &(procs[i]);
-+ /* Don't probe system processes and processes without arguments */
-+ if (((procs[i].p_flag & P_SYSTEM) == 0)
-+ && (procs[i].p_comm[0] != 0))
-+ {
-+ char **argv;
-+ int argc;
-+ int status;
-+
-+ /* retrieve the arguments */
-+ argv = kvm_getargv2 (kd, proc_ptr, 0);
-+ argc = 0;
-+ if ((argv != NULL) && (argv[0] != NULL))
-+ {
-+ while (argv[argc] != NULL)
-+ argc++;
-+
-+ status = strjoin (cmdline, sizeof (cmdline), argv, argc, " ");
-+ if (status < 0)
-+ WARNING ("processes plugin: Command line did not fit into buffer.");
-+ else
-+ have_cmdline = 1;
-+ }
-+ } /* if (process has argument list) */
-+
-+ pse.id = procs[i].p_pid;
-+ pse.age = 0;
-+
-+ pse.num_proc = 1;
-+ pse.num_lwp = procs[i].p_nlwps;
-+
-+ pse.vmem_size = procs[i].p_uru_maxrss * pagesize;
-+ pse.vmem_rss = procs[i].p_vm_rssize * pagesize;
-+ pse.vmem_data = procs[i].p_vm_dsize * pagesize;
-+ pse.vmem_code = procs[i].p_vm_tsize * pagesize;
-+ pse.stack_size = procs[i].p_vm_ssize * pagesize;
-+ pse.vmem_minflt = 0;
-+ pse.vmem_minflt_counter = procs[i].p_uru_minflt;
-+ pse.vmem_majflt = 0;
-+ pse.vmem_majflt_counter = procs[i].p_uru_majflt;
-+
-+ pse.cpu_user = 0;
-+ pse.cpu_system = 0;
-+ pse.cpu_user_counter = 0;
-+ pse.cpu_system_counter = 0;
-+ /*
-+ * The u-area might be swapped out, and we can't get
-+ * at it because we have a crashdump and no swap.
-+ * If it's here fill in these fields, otherwise, just
-+ * leave them 0.
-+ */
-+ if (procs[i].p_flag & P_INMEM)
-+ {
-+ pse.cpu_user_counter = procs[i].p_uutime_usec
-+ + (1000000lu * procs[i].p_uutime_sec);
-+ pse.cpu_system_counter = procs[i].p_ustime_usec
-+ + (1000000lu * procs[i].p_ustime_sec);
-+ }
-+
-+ /* no I/O data */
-+ pse.io_rchar = -1;
-+ pse.io_wchar = -1;
-+ pse.io_syscr = procs[i].p_uru_inblock;
-+ pse.io_syscw = procs[i].p_uru_oublock;
-+
-+ ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse);
-+ } /* if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid)) */
-+
-+ /* system processes' LWPs end up in "running" state */
-+ if ((procs[i].p_flag & P_SYSTEM) != 0)
-+ continue;
-+
-+ switch (procs[i].p_realstat)
-+ {
-+ case SSTOP:
-+ case SACTIVE:
-+ case SIDL:
-+ p = &(procs[i]);
-+ /* get info about LWPs */
-+ kl = kvm_getlwps(kd, p->p_pid, (u_long)p->p_paddr,
-+ sizeof(struct kinfo_lwp), &nlwps);
-+
-+ for (l = 0; kl && l < nlwps; l++) {
-+ switch (kl[l].l_stat) {
-+ case LSONPROC:
-+ case LSRUN:
-+ running++;
-+ break;
-+ case LSSLEEP:
-+ if (kl[l].l_flag & L_SINTR) {
-+ if (kl[l].l_slptime > maxslp)
-+ idle++;
-+ else
-+ sleeping++;
-+ } else
-+ blocked++;
-+ break;
-+ case LSSTOP:
-+ stopped++; break;
-+ case LSIDL:
-+ idle++; break;
-+ }
-+ }
-+ break;
-+ case SZOMB:
-+ case SDYING:
-+ case SDEAD:
-+ zombies++; break;
-+
-+ }
-+ }
-+
-+ kvm_close(kd);
-+
-+ ps_submit_state ("running", running);
-+ ps_submit_state ("sleeping", sleeping);
-+ ps_submit_state ("zombies", zombies);
-+ ps_submit_state ("stopped", stopped);
-+ ps_submit_state ("blocked", blocked);
-+ ps_submit_state ("idle", idle);
-+ ps_submit_state ("wait", wait);
-+
-+ for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
-+ ps_submit_proc_list (ps_ptr);
++ int running = 0;
++ int sleeping = 0;
++ int zombies = 0;
++ int stopped = 0;
++ int blocked = 0;
++ int idle = 0;
++ int wait = 0;
++
++ kvm_t *kd;
++ char errbuf[_POSIX2_LINE_MAX];
++ struct kinfo_proc2 *procs; /* array of processes */
++ struct kinfo_proc2 *proc_ptr = NULL;
++ struct kinfo_proc2 *p;
++ int count; /* returns number of processes */
++ int i;
++ int l, nlwps;
++ struct kinfo_lwp *kl;
++
++ procstat_t *ps_ptr;
++ procstat_entry_t pse;
++
++ ps_list_reset ();
++
++ /* Open the kvm interface, get a descriptor */
++ kd = kvm_openfiles (NULL, NULL, NULL, KVM_NO_FILES, errbuf);
++ if (kd == NULL)
++ {
++ ERROR ("processes plugin: Cannot open kvm interface: %s",
++ errbuf);
++ return (0);
++ }
++
++ /* Get the list of processes. */
++ procs = kvm_getproc2(kd, KERN_PROC_ALL, 0,
++ sizeof(struct kinfo_proc2), &count);
++ if (procs == NULL)
++ {
++ ERROR ("processes plugin: Cannot get kvm processes list: %s",
++ kvm_geterr(kd));
++ kvm_close (kd);
++ return (0);
++ }
++
++ /* Iterate through the processes in kinfo_proc */
++ for (i = 0; i < count; i++)
++ {
++ /* Create only one process list entry per _process_, i.e.
++ * filter out threads (duplicate PID entries). */
++ if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid))
++ {
++ char cmdline[CMDLINE_BUFFER_SIZE] = "";
++ _Bool have_cmdline = 0;
++
++ proc_ptr = &(procs[i]);
++ /* Don't probe system processes and processes without arguments */
++ if (((procs[i].p_flag & P_SYSTEM) == 0)
++ && (procs[i].p_comm[0] != 0))
++ {
++ char **argv;
++ int argc;
++ int status;
++
++ /* retrieve the arguments */
++ argv = kvm_getargv2 (kd, proc_ptr, 0);
++ argc = 0;
++ if ((argv != NULL) && (argv[0] != NULL))
++ {
++ while (argv[argc] != NULL)
++ argc++;
++
++ status = strjoin (cmdline, sizeof (cmdline), argv, argc, " ");
++ if (status < 0)
++ WARNING ("processes plugin: Command line did not fit into buffer.");
++ else
++ have_cmdline = 1;
++ }
++ } /* if (process has argument list) */
++
++ pse.id = procs[i].p_pid;
++ pse.age = 0;
++
++ pse.num_proc = 1;
++ pse.num_lwp = procs[i].p_nlwps;
++
++ pse.vmem_size = procs[i].p_uru_maxrss * pagesize;
++ pse.vmem_rss = procs[i].p_vm_rssize * pagesize;
++ pse.vmem_data = procs[i].p_vm_dsize * pagesize;
++ pse.vmem_code = procs[i].p_vm_tsize * pagesize;
++ pse.stack_size = procs[i].p_vm_ssize * pagesize;
++ pse.vmem_minflt = 0;
++ pse.vmem_minflt_counter = procs[i].p_uru_minflt;
++ pse.vmem_majflt = 0;
++ pse.vmem_majflt_counter = procs[i].p_uru_majflt;
++
++ pse.cpu_user = 0;
++ pse.cpu_system = 0;
++ pse.cpu_user_counter = 0;
++ pse.cpu_system_counter = 0;
++ /*
++ * The u-area might be swapped out, and we can't get
++ * at it because we have a crashdump and no swap.
++ * If it's here fill in these fields, otherwise, just
++ * leave them 0.
++ */
++ if (procs[i].p_flag & P_INMEM)
++ {
++ pse.cpu_user_counter = procs[i].p_uutime_usec
++ + (1000000lu * procs[i].p_uutime_sec);
++ pse.cpu_system_counter = procs[i].p_ustime_usec
++ + (1000000lu * procs[i].p_ustime_sec);
++ }
++
++ /* no I/O data */
++ pse.io_rchar = -1;
++ pse.io_wchar = -1;
++ pse.io_syscr = procs[i].p_uru_inblock;
++ pse.io_syscw = procs[i].p_uru_oublock;
++
++ ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse);
++ } /* if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid)) */
++
++ /* system processes' LWPs end up in "running" state */
++ if ((procs[i].p_flag & P_SYSTEM) != 0)
++ continue;
++
++ switch (procs[i].p_realstat)
++ {
++ case SSTOP:
++ case SACTIVE:
++ case SIDL:
++ p = &(procs[i]);
++ /* get info about LWPs */
++ kl = kvm_getlwps(kd, p->p_pid, (u_long)p->p_paddr,
++ sizeof(struct kinfo_lwp), &nlwps);
++
++ for (l = 0; kl && l < nlwps; l++) {
++ switch (kl[l].l_stat) {
++ case LSONPROC:
++ case LSRUN:
++ running++;
++ break;
++ case LSSLEEP:
++ if (kl[l].l_flag & L_SINTR) {
++ if (kl[l].l_slptime > maxslp)
++ idle++;
++ else
++ sleeping++;
++ } else
++ blocked++;
++ break;
++ case LSSTOP:
++ stopped++; break;
++ case LSIDL:
++ idle++; break;
++ }
++ }
++ break;
++ case SZOMB:
++ case SDYING:
++ case SDEAD:
++ zombies++; break;
++
++ }
++ }
++
++ kvm_close(kd);
++
++ ps_submit_state ("running", running);
++ ps_submit_state ("sleeping", sleeping);
++ ps_submit_state ("zombies", zombies);
++ ps_submit_state ("stopped", stopped);
++ ps_submit_state ("blocked", blocked);
++ ps_submit_state ("idle", idle);
++ ps_submit_state ("wait", wait);
++
++ for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
++ ps_submit_proc_list (ps_ptr);
+/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC2_NETBSD */
+
++
#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_OPENBSD
- int running = 0;
- int sleeping = 0;
+ int running = 0;
+ int sleeping = 0;
diff --git a/sysutils/collectd/patches/patch-src_swap.c b/sysutils/collectd/patches/patch-src_swap.c
index 7b1c49e2af4..b0cc2dfe8d4 100644
--- a/sysutils/collectd/patches/patch-src_swap.c
+++ b/sysutils/collectd/patches/patch-src_swap.c
@@ -1,17 +1,17 @@
-$NetBSD: patch-src_swap.c,v 1.3 2016/10/13 15:17:28 fhajny Exp $
+$NetBSD: patch-src_swap.c,v 1.4 2016/12/07 17:28:39 fhajny Exp $
Extend support for NetBSD, and add per-swap-device
reporting for HAVE_SWAPCTL_THREE_ARGS.
---- src/swap.c.orig 2016-09-11 08:10:25.271038709 +0000
+--- src/swap.c.orig 2016-11-30 08:52:01.324910450 +0000
+++ src/swap.c
-@@ -77,9 +77,12 @@ static _Bool report_bytes = 0;
+@@ -78,9 +78,12 @@ static _Bool report_bytes = 0;
static _Bool report_by_device = 0;
/* #endif KERNEL_LINUX */
-#elif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS
+#elif HAVE_SWAPCTL && (HAVE_SWAPCTL_TWO_ARGS || HAVE_SWAPCTL_THREE_ARGS)
- # define SWAP_HAVE_REPORT_BY_DEVICE 1
+ #define SWAP_HAVE_REPORT_BY_DEVICE 1
static derive_t pagesize;
+#if KERNEL_NETBSD
+static _Bool report_bytes = 0;
@@ -19,35 +19,35 @@ reporting for HAVE_SWAPCTL_THREE_ARGS.
static _Bool report_by_device = 0;
/* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */
-@@ -117,7 +120,7 @@ static int swap_config (oconfig_item_t *
- {
- oconfig_item_t *child = ci->children + i;
- if (strcasecmp ("ReportBytes", child->key) == 0)
+@@ -117,7 +120,7 @@ static int swap_config(oconfig_item_t *c
+ for (int i = 0; i < ci->children_num; i++) {
+ oconfig_item_t *child = ci->children + i;
+ if (strcasecmp("ReportBytes", child->key) == 0)
-#if KERNEL_LINUX
+#if KERNEL_LINUX || KERNEL_NETBSD
- cf_util_get_boolean (child, &report_bytes);
+ cf_util_get_boolean(child, &report_bytes);
#else
- WARNING ("swap plugin: The \"ReportBytes\" option "
-@@ -150,7 +153,7 @@ static int swap_init (void) /* {{{ */
- pagesize = (derive_t) sysconf (_SC_PAGESIZE);
+ WARNING("swap plugin: The \"ReportBytes\" option "
+@@ -149,7 +152,7 @@ static int swap_init(void) /* {{{ */
+ pagesize = (derive_t)sysconf(_SC_PAGESIZE);
/* #endif KERNEL_LINUX */
-#elif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS
+#elif HAVE_SWAPCTL && (HAVE_SWAPCTL_TWO_ARGS || HAVE_SWAPCTL_THREE_ARGS)
- /* getpagesize(3C) tells me this does not fail.. */
- pagesize = (derive_t) getpagesize ();
+ /* getpagesize(3C) tells me this does not fail.. */
+ pagesize = (derive_t)getpagesize();
/* #endif HAVE_SWAPCTL */
-@@ -216,7 +219,7 @@ static void swap_submit_usage (char cons
- other_name, other_value, NULL);
+@@ -209,7 +212,7 @@ static void swap_submit_usage(char const
+ free, other_name, other_value, NULL);
} /* }}} void swap_submit_usage */
-#if KERNEL_LINUX || HAVE_PERFSTAT
+#if KERNEL_LINUX || HAVE_PERFSTAT || KERNEL_NETBSD
- __attribute__((nonnull(1)))
- static void swap_submit_derive (char const *type_instance, /* {{{ */
- derive_t value)
-@@ -618,6 +621,43 @@ static int swap_read (void) /* {{{ */
- /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */
+ __attribute__((nonnull(1))) static void
+ swap_submit_derive(char const *type_instance, /* {{{ */
+ derive_t value) {
+@@ -579,6 +582,43 @@ static int swap_read(void) /* {{{ */
+ /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */
#elif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS
+#if KERNEL_NETBSD
@@ -56,90 +56,89 @@ reporting for HAVE_SWAPCTL_THREE_ARGS.
+static int
+swap_read_io (void) /* {{{ */
+{
-+ static int uvmexp_mib[] = { CTL_VM, VM_UVMEXP2 };
-+ struct uvmexp_sysctl uvmexp;
-+ size_t ssize;
-+ derive_t swap_in, swap_out;
++ static int uvmexp_mib[] = { CTL_VM, VM_UVMEXP2 };
++ struct uvmexp_sysctl uvmexp;
++ size_t ssize;
++ derive_t swap_in, swap_out;
+
-+ ssize = sizeof(uvmexp);
-+ memset(&uvmexp, 0, ssize);
-+ if (sysctl(uvmexp_mib, __arraycount(uvmexp_mib), &uvmexp,
-+ &ssize, NULL, 0) == -1) {
-+ char errbuf[1024];
-+ WARNING ("swap: sysctl for uvmexp failed: %s",
-+ sstrerror (errno, errbuf, sizeof (errbuf)));
-+ return (-1);
-+ }
++ ssize = sizeof(uvmexp);
++ memset(&uvmexp, 0, ssize);
++ if (sysctl(uvmexp_mib, __arraycount(uvmexp_mib), &uvmexp,
++ &ssize, NULL, 0) == -1) {
++ char errbuf[1024];
++ WARNING ("swap: sysctl for uvmexp failed: %s",
++ sstrerror (errno, errbuf, sizeof (errbuf)));
++ return (-1);
++ }
+
-+ swap_in = uvmexp.pgswapin;
-+ swap_out = uvmexp.pgswapout;
++ swap_in = uvmexp.pgswapin;
++ swap_out = uvmexp.pgswapout;
+
-+ if (report_bytes)
-+ {
-+ swap_in = swap_in * pagesize;
-+ swap_out = swap_out * pagesize;
-+ }
++ if (report_bytes)
++ {
++ swap_in = swap_in * pagesize;
++ swap_out = swap_out * pagesize;
++ }
+
-+ swap_submit_derive ("in", swap_in);
-+ swap_submit_derive ("out", swap_out);
++ swap_submit_derive ("in", swap_in);
++ swap_submit_derive ("out", swap_out);
+
-+ return (0);
++ return (0);
+} /* }}} */
+#endif
+
- static int swap_read (void) /* {{{ */
+ static int swap_read(void) /* {{{ */
{
- struct swapent *swap_entries;
-@@ -663,12 +703,33 @@ static int swap_read (void) /* {{{ */
- * swap_entries[i].se_path */
- for (int i = 0; i < swap_num; i++)
- {
-+ char path[PATH_MAX];
-+ gauge_t this_used;
-+ gauge_t this_total;
+ struct swapent *swap_entries;
+@@ -617,12 +657,32 @@ static int swap_read(void) /* {{{ */
+ /* TODO: Report per-device stats. The path name is available from
+ * swap_entries[i].se_path */
+ for (int i = 0; i < swap_num; i++) {
++ char path[PATH_MAX];
++ gauge_t this_used;
++ gauge_t this_total;
+
- if ((swap_entries[i].se_flags & SWF_ENABLE) == 0)
- continue;
+ if ((swap_entries[i].se_flags & SWF_ENABLE) == 0)
+ continue;
-- used += ((gauge_t) swap_entries[i].se_inuse) * C_SWAP_BLOCK_SIZE;
-- total += ((gauge_t) swap_entries[i].se_nblks) * C_SWAP_BLOCK_SIZE;
-- }
-+ this_used = ((gauge_t) swap_entries[i].se_inuse)
-+ * C_SWAP_BLOCK_SIZE;
-+ this_total = ((gauge_t) swap_entries[i].se_nblks)
-+ * C_SWAP_BLOCK_SIZE;
-+
+- used += ((gauge_t)swap_entries[i].se_inuse) * C_SWAP_BLOCK_SIZE;
+- total += ((gauge_t)swap_entries[i].se_nblks) * C_SWAP_BLOCK_SIZE;
+- }
++ this_used = ((gauge_t) swap_entries[i].se_inuse)
++ * C_SWAP_BLOCK_SIZE;
++ this_total = ((gauge_t) swap_entries[i].se_nblks)
++ * C_SWAP_BLOCK_SIZE;
+
-+ /* Shortcut for the "combined" setting (default) */
-+ if (!report_by_device)
-+ {
-+ used += this_used;
-+ total += this_total;
-+ continue;
-+ }
++ /* Shortcut for the "combined" setting (default) */
++ if (!report_by_device)
++ {
++ used += this_used;
++ total += this_total;
++ continue;
++ }
+
-+ sstrncpy (path, swap_entries[i].se_path, sizeof (path));
-+ escape_slashes (path, sizeof (path));
++ sstrncpy (path, swap_entries[i].se_path, sizeof (path));
++ escape_slashes (path, sizeof (path));
+
-+ swap_submit_usage (path, this_used, this_total - this_used,
-+ NULL, NAN);
-+ } /* for (swap_num) */
++ swap_submit_usage (path, this_used, this_total - this_used,
++ NULL, NAN);
++ } /* for (swap_num) */
- if (total < used)
- {
-@@ -679,8 +740,15 @@ static int swap_read (void) /* {{{ */
- }
+ if (total < used) {
+ ERROR(
+@@ -633,8 +693,15 @@ static int swap_read(void) /* {{{ */
+ }
- swap_submit_usage (NULL, used, total - used, NULL, NAN);
-+ /* If the "separate" option was specified (report_by_device == 1), all
-+ * values have already been dispatched from within the loop. */
-+ if (!report_by_device)
-+ swap_submit_usage (NULL, used, total - used, NULL, NAN);
+ swap_submit_usage(NULL, used, total - used, NULL, NAN);
++ /* If the "separate" option was specified (report_by_device == 1), all
++ * values have already been dispatched from within the loop. */
++ if (!report_by_device)
++ swap_submit_usage (NULL, used, total - used, NULL, NAN);
- sfree (swap_entries);
+ sfree(swap_entries);
+#if KERNEL_NETBSD
-+ swap_read_io ();
++ swap_read_io ();
+#endif
- return (0);
+ return (0);
} /* }}} int swap_read */
- /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
+ /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
diff --git a/sysutils/collectd/patches/patch-src_tcpconns.c b/sysutils/collectd/patches/patch-src_tcpconns.c
index 409701700f2..24d5153f2bf 100644
--- a/sysutils/collectd/patches/patch-src_tcpconns.c
+++ b/sysutils/collectd/patches/patch-src_tcpconns.c
@@ -1,14 +1,26 @@
-$NetBSD: patch-src_tcpconns.c,v 1.5 2015/08/11 13:19:21 he Exp $
+$NetBSD: patch-src_tcpconns.c,v 1.6 2016/12/07 17:28:39 fhajny Exp $
Include <sys/param.h>
+Re-order to fix build on NetBSD.
---- src/tcpconns.c.orig 2015-05-20 12:04:47.191035542 +0000
+--- src/tcpconns.c.orig 2016-11-30 08:52:01.328910078 +0000
+++ src/tcpconns.c
-@@ -948,6 +948,7 @@ static int conn_init (void)
+@@ -111,9 +111,9 @@
+ #include <net/route.h>
+ #include <netdb.h>
+ #include <netinet/in.h>
++#include <netinet/ip.h>
+ #include <netinet/in_pcb.h>
+ #include <netinet/in_systm.h>
+-#include <netinet/ip.h>
+ #include <netinet/ip_var.h>
+ #include <netinet/tcp.h>
+ #include <netinet/tcp_timer.h>
+@@ -820,6 +820,7 @@ static int conn_init(void) {
return (0);
} /* int conn_init */
+#include <sys/param.h>
- static int conn_read (void)
- {
+ static int conn_read(void) {
struct inpcbtable table;
+ #if !defined(__OpenBSD__) && \
diff --git a/sysutils/collectd/patches/patch-src_utils__dns.c b/sysutils/collectd/patches/patch-src_utils__dns.c
index 32dbc604b62..45b4f6f8484 100644
--- a/sysutils/collectd/patches/patch-src_utils__dns.c
+++ b/sysutils/collectd/patches/patch-src_utils__dns.c
@@ -1,15 +1,15 @@
-$NetBSD: patch-src_utils__dns.c,v 1.1 2015/04/07 13:20:41 fhajny Exp $
+$NetBSD: patch-src_utils__dns.c,v 1.2 2016/12/07 17:28:39 fhajny Exp $
Resolve conflict with pkgsrc PCAP on NetBSD 7.
---- src/utils_dns.c.orig 2015-02-26 10:43:48.496180984 +0000
+--- src/utils_dns.c.orig 2016-11-30 08:52:01.328910078 +0000
+++ src/utils_dns.c
-@@ -96,6 +96,9 @@
+@@ -91,6 +91,9 @@
#endif
#if HAVE_PCAP_H
+# if defined(DLT_MATCHING_MAX)
+# undef DLT_MATCHING_MAX
+# endif
- # include <pcap.h>
+ #include <pcap.h>
#endif
diff --git a/sysutils/collectd/patches/patch-src_utils__format__kairosdb.c b/sysutils/collectd/patches/patch-src_utils__format__kairosdb.c
index 06b497775d0..9fc731a959c 100644
--- a/sysutils/collectd/patches/patch-src_utils__format__kairosdb.c
+++ b/sysutils/collectd/patches/patch-src_utils__format__kairosdb.c
@@ -1,18 +1,16 @@
-$NetBSD: patch-src_utils__format__kairosdb.c,v 1.1 2016/11/20 22:11:28 joerg Exp $
+$NetBSD: patch-src_utils__format__kairosdb.c,v 1.2 2016/12/07 17:28:39 fhajny Exp $
---- src/utils_format_kairosdb.c.orig 2016-11-19 12:00:24.000000000 +0000
+--- src/utils_format_kairosdb.c.orig 2016-11-30 08:52:01.332909704 +0000
+++ src/utils_format_kairosdb.c
-@@ -83,11 +83,11 @@ static int kairosdb_escape_string (char
- BUFFER_ADD ('"');
- for (size_t src_pos = 0; string[src_pos] != 0; src_pos++)
- {
-- if (isalnum(string[src_pos]) ||
-+ if (isalnum((unsigned char)string[src_pos]) ||
- 0x2d == string[src_pos] ||
- 0x2e == string[src_pos] ||
- 0x5f == string[src_pos])
-- BUFFER_ADD (tolower(string[src_pos]));
-+ BUFFER_ADD (tolower((unsigned char)string[src_pos]));
+@@ -80,9 +80,9 @@ static int kairosdb_escape_string(char *
+ /* authorize -_. and alpha num but also escapes " */
+ BUFFER_ADD('"');
+ for (size_t src_pos = 0; string[src_pos] != 0; src_pos++) {
+- if (isalnum(string[src_pos]) || 0x2d == string[src_pos] ||
++ if ((unsigned char)isalnum(string[src_pos]) || 0x2d == string[src_pos] ||
+ 0x2e == string[src_pos] || 0x5f == string[src_pos])
+- BUFFER_ADD(tolower(string[src_pos]));
++ BUFFER_ADD(tolower((unsigned char)string[src_pos]));
} /* for */
- BUFFER_ADD ('"');
+ BUFFER_ADD('"');
buffer[dst_pos] = 0;