pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Copy over collectd-5.5.0 as of 2016-10-01.



Module Name:	pkgsrc-wip
Committed By:	Benny Siegert <bsiegert%gmail.com@localhost>
Pushed By:	bsiegert
Date:		Thu Feb 14 19:48:35 2019 +0100
Changeset:	40be1b5f9b847149b9b072ff5d2a07f90f4a32cc

Added Files:
	stackdriver-collectd/DESCR
	stackdriver-collectd/Makefile
	stackdriver-collectd/Makefile.common
	stackdriver-collectd/PLIST
	stackdriver-collectd/distinfo
	stackdriver-collectd/files/collectd.sh
	stackdriver-collectd/files/smf/manifest.xml
	stackdriver-collectd/options.mk
	stackdriver-collectd/patches/patch-Makefile.am
	stackdriver-collectd/patches/patch-Makefile.in
	stackdriver-collectd/patches/patch-configure
	stackdriver-collectd/patches/patch-configure.ac
	stackdriver-collectd/patches/patch-src_Makefile.am
	stackdriver-collectd/patches/patch-src_Makefile.in
	stackdriver-collectd/patches/patch-src_collectd-tg.c
	stackdriver-collectd/patches/patch-src_collectd.conf.in
	stackdriver-collectd/patches/patch-src_config.h.in
	stackdriver-collectd/patches/patch-src_cpu.c
	stackdriver-collectd/patches/patch-src_df.c
	stackdriver-collectd/patches/patch-src_disk.c
	stackdriver-collectd/patches/patch-src_entropy.c
	stackdriver-collectd/patches/patch-src_irq.c
	stackdriver-collectd/patches/patch-src_libcollectclient_network__buffer.c
	stackdriver-collectd/patches/patch-src_memory.c
	stackdriver-collectd/patches/patch-src_netstat__udp.c
	stackdriver-collectd/patches/patch-src_processes.c
	stackdriver-collectd/patches/patch-src_swap.c
	stackdriver-collectd/patches/patch-src_tcpconns.c
	stackdriver-collectd/patches/patch-src_utils__dns.c
	stackdriver-collectd/patches/patch-version-gen.sh

Log Message:
Copy over collectd-5.5.0 as of 2016-10-01.

Yes, really!

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=40be1b5f9b847149b9b072ff5d2a07f90f4a32cc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 stackdriver-collectd/DESCR                         |   3 +
 stackdriver-collectd/Makefile                      |  45 ++
 stackdriver-collectd/Makefile.common               |  82 +++
 stackdriver-collectd/PLIST                         |  83 +++
 stackdriver-collectd/distinfo                      |  28 +
 stackdriver-collectd/files/collectd.sh             |  26 +
 stackdriver-collectd/files/smf/manifest.xml        |  29 +
 stackdriver-collectd/options.mk                    |  36 ++
 stackdriver-collectd/patches/patch-Makefile.am     |  15 +
 stackdriver-collectd/patches/patch-Makefile.in     | 159 ++++++
 stackdriver-collectd/patches/patch-configure       | 324 +++++++++++
 stackdriver-collectd/patches/patch-configure.ac    | 135 +++++
 stackdriver-collectd/patches/patch-src_Makefile.am |  61 ++
 stackdriver-collectd/patches/patch-src_Makefile.in | 616 +++++++++++++++++++++
 .../patches/patch-src_collectd-tg.c                |  19 +
 .../patches/patch-src_collectd.conf.in             | 106 ++++
 stackdriver-collectd/patches/patch-src_config.h.in |  52 ++
 stackdriver-collectd/patches/patch-src_cpu.c       |  50 ++
 stackdriver-collectd/patches/patch-src_df.c        |  21 +
 stackdriver-collectd/patches/patch-src_disk.c      | 209 +++++++
 stackdriver-collectd/patches/patch-src_entropy.c   | 113 ++++
 stackdriver-collectd/patches/patch-src_irq.c       | 103 ++++
 .../patch-src_libcollectclient_network__buffer.c   |  23 +
 stackdriver-collectd/patches/patch-src_memory.c    | 128 +++++
 .../patches/patch-src_netstat__udp.c               | 165 ++++++
 stackdriver-collectd/patches/patch-src_processes.c | 249 +++++++++
 stackdriver-collectd/patches/patch-src_swap.c      | 150 +++++
 stackdriver-collectd/patches/patch-src_tcpconns.c  |  14 +
 .../patches/patch-src_utils__dns.c                 |  15 +
 stackdriver-collectd/patches/patch-version-gen.sh  |  14 +
 30 files changed, 3073 insertions(+)

diffs:
diff --git a/stackdriver-collectd/DESCR b/stackdriver-collectd/DESCR
new file mode 100644
index 0000000000..2fea573116
--- /dev/null
+++ b/stackdriver-collectd/DESCR
@@ -0,0 +1,3 @@
+collectd is a daemon which collects system performance statistics periodically
+and provides mechanisms to store the values in a variety of ways, for example
+in RRD-files.
diff --git a/stackdriver-collectd/Makefile b/stackdriver-collectd/Makefile
new file mode 100644
index 0000000000..59e5de3003
--- /dev/null
+++ b/stackdriver-collectd/Makefile
@@ -0,0 +1,45 @@
+# $NetBSD: Makefile,v 1.17 2016/07/09 06:38:58 wiz Exp $
+
+PKGREVISION= 12
+.include "../../sysutils/collectd/Makefile.common"
+
+COMMENT=	Statistics collection daemon base
+
+RCD_SCRIPTS=	collectd
+
+.include "../../mk/bsd.prefs.mk"
+
+# Simple plugins that have no dependencies
+DEFAULT_PLUGINS+=	aggregation apcups csv email exec filecount	\
+			hddtemp logfile match_empty_counter match_hashed\
+			match_regex match_timediff match_value mbmon	\
+			ntpd olsrd openvpn powerdns statsd table tail	\
+			tail_csv target_notification target_replace	\
+			target_scale target_set	target_v5upgrade	\
+			teamspeak2 threshold unixsock uuid write_graphite
+
+.for option in ${DEFAULT_PLUGINS}
+CONFIGURE_ARGS+=	--enable-${option}
+.endfor
+
+# Several libs not generated in time for linking collectd
+MAKE_JOBS_SAFE=		no
+
+.include "options.mk"
+
+CONF_FILES+=		share/examples/collectd/collectd.conf 		\
+			${PKG_SYSCONFDIR}/collectd.conf
+
+BUILD_DEFS+=		VARBASE
+
+OWN_DIRS+=		${VARBASE}/db/collectd
+
+COLLECTD_USER?=			collectd
+COLLECTD_GROUP?=		${COLLECTD_USER}
+PKG_USERS_VARS+=		COLLECTD_USER
+PKG_GROUPS_VARS+=		COLLECTD_GROUP
+PKG_GROUPS=			${COLLECTD_GROUP}
+PKG_USERS=			${COLLECTD_USER}:${COLLECTD_GROUP}
+PKG_GECOS.${COLLECTD_USER}=	collectd unprivileged user
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/stackdriver-collectd/Makefile.common b/stackdriver-collectd/Makefile.common
new file mode 100644
index 0000000000..8f7e6bf958
--- /dev/null
+++ b/stackdriver-collectd/Makefile.common
@@ -0,0 +1,82 @@
+# $NetBSD: Makefile.common,v 1.11 2015/10/28 11:46:07 jperkin Exp $
+#
+# used by sysutils/collectd/Makefile
+# used by sysutils/collectd-amqp/Makefile
+# used by sysutils/collectd-curl/Makefile
+# used by sysutils/collectd-dbi/Makefile
+# used by sysutils/collectd-dns/Makefile
+# used by sysutils/collectd-memcached/Makefile
+# used by sysutils/collectd-mysql/Makefile
+# used by sysutils/collectd-network/Makefile
+# used by sysutils/collectd-notify-email/Makefile
+# used by sysutils/collectd-postgresql/Makefile
+# used by sysutils/collectd-riemann/Makefile
+# used by sysutils/collectd-rrdtool/Makefile
+# used by sysutils/collectd-snmp/Makefile
+# used by sysutils/p5-collectd/Makefile
+# used by sysutils/py-collectd/Makefile
+
+DISTNAME=	collectd-5.5.0
+MASTER_SITES=	http://collectd.org/files/
+CATEGORIES=	sysutils
+
+MAINTAINER=	filip%joyent.com@localhost
+HOMEPAGE=	http://collectd.org/
+LICENSE=	gnu-gpl-v2
+
+GNU_CONFIGURE=		yes
+USE_LIBTOOL=		yes
+USE_TOOLS+=		pkg-config
+USE_LANGUAGES=		c c99 c++
+
+DISTINFO_FILE=		${.CURDIR}/../../sysutils/collectd/distinfo
+PATCHDIR=		${.CURDIR}/../../sysutils/collectd/patches
+
+.if !empty(COLLECTD_PACKAGE)
+PKGNAME?=		${DISTNAME:S/collectd/collectd-${COLLECTD_PACKAGE}/}
+
+DEPENDS+=		collectd>=${PKGVERSION_NOREV}:../../sysutils/collectd
+
+COLLECTD_PLUGINS?=	${COLLECTD_PACKAGE:S/-/_/}
+
+BUILD_DIRS=		src
+BUILD_TARGET=		${COLLECTD_PLUGINS:S/$/.la/}
+INSTALL_DIRS=		src
+INSTALL_TARGET=		install-pkglibLTLIBRARIES
+.  for plugin in ${COLLECTD_PLUGINS}
+CONFIGURE_ARGS+=	--enable-${plugin}
+GENERATE_PLIST+=	${ECHO} "lib/collectd/${plugin}.la";
+.  endfor
+.endif
+
+.include "../../mk/bsd.prefs.mk"
+
+BUILD_DEFS+=		VARBASE
+
+# Disable all libs support by default
+DISABLED_LIBS=		aquaero5 credis curl dbi esmtp ganglia gcrypt	\
+			iptc lvm2app memcached mnl modbus mongoc mysql	\
+			netsnmp notify oping owcapi pcap perl pq	\
+			rabbitmq routeros rrd sensors sigrok statgrab	\
+			tokyotyrant upsclient varnish xml2 xmms yajl
+CONFIGURE_ARGS+=	--with-java=no --with-mic=no --with-oracle=no	\
+			--with-perl-bindings=no --with-python=no	\
+			--disable-all-plugins
+.for lib in ${DISABLED_LIBS}
+CONFIGURE_ARGS+=	--with-lib${lib}=no
+.endfor
+CONFIGURE_ARGS+=	--localstatedir=${VARBASE}
+CONFIGURE_ARGS+=	--with-ltdl-lib=${BUILDLINK_PREFIX.libltdl}/lib
+CONFIGURE_ARGS+=	--with-ltdl-include=${BUILDLINK_PREFIX.libltdl}/include
+
+CPPFLAGS.SunOS+=	-DSOLARIS2=${OS_VERSION:C/5.//}
+
+.include "../../mk/compiler.mk"
+# XXX: proper clang version check when we have support for it.
+.if !empty(PKGSRC_COMPILER:Mclang) && ${OPSYS} != "Darwin"
+CFLAGS+=	-Wno-error=tautological-pointer-compare \
+		-Wno-error=pointer-bool-conversion
+.endif
+
+.include "../../devel/libltdl/buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
diff --git a/stackdriver-collectd/PLIST b/stackdriver-collectd/PLIST
new file mode 100644
index 0000000000..ecdd3c2eca
--- /dev/null
+++ b/stackdriver-collectd/PLIST
@@ -0,0 +1,83 @@
+@comment $NetBSD: PLIST,v 1.6 2015/09/12 19:04:56 he Exp $
+bin/collectd-nagios
+bin/collectd-tg
+bin/collectdctl
+include/collectd/client.h
+include/collectd/lcc_features.h
+include/collectd/network.h
+include/collectd/network_buffer.h
+lib/collectd/aggregation.la
+lib/collectd/apcups.la
+${PLIST.apple-sensors}lib/collectd/apple_sensors.la
+${PLIST.battery}lib/collectd/battery.la
+${PLIST.contextswitch}lib/collectd/contextswitch.la
+${PLIST.cpu}lib/collectd/cpu.la
+lib/collectd/csv.la
+${PLIST.entropy}lib/collectd/entropy.la
+${PLIST.df}lib/collectd/df.la
+${PLIST.disk}lib/collectd/disk.la
+lib/collectd/email.la
+lib/collectd/exec.la
+lib/collectd/filecount.la
+lib/collectd/hddtemp.la
+${PLIST.interface}lib/collectd/interface.la
+${PLIST.irq}lib/collectd/irq.la
+${PLIST.load}lib/collectd/load.la
+lib/collectd/logfile.la
+lib/collectd/match_empty_counter.la
+lib/collectd/match_hashed.la
+lib/collectd/match_regex.la
+lib/collectd/match_timediff.la
+lib/collectd/match_value.la
+lib/collectd/mbmon.la
+${PLIST.memory}lib/collectd/memory.la
+${PLIST.netstat_udp}lib/collectd/netstat_udp.la
+${PLIST.nfs}lib/collectd/nfs.la
+lib/collectd/ntpd.la
+lib/collectd/olsrd.la
+lib/collectd/openvpn.la
+${PLIST.pf}lib/collectd/pf.la
+lib/collectd/powerdns.la
+${PLIST.processes}lib/collectd/processes.la
+lib/collectd/statsd.la
+${PLIST.swap}lib/collectd/swap.la
+${PLIST.syslog}lib/collectd/syslog.la
+lib/collectd/table.la
+lib/collectd/tail.la
+lib/collectd/tail_csv.la
+lib/collectd/target_notification.la
+lib/collectd/target_replace.la
+lib/collectd/target_scale.la
+lib/collectd/target_set.la
+lib/collectd/target_v5upgrade.la
+lib/collectd/teamspeak2.la
+${PLIST.tcpconns}lib/collectd/tcpconns.la
+lib/collectd/threshold.la
+lib/collectd/unixsock.la
+${PLIST.uptime}lib/collectd/uptime.la
+${PLIST.users}lib/collectd/users.la
+lib/collectd/uuid.la
+lib/collectd/write_graphite.la
+${PLIST.zfs-arc}lib/collectd/zfs_arc.la
+lib/libcollectdclient.la
+lib/pkgconfig/libcollectdclient.pc
+man/man1/collectd-nagios.1
+man/man1/collectd-tg.1
+man/man1/collectd.1
+man/man1/collectdctl.1
+man/man1/collectdmon.1
+man/man5/collectd-email.5
+man/man5/collectd-exec.5
+man/man5/collectd-java.5
+man/man5/collectd-perl.5
+man/man5/collectd-python.5
+man/man5/collectd-snmp.5
+man/man5/collectd-threshold.5
+man/man5/collectd-unixsock.5
+man/man5/collectd.conf.5
+man/man5/types.db.5
+sbin/collectd
+sbin/collectdmon
+share/collectd/postgresql_default.conf
+share/collectd/types.db
+share/examples/collectd/collectd.conf
diff --git a/stackdriver-collectd/distinfo b/stackdriver-collectd/distinfo
new file mode 100644
index 0000000000..f10f924770
--- /dev/null
+++ b/stackdriver-collectd/distinfo
@@ -0,0 +1,28 @@
+$NetBSD: distinfo,v 1.27 2016/02/03 15:10:43 he Exp $
+
+SHA1 (collectd-5.5.0.tar.gz) = d24e284c1eae20c5e75b846c8b2612ab65bd5565
+RMD160 (collectd-5.5.0.tar.gz) = 2197758942a5fe56e4eabda3786f09d4138e943a
+SHA512 (collectd-5.5.0.tar.gz) = b7ab9db91bf8c0eadbf9893421c019239acf85d2d84a5adb834582ed218a7dd03f750b7279dc4b1bb0030a8b9d3302bea9ae9f201c913128e1896cbd1349b5a9
+Size (collectd-5.5.0.tar.gz) = 2244454 bytes
+SHA1 (patch-Makefile.am) = ed45b75293a4ea2dd577d04eeb3b9017b8f47319
+SHA1 (patch-Makefile.in) = a7cf69ca29c526be643af0ef85544e3a2dc80a77
+SHA1 (patch-configure) = f4bf389b98f03152347f0d1c6fba34e948e81625
+SHA1 (patch-configure.ac) = 8313b139c3b23f10e26a42a976e97b09ad72e656
+SHA1 (patch-src_Makefile.am) = 45930ca400c6c67927020c9a264d3d5adc30ca46
+SHA1 (patch-src_Makefile.in) = 46bea4aa9a045e56478ff96730245134ddb0b362
+SHA1 (patch-src_collectd-tg.c) = f9f41dfb0b1b55a62202128a165d5c9943faf5bc
+SHA1 (patch-src_collectd.conf.in) = f0b35085cf0ddfd766e140b145177ab1f1326f5f
+SHA1 (patch-src_config.h.in) = be17db23b6ee7a90ba57e73f073ed5be11c369c5
+SHA1 (patch-src_cpu.c) = 55b5cfc69bf0df279d1a12003eb6a8e681155e18
+SHA1 (patch-src_df.c) = 7e75dfbc72ecad48eb0eb7427a19329daf6b9a60
+SHA1 (patch-src_disk.c) = 159862e8ca1e841e3c4013c03ba03f059fdbbab5
+SHA1 (patch-src_entropy.c) = 4fa683654936f57fb7366faebb93d572af08db9c
+SHA1 (patch-src_irq.c) = 8d5c516fea31bf2ab9736c32540be3223dea15d9
+SHA1 (patch-src_libcollectclient_network__buffer.c) = e07d403d299613fa0885a0e7285849eb85510253
+SHA1 (patch-src_memory.c) = f48d50245176426e26af7fa1b1f4ff6fbf0b1d95
+SHA1 (patch-src_netstat__udp.c) = 30cb12d25f56c60959658dbd181783212e00cc61
+SHA1 (patch-src_processes.c) = e00d2edf6b4e6bfe3663e34fffb05f40652affe5
+SHA1 (patch-src_swap.c) = e7602eb83eed6b90752b8293b9666b94bdd42493
+SHA1 (patch-src_tcpconns.c) = 712af1b821d62217283df884dd283d5b1218ab7c
+SHA1 (patch-src_utils__dns.c) = c3782dc9127f42da30e3142b853aa2cb2259af94
+SHA1 (patch-version-gen.sh) = 07d830019e22ac651514b75acf299b1f50c4632d
diff --git a/stackdriver-collectd/files/collectd.sh b/stackdriver-collectd/files/collectd.sh
new file mode 100644
index 0000000000..5c7b3b4862
--- /dev/null
+++ b/stackdriver-collectd/files/collectd.sh
@@ -0,0 +1,26 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: collectd.sh,v 1.1 2014/02/17 11:21:55 fhajny Exp $
+#
+# PROVIDE: collectd 
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+# You will need to set some variables in /etc/rc.conf to start collectd:
+#
+# collectd=YES
+#
+
+if [ -f /etc/rc.subr ]
+then
+    . /etc/rc.subr
+fi
+
+name="collectd"
+rcvar=${name}
+command=@PREFIX@/sbin/collectd
+pidfile="@VARBASE@/run/collectd.pid"
+required_files=@PKG_SYSCONFDIR@/collectd.conf
+
+load_rc_config ${name}
+run_rc_command "$1"
diff --git a/stackdriver-collectd/files/smf/manifest.xml b/stackdriver-collectd/files/smf/manifest.xml
new file mode 100644
index 0000000000..b145e24081
--- /dev/null
+++ b/stackdriver-collectd/files/smf/manifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<service_bundle type='manifest' name='export'>
+  <service name='@SMF_PREFIX@/@SMF_NAME@' type='service' version='1'>
+    <create_default_instance enabled='false' />
+    <single_instance />
+    <dependency name='network' grouping='require_all' restart_on='none' type='service'>
+      <service_fmri value='svc:/milestone/network:default' />
+    </dependency>
+    <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
+      <service_fmri value='svc:/system/filesystem/local:default' />
+    </dependency>
+    <exec_method type='method' name='start' exec='@PREFIX@/sbin/collectd' timeout_seconds='60'>
+      <method_context>
+        <method_credential user='root' group='root' />
+      </method_context>
+    </exec_method>
+    <exec_method type='method' name='stop' exec=':kill' timeout_seconds='60'>
+      <method_context>
+        <method_credential user='root' group='root' />
+      </method_context>
+    </exec_method>
+    <property_group name='startd' type='framework'>
+      <propval name="duration" type="astring" value="contract" />
+      <!-- sub-process core dumps shouldn't restart session -->
+      <propval name='ignore_error' type='astring' value='core,signal' />
+    </property_group>
+  </service>
+</service_bundle>
diff --git a/stackdriver-collectd/options.mk b/stackdriver-collectd/options.mk
new file mode 100644
index 0000000000..117adde782
--- /dev/null
+++ b/stackdriver-collectd/options.mk
@@ -0,0 +1,36 @@
+# $NetBSD: options.mk,v 1.7 2016/02/26 10:24:11 jperkin Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.collectd
+PKG_SUPPORTED_OPTIONS=	cpu df interface load memory syslog uptime
+PKG_SUGGESTED_OPTIONS+=	cpu df interface load memory syslog uptime
+
+PKG_SUPPORTED_OPTIONS.NetBSD+=	contextswitch disk entropy irq pf netstat_udp
+PKG_SUPPORTED_OPTIONS.NetBSD+=	processes swap tcpconns users
+PKG_SUGGESTED_OPTIONS.NetBSD+=	contextswitch disk entropy irq pf netstat_udp
+PKG_SUGGESTED_OPTIONS.NetBSD+=	processes swap tcpconns users
+
+PKG_SUPPORTED_OPTIONS.FreeBSD+=	contextswitch pf processes swap tcpconns zfs-arc
+PKG_SUGGESTED_OPTIONS.FreeBSD+=	contextswitch pf processes swap tcpconns zfs-arc
+
+PKG_SUPPORTED_OPTIONS.Darwin+=	apple-sensors battery contextswitch disk
+PKG_SUPPORTED_OPTIONS.Darwin+=	processes swap tcpconns users
+PKG_SUGGESTED_OPTIONS.Darwin+=	apple-sensors battery contextswitch disk
+PKG_SUGGESTED_OPTIONS.Darwin+=	processes swap tcpconns users
+
+PKG_SUPPORTED_OPTIONS.SunOS+=	disk nfs swap users zfs-arc
+PKG_SUGGESTED_OPTIONS.SunOS+=	disk nfs swap users zfs-arc
+
+.include "../../mk/bsd.options.mk"
+
+PLIST_VARS+=		apple-sensors battery contextswitch cpu entropy \
+			df disk		\
+			interface irq load netstat_udp \
+			memory nfs pf processes swap	\
+			syslog tcpconns uptime users zfs-arc
+
+.for option in ${PLIST_VARS}
+.  if !empty(PKG_OPTIONS:M${option})
+CONFIGURE_ARGS+=	--enable-${option:S/-/_/}
+PLIST.${option}=	yes
+.  endif
+.endfor
diff --git a/stackdriver-collectd/patches/patch-Makefile.am b/stackdriver-collectd/patches/patch-Makefile.am
new file mode 100644
index 0000000000..2dd339826b
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-Makefile.am
@@ -0,0 +1,15 @@
+$NetBSD: patch-Makefile.am,v 1.1 2015/08/18 07:47:46 he Exp $
+
+Use other data directory.
+
+--- Makefile.am.orig	2015-03-09 09:38:22.000000000 +0000
++++ Makefile.am
+@@ -8,7 +8,7 @@ EXTRA_DIST = contrib version-gen.sh
+ 
+ install-exec-hook:
+ 	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run
+-	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/lib/$(PACKAGE_NAME)
++	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/db/$(PACKAGE_NAME)
+ 	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/log
+ 
+ maintainer-clean-local:
diff --git a/stackdriver-collectd/patches/patch-Makefile.in b/stackdriver-collectd/patches/patch-Makefile.in
new file mode 100644
index 0000000000..ec5d187c5f
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-Makefile.in
@@ -0,0 +1,159 @@
+$NetBSD: patch-Makefile.in,v 1.2 2015/08/18 07:47:46 he Exp $
+
+Regenerate.
+
+--- Makefile.in.orig	2014-01-26 08:09:57.577219038 +0000
++++ Makefile.in
+@@ -1,7 +1,7 @@
+-# Makefile.in generated by automake 1.14.1 from Makefile.am.
++# Makefile.in generated by automake 1.15 from Makefile.am.
+ # @configure_input@
+ 
+-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
++# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+ 
+ # This Makefile.in is free software; the Free Software Foundation
+ # gives unlimited permission to copy and/or distribute it,
+@@ -14,7 +14,17 @@
+ 
+ @SET_MAKE@
+ VPATH = @srcdir@
+-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
++am__is_gnu_make = { \
++  if test -z '$(MAKELEVEL)'; then \
++    false; \
++  elif test -n '$(MAKE_HOST)'; then \
++    true; \
++  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
++    true; \
++  else \
++    false; \
++  fi; \
++}
+ am__make_running_with_option = \
+   case $${target_option-} in \
+       ?) ;; \
+@@ -78,25 +88,12 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ subdir = .
+-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+-	$(top_srcdir)/configure $(am__configure_deps) \
+-	$(top_srcdir)/src/libcollectdclient/collectd/lcc_features.h.in \
+-	AUTHORS COPYING ChangeLog INSTALL NEWS README TODO compile \
+-	libltdl/config/compile config.guess \
+-	libltdl/config/config.guess config.sub \
+-	libltdl/config/config.sub depcomp libltdl/config/depcomp \
+-	install-sh libltdl/config/install-sh missing \
+-	libltdl/config/missing ylwrap libltdl/config/ylwrap ltmain.sh \
+-	libltdl/config/ltmain.sh $(top_srcdir)/libltdl/config/compile \
+-	$(top_srcdir)/libltdl/config/config.guess \
+-	$(top_srcdir)/libltdl/config/config.sub \
+-	$(top_srcdir)/libltdl/config/install-sh \
+-	$(top_srcdir)/libltdl/config/ltmain.sh \
+-	$(top_srcdir)/libltdl/config/missing
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
++DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
++	$(am__configure_deps) $(am__DIST_COMMON)
+ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+  configure.lineno config.status.lineno
+ mkinstalldirs = $(install_sh) -d
+@@ -159,6 +156,21 @@ ETAGS = etags
+ CTAGS = ctags
+ CSCOPE = cscope
+ DIST_SUBDIRS = $(SUBDIRS)
++am__DIST_COMMON = $(srcdir)/Makefile.in \
++	$(top_srcdir)/libltdl/config/compile \
++	$(top_srcdir)/libltdl/config/config.guess \
++	$(top_srcdir)/libltdl/config/config.sub \
++	$(top_srcdir)/libltdl/config/install-sh \
++	$(top_srcdir)/libltdl/config/ltmain.sh \
++	$(top_srcdir)/libltdl/config/missing \
++	$(top_srcdir)/src/libcollectdclient/collectd/lcc_features.h.in \
++	AUTHORS COPYING ChangeLog INSTALL NEWS README TODO compile \
++	config.guess config.sub depcomp install-sh \
++	libltdl/config/compile libltdl/config/config.guess \
++	libltdl/config/config.sub libltdl/config/depcomp \
++	libltdl/config/install-sh libltdl/config/ltmain.sh \
++	libltdl/config/missing libltdl/config/ylwrap ltmain.sh missing \
++	ylwrap
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ distdir = $(PACKAGE)-$(VERSION)
+ top_distdir = $(distdir)
+@@ -353,9 +365,6 @@ LIBADD_DL = @LIBADD_DL@
+ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
+ LIBADD_DLOPEN = @LIBADD_DLOPEN@
+ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@
+-LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+-LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+-LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
+ LIBLTDL = @LIBLTDL@
+ LIBNETAPP_CPPFLAGS = @LIBNETAPP_CPPFLAGS@
+ LIBNETAPP_LDFLAGS = @LIBNETAPP_LDFLAGS@
+@@ -493,7 +502,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefi
+ 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+ 	$(am__cd) $(top_srcdir) && \
+ 	  $(AUTOMAKE) --foreign Makefile
+-.PRECIOUS: Makefile
+ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ 	@case '$?' in \
+ 	  *config.status*) \
+@@ -710,15 +718,15 @@ dist-xz: distdir
+ 	$(am__post_remove_distdir)
+ 
+ dist-tarZ: distdir
+-	@echo WARNING: "Support for shar distribution archives is" \
+-	               "deprecated." >&2
++	@echo WARNING: "Support for distribution archives compressed with" \
++		       "legacy program 'compress' is deprecated." >&2
+ 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ 	$(am__post_remove_distdir)
+ 
+ dist-shar: distdir
+-	@echo WARNING: "Support for distribution archives compressed with" \
+-		       "legacy program 'compress' is deprecated." >&2
++	@echo WARNING: "Support for shar distribution archives is" \
++	               "deprecated." >&2
+ 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ 	$(am__post_remove_distdir)
+@@ -754,17 +762,17 @@ distcheck: dist
+ 	esac
+ 	chmod -R a-w $(distdir)
+ 	chmod u+w $(distdir)
+-	mkdir $(distdir)/_build $(distdir)/_inst
++	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
+ 	chmod a-w $(distdir)
+ 	test -d $(distdir)/_build || exit 0; \
+ 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+ 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+ 	  && am__cwd=`pwd` \
+-	  && $(am__cd) $(distdir)/_build \
+-	  && ../configure \
++	  && $(am__cd) $(distdir)/_build/sub \
++	  && ../../configure \
+ 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+ 	    $(DISTCHECK_CONFIGURE_FLAGS) \
+-	    --srcdir=.. --prefix="$$dc_install_base" \
++	    --srcdir=../.. --prefix="$$dc_install_base" \
+ 	  && $(MAKE) $(AM_MAKEFLAGS) \
+ 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ 	  && $(MAKE) $(AM_MAKEFLAGS) check \
+@@ -944,10 +952,12 @@ uninstall-am:
+ 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ 	tags tags-am uninstall uninstall-am
+ 
++.PRECIOUS: Makefile
++
+ 
+ install-exec-hook:
+ 	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run
+-	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/lib/$(PACKAGE_NAME)
++	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/db/$(PACKAGE_NAME)
+ 	$(mkinstalldirs) $(DESTDIR)$(localstatedir)/log
+ 
+ maintainer-clean-local:
diff --git a/stackdriver-collectd/patches/patch-configure b/stackdriver-collectd/patches/patch-configure
new file mode 100644
index 0000000000..40b2ba9c97
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-configure
@@ -0,0 +1,324 @@
+$NetBSD: patch-configure,v 1.11 2016/02/03 13:10:27 he Exp $
+
+Regen from configure.ac.
+
+--- configure.orig	2015-05-27 07:51:50.000000000 +0000
++++ configure
+@@ -797,6 +797,8 @@ BUILD_PLUGIN_NFS_FALSE
+ BUILD_PLUGIN_NFS_TRUE
+ BUILD_PLUGIN_NETWORK_FALSE
+ BUILD_PLUGIN_NETWORK_TRUE
++BUILD_PLUGIN_NETSTAT_UDP_FALSE
++BUILD_PLUGIN_NETSTAT_UDP_TRUE
+ BUILD_PLUGIN_NETLINK_FALSE
+ BUILD_PLUGIN_NETLINK_TRUE
+ BUILD_PLUGIN_NETAPP_FALSE
+@@ -1431,6 +1433,7 @@ enable_multimeter
+ enable_mysql
+ enable_netapp
+ enable_netlink
++enable_netstat_udp
+ enable_network
+ enable_nfs
+ enable_nginx
+@@ -2230,6 +2233,7 @@ collectd plugins:
+   --enable-mysql          MySQL statistics
+   --enable-netapp         NetApp plugin
+   --enable-netlink        Enhanced Linux network statistics
++  --enable-netstat_udp    UDP network statistics
+   --enable-network        Network communication plugin
+   --enable-nfs            NFS statistics
+   --enable-nginx          nginx statistics
+@@ -13908,7 +13912,7 @@ else
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -13954,7 +13958,7 @@ else
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -13978,7 +13982,7 @@ rm -f core conftest.err conftest.$ac_obj
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -14023,7 +14027,7 @@ else
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -14047,7 +14051,7 @@ rm -f core conftest.err conftest.$ac_obj
+     We can't simply define LARGE_OFF_T to be 9223372036854775807,
+     since some C++ compilers masquerading as C compilers
+     incorrectly reject 9223372036854775807.  */
+-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ 		       && LARGE_OFF_T % 2147483647 == 1)
+ 		      ? 1 : -1];
+@@ -15319,6 +15323,12 @@ $as_echo "#define KERNEL_OPENBSD 1" >>co
+ 
+ 	ac_system="OpenBSD"
+ 	;;
++	*netbsd*)
++
++$as_echo "#define KERNEL_NETBSD 1" >>confdefs.h
++
++	ac_system="NetBSD"
++	;;
+ 	*aix*)
+ 
+ $as_echo "#define KERNEL_AIX 1" >>confdefs.h
+@@ -15876,6 +15886,29 @@ fi
+ done
+ 
+ 
++# For entropy plugin on newer NetBSD
++for ac_header in sys/rndio.h
++do :
++  ac_fn_c_check_header_compile "$LINENO" "sys/rndio.h" "ac_cv_header_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
++
++"
++if test "x$ac_cv_header_sys_rndio_h" = xyes; then :
++  cat >>confdefs.h <<_ACEOF
++#define HAVE_SYS_RNDIO_H 1
++_ACEOF
++
++fi
++
++done
++
+ # For ping library
+ for ac_header in netinet/in_systm.h
+ do :
+@@ -16215,6 +16248,27 @@ else
+ 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ $as_echo "no" >&6; }
+ fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysctl kern.cp_time" >&5
++$as_echo_n "checking for sysctl kern.cp_time... " >&6; }
++if test -x /sbin/sysctl
++then
++	/sbin/sysctl kern.cp_time 2>/dev/null
++	if test $? -eq 0
++	then
++		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++
++$as_echo "#define HAVE_SYSCTL_KERN_CP_TIME 1" >>confdefs.h
++
++	else
++		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++	fi
++else
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
+ 
+ # For hddtemp module
+ for ac_header in linux/major.h
+@@ -19171,6 +19225,54 @@ else
+ fi
+ 
+ 
++ac_fn_c_check_member "$LINENO" "struct kinfo_proc2" "p_pid" "ac_cv_member_struct_kinfo_proc2_p_pid" "
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <kvm.h>
++
++"
++if test "x$ac_cv_member_struct_kinfo_proc2_p_pid" = xyes; then :
++
++cat >>confdefs.h <<_ACEOF
++#define HAVE_STRUCT_KINFO_PROC2_P_PID 1
++_ACEOF
++
++
++
++$as_echo "#define HAVE_STRUCT_KINFO_PROC2_NETBSD 1" >>confdefs.h
++
++		have_struct_kinfo_proc2_netbsd="yes"
++
++else
++
++		have_struct_kinfo_proc2_netbsd="no"
++
++fi
++ac_fn_c_check_member "$LINENO" "struct kinfo_proc2" "p_uru_maxrss" "ac_cv_member_struct_kinfo_proc2_p_uru_maxrss" "
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <kvm.h>
++
++"
++if test "x$ac_cv_member_struct_kinfo_proc2_p_uru_maxrss" = xyes; then :
++
++cat >>confdefs.h <<_ACEOF
++#define HAVE_STRUCT_KINFO_PROC2_P_URU_MAXRSS 1
++_ACEOF
++
++
++
++$as_echo "#define HAVE_STRUCT_KINFO_PROC2_NETBSD 1" >>confdefs.h
++
++		have_struct_kinfo_proc2_netbsd="yes"
++
++else
++
++		have_struct_kinfo_proc2_netbsd="no"
++
++fi
++
++
+ ac_fn_c_check_member "$LINENO" "struct udphdr" "uh_dport" "ac_cv_member_struct_udphdr_uh_dport" "#define _BSD_SOURCE
+ #define _DEFAULT_SOURCE
+ #if HAVE_STDINT_H
+@@ -27579,6 +27681,7 @@ plugin_load="no"
+ plugin_log_logstash="no"
+ plugin_memory="no"
+ plugin_multimeter="no"
++plugin_netstat_udp="no"
+ plugin_nfs="no"
+ plugin_numa="no"
+ plugin_perl="no"
+@@ -27648,6 +27751,15 @@ then
+ 	plugin_tcpconns="yes"
+ fi
+ 
++if test "x$ac_system" = "xNetBSD"
++then
++	plugin_entropy="yes"
++	plugin_irq="yes"
++	plugin_processes="yes"
++	plugin_disk="yes"
++	plugin_netstat_udp="yes"
++fi
++
+ # Mac OS X devices
+ if test "x$with_libiokit" = "xyes"
+ then
+@@ -27890,6 +28002,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"
+@@ -31715,6 +31832,66 @@ fi
+ 
+     enable_plugin="no"
+     force="no"
++    # Check whether --enable-netstat_udp was given.
++if test "${enable_netstat_udp+set}" = set; then :
++  enableval=$enable_netstat_udp;
++     if test "x$enableval" = "xyes"
++     then
++	     enable_plugin="yes"
++     else if test "x$enableval" = "xforce"
++     then
++	     enable_plugin="yes"
++	     force="yes"
++     else
++	     enable_plugin="no (disabled on command line)"
++     fi; fi
++
++else
++
++	 if test "x$enable_all_plugins" = "xauto"
++	 then
++	     if test "x$plugin_netstat_udp" = "xyes"
++	     then
++		     enable_plugin="yes"
++	     else
++		     enable_plugin="no"
++	     fi
++	 else
++	     enable_plugin="$enable_all_plugins"
++	 fi
++
++fi
++
++    if test "x$enable_plugin" = "xyes"
++    then
++	    if test "x$plugin_netstat_udp" = "xyes" || test "x$force" = "xyes"
++	    then
++
++$as_echo "#define HAVE_PLUGIN_NETSTAT_UDP 1" >>confdefs.h
++
++		    if test "x$plugin_netstat_udp" != "xyes"
++		    then
++			    dependency_warning="yes"
++		    fi
++	    else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
++		    dependency_error="yes"
++		    enable_plugin="no (dependency error)"
++	    fi
++    fi
++     if test "x$enable_plugin" = "xyes"; then
++  BUILD_PLUGIN_NETSTAT_UDP_TRUE=
++  BUILD_PLUGIN_NETSTAT_UDP_FALSE='#'
++else
++  BUILD_PLUGIN_NETSTAT_UDP_TRUE='#'
++  BUILD_PLUGIN_NETSTAT_UDP_FALSE=
++fi
++
++    enable_netstat_udp="$enable_plugin"
++
++
++
++    enable_plugin="no"
++    force="no"
+     # Check whether --enable-network was given.
+ if test "${enable_network+set}" = set; then :
+   enableval=$enable_network;
+@@ -36781,6 +36958,10 @@ if test -z "${BUILD_PLUGIN_NETLINK_TRUE}
+   as_fn_error $? "conditional \"BUILD_PLUGIN_NETLINK\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${BUILD_PLUGIN_NETSTAT_UDP_TRUE}" && test -z "${BUILD_PLUGIN_NETSTAT_UDP_FALSE}"; then
++  as_fn_error $? "conditional \"BUILD_PLUGIN_NETSTAT_UDP\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${BUILD_PLUGIN_NETWORK_TRUE}" && test -z "${BUILD_PLUGIN_NETWORK_FALSE}"; then
+   as_fn_error $? "conditional \"BUILD_PLUGIN_NETWORK\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+@@ -39602,6 +39783,7 @@ Configuration:
+     mysql . . . . . . . . $enable_mysql
+     netapp  . . . . . . . $enable_netapp
+     netlink . . . . . . . $enable_netlink
++    netstat_udp . . . . . $enable_netstat_udp
+     network . . . . . . . $enable_network
+     nfs . . . . . . . . . $enable_nfs
+     nginx . . . . . . . . $enable_nginx
diff --git a/stackdriver-collectd/patches/patch-configure.ac b/stackdriver-collectd/patches/patch-configure.ac
new file mode 100644
index 0000000000..c7c05ddb6b
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-configure.ac
@@ -0,0 +1,135 @@
+$NetBSD: patch-configure.ac,v 1.9 2016/02/03 13:10:27 he Exp $
+
+Add KERNEL_NETBSD, add entry and disk plugins for NetBSD,
+and also do swap for "have_swapctl_three_args" (as for NetBSD).
+Also, the start of process support, but that's not yet finished.
+
+--- configure.ac.orig	2015-05-27 07:51:35.000000000 +0000
++++ configure.ac
+@@ -77,6 +77,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"
+@@ -151,6 +155,18 @@ 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
+@@ -329,6 +345,22 @@ then
+ 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 2>/dev/null
++	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)
+@@ -1363,6 +1395,21 @@ AC_CHECK_MEMBERS([struct kinfo_proc.p_pi
+ #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
+@@ -5175,6 +5222,7 @@ plugin_load="no"
+ plugin_log_logstash="no"
+ plugin_memory="no"
+ plugin_multimeter="no"
++plugin_netstat_udp="no"
+ plugin_nfs="no"
+ plugin_numa="no"
+ plugin_perl="no"
+@@ -5244,6 +5292,15 @@ then
+ 	plugin_tcpconns="yes"
+ fi
+ 
++if test "x$ac_system" = "xNetBSD"
++then
++	plugin_entropy="yes"
++	plugin_irq="yes"
++	plugin_processes="yes"
++	plugin_disk="yes"
++	plugin_netstat_udp="yes"
++fi
++
+ # Mac OS X devices
+ if test "x$with_libiokit" = "xyes"
+ then
+@@ -5482,6 +5539,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"
+@@ -5585,6 +5647,7 @@ AC_PLUGIN([multimeter],  [$plugin_multim
+ AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
+ AC_PLUGIN([netapp],      [$with_libnetapp],    [NetApp plugin])
+ AC_PLUGIN([netlink],     [$with_libmnl],       [Enhanced Linux network statistics])
++AC_PLUGIN([netstat_udp], [$plugin_netstat_udp], [UDP network statistics])
+ AC_PLUGIN([network],     [yes],                [Network communication plugin])
+ AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
+ AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
+@@ -5963,6 +6026,7 @@ Configuration:
+     mysql . . . . . . . . $enable_mysql
+     netapp  . . . . . . . $enable_netapp
+     netlink . . . . . . . $enable_netlink
++    netstat_udp . . . . . $enable_netstat_udp
+     network . . . . . . . $enable_network
+     nfs . . . . . . . . . $enable_nfs
+     nginx . . . . . . . . $enable_nginx
diff --git a/stackdriver-collectd/patches/patch-src_Makefile.am b/stackdriver-collectd/patches/patch-src_Makefile.am
new file mode 100644
index 0000000000..daa66c60be
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_Makefile.am
@@ -0,0 +1,61 @@
+$NetBSD: patch-src_Makefile.am,v 1.2 2015/09/12 19:04:56 he Exp $
+
+Install config file in example directory.
+
+--- src/Makefile.am.orig	2015-05-26 19:38:14.000000000 +0000
++++ src/Makefile.am
+@@ -14,13 +14,15 @@ AM_CPPFLAGS = -I$(srcdir)/daemon
+ AM_CPPFLAGS += -DPREFIX='"${prefix}"'
+ AM_CPPFLAGS += -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"'
+ AM_CPPFLAGS += -DLOCALSTATEDIR='"${localstatedir}"'
+-AM_CPPFLAGS += -DPKGLOCALSTATEDIR='"${localstatedir}/lib/${PACKAGE_NAME}"'
++AM_CPPFLAGS += -DPKGLOCALSTATEDIR='"${localstatedir}/db/${PACKAGE_NAME}"'
+ if BUILD_FEATURE_DAEMON
+ AM_CPPFLAGS += -DPIDFILE='"${localstatedir}/run/${PACKAGE_NAME}.pid"'
+ endif
+ AM_CPPFLAGS += -DPLUGINDIR='"${pkglibdir}"'
+ AM_CPPFLAGS += -DPKGDATADIR='"${pkgdatadir}"'
+ 
++egdir = @exec_prefix@/share/examples/@PACKAGE@
++
+ AUTOMAKE_OPTIONS = subdir-objects
+ 
+ noinst_LTLIBRARIES = libmount.la liblookup.la
+@@ -657,6 +659,12 @@ netlink_la_CFLAGS = $(AM_CFLAGS) $(BUILD
+ netlink_la_LIBADD = $(BUILD_WITH_LIBMNL_LIBS)
+ endif
+ 
++if BUILD_PLUGIN_NETSTAT_UDP
++pkglib_LTLIBRARIES += netstat_udp.la
++netstat_udp_la_SOURCES = netstat_udp.c
++netstat_udp_la_LDFLAGS = $(PLUGIN_LDFLAGS)
++endif
++
+ if BUILD_PLUGIN_NETWORK
+ pkglib_LTLIBRARIES += network.la
+ network_la_SOURCES = network.c network.h \
+@@ -1363,13 +1371,8 @@ riemann.pb-c.c riemann.pb-c.h: riemann.p
+ endif
+ 
+ install-exec-hook:
+-	$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
+-	if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \
+-	then \
+-		$(INSTALL) -m 0640 collectd.conf $(DESTDIR)$(sysconfdir)/collectd.conf.pkg-orig; \
+-	else \
+-		$(INSTALL) -m 0640 collectd.conf $(DESTDIR)$(sysconfdir)/collectd.conf; \
+-	fi; \
++	$(mkinstalldirs) $(DESTDIR)$(egdir)
++	$(INSTALL) -m 0640 collectd.conf $(DESTDIR)$(egdir)/collectd.conf
+ 	$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
+ 	$(INSTALL) -m 0644 $(srcdir)/types.db $(DESTDIR)$(pkgdatadir)/types.db;
+ 	$(INSTALL) -m 0644 $(srcdir)/postgresql_default.conf \
+@@ -1377,7 +1380,7 @@ install-exec-hook:
+ 
+ uninstall-hook:
+ 	rm -f $(DESTDIR)$(pkgdatadir)/types.db;
+-	rm -f $(DESTDIR)$(sysconfdir)/collectd.conf
++	rm -f $(DESTDIR)$(egdir)/collectd.conf
+ 	rm -f $(DESTDIR)$(pkgdatadir)/postgresql_default.conf;
+ 
+ check_PROGRAMS = test_utils_mount test_utils_vl_lookup
diff --git a/stackdriver-collectd/patches/patch-src_Makefile.in b/stackdriver-collectd/patches/patch-src_Makefile.in
new file mode 100644
index 0000000000..2a771fc01a
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_Makefile.in
@@ -0,0 +1,616 @@
+$NetBSD: patch-src_Makefile.in,v 1.5 2015/09/17 11:24:11 he Exp $
+
+Use a reasonable db dir.
+Install config file into examples.
+
+--- src/Makefile.in.orig	2015-05-27 07:51:49.001922959 +0000
++++ src/Makefile.in
+@@ -1,7 +1,7 @@
+-# Makefile.in generated by automake 1.14.1 from Makefile.am.
++# Makefile.in generated by automake 1.15 from Makefile.am.
+ # @configure_input@
+ 
+-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
++# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+ 
+ # This Makefile.in is free software; the Free Software Foundation
+ # gives unlimited permission to copy and/or distribute it,
+@@ -16,7 +16,17 @@
+ 
+ 
+ VPATH = @srcdir@
+-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
++am__is_gnu_make = { \
++  if test -z '$(MAKELEVEL)'; then \
++    false; \
++  elif test -n '$(MAKE_HOST)'; then \
++    true; \
++  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
++    true; \
++  else \
++    false; \
++  fi; \
++}
+ am__make_running_with_option = \
+   case $${target_option-} in \
+       ?) ;; \
+@@ -193,124 +203,122 @@ bin_PROGRAMS = collectd-nagios$(EXEEXT) 
+ @BUILD_PLUGIN_MYSQL_TRUE@@BUILD_WITH_LIBMYSQL_TRUE@am__append_109 = $(BUILD_WITH_LIBMYSQL_LIBS)
+ @BUILD_PLUGIN_NETAPP_TRUE@am__append_110 = netapp.la
+ @BUILD_PLUGIN_NETLINK_TRUE@am__append_111 = netlink.la
+-@BUILD_PLUGIN_NETWORK_TRUE@am__append_112 = network.la
+-@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_113 = -lsocket
+-@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBGCRYPT_TRUE@am__append_114 = $(GCRYPT_CPPFLAGS)
+-@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBGCRYPT_TRUE@am__append_115 = $(GCRYPT_LDFLAGS)
+-@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBGCRYPT_TRUE@am__append_116 = $(GCRYPT_LIBS)
+-@BUILD_PLUGIN_NFS_TRUE@am__append_117 = nfs.la
+-@BUILD_PLUGIN_FSCACHE_TRUE@am__append_118 = fscache.la
+-@BUILD_PLUGIN_NGINX_TRUE@am__append_119 = nginx.la
+-@BUILD_PLUGIN_NGINX_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_120 = $(BUILD_WITH_LIBCURL_CFLAGS)
+-@BUILD_PLUGIN_NGINX_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_121 = $(BUILD_WITH_LIBCURL_LIBS)
+-@BUILD_PLUGIN_NOTIFY_DESKTOP_TRUE@am__append_122 = notify_desktop.la
+-@BUILD_PLUGIN_NOTIFY_EMAIL_TRUE@am__append_123 = notify_email.la
+-@BUILD_PLUGIN_NTPD_TRUE@am__append_124 = ntpd.la
+-@BUILD_PLUGIN_NTPD_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_125 = -lsocket
+-@BUILD_PLUGIN_NUMA_TRUE@am__append_126 = numa.la
+-@BUILD_PLUGIN_NUT_TRUE@am__append_127 = nut.la
+-@BUILD_PLUGIN_OLSRD_TRUE@am__append_128 = olsrd.la
+-@BUILD_PLUGIN_OLSRD_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_129 = -lsocket
+-@BUILD_PLUGIN_ONEWIRE_TRUE@am__append_130 = onewire.la
+-@BUILD_PLUGIN_OPENLDAP_TRUE@am__append_131 = openldap.la
+-@BUILD_PLUGIN_OPENVPN_TRUE@am__append_132 = openvpn.la
+-@BUILD_PLUGIN_ORACLE_TRUE@am__append_133 = oracle.la
+-@BUILD_PLUGIN_PERL_TRUE@am__append_134 = perl.la
++@BUILD_PLUGIN_NETSTAT_UDP_TRUE@am__append_112 = netstat_udp.la
++@BUILD_PLUGIN_NETWORK_TRUE@am__append_113 = network.la
++@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_114 = -lsocket
++@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBGCRYPT_TRUE@am__append_115 = $(GCRYPT_CPPFLAGS)
++@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBGCRYPT_TRUE@am__append_116 = $(GCRYPT_LDFLAGS)
++@BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBGCRYPT_TRUE@am__append_117 = $(GCRYPT_LIBS)
++@BUILD_PLUGIN_NFS_TRUE@am__append_118 = nfs.la
++@BUILD_PLUGIN_FSCACHE_TRUE@am__append_119 = fscache.la
++@BUILD_PLUGIN_NGINX_TRUE@am__append_120 = nginx.la
++@BUILD_PLUGIN_NGINX_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_121 = $(BUILD_WITH_LIBCURL_CFLAGS)
++@BUILD_PLUGIN_NGINX_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_122 = $(BUILD_WITH_LIBCURL_LIBS)
++@BUILD_PLUGIN_NOTIFY_DESKTOP_TRUE@am__append_123 = notify_desktop.la
++@BUILD_PLUGIN_NOTIFY_EMAIL_TRUE@am__append_124 = notify_email.la
++@BUILD_PLUGIN_NTPD_TRUE@am__append_125 = ntpd.la
++@BUILD_PLUGIN_NTPD_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_126 = -lsocket
++@BUILD_PLUGIN_NUMA_TRUE@am__append_127 = numa.la
++@BUILD_PLUGIN_NUT_TRUE@am__append_128 = nut.la
++@BUILD_PLUGIN_OLSRD_TRUE@am__append_129 = olsrd.la
++@BUILD_PLUGIN_OLSRD_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_130 = -lsocket
++@BUILD_PLUGIN_ONEWIRE_TRUE@am__append_131 = onewire.la
++@BUILD_PLUGIN_OPENLDAP_TRUE@am__append_132 = openldap.la
++@BUILD_PLUGIN_OPENVPN_TRUE@am__append_133 = openvpn.la
++@BUILD_PLUGIN_ORACLE_TRUE@am__append_134 = oracle.la
++@BUILD_PLUGIN_PERL_TRUE@am__append_135 = perl.la
+ # Work-around for issues #41 and #42 - Perl 5.10 incorrectly introduced
+ # __attribute__nonnull__(3) for Perl_load_module().
+-@BUILD_PLUGIN_PERL_TRUE@@HAVE_BROKEN_PERL_LOAD_MODULE_TRUE@am__append_135 = -Wno-nonnull
+-@BUILD_PLUGIN_PF_TRUE@am__append_136 = pf.la
+-@BUILD_PLUGIN_PINBA_TRUE@am__append_137 = pinba.la
+-@BUILD_PLUGIN_PING_TRUE@am__append_138 = ping.la
+-@BUILD_PLUGIN_POSTGRESQL_TRUE@am__append_139 = postgresql.la
+-@BUILD_PLUGIN_POWERDNS_TRUE@am__append_140 = powerdns.la
+-@BUILD_PLUGIN_PYTHON_TRUE@am__append_141 = python.la
+-@BUILD_PLUGIN_PYTHON_TRUE@@COMPILER_IS_GCC_TRUE@am__append_142 = -fno-strict-aliasing -Wno-strict-aliasing
+-@BUILD_PLUGIN_PROCESSES_TRUE@am__append_143 = processes.la
+-@BUILD_PLUGIN_PROCESSES_TRUE@@BUILD_WITH_LIBKVM_GETPROCS_TRUE@am__append_144 = -lkvm
+-@BUILD_PLUGIN_PROTOCOLS_TRUE@am__append_145 = protocols.la
+-@BUILD_PLUGIN_REDIS_TRUE@am__append_146 = redis.la
+-@BUILD_PLUGIN_ROUTEROS_TRUE@am__append_147 = routeros.la
+-@BUILD_PLUGIN_RRDCACHED_TRUE@am__append_148 = rrdcached.la
+-@BUILD_PLUGIN_RRDTOOL_TRUE@am__append_149 = rrdtool.la
+-@BUILD_PLUGIN_SENSORS_TRUE@am__append_150 = sensors.la
+-@BUILD_PLUGIN_SERIAL_TRUE@am__append_151 = serial.la
+-@BUILD_PLUGIN_SIGROK_TRUE@am__append_152 = sigrok.la
+-@BUILD_PLUGIN_SMART_TRUE@@BUILD_WITH_LIBUDEV_TRUE@am__append_153 = smart.la
+-@BUILD_PLUGIN_SNMP_TRUE@am__append_154 = snmp.la
+-@BUILD_PLUGIN_SNMP_TRUE@@BUILD_WITH_LIBNETSNMP_TRUE@am__append_155 = $(BUILD_WITH_LIBSNMP_CFLAGS)
+-@BUILD_PLUGIN_SNMP_TRUE@@BUILD_WITH_LIBNETSNMP_TRUE@am__append_156 = $(BUILD_WITH_LIBSNMP_LIBS)
+-@BUILD_PLUGIN_SNMP_TRUE@@BUILD_WITH_LIBPTHREAD_TRUE@am__append_157 = -lpthread
+-@BUILD_PLUGIN_STATSD_TRUE@am__append_158 = statsd.la
+-@BUILD_PLUGIN_SWAP_TRUE@am__append_159 = swap.la
+-@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBKSTAT_TRUE@am__append_160 = -lkstat
+-@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBDEVINFO_TRUE@am__append_161 = -ldevinfo
+-@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBKVM_GETSWAPINFO_TRUE@am__append_162 = -lkvm
+-@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_163 = $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+-@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_164 = $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+-@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_PERFSTAT_TRUE@am__append_165 = -lperfstat
+-@BUILD_PLUGIN_SYSLOG_TRUE@am__append_166 = syslog.la
+-@BUILD_PLUGIN_TABLE_TRUE@am__append_167 = table.la
+-@BUILD_PLUGIN_TAIL_TRUE@am__append_168 = tail.la
+-@BUILD_PLUGIN_TAIL_CSV_TRUE@am__append_169 = tail_csv.la
+-@BUILD_PLUGIN_TAPE_TRUE@am__append_170 = tape.la
+-@BUILD_PLUGIN_TARGET_NOTIFICATION_TRUE@am__append_171 = target_notification.la
+-@BUILD_PLUGIN_TARGET_REPLACE_TRUE@am__append_172 = target_replace.la
+-@BUILD_PLUGIN_TARGET_SCALE_TRUE@am__append_173 = target_scale.la
+-@BUILD_PLUGIN_TARGET_SET_TRUE@am__append_174 = target_set.la
+-@BUILD_PLUGIN_TARGET_V5UPGRADE_TRUE@am__append_175 = target_v5upgrade.la
+-@BUILD_PLUGIN_TCPCONNS_TRUE@am__append_176 = tcpconns.la
+-@BUILD_PLUGIN_TCPCONNS_TRUE@@BUILD_WITH_LIBKVM_NLIST_TRUE@am__append_177 = -lkvm
+-@BUILD_PLUGIN_TEAMSPEAK2_TRUE@am__append_178 = teamspeak2.la
+-@BUILD_PLUGIN_TED_TRUE@am__append_179 = ted.la
+-@BUILD_PLUGIN_THERMAL_TRUE@am__append_180 = thermal.la
+-@BUILD_PLUGIN_THRESHOLD_TRUE@am__append_181 = threshold.la
+-@BUILD_PLUGIN_TOKYOTYRANT_TRUE@am__append_182 = tokyotyrant.la
+-@BUILD_PLUGIN_TOKYOTYRANT_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_183 = -lsocket
+-@BUILD_PLUGIN_TURBOSTAT_TRUE@am__append_184 = turbostat.la
+-@BUILD_PLUGIN_UNIXSOCK_TRUE@am__append_185 = unixsock.la
+-@BUILD_PLUGIN_UPTIME_TRUE@am__append_186 = uptime.la
+-@BUILD_PLUGIN_UPTIME_TRUE@@BUILD_WITH_LIBKSTAT_TRUE@am__append_187 = -lkstat
+-@BUILD_PLUGIN_UPTIME_TRUE@@BUILD_WITH_PERFSTAT_TRUE@am__append_188 = -lperfstat
+-@BUILD_PLUGIN_USERS_TRUE@am__append_189 = users.la
+-@BUILD_PLUGIN_USERS_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_190 = $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+-@BUILD_PLUGIN_USERS_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_191 = $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+-@BUILD_PLUGIN_UUID_TRUE@am__append_192 = uuid.la
+-@BUILD_PLUGIN_VARNISH_TRUE@am__append_193 = varnish.la
+-@BUILD_PLUGIN_VIRT_TRUE@am__append_194 = virt.la
+-@BUILD_PLUGIN_VMEM_TRUE@am__append_195 = vmem.la
+-@BUILD_PLUGIN_VSERVER_TRUE@am__append_196 = vserver.la
+-@BUILD_PLUGIN_WIRELESS_TRUE@am__append_197 = wireless.la
+-@BUILD_PLUGIN_WRITE_GRAPHITE_TRUE@am__append_198 = write_graphite.la
+-@BUILD_PLUGIN_WRITE_HTTP_TRUE@am__append_199 = write_http.la
+-@BUILD_PLUGIN_WRITE_HTTP_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_200 = $(BUILD_WITH_LIBCURL_CFLAGS)
+-@BUILD_PLUGIN_WRITE_HTTP_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_201 = $(BUILD_WITH_LIBCURL_LIBS)
+-@BUILD_PLUGIN_WRITE_KAFKA_TRUE@am__append_202 = write_kafka.la
+-@BUILD_PLUGIN_WRITE_LOG_TRUE@am__append_203 = write_log.la
+-@BUILD_PLUGIN_WRITE_MONGODB_TRUE@am__append_204 = write_mongodb.la
+-@BUILD_PLUGIN_WRITE_REDIS_TRUE@am__append_205 = write_redis.la
+-@BUILD_PLUGIN_WRITE_RIEMANN_TRUE@am__append_206 = write_riemann.la
+-@BUILD_PLUGIN_WRITE_SENSU_TRUE@am__append_207 = write_sensu.la
+-@BUILD_PLUGIN_WRITE_TSDB_TRUE@am__append_208 = write_tsdb.la
+-@BUILD_PLUGIN_XMMS_TRUE@am__append_209 = xmms.la
+-@BUILD_PLUGIN_ZFS_ARC_TRUE@am__append_210 = zfs_arc.la
+-@BUILD_PLUGIN_ZOOKEEPER_TRUE@am__append_211 = zookeeper.la
+-@HAVE_PROTOC_C_TRUE@am__append_212 = pinba.pb-c.c pinba.pb-c.h \
+-@HAVE_PROTOC_C_TRUE@	riemann.pb-c.c riemann.pb-c.h
++@BUILD_PLUGIN_PERL_TRUE@@HAVE_BROKEN_PERL_LOAD_MODULE_TRUE@am__append_136 = -Wno-nonnull
++@BUILD_PLUGIN_PF_TRUE@am__append_137 = pf.la
++@BUILD_PLUGIN_PINBA_TRUE@am__append_138 = pinba.la
++@BUILD_PLUGIN_PING_TRUE@am__append_139 = ping.la
++@BUILD_PLUGIN_POSTGRESQL_TRUE@am__append_140 = postgresql.la
++@BUILD_PLUGIN_POWERDNS_TRUE@am__append_141 = powerdns.la
++@BUILD_PLUGIN_PYTHON_TRUE@am__append_142 = python.la
++@BUILD_PLUGIN_PYTHON_TRUE@@COMPILER_IS_GCC_TRUE@am__append_143 = -fno-strict-aliasing -Wno-strict-aliasing
++@BUILD_PLUGIN_PROCESSES_TRUE@am__append_144 = processes.la
++@BUILD_PLUGIN_PROCESSES_TRUE@@BUILD_WITH_LIBKVM_GETPROCS_TRUE@am__append_145 = -lkvm
++@BUILD_PLUGIN_PROTOCOLS_TRUE@am__append_146 = protocols.la
++@BUILD_PLUGIN_REDIS_TRUE@am__append_147 = redis.la
++@BUILD_PLUGIN_ROUTEROS_TRUE@am__append_148 = routeros.la
++@BUILD_PLUGIN_RRDCACHED_TRUE@am__append_149 = rrdcached.la
++@BUILD_PLUGIN_RRDTOOL_TRUE@am__append_150 = rrdtool.la
++@BUILD_PLUGIN_SENSORS_TRUE@am__append_151 = sensors.la
++@BUILD_PLUGIN_SERIAL_TRUE@am__append_152 = serial.la
++@BUILD_PLUGIN_SIGROK_TRUE@am__append_153 = sigrok.la
++@BUILD_PLUGIN_SMART_TRUE@@BUILD_WITH_LIBUDEV_TRUE@am__append_154 = smart.la
++@BUILD_PLUGIN_SNMP_TRUE@am__append_155 = snmp.la
++@BUILD_PLUGIN_SNMP_TRUE@@BUILD_WITH_LIBNETSNMP_TRUE@am__append_156 = $(BUILD_WITH_LIBSNMP_CFLAGS)
++@BUILD_PLUGIN_SNMP_TRUE@@BUILD_WITH_LIBNETSNMP_TRUE@am__append_157 = $(BUILD_WITH_LIBSNMP_LIBS)
++@BUILD_PLUGIN_SNMP_TRUE@@BUILD_WITH_LIBPTHREAD_TRUE@am__append_158 = -lpthread
++@BUILD_PLUGIN_STATSD_TRUE@am__append_159 = statsd.la
++@BUILD_PLUGIN_SWAP_TRUE@am__append_160 = swap.la
++@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBKSTAT_TRUE@am__append_161 = -lkstat
++@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBDEVINFO_TRUE@am__append_162 = -ldevinfo
++@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBKVM_GETSWAPINFO_TRUE@am__append_163 = -lkvm
++@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_164 = $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
++@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_165 = $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
++@BUILD_PLUGIN_SWAP_TRUE@@BUILD_WITH_PERFSTAT_TRUE@am__append_166 = -lperfstat
++@BUILD_PLUGIN_SYSLOG_TRUE@am__append_167 = syslog.la
++@BUILD_PLUGIN_TABLE_TRUE@am__append_168 = table.la
++@BUILD_PLUGIN_TAIL_TRUE@am__append_169 = tail.la
++@BUILD_PLUGIN_TAIL_CSV_TRUE@am__append_170 = tail_csv.la
++@BUILD_PLUGIN_TAPE_TRUE@am__append_171 = tape.la
++@BUILD_PLUGIN_TARGET_NOTIFICATION_TRUE@am__append_172 = target_notification.la
++@BUILD_PLUGIN_TARGET_REPLACE_TRUE@am__append_173 = target_replace.la
++@BUILD_PLUGIN_TARGET_SCALE_TRUE@am__append_174 = target_scale.la
++@BUILD_PLUGIN_TARGET_SET_TRUE@am__append_175 = target_set.la
++@BUILD_PLUGIN_TARGET_V5UPGRADE_TRUE@am__append_176 = target_v5upgrade.la
++@BUILD_PLUGIN_TCPCONNS_TRUE@am__append_177 = tcpconns.la
++@BUILD_PLUGIN_TCPCONNS_TRUE@@BUILD_WITH_LIBKVM_NLIST_TRUE@am__append_178 = -lkvm
++@BUILD_PLUGIN_TEAMSPEAK2_TRUE@am__append_179 = teamspeak2.la
++@BUILD_PLUGIN_TED_TRUE@am__append_180 = ted.la
++@BUILD_PLUGIN_THERMAL_TRUE@am__append_181 = thermal.la
++@BUILD_PLUGIN_THRESHOLD_TRUE@am__append_182 = threshold.la
++@BUILD_PLUGIN_TOKYOTYRANT_TRUE@am__append_183 = tokyotyrant.la
++@BUILD_PLUGIN_TOKYOTYRANT_TRUE@@BUILD_WITH_LIBSOCKET_TRUE@am__append_184 = -lsocket
++@BUILD_PLUGIN_TURBOSTAT_TRUE@am__append_185 = turbostat.la
++@BUILD_PLUGIN_UNIXSOCK_TRUE@am__append_186 = unixsock.la
++@BUILD_PLUGIN_UPTIME_TRUE@am__append_187 = uptime.la
++@BUILD_PLUGIN_UPTIME_TRUE@@BUILD_WITH_LIBKSTAT_TRUE@am__append_188 = -lkstat
++@BUILD_PLUGIN_UPTIME_TRUE@@BUILD_WITH_PERFSTAT_TRUE@am__append_189 = -lperfstat
++@BUILD_PLUGIN_USERS_TRUE@am__append_190 = users.la
++@BUILD_PLUGIN_USERS_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_191 = $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
++@BUILD_PLUGIN_USERS_TRUE@@BUILD_WITH_LIBSTATGRAB_TRUE@am__append_192 = $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
++@BUILD_PLUGIN_UUID_TRUE@am__append_193 = uuid.la
++@BUILD_PLUGIN_VARNISH_TRUE@am__append_194 = varnish.la
++@BUILD_PLUGIN_VIRT_TRUE@am__append_195 = virt.la
++@BUILD_PLUGIN_VMEM_TRUE@am__append_196 = vmem.la
++@BUILD_PLUGIN_VSERVER_TRUE@am__append_197 = vserver.la
++@BUILD_PLUGIN_WIRELESS_TRUE@am__append_198 = wireless.la
++@BUILD_PLUGIN_WRITE_GRAPHITE_TRUE@am__append_199 = write_graphite.la
++@BUILD_PLUGIN_WRITE_HTTP_TRUE@am__append_200 = write_http.la
++@BUILD_PLUGIN_WRITE_HTTP_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_201 = $(BUILD_WITH_LIBCURL_CFLAGS)
++@BUILD_PLUGIN_WRITE_HTTP_TRUE@@BUILD_WITH_LIBCURL_TRUE@am__append_202 = $(BUILD_WITH_LIBCURL_LIBS)
++@BUILD_PLUGIN_WRITE_KAFKA_TRUE@am__append_203 = write_kafka.la
++@BUILD_PLUGIN_WRITE_LOG_TRUE@am__append_204 = write_log.la
++@BUILD_PLUGIN_WRITE_MONGODB_TRUE@am__append_205 = write_mongodb.la
++@BUILD_PLUGIN_WRITE_REDIS_TRUE@am__append_206 = write_redis.la
++@BUILD_PLUGIN_WRITE_RIEMANN_TRUE@am__append_207 = write_riemann.la
++@BUILD_PLUGIN_WRITE_SENSU_TRUE@am__append_208 = write_sensu.la
++@BUILD_PLUGIN_WRITE_TSDB_TRUE@am__append_209 = write_tsdb.la
++@BUILD_PLUGIN_XMMS_TRUE@am__append_210 = xmms.la
++@BUILD_PLUGIN_ZFS_ARC_TRUE@am__append_211 = zfs_arc.la
++@BUILD_PLUGIN_ZOOKEEPER_TRUE@am__append_212 = zookeeper.la
+ @HAVE_PROTOC_C_TRUE@am__append_213 = pinba.pb-c.c pinba.pb-c.h \
+ @HAVE_PROTOC_C_TRUE@	riemann.pb-c.c riemann.pb-c.h
++@HAVE_PROTOC_C_TRUE@am__append_214 = pinba.pb-c.c pinba.pb-c.h \
++@HAVE_PROTOC_C_TRUE@	riemann.pb-c.c riemann.pb-c.h
+ check_PROGRAMS = test_utils_mount$(EXEEXT) \
+ 	test_utils_vl_lookup$(EXEEXT)
+ TESTS = test_utils_mount$(EXEEXT) test_utils_vl_lookup$(EXEEXT)
+ subdir = src
+-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+-	$(srcdir)/config.h.in $(srcdir)/collectd.conf.in \
+-	$(top_srcdir)/libltdl/config/depcomp $(dist_man_MANS) \
+-	$(top_srcdir)/libltdl/config/test-driver
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
++DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+ mkinstalldirs = $(install_sh) -d
+ CONFIG_HEADER = config.h
+ CONFIG_CLEAN_FILES = collectd.conf
+@@ -977,6 +985,17 @@ netlink_la_LINK = $(LIBTOOL) $(AM_V_lt) 
+ 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(netlink_la_CFLAGS) \
+ 	$(CFLAGS) $(netlink_la_LDFLAGS) $(LDFLAGS) -o $@
+ @BUILD_PLUGIN_NETLINK_TRUE@am_netlink_la_rpath = -rpath $(pkglibdir)
++netstat_udp_la_LIBADD =
++am__netstat_udp_la_SOURCES_DIST = netstat_udp.c
++@BUILD_PLUGIN_NETSTAT_UDP_TRUE@am_netstat_udp_la_OBJECTS =  \
++@BUILD_PLUGIN_NETSTAT_UDP_TRUE@	netstat_udp.lo
++netstat_udp_la_OBJECTS = $(am_netstat_udp_la_OBJECTS)
++netstat_udp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
++	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
++	$(AM_CFLAGS) $(CFLAGS) $(netstat_udp_la_LDFLAGS) $(LDFLAGS) -o \
++	$@
++@BUILD_PLUGIN_NETSTAT_UDP_TRUE@am_netstat_udp_la_rpath = -rpath \
++@BUILD_PLUGIN_NETSTAT_UDP_TRUE@	$(pkglibdir)
+ @BUILD_PLUGIN_NETWORK_TRUE@@BUILD_WITH_LIBGCRYPT_TRUE@am__DEPENDENCIES_11 = $(am__DEPENDENCIES_1)
+ @BUILD_PLUGIN_NETWORK_TRUE@network_la_DEPENDENCIES =  \
+ @BUILD_PLUGIN_NETWORK_TRUE@	$(am__DEPENDENCIES_1) \
+@@ -1780,7 +1799,8 @@ SOURCES = $(aggregation_la_SOURCES) $(am
+ 	$(memcached_la_SOURCES) $(memory_la_SOURCES) $(mic_la_SOURCES) \
+ 	$(modbus_la_SOURCES) $(multimeter_la_SOURCES) \
+ 	$(mysql_la_SOURCES) $(netapp_la_SOURCES) $(netlink_la_SOURCES) \
+-	$(network_la_SOURCES) $(nfs_la_SOURCES) $(nginx_la_SOURCES) \
++	$(netstat_udp_la_SOURCES) $(network_la_SOURCES) \
++	$(nfs_la_SOURCES) $(nginx_la_SOURCES) \
+ 	$(notify_desktop_la_SOURCES) $(notify_email_la_SOURCES) \
+ 	$(ntpd_la_SOURCES) $(numa_la_SOURCES) $(nut_la_SOURCES) \
+ 	$(olsrd_la_SOURCES) $(onewire_la_SOURCES) \
+@@ -1857,6 +1877,7 @@ DIST_SOURCES = $(am__aggregation_la_SOUR
+ 	$(am__mic_la_SOURCES_DIST) $(am__modbus_la_SOURCES_DIST) \
+ 	$(am__multimeter_la_SOURCES_DIST) $(am__mysql_la_SOURCES_DIST) \
+ 	$(am__netapp_la_SOURCES_DIST) $(am__netlink_la_SOURCES_DIST) \
++	$(am__netstat_udp_la_SOURCES_DIST) \
+ 	$(am__network_la_SOURCES_DIST) $(am__nfs_la_SOURCES_DIST) \
+ 	$(am__nginx_la_SOURCES_DIST) \
+ 	$(am__notify_desktop_la_SOURCES_DIST) \
+@@ -2132,6 +2153,10 @@ TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)
+ TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ 	$(TEST_LOG_FLAGS)
+ DIST_SUBDIRS = libcollectdclient liboconfig daemon
++am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \
++	$(srcdir)/collectd.conf.in $(srcdir)/config.h.in \
++	$(top_srcdir)/libltdl/config/depcomp \
++	$(top_srcdir)/libltdl/config/test-driver
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ am__relativize = \
+   dir0=`pwd`; \
+@@ -2275,12 +2300,6 @@ GANGLIA_LIBS = @GANGLIA_LIBS@
+ GCRYPT_CPPFLAGS = @GCRYPT_CPPFLAGS@
+ GCRYPT_LDFLAGS = @GCRYPT_LDFLAGS@
+ GCRYPT_LIBS = @GCRYPT_LIBS@
+-GLIB_CFLAGS = @GLIB_CFLAGS@
+-GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@
+-GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+-GLIB_LIBS = @GLIB_LIBS@
+-GLIB_MKENUMS = @GLIB_MKENUMS@
+-GOBJECT_QUERY = @GOBJECT_QUERY@
+ GREP = @GREP@
+ INCLTDL = @INCLTDL@
+ INSTALL = @INSTALL@
+@@ -2310,9 +2329,6 @@ LIBADD_DL = @LIBADD_DL@
+ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
+ LIBADD_DLOPEN = @LIBADD_DLOPEN@
+ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@
+-LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+-LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+-LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
+ LIBLTDL = @LIBLTDL@
+ LIBNETAPP_CPPFLAGS = @LIBNETAPP_CPPFLAGS@
+ LIBNETAPP_LDFLAGS = @LIBNETAPP_LDFLAGS@
+@@ -2434,9 +2450,10 @@ PLUGIN_LDFLAGS = -module -avoid-version 
+ AM_CPPFLAGS = -I$(srcdir)/daemon -DPREFIX='"${prefix}"' \
+ 	-DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"' \
+ 	-DLOCALSTATEDIR='"${localstatedir}"' \
+-	-DPKGLOCALSTATEDIR='"${localstatedir}/lib/${PACKAGE_NAME}"' \
++	-DPKGLOCALSTATEDIR='"${localstatedir}/db/${PACKAGE_NAME}"' \
+ 	$(am__append_2) -DPLUGINDIR='"${pkglibdir}"' \
+ 	-DPKGDATADIR='"${pkgdatadir}"'
++egdir = @exec_prefix@/share/examples/@PACKAGE@
+ AUTOMAKE_OPTIONS = subdir-objects
+ noinst_LTLIBRARIES = libmount.la liblookup.la
+ libmount_la_SOURCES = utils_mount.c utils_mount.h
+@@ -2482,32 +2499,33 @@ pkglib_LTLIBRARIES = $(am__append_11) $(
+ 	$(am__append_95) $(am__append_96) $(am__append_98) \
+ 	$(am__append_104) $(am__append_105) $(am__append_106) \
+ 	$(am__append_107) $(am__append_110) $(am__append_111) \
+-	$(am__append_112) $(am__append_117) $(am__append_118) \
+-	$(am__append_119) $(am__append_122) $(am__append_123) \
+-	$(am__append_124) $(am__append_126) $(am__append_127) \
+-	$(am__append_128) $(am__append_130) $(am__append_131) \
++	$(am__append_112) $(am__append_113) $(am__append_118) \
++	$(am__append_119) $(am__append_120) $(am__append_123) \
++	$(am__append_124) $(am__append_125) $(am__append_127) \
++	$(am__append_128) $(am__append_129) $(am__append_131) \
+ 	$(am__append_132) $(am__append_133) $(am__append_134) \
+-	$(am__append_136) $(am__append_137) $(am__append_138) \
++	$(am__append_135) $(am__append_137) $(am__append_138) \
+ 	$(am__append_139) $(am__append_140) $(am__append_141) \
+-	$(am__append_143) $(am__append_145) $(am__append_146) \
++	$(am__append_142) $(am__append_144) $(am__append_146) \
+ 	$(am__append_147) $(am__append_148) $(am__append_149) \
+ 	$(am__append_150) $(am__append_151) $(am__append_152) \
+-	$(am__append_153) $(am__append_154) $(am__append_158) \
+-	$(am__append_159) $(am__append_166) $(am__append_167) \
++	$(am__append_153) $(am__append_154) $(am__append_155) \
++	$(am__append_159) $(am__append_160) $(am__append_167) \
+ 	$(am__append_168) $(am__append_169) $(am__append_170) \
+ 	$(am__append_171) $(am__append_172) $(am__append_173) \
+ 	$(am__append_174) $(am__append_175) $(am__append_176) \
+-	$(am__append_178) $(am__append_179) $(am__append_180) \
+-	$(am__append_181) $(am__append_182) $(am__append_184) \
+-	$(am__append_185) $(am__append_186) $(am__append_189) \
+-	$(am__append_192) $(am__append_193) $(am__append_194) \
++	$(am__append_177) $(am__append_179) $(am__append_180) \
++	$(am__append_181) $(am__append_182) $(am__append_183) \
++	$(am__append_185) $(am__append_186) $(am__append_187) \
++	$(am__append_190) $(am__append_193) $(am__append_194) \
+ 	$(am__append_195) $(am__append_196) $(am__append_197) \
+-	$(am__append_198) $(am__append_199) $(am__append_202) \
++	$(am__append_198) $(am__append_199) $(am__append_200) \
+ 	$(am__append_203) $(am__append_204) $(am__append_205) \
+ 	$(am__append_206) $(am__append_207) $(am__append_208) \
+-	$(am__append_209) $(am__append_210) $(am__append_211)
+-BUILT_SOURCES = $(dist_man_MANS) $(am__append_213)
+-CLEANFILES = $(am__append_212)
++	$(am__append_209) $(am__append_210) $(am__append_211) \
++	$(am__append_212)
++BUILT_SOURCES = $(dist_man_MANS) $(am__append_214)
++CLEANFILES = $(am__append_213)
+ @BUILD_PLUGIN_AGGREGATION_TRUE@aggregation_la_SOURCES = aggregation.c \
+ @BUILD_PLUGIN_AGGREGATION_TRUE@                         utils_vl_lookup.c utils_vl_lookup.h
+ 
+@@ -2765,23 +2783,25 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_NETLINK_TRUE@netlink_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_NETLINK_TRUE@netlink_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMNL_CFLAGS)
+ @BUILD_PLUGIN_NETLINK_TRUE@netlink_la_LIBADD = $(BUILD_WITH_LIBMNL_LIBS)
++@BUILD_PLUGIN_NETSTAT_UDP_TRUE@netstat_udp_la_SOURCES = netstat_udp.c
++@BUILD_PLUGIN_NETSTAT_UDP_TRUE@netstat_udp_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_NETWORK_TRUE@network_la_SOURCES = network.c network.h \
+ @BUILD_PLUGIN_NETWORK_TRUE@		     utils_fbhash.c utils_fbhash.h
+ 
+ @BUILD_PLUGIN_NETWORK_TRUE@network_la_CPPFLAGS = $(AM_CPPFLAGS) \
+-@BUILD_PLUGIN_NETWORK_TRUE@	$(am__append_114)
+-@BUILD_PLUGIN_NETWORK_TRUE@network_la_LDFLAGS = $(PLUGIN_LDFLAGS) \
+ @BUILD_PLUGIN_NETWORK_TRUE@	$(am__append_115)
++@BUILD_PLUGIN_NETWORK_TRUE@network_la_LDFLAGS = $(PLUGIN_LDFLAGS) \
++@BUILD_PLUGIN_NETWORK_TRUE@	$(am__append_116)
+ @BUILD_PLUGIN_NETWORK_TRUE@network_la_LIBADD = -lpthread \
+-@BUILD_PLUGIN_NETWORK_TRUE@	$(am__append_113) $(am__append_116)
++@BUILD_PLUGIN_NETWORK_TRUE@	$(am__append_114) $(am__append_117)
+ @BUILD_PLUGIN_NFS_TRUE@nfs_la_SOURCES = nfs.c
+ @BUILD_PLUGIN_NFS_TRUE@nfs_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_FSCACHE_TRUE@fscache_la_SOURCES = fscache.c
+ @BUILD_PLUGIN_FSCACHE_TRUE@fscache_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_NGINX_TRUE@nginx_la_SOURCES = nginx.c
+ @BUILD_PLUGIN_NGINX_TRUE@nginx_la_CFLAGS = $(AM_CFLAGS) \
+-@BUILD_PLUGIN_NGINX_TRUE@	$(am__append_120)
+-@BUILD_PLUGIN_NGINX_TRUE@nginx_la_LIBADD = $(am__append_121)
++@BUILD_PLUGIN_NGINX_TRUE@	$(am__append_121)
++@BUILD_PLUGIN_NGINX_TRUE@nginx_la_LIBADD = $(am__append_122)
+ @BUILD_PLUGIN_NGINX_TRUE@nginx_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_NOTIFY_DESKTOP_TRUE@notify_desktop_la_SOURCES = notify_desktop.c
+ @BUILD_PLUGIN_NOTIFY_DESKTOP_TRUE@notify_desktop_la_CFLAGS = $(AM_CFLAGS) $(LIBNOTIFY_CFLAGS)
+@@ -2792,7 +2812,7 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_NOTIFY_EMAIL_TRUE@notify_email_la_LIBADD = -lesmtp -lssl -lcrypto -lpthread
+ @BUILD_PLUGIN_NTPD_TRUE@ntpd_la_SOURCES = ntpd.c
+ @BUILD_PLUGIN_NTPD_TRUE@ntpd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+-@BUILD_PLUGIN_NTPD_TRUE@ntpd_la_LIBADD = $(am__append_125)
++@BUILD_PLUGIN_NTPD_TRUE@ntpd_la_LIBADD = $(am__append_126)
+ @BUILD_PLUGIN_NUMA_TRUE@numa_la_SOURCES = numa.c
+ @BUILD_PLUGIN_NUMA_TRUE@numa_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_NUT_TRUE@nut_la_SOURCES = nut.c
+@@ -2801,7 +2821,7 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_NUT_TRUE@nut_la_LIBADD = -lpthread $(BUILD_WITH_LIBUPSCLIENT_LIBS)
+ @BUILD_PLUGIN_OLSRD_TRUE@olsrd_la_SOURCES = olsrd.c
+ @BUILD_PLUGIN_OLSRD_TRUE@olsrd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+-@BUILD_PLUGIN_OLSRD_TRUE@olsrd_la_LIBADD = $(am__append_129)
++@BUILD_PLUGIN_OLSRD_TRUE@olsrd_la_LIBADD = $(am__append_130)
+ @BUILD_PLUGIN_ONEWIRE_TRUE@onewire_la_SOURCES = onewire.c \
+ @BUILD_PLUGIN_ONEWIRE_TRUE@		     utils_ignorelist.c utils_ignorelist.h
+ 
+@@ -2830,7 +2850,7 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_PERL_TRUE@perl_la_CFLAGS = $(AM_CFLAGS) $(PERL_CFLAGS) \
+ @BUILD_PLUGIN_PERL_TRUE@	-DXS_VERSION=\"$(VERSION)\" \
+ @BUILD_PLUGIN_PERL_TRUE@	-DVERSION=\"$(VERSION)\" \
+-@BUILD_PLUGIN_PERL_TRUE@	$(am__append_135)
++@BUILD_PLUGIN_PERL_TRUE@	$(am__append_136)
+ @BUILD_PLUGIN_PERL_TRUE@perl_la_LDFLAGS = $(PLUGIN_LDFLAGS) \
+ @BUILD_PLUGIN_PERL_TRUE@		$(PERL_LDFLAGS)
+ 
+@@ -2858,12 +2878,12 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_PYTHON_TRUE@python_la_SOURCES = python.c pyconfig.c pyvalues.c cpython.h
+ @BUILD_PLUGIN_PYTHON_TRUE@python_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_PYTHON_CPPFLAGS)
+ @BUILD_PLUGIN_PYTHON_TRUE@python_la_CFLAGS = $(AM_CFLAGS) \
+-@BUILD_PLUGIN_PYTHON_TRUE@	$(am__append_142)
++@BUILD_PLUGIN_PYTHON_TRUE@	$(am__append_143)
+ @BUILD_PLUGIN_PYTHON_TRUE@python_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_PYTHON_LDFLAGS)
+ @BUILD_PLUGIN_PYTHON_TRUE@python_la_LIBADD = $(BUILD_WITH_PYTHON_LIBS)
+ @BUILD_PLUGIN_PROCESSES_TRUE@processes_la_SOURCES = processes.c
+ @BUILD_PLUGIN_PROCESSES_TRUE@processes_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+-@BUILD_PLUGIN_PROCESSES_TRUE@processes_la_LIBADD = $(am__append_144)
++@BUILD_PLUGIN_PROCESSES_TRUE@processes_la_LIBADD = $(am__append_145)
+ @BUILD_PLUGIN_PROTOCOLS_TRUE@protocols_la_SOURCES = protocols.c \
+ @BUILD_PLUGIN_PROTOCOLS_TRUE@		       utils_ignorelist.c utils_ignorelist.h
+ 
+@@ -2905,9 +2925,9 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_SNMP_TRUE@snmp_la_SOURCES = snmp.c
+ @BUILD_PLUGIN_SNMP_TRUE@snmp_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_SNMP_TRUE@snmp_la_CFLAGS = $(AM_CFLAGS) \
+-@BUILD_PLUGIN_SNMP_TRUE@	$(am__append_155)
+-@BUILD_PLUGIN_SNMP_TRUE@snmp_la_LIBADD = $(am__append_156) \
+-@BUILD_PLUGIN_SNMP_TRUE@	$(am__append_157)
++@BUILD_PLUGIN_SNMP_TRUE@	$(am__append_156)
++@BUILD_PLUGIN_SNMP_TRUE@snmp_la_LIBADD = $(am__append_157) \
++@BUILD_PLUGIN_SNMP_TRUE@	$(am__append_158)
+ @BUILD_PLUGIN_STATSD_TRUE@statsd_la_SOURCES = statsd.c \
+ @BUILD_PLUGIN_STATSD_TRUE@                    utils_latency.h utils_latency.c
+ 
+@@ -2915,11 +2935,11 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_STATSD_TRUE@statsd_la_LIBADD = -lpthread
+ @BUILD_PLUGIN_SWAP_TRUE@swap_la_SOURCES = swap.c
+ @BUILD_PLUGIN_SWAP_TRUE@swap_la_CFLAGS = $(AM_CFLAGS) \
+-@BUILD_PLUGIN_SWAP_TRUE@	$(am__append_163)
++@BUILD_PLUGIN_SWAP_TRUE@	$(am__append_164)
+ @BUILD_PLUGIN_SWAP_TRUE@swap_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+-@BUILD_PLUGIN_SWAP_TRUE@swap_la_LIBADD = $(am__append_160) \
+-@BUILD_PLUGIN_SWAP_TRUE@	$(am__append_161) $(am__append_162) \
+-@BUILD_PLUGIN_SWAP_TRUE@	$(am__append_164) $(am__append_165)
++@BUILD_PLUGIN_SWAP_TRUE@swap_la_LIBADD = $(am__append_161) \
++@BUILD_PLUGIN_SWAP_TRUE@	$(am__append_162) $(am__append_163) \
++@BUILD_PLUGIN_SWAP_TRUE@	$(am__append_165) $(am__append_166)
+ @BUILD_PLUGIN_SYSLOG_TRUE@syslog_la_SOURCES = syslog.c
+ @BUILD_PLUGIN_SYSLOG_TRUE@syslog_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_TABLE_TRUE@table_la_SOURCES = table.c
+@@ -2943,7 +2963,7 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_TARGET_V5UPGRADE_TRUE@target_v5upgrade_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_TCPCONNS_TRUE@tcpconns_la_SOURCES = tcpconns.c
+ @BUILD_PLUGIN_TCPCONNS_TRUE@tcpconns_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+-@BUILD_PLUGIN_TCPCONNS_TRUE@tcpconns_la_LIBADD = $(am__append_177)
++@BUILD_PLUGIN_TCPCONNS_TRUE@tcpconns_la_LIBADD = $(am__append_178)
+ @BUILD_PLUGIN_TEAMSPEAK2_TRUE@teamspeak2_la_SOURCES = teamspeak2.c
+ @BUILD_PLUGIN_TEAMSPEAK2_TRUE@teamspeak2_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_TED_TRUE@ted_la_SOURCES = ted.c
+@@ -2958,7 +2978,7 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_TOKYOTYRANT_TRUE@tokyotyrant_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
+ @BUILD_PLUGIN_TOKYOTYRANT_TRUE@tokyotyrant_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
+ @BUILD_PLUGIN_TOKYOTYRANT_TRUE@tokyotyrant_la_LIBADD = $(BUILD_WITH_LIBTOKYOTYRANT_LIBS) \
+-@BUILD_PLUGIN_TOKYOTYRANT_TRUE@	$(am__append_183)
++@BUILD_PLUGIN_TOKYOTYRANT_TRUE@	$(am__append_184)
+ @BUILD_PLUGIN_TURBOSTAT_TRUE@turbostat_la_SOURCES = turbostat.c
+ @BUILD_PLUGIN_TURBOSTAT_TRUE@turbostat_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_UNIXSOCK_TRUE@unixsock_la_SOURCES = unixsock.c \
+@@ -2975,13 +2995,13 @@ CLEANFILES = $(am__append_212)
+ @BUILD_PLUGIN_UPTIME_TRUE@uptime_la_SOURCES = uptime.c
+ @BUILD_PLUGIN_UPTIME_TRUE@uptime_la_CFLAGS = $(AM_CFLAGS)
+ @BUILD_PLUGIN_UPTIME_TRUE@uptime_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+-@BUILD_PLUGIN_UPTIME_TRUE@uptime_la_LIBADD = $(am__append_187) \
+-@BUILD_PLUGIN_UPTIME_TRUE@	$(am__append_188)
++@BUILD_PLUGIN_UPTIME_TRUE@uptime_la_LIBADD = $(am__append_188) \
++@BUILD_PLUGIN_UPTIME_TRUE@	$(am__append_189)
+ @BUILD_PLUGIN_USERS_TRUE@users_la_SOURCES = users.c
+ @BUILD_PLUGIN_USERS_TRUE@users_la_CFLAGS = $(AM_CFLAGS) \
+-@BUILD_PLUGIN_USERS_TRUE@	$(am__append_190)
++@BUILD_PLUGIN_USERS_TRUE@	$(am__append_191)
+ @BUILD_PLUGIN_USERS_TRUE@users_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+-@BUILD_PLUGIN_USERS_TRUE@users_la_LIBADD = $(am__append_191)
++@BUILD_PLUGIN_USERS_TRUE@users_la_LIBADD = $(am__append_192)
+ @BUILD_PLUGIN_UUID_TRUE@uuid_la_SOURCES = uuid.c
+ @BUILD_PLUGIN_UUID_TRUE@uuid_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBHAL_CFLAGS)
+ @BUILD_PLUGIN_UUID_TRUE@uuid_la_LIBADD = $(BUILD_WITH_LIBHAL_LIBS)
+@@ -3014,9 +3034,9 @@ CLEANFILES = $(am__append_212)
+ 
+ @BUILD_PLUGIN_WRITE_HTTP_TRUE@write_http_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ @BUILD_PLUGIN_WRITE_HTTP_TRUE@write_http_la_CFLAGS = $(AM_CFLAGS) \
+-@BUILD_PLUGIN_WRITE_HTTP_TRUE@	$(am__append_200)
+-@BUILD_PLUGIN_WRITE_HTTP_TRUE@write_http_la_LIBADD =  \
+ @BUILD_PLUGIN_WRITE_HTTP_TRUE@	$(am__append_201)
++@BUILD_PLUGIN_WRITE_HTTP_TRUE@write_http_la_LIBADD =  \
++@BUILD_PLUGIN_WRITE_HTTP_TRUE@	$(am__append_202)
+ @BUILD_PLUGIN_WRITE_KAFKA_TRUE@write_kafka_la_SOURCES = write_kafka.c \
+ @BUILD_PLUGIN_WRITE_KAFKA_TRUE@                        utils_format_graphite.c utils_format_graphite.h \
+ @BUILD_PLUGIN_WRITE_KAFKA_TRUE@                        utils_format_json.c utils_format_json.h \
+@@ -3108,7 +3128,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefi
+ 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+ 	$(am__cd) $(top_srcdir) && \
+ 	  $(AUTOMAKE) --foreign src/Makefile
+-.PRECIOUS: Makefile
+ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ 	@case '$?' in \
+ 	  *config.status*) \
+@@ -3385,6 +3404,9 @@ netapp.la: $(netapp_la_OBJECTS) $(netapp
+ netlink.la: $(netlink_la_OBJECTS) $(netlink_la_DEPENDENCIES) $(EXTRA_netlink_la_DEPENDENCIES) 
+ 	$(AM_V_CCLD)$(netlink_la_LINK) $(am_netlink_la_rpath) $(netlink_la_OBJECTS) $(netlink_la_LIBADD) $(LIBS)
+ 
++netstat_udp.la: $(netstat_udp_la_OBJECTS) $(netstat_udp_la_DEPENDENCIES) $(EXTRA_netstat_udp_la_DEPENDENCIES) 
++	$(AM_V_CCLD)$(netstat_udp_la_LINK) $(am_netstat_udp_la_rpath) $(netstat_udp_la_OBJECTS) $(netstat_udp_la_LIBADD) $(LIBS)
++
+ network.la: $(network_la_OBJECTS) $(network_la_DEPENDENCIES) $(EXTRA_network_la_DEPENDENCIES) 
+ 	$(AM_V_CCLD)$(network_la_LINK) $(am_network_la_rpath) $(network_la_OBJECTS) $(network_la_LIBADD) $(LIBS)
+ 
+@@ -3811,6 +3833,7 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netapp_la-netapp.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netapp_la-utils_ignorelist.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netlink_la-netlink.Plo@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netstat_udp.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network_la-network.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network_la-utils_fbhash.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfs.Plo@am__quote@
+@@ -4821,7 +4844,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
+ 	if test -n "$$am__remaking_logs"; then \
+ 	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ 	       "recursion detected" >&2; \
+-	else \
++	elif test -n "$$redo_logs"; then \
+ 	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ 	fi; \
+ 	if $(am__make_dryrun); then :; else \
+@@ -5166,6 +5189,8 @@ uninstall-man: uninstall-man1 uninstall-
+ 	uninstall-man1 uninstall-man5 uninstall-pkglibLTLIBRARIES \
+ 	uninstall-sbinPROGRAMS
+ 
++.PRECIOUS: Makefile
++
+ 
+ .pod.1:
+ 	pod2man --release=$(VERSION) --center=$(PACKAGE) $< \
+@@ -5190,13 +5215,8 @@ uninstall-man: uninstall-man1 uninstall-
+ @HAVE_PROTOC_C_TRUE@	protoc-c -I$(srcdir) --c_out . $(srcdir)/riemann.proto
+ 
+ install-exec-hook:
+-	$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
+-	if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \
+-	then \
+-		$(INSTALL) -m 0640 collectd.conf $(DESTDIR)$(sysconfdir)/collectd.conf.pkg-orig; \
+-	else \
+-		$(INSTALL) -m 0640 collectd.conf $(DESTDIR)$(sysconfdir)/collectd.conf; \
+-	fi; \
++	$(mkinstalldirs) $(DESTDIR)$(egdir)
++	$(INSTALL) -m 0640 collectd.conf $(DESTDIR)$(egdir)/collectd.conf
+ 	$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
+ 	$(INSTALL) -m 0644 $(srcdir)/types.db $(DESTDIR)$(pkgdatadir)/types.db;
+ 	$(INSTALL) -m 0644 $(srcdir)/postgresql_default.conf \
+@@ -5204,7 +5224,7 @@ install-exec-hook:
+ 
+ uninstall-hook:
+ 	rm -f $(DESTDIR)$(pkgdatadir)/types.db;
+-	rm -f $(DESTDIR)$(sysconfdir)/collectd.conf
++	rm -f $(DESTDIR)$(egdir)/collectd.conf
+ 	rm -f $(DESTDIR)$(pkgdatadir)/postgresql_default.conf;
+ 
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/stackdriver-collectd/patches/patch-src_collectd-tg.c b/stackdriver-collectd/patches/patch-src_collectd-tg.c
new file mode 100644
index 0000000000..6fa00abaa0
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_collectd-tg.c
@@ -0,0 +1,19 @@
+$NetBSD: patch-src_collectd-tg.c,v 1.1 2015/03/19 13:50:30 jperkin Exp $
+
+Don't go past _XOPEN_SOURCE=600 on SunOS.
+
+--- src/collectd-tg.c.orig	2014-01-26 08:09:14.836391498 +0000
++++ src/collectd-tg.c
+@@ -32,8 +32,12 @@
+ #endif
+ 
+ #ifndef _XOPEN_SOURCE
++#ifdef __sun
++# define _XOPEN_SOURCE 600
++#else
+ # define _XOPEN_SOURCE 700
+ #endif
++#endif
+ 
+ #if !__GNUC__
+ # define __attribute__(x) /**/
diff --git a/stackdriver-collectd/patches/patch-src_collectd.conf.in b/stackdriver-collectd/patches/patch-src_collectd.conf.in
new file mode 100644
index 0000000000..8081b1e051
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_collectd.conf.in
@@ -0,0 +1,106 @@
+$NetBSD: patch-src_collectd.conf.in,v 1.2 2015/06/10 20:05:26 fhajny Exp $
+
+Fix default dirs.
+--- src/collectd.conf.in.orig	2015-05-20 12:05:42.672060002 +0000
++++ src/collectd.conf.in
+@@ -12,7 +12,7 @@
+ 
+ #Hostname    "localhost"
+ #FQDNLookup   true
+-#BaseDir     "@localstatedir@/lib/@PACKAGE_NAME@"
++#BaseDir     "@localstatedir@/db/@PACKAGE_NAME@"
+ #PIDFile     "@localstatedir@/run/@PACKAGE_NAME@.pid"
+ #PluginDir   "@libdir@/@PACKAGE_NAME@"
+ #TypesDB     "@prefix@/share/@PACKAGE_NAME@/types.db"
+@@ -315,16 +315,16 @@
+ #  LongRunAvgLatency false
+ #  ConvertSpecialMetricTypes true
+ #  <Daemon "osd.0">
+-#    SocketPath "/var/run/ceph/ceph-osd.0.asok"
++#    SocketPath "@localstatedir@/run/ceph/ceph-osd.0.asok"
+ #  </Daemon>
+ #  <Daemon "osd.1">
+-#    SocketPath "/var/run/ceph/ceph-osd.1.asok"
++#    SocketPath "@localstatedir@/run/ceph/ceph-osd.1.asok"
+ #  </Daemon>
+ #  <Daemon "mon.a">
+-#    SocketPath "/var/run/ceph/ceph-mon.ceph1.asok"
++#    SocketPath "@localstatedir@/run/ceph/ceph-mon.ceph1.asok"
+ #  </Daemon>
+ #  <Daemon "mds.a">
+-#    SocketPath "/var/run/ceph/ceph-mds.ceph1.asok"
++#    SocketPath "@localstatedir@/run/ceph/ceph-mds.ceph1.asok"
+ #  </Daemon>
+ #</Plugin>
+ 
+@@ -340,7 +340,7 @@
+ #</Plugin>
+ #
+ #<Plugin csv>
+-#	DataDir "@localstatedir@/lib/@PACKAGE_NAME@/csv"
++#	DataDir "@localstatedir@/db/@PACKAGE_NAME@/csv"
+ #	StoreRates false
+ #</Plugin>
+ 
+@@ -683,7 +683,7 @@
+ #	<Database db_name2>
+ #		Alias "squeeze"
+ #		Host "localhost"
+-#		Socket "/var/run/mysql/mysqld.sock"
++#		Socket "@localstatedir@/run/mysql/mysqld.sock"
+ #		SlaveStats true
+ #		SlaveNotifications true
+ #	</Database>
+@@ -956,14 +956,14 @@
+ #  <Server "server_name">
+ #    Collect "latency"
+ #    Collect "udp-answers" "udp-queries"
+-#    Socket "/var/run/pdns.controlsocket"
++#    Socket "@localstatedir@/run/pdns.controlsocket"
+ #  </Server>
+ #  <Recursor "recursor_name">
+ #    Collect "questions"
+ #    Collect "cache-hits" "cache-misses"
+-#    Socket "/var/run/pdns_recursor.controlsocket"
++#    Socket "@localstatedir@/run/pdns_recursor.controlsocket"
+ #  </Recursor>
+-#  LocalSocket "/opt/collectd/var/run/collectd-powerdns"
++#  LocalSocket "@localstatedir@/run/collectd-powerdns"
+ #</Plugin>
+ 
+ #<Plugin processes>
+@@ -1011,14 +1011,14 @@
+ 
+ #<Plugin rrdcached>
+ #	DaemonAddress "unix:/tmp/rrdcached.sock"
+-#	DataDir "@localstatedir@/lib/@PACKAGE_NAME@/rrd"
++#	DataDir "@localstatedir@/db/@PACKAGE_NAME@/rrd"
+ #	CreateFiles true
+ #	CreateFilesAsync false
+ #	CollectStatistics true
+ #</Plugin>
+ 
+ #<Plugin rrdtool>
+-#	DataDir "@localstatedir@/lib/@PACKAGE_NAME@/rrd"
++#	DataDir "@localstatedir@/db/@PACKAGE_NAME@/rrd"
+ #	CreateFilesAsync false
+ #	CacheTimeout 120
+ #	CacheFlush   900
+@@ -1174,7 +1174,7 @@
+ #       Type "kpackets_wire_per_sec.realtime"
+ #       ValueFrom 4
+ #   </Metric>
+-#   <File "/var/log/snort/snort.stats">
++#   <File "@localstatedir@/log/snort/snort.stats">
+ #       Instance "snort-eth0"
+ #       Interval 600
+ #       Collect "dropped" "mbps" "alerts" "kpps"
+@@ -1231,7 +1231,7 @@
+ #</Plugin>
+ 
+ #<Plugin unixsock>
+-#	SocketFile "@prefix@/var/run/@PACKAGE_NAME@-unixsock"
++#	SocketFile "@localstatedir@/run/@PACKAGE_NAME@-unixsock"
+ #	SocketGroup "collectd"
+ #	SocketPerms "0660"
+ #	DeleteSocket false
diff --git a/stackdriver-collectd/patches/patch-src_config.h.in b/stackdriver-collectd/patches/patch-src_config.h.in
new file mode 100644
index 0000000000..1929ae35ff
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_config.h.in
@@ -0,0 +1,52 @@
+$NetBSD: patch-src_config.h.in,v 1.4 2015/09/01 09:00:04 he Exp $
+
+Optionally define a few vars for NetBSD.
+
+--- src/config.h.in.orig	2015-05-27 07:53:03.000000000 +0000
++++ src/config.h.in
+@@ -1246,6 +1246,15 @@
+ /* Define to 1 if `imr_ifindex' is a member of `struct ip_mreqn'. */
+ #undef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
+ 
++/* Define if struct kinfo_proc2 exists in the NetBSD variant. */
++#undef HAVE_STRUCT_KINFO_PROC2_NETBSD
++
++/* Define to 1 if `p_pid' is a member of `struct kinfo_proc2'. */
++#undef HAVE_STRUCT_KINFO_PROC2_P_PID
++
++/* Define to 1 if `p_uru_maxrss' is a member of `struct kinfo_proc2'. */
++#undef HAVE_STRUCT_KINFO_PROC2_P_URU_MAXRSS
++
+ /* Define if struct kinfo_proc exists in the FreeBSD variant. */
+ #undef HAVE_STRUCT_KINFO_PROC_FREEBSD
+ 
+@@ -1319,6 +1328,9 @@
+ /* Define to 1 if you have the `sysctlbyname' function. */
+ #undef HAVE_SYSCTLBYNAME
+ 
++/* Define if sysctl supports kern.cp_time */
++#undef HAVE_SYSCTL_KERN_CP_TIME
++
+ /* Define if sysctl supports kern.cp_times */
+ #undef HAVE_SYSCTL_KERN_CP_TIMES
+ 
+@@ -1375,6 +1387,9 @@
+ /* Define to 1 if you have the <sys/resource.h> header file. */
+ #undef HAVE_SYS_RESOURCE_H
+ 
++/* Define to 1 if you have the <sys/rndio.h> header file. */
++#undef HAVE_SYS_RNDIO_H
++
+ /* Define to 1 if you have the <sys/select.h> header file. */
+ #undef HAVE_SYS_SELECT_H
+ 
+@@ -1507,6 +1522,9 @@
+ /* True if program is to be compiled for a Linux kernel */
+ #undef KERNEL_LINUX
+ 
++/* True if program is to be compiled for a NetBSD kernel */
++#undef KERNEL_NETBSD
++
+ /* True if program is to be compiled for an OpenBSD kernel */
+ #undef KERNEL_OPENBSD
+ 
diff --git a/stackdriver-collectd/patches/patch-src_cpu.c b/stackdriver-collectd/patches/patch-src_cpu.c
new file mode 100644
index 0000000000..13e67c6355
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_cpu.c
@@ -0,0 +1,50 @@
+$NetBSD: patch-src_cpu.c,v 1.1 2015/08/26 12:19:27 he Exp $
+
+Port this too to NetBSD.
+
+--- src/cpu.c.orig	2015-03-10 14:14:45.000000000 +0000
++++ src/cpu.c
+@@ -79,7 +79,9 @@
+ 
+ #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
+@@ -676,6 +678,24 @@ static int cpu_read (void)
+ 
+ 	memset (cpuinfo, 0, sizeof (cpuinfo));
+ 
++#if defined(KERN_CP_TIME) && defined(KERNEL_NETBSD)
++	{
++		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];
++
++			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 (i = 0; i < numcpu; i++) {
+@@ -715,6 +735,7 @@ static int cpu_read (void)
+ 			cpuinfo[0][i] = cpuinfo_tmp[i];
+ 		}
+ 	}
++#endif /* defined(KERN_CP_TIME) && defined(KERNEL_NETBSD) */
+ 
+ 	for (i = 0; i < numcpu; i++) {
+ 		cpu_stage (i, COLLECTD_CPU_STATE_USER,      (derive_t) cpuinfo[i][CP_USER], now);
diff --git a/stackdriver-collectd/patches/patch-src_df.c b/stackdriver-collectd/patches/patch-src_df.c
new file mode 100644
index 0000000000..7c0c65c5c6
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_df.c
@@ -0,0 +1,21 @@
+$NetBSD: patch-src_df.c,v 1.4 2015/08/18 07:52:20 he Exp $
+
+Older NetBSD doesn't have float_t.
+
+--- src/df.c.orig	2015-03-10 14:14:45.000000000 +0000
++++ src/df.c
+@@ -28,6 +28,14 @@
+ #include "utils_mount.h"
+ #include "utils_ignorelist.h"
+ 
++#if defined(__NetBSD__)
++#include <sys/param.h>
++#include <math.h>
++#if __NetBSD_Version__ < 699001900
++typedef float float_t;
++#endif
++#endif
++
+ #if HAVE_STATVFS
+ # if HAVE_SYS_STATVFS_H
+ #  include <sys/statvfs.h>
diff --git a/stackdriver-collectd/patches/patch-src_disk.c b/stackdriver-collectd/patches/patch-src_disk.c
new file mode 100644
index 0000000000..aabff0e475
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_disk.c
@@ -0,0 +1,209 @@
+$NetBSD: patch-src_disk.c,v 1.1 2015/08/11 13:19:21 he Exp $
+
+Provide a port to NetBSD.
+
+--- src/disk.c.orig	2015-03-10 14:14:45.000000000 +0000
++++ src/disk.c
+@@ -124,6 +124,35 @@ static int numdisk;
+ static int pnumdisk;
+ /* #endif HAVE_PERFSTAT */
+ 
++#elif HAVE_SYSCTL && KERNEL_NETBSD
++
++#include <sys/sysctl.h>
++#include <sys/iostat.h>
++
++typedef struct diskstats {
++	char *name;
++
++	u_int poll_count;
++
++	derive_t read_ops;
++	derive_t write_ops;
++
++	derive_t read_bytes;
++	derive_t write_bytes;
++
++	derive_t avg_io_time;
++
++	struct io_sysctl stats;
++
++	struct diskstats *next;
++} diskstats_t;
++
++static diskstats_t *disklist;
++static struct io_sysctl *drives = NULL;
++static size_t ndrive = 0;
++
++/* #endif HAVE_SYSCTL && KERNEL_NETBSD */
++
+ #else
+ # error "No applicable input method."
+ #endif
+@@ -241,7 +270,34 @@ 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 */
++
+ 
+ 	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);
+ 	}
+-#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];
++	}
++
++#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
+ 
+ 	return (0);
+ } /* int disk_read */
diff --git a/stackdriver-collectd/patches/patch-src_entropy.c b/stackdriver-collectd/patches/patch-src_entropy.c
new file mode 100644
index 0000000000..b6dfa2fc43
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_entropy.c
@@ -0,0 +1,113 @@
+$NetBSD: patch-src_entropy.c,v 1.6 2015/12/12 22:23:32 he 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
+@@ -28,27 +28,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;
++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
+ 
+-	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
+ 
+-	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)
+ 
+ 	return (0);
+ }
++#endif /* KERNEL_LINUX */
++
++#if KERNEL_NETBSD
++/* Provide a NetBSD implementation, partial from rndctl.c */
++
++/*
++ * Improved to keep the /dev/urandom open, since there's a consumption
++ * of entropy from /dev/random for every open of /dev/urandom, and this
++ * will end up opening /dev/urandom lots of times.
++ */
++
++#include <sys/types.h>
++#include <sys/ioctl.h>
++#include <sys/param.h>
++#include <sys/rnd.h>
++#if HAVE_SYS_RNDIO_H
++# include <sys/rndio.h>
++#endif
++#include <paths.h>
++
++static int
++entropy_read (void)
++{
++	rndpoolstat_t rs;
++	static int fd;
++
++	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;
++	}
++
++	entropy_submit (rs.curentropy);
++
++	return 0;
++}
++
++#endif /* KERNEL_NETBSD */
++
++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);
++}
+ 
+ void module_register (void)
+ {
diff --git a/stackdriver-collectd/patches/patch-src_irq.c b/stackdriver-collectd/patches/patch-src_irq.c
new file mode 100644
index 0000000000..60210423f4
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_irq.c
@@ -0,0 +1,103 @@
+$NetBSD: patch-src_irq.c,v 1.2 2016/02/03 15:10:43 he Exp $
+
+Provide a port to NetBSD.
+
+--- src/irq.c.orig	2014-09-05 08:57:01.000000000 +0000
++++ src/irq.c
+@@ -27,10 +27,22 @@
+ #include "configfile.h"
+ #include "utils_ignorelist.h"
+ 
+-#if !KERNEL_LINUX
++#if !KERNEL_LINUX && !KERNEL_NETBSD
+ # error "No applicable input method."
+ #endif
+ 
++#if KERNEL_NETBSD
++
++#include <sys/param.h>
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <sys/evcnt.h>
++#include <malloc.h>
++
++#endif /* KERNEL_NETBSD */
++
++
++
+ /*
+  * (Module-)Global variables
+  */
+@@ -90,6 +102,7 @@ static void irq_submit (const char *irq_
+ 	plugin_dispatch_values (&vl);
+ } /* void irq_submit */
+ 
++#if KERNEL_LINUX
+ static int irq_read (void)
+ {
+ 	FILE *fh;
+@@ -183,6 +196,64 @@ static int irq_read (void)
+ 
+ 	return (0);
+ } /* int irq_read */
++#endif /* KERNEL_LINUX */
++
++#if KERNEL_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;
++
++	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];
++
++		snprintf(irqname, 80, "%s-%s", evs->ev_strings,
++			 evs->ev_strings + evs->ev_grouplen + 1);
++
++		irq_submit(irqname, evs->ev_count);
++
++		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)
+ {
diff --git a/stackdriver-collectd/patches/patch-src_libcollectclient_network__buffer.c b/stackdriver-collectd/patches/patch-src_libcollectclient_network__buffer.c
new file mode 100644
index 0000000000..b8194f2cb6
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_libcollectclient_network__buffer.c
@@ -0,0 +1,23 @@
+$NetBSD: patch-src_libcollectclient_network__buffer.c,v 1.1 2014/02/17 11:21:55 fhajny Exp $
+
+Need the workaround on at least SunOS too.
+--- src/libcollectdclient/network_buffer.c.orig	2014-01-26 08:09:14.868392118 +0000
++++ src/libcollectdclient/network_buffer.c
+@@ -37,7 +37,7 @@
+ 
+ #if HAVE_LIBGCRYPT
+ # include <pthread.h>
+-# 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
+@@ -50,7 +50,7 @@
+  */
+ # 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
diff --git a/stackdriver-collectd/patches/patch-src_memory.c b/stackdriver-collectd/patches/patch-src_memory.c
new file mode 100644
index 0000000000..706a35e150
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_memory.c
@@ -0,0 +1,128 @@
+$NetBSD: patch-src_memory.c,v 1.2 2015/08/16 08:01:58 he Exp $
+
+Add a port for NetBSD using VM_UVMEXP2, and preferring
+sysctl over sysctlbyname.
+
+--- src/memory.c.orig	2015-03-10 14:14:45.000000000 +0000
++++ src/memory.c
+@@ -65,6 +65,10 @@ static mach_port_t port_host;
+ static vm_size_t pagesize;
+ /* #endif HAVE_HOST_STATISTICS */
+ 
++#elif HAVE_SYSCTL
++static int pagesize;
++/* #endif HAVE_SYSCTL */
++
+ #elif HAVE_SYSCTLBYNAME
+ /* no global variables */
+ /* #endif HAVE_SYSCTLBYNAME */
+@@ -78,10 +82,6 @@ static int pagesize;
+ static kstat_t *ksp;
+ /* #endif HAVE_LIBKSTAT */
+ 
+-#elif HAVE_SYSCTL
+-static int pagesize;
+-/* #endif HAVE_SYSCTL */
+-
+ #elif HAVE_LIBSTATGRAB
+ /* no global variables */
+ /* endif HAVE_LIBSTATGRAB */
+@@ -92,6 +92,10 @@ static int pagesize;
+ # error "No applicable input method."
+ #endif
+ 
++#if KERNEL_NETBSD
++# include <uvm/uvm_extern.h>
++#endif
++
+ 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);
+ /* #endif HAVE_HOST_STATISTICS */
+ 
++#elif HAVE_SYSCTL
++	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 */
+@@ -139,15 +152,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);
+-	}
+-/* #endif HAVE_SYSCTL */
+-
+ #elif HAVE_LIBSTATGRAB
+ /* no init stuff */
+ /* #endif HAVE_LIBSTATGRAB */
+@@ -221,6 +225,46 @@ static int memory_read_internal (value_l
+ /* #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;
++
++	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);
++	}
++
++	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);
++/* #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
+@@ -272,6 +316,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]);
++
++#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
+ /* #endif HAVE_SYSCTLBYNAME */
+ 
+ #elif KERNEL_LINUX
diff --git a/stackdriver-collectd/patches/patch-src_netstat__udp.c b/stackdriver-collectd/patches/patch-src_netstat__udp.c
new file mode 100644
index 0000000000..e65c4f904a
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_netstat__udp.c
@@ -0,0 +1,165 @@
+$NetBSD: patch-src_netstat__udp.c,v 1.1 2015/09/12 19:04:56 he Exp $
+
+Add a plugin which reports the UDP summary statistics.
+Useful for busyish DNS name servers.
+
+--- src/netstat_udp.c.orig	2015-09-11 16:55:05.000000000 +0000
++++ src/netstat_udp.c
+@@ -0,0 +1,157 @@
++/**
++ * collectd - src/netstat-udp.c
++ * Copyright (C) 2015  Håvard Eidnes
++ *
++ * This program is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License as published by the
++ * Free Software Foundation; only version 2 of the License is applicable.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License along
++ * with this program; if not, write to the Free Software Foundation, Inc.,
++ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
++ *
++ * Authors:
++ *   Håvard Eidnes <he at NetBSD.org>
++ **/
++
++#include "collectd.h"
++#include "common.h"
++#include "plugin.h"
++
++#if !defined(KERNEL_NETBSD)
++# error "No applicable input method."
++#endif
++
++#include <sys/cdefs.h>
++#include <sys/types.h>
++#include <sys/sysctl.h>
++
++#include <netinet/in.h>
++#include <netinet/ip_var.h>
++#include <netinet/udp.h>
++#include <netinet/udp_var.h>
++#include <netinet6/udp6_var.h>
++
++static int
++netstat_udp_init (void)
++{
++	return (0);
++} /* int netstat_udp_init */
++
++#define SUBMIT_VARS(...) \
++   plugin_dispatch_multivalue (vl, 0, DS_TYPE_DERIVE, __VA_ARGS__, NULL)
++
++static int
++netstat_udp_internal (value_list_t *vl)
++{
++	uint64_t udpstat[UDP_NSTATS];
++	uint64_t udp6stat[UDP6_NSTATS];
++	size_t size;
++	uint64_t delivered, delivered6;
++	int err;
++
++	size = sizeof(udpstat);
++	if (sysctlbyname("net.inet.udp.stats", udpstat, &size, NULL, 0) == -1) {
++		ERROR("netstat-udp plugin: could not get udp stats");
++		return -1;
++	}
++
++	delivered = udpstat[UDP_STAT_IPACKETS] -
++		udpstat[UDP_STAT_HDROPS] -
++		udpstat[UDP_STAT_BADLEN] -
++		udpstat[UDP_STAT_BADSUM] -
++		udpstat[UDP_STAT_NOPORT] -
++		udpstat[UDP_STAT_NOPORTBCAST] -
++		udpstat[UDP_STAT_FULLSOCK];
++
++	err = SUBMIT_VARS ("udp-received",
++		     (derive_t) udpstat[UDP_STAT_IPACKETS],
++		     "udp-bad-header",
++		     (derive_t) udpstat[UDP_STAT_HDROPS],
++		     "udp-bad-length",
++		     (derive_t) udpstat[UDP_STAT_BADLEN],
++		     "udp-bad-checksum",
++		     (derive_t) udpstat[UDP_STAT_BADSUM],
++		     "udp-no-port",
++		     (derive_t) udpstat[UDP_STAT_NOPORT],
++		     "udp-no-port-broadcast",
++		     (derive_t) udpstat[UDP_STAT_NOPORTBCAST],
++		     "udp-full-socket",
++		     (derive_t) udpstat[UDP_STAT_FULLSOCK],
++		     "udp-delivered",
++		     (derive_t) delivered
++		);
++	if (err != 0) {
++		ERROR("netstat-udp plugin: could not submit, err=%d\n", err);
++	}
++
++	size = sizeof(udp6stat);
++	if (sysctlbyname("net.inet6.udp6.stats", udp6stat, &size,
++			 NULL, 0) == -1) {
++		ERROR("netstat-udp plugin: could not get udp6 stats");
++		return -1;
++	}
++
++	delivered6 = udp6stat[UDP6_STAT_IPACKETS] -
++		udp6stat[UDP6_STAT_HDROPS] -
++		udp6stat[UDP6_STAT_BADLEN] -
++		udp6stat[UDP6_STAT_BADSUM] -
++		udp6stat[UDP6_STAT_NOSUM] -
++		udp6stat[UDP6_STAT_NOPORT] -
++		udp6stat[UDP6_STAT_NOPORTMCAST] -
++		udp6stat[UDP6_STAT_FULLSOCK];
++
++	err = SUBMIT_VARS ("udp6-received",
++		     (derive_t) udp6stat[UDP6_STAT_IPACKETS],
++		     "udp6-bad-header",
++		     (derive_t) udp6stat[UDP6_STAT_HDROPS],
++		     "udp6-bad-length",
++		     (derive_t) udp6stat[UDP6_STAT_BADLEN],
++		     "udp6-bad-checksum",
++		     (derive_t) udp6stat[UDP6_STAT_BADSUM],
++		     "udp6-no-checksum",
++		     (derive_t) udp6stat[UDP6_STAT_NOSUM],
++		     "udp6-no-port",
++		     (derive_t) udp6stat[UDP6_STAT_NOPORT],
++		     "udp6-no-port-multicast",
++		     (derive_t) udp6stat[UDP6_STAT_NOPORTMCAST],
++		     "udp6-full-socket",
++		     (derive_t) udp6stat[UDP6_STAT_FULLSOCK],
++		     "udp6-delivered",
++		     (derive_t) delivered6
++		);
++	if (err != 0) {
++		ERROR("netstat-udp plugin ipv6: could not submit, err=%d\n",
++		      err);
++	}
++
++	return (0);
++} /* }}} int netstat_udp_internal */
++
++static int
++netstat_udp_read (void) /* {{{ */
++{
++	value_t v[1];
++	value_list_t vl = VALUE_LIST_INIT;
++
++	vl.values = v;
++	vl.values_len = STATIC_ARRAY_SIZE (v);
++	sstrncpy (vl.host, hostname_g, sizeof (vl.host));
++	sstrncpy (vl.plugin, "netstat_udp", sizeof (vl.plugin));
++	sstrncpy (vl.type, "packets", sizeof (vl.type));
++	vl.time = cdtime ();
++
++	return (netstat_udp_internal (&vl));
++} /* }}} int netstat_udp_read */
++
++void
++module_register (void)
++{
++	plugin_register_init ("netstat_udp", netstat_udp_init);
++	plugin_register_read ("netstat_udp", netstat_udp_read);
++} /* void module_register */
diff --git a/stackdriver-collectd/patches/patch-src_processes.c b/stackdriver-collectd/patches/patch-src_processes.c
new file mode 100644
index 0000000000..090a1ce04c
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_processes.c
@@ -0,0 +1,249 @@
+$NetBSD: patch-src_processes.c,v 1.3 2015/09/01 09:00:04 he Exp $
+
+Add a port to NetBSD.
+
+--- src/processes.c.orig	2015-05-20 12:04:47.000000000 +0000
++++ src/processes.c
+@@ -94,13 +94,13 @@
+ #  endif
+ /* #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_PROCINFO_H
+ #  include <procinfo.h>
+@@ -229,9 +229,14 @@ static mach_msg_type_number_t     pset_l
+ 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)
+ 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) */
+ 
+ #elif HAVE_PROCINFO_H
+ static  struct procentry64 procentry[MAXPROCENTRY];
+@@ -638,9 +643,20 @@ static int ps_init (void)
+ 			pagesize_g, CONFIG_HZ);
+ /* #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)
++#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? */
++#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) */
+ 
+ #elif HAVE_PROCINFO_H
+ 	pagesize = getpagesize();
+@@ -1940,6 +1956,186 @@ 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);
++/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC2_NETBSD */
++
+ #elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_OPENBSD
+ 	int running  = 0;
+ 	int sleeping = 0;
diff --git a/stackdriver-collectd/patches/patch-src_swap.c b/stackdriver-collectd/patches/patch-src_swap.c
new file mode 100644
index 0000000000..dbac98a1ec
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_swap.c
@@ -0,0 +1,150 @@
+$NetBSD: patch-src_swap.c,v 1.2 2015/08/11 14:15:00 he Exp $
+
+Extend support for NetBSD, and add per-swap-device
+reporting for HAVE_SWAPCTL_THREE_ARGS.
+
+--- src/swap.c.orig	2015-05-20 12:04:47.000000000 +0000
++++ src/swap.c
+@@ -76,9 +76,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
+ static derive_t pagesize;
++#if KERNEL_NETBSD
++static _Bool report_bytes = 0;
++#endif
+ static _Bool report_by_device = 0;
+ /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */
+ 
+@@ -114,7 +117,7 @@ static int swap_config (oconfig_item_t *
+ 	{
+ 		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);
+ #else
+ 			WARNING ("swap plugin: The \"ReportBytes\" option "
+@@ -147,7 +150,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 ();
+ /* #endif HAVE_SWAPCTL */
+@@ -213,7 +216,7 @@ static void swap_submit_usage (char cons
+ 				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)
+@@ -614,6 +617,43 @@ static int swap_read (void) /* {{{ */
+ /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */
+ 
+ #elif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS
++#if KERNEL_NETBSD
++#include <uvm/uvm_extern.h>
++
++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;
++
++	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;
++
++	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);
++
++	return (0);
++} /* }}} */
++#endif
++
+ static int swap_read (void) /* {{{ */
+ {
+ 	struct swapent *swap_entries;
+@@ -660,23 +700,53 @@ static int swap_read (void) /* {{{ */
+ 	 * swap_entries[i].se_path */
+ 	for (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;
+ 
+-		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;
++		}
++
++		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) */
++
+ 
+ 	if (total < used)
+ 	{
+ 		ERROR ("swap plugin: Total swap space (%g) is less than used swap space (%g).",
+ 				total, used);
++		sfree (swap_entries);
+ 		return (-1);
+ 	}
+ 
+-	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);
++
++#if KERNEL_NETBSD
++	swap_read_io ();
++#endif
+ 	return (0);
+ } /* }}} int swap_read */
+ /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
diff --git a/stackdriver-collectd/patches/patch-src_tcpconns.c b/stackdriver-collectd/patches/patch-src_tcpconns.c
new file mode 100644
index 0000000000..409701700f
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_tcpconns.c
@@ -0,0 +1,14 @@
+$NetBSD: patch-src_tcpconns.c,v 1.5 2015/08/11 13:19:21 he Exp $
+
+Include <sys/param.h>
+
+--- src/tcpconns.c.orig	2015-05-20 12:04:47.191035542 +0000
++++ src/tcpconns.c
+@@ -948,6 +948,7 @@ static int conn_init (void)
+   return (0);
+ } /* int conn_init */
+ 
++#include <sys/param.h>
+ static int conn_read (void)
+ {
+   struct inpcbtable table;
diff --git a/stackdriver-collectd/patches/patch-src_utils__dns.c b/stackdriver-collectd/patches/patch-src_utils__dns.c
new file mode 100644
index 0000000000..32dbc604b6
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-src_utils__dns.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_utils__dns.c,v 1.1 2015/04/07 13:20:41 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
+@@ -96,6 +96,9 @@
+ #endif
+ 
+ #if HAVE_PCAP_H
++# if defined(DLT_MATCHING_MAX)
++#  undef DLT_MATCHING_MAX
++# endif
+ # include <pcap.h>
+ #endif
+ 
diff --git a/stackdriver-collectd/patches/patch-version-gen.sh b/stackdriver-collectd/patches/patch-version-gen.sh
new file mode 100644
index 0000000000..6ca0cc93fd
--- /dev/null
+++ b/stackdriver-collectd/patches/patch-version-gen.sh
@@ -0,0 +1,14 @@
+$NetBSD: patch-version-gen.sh,v 1.1 2015/08/11 13:19:21 he Exp $
+
+For work in pkgsrc, also strip '.git' suffix.
+
+--- version-gen.sh.orig	2015-05-26 20:23:28.000000000 +0000
++++ version-gen.sh
+@@ -8,6 +8,6 @@ if test -z "$VERSION"; then
+ 	VERSION="$DEFAULT_VERSION"
+ fi
+ 
+-VERSION="`echo \"$VERSION\" | sed -e 's/-/./g'`"
++VERSION="`echo \"$VERSION\" | sed -e 's/-/./g' | sed -e 's/.git//'`"
+ 
+ printf "%s" "$VERSION"


Home | Main Index | Thread Index | Old Index