pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Import collectd and friends from sysutils
Module Name: pkgsrc-wip
Committed By: Edgar Fuß <ef%math.uni-bonn.de@localhost>
Pushed By: ef
Date: Fri Jul 17 13:11:48 2020 +0200
Changeset: 75cfdca358a64ff50a130f80d35863fe357966e6
Modified Files:
Makefile
Added Files:
collectd-amqp/DESCR
collectd-amqp/Makefile
collectd-curl/DESCR
collectd-curl/Makefile
collectd-dbi/DESCR
collectd-dbi/Makefile
collectd-dns/DESCR
collectd-dns/Makefile
collectd-lua/DESCR
collectd-lua/Makefile
collectd-memcached/DESCR
collectd-memcached/Makefile
collectd-mysql/DESCR
collectd-mysql/Makefile
collectd-network/DESCR
collectd-network/Makefile
collectd-notify-email/DESCR
collectd-notify-email/Makefile
collectd-postgresql/DESCR
collectd-postgresql/Makefile
collectd-riemann/DESCR
collectd-riemann/Makefile
collectd-rrdtool/DESCR
collectd-rrdtool/Makefile
collectd-snmp/DESCR
collectd-snmp/Makefile
collectd-write_prometheus/DESCR
collectd-write_prometheus/Makefile
collectd/DESCR
collectd/Makefile
collectd/Makefile.common
collectd/PLIST
collectd/distinfo
collectd/files/collectd.sh
collectd/files/smf/manifest.xml
collectd/options.mk
collectd/patches/patch-Makefile.am
collectd/patches/patch-configure.ac
collectd/patches/patch-src_bind.c
collectd/patches/patch-src_collectd.conf.in
collectd/patches/patch-src_cpu.c
collectd/patches/patch-src_daemon_collectd.c
collectd/patches/patch-src_daemon_common.h
collectd/patches/patch-src_df.c
collectd/patches/patch-src_disk.c
collectd/patches/patch-src_entropy.c
collectd/patches/patch-src_irq.c
collectd/patches/patch-src_libcollectclient_network__buffer.c
collectd/patches/patch-src_lua.c
collectd/patches/patch-src_memory.c
collectd/patches/patch-src_netstat__udp.c
collectd/patches/patch-src_processes.c
collectd/patches/patch-src_statsd.c
collectd/patches/patch-src_swap.c
collectd/patches/patch-src_tcpconns.c
collectd/patches/patch-src_utils__dns.c
collectd/patches/patch-src_utils__format__kairosdb.c
p5-collectd/DESCR
p5-collectd/Makefile
py-collectd/DESCR
py-collectd/Makefile
Log Message:
Import collectd and friends from sysutils
Import collectd, collectd-{amqp,curl,dbi,dns,lua,memcached,mysql,network,notify-email,postgresql,riemann,rrdtool,snmp,write_prometheus} and p[y5]-collectd from sysutils.
Add new packages to top Makefile
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=75cfdca358a64ff50a130f80d35863fe357966e6
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 17 ++
collectd-amqp/DESCR | 1 +
collectd-amqp/Makefile | 13 +
collectd-curl/DESCR | 2 +
collectd-curl/Makefile | 18 ++
collectd-dbi/DESCR | 1 +
collectd-dbi/Makefile | 13 +
collectd-dns/DESCR | 1 +
collectd-dns/Makefile | 18 ++
collectd-lua/DESCR | 1 +
collectd-lua/Makefile | 14 ++
collectd-memcached/DESCR | 1 +
collectd-memcached/Makefile | 14 ++
collectd-mysql/DESCR | 1 +
collectd-mysql/Makefile | 15 ++
collectd-network/DESCR | 1 +
collectd-network/Makefile | 12 +
collectd-notify-email/DESCR | 1 +
collectd-notify-email/Makefile | 13 +
collectd-postgresql/DESCR | 1 +
collectd-postgresql/Makefile | 14 ++
collectd-riemann/DESCR | 1 +
collectd-riemann/Makefile | 13 +
collectd-rrdtool/DESCR | 1 +
collectd-rrdtool/Makefile | 14 ++
collectd-snmp/DESCR | 1 +
collectd-snmp/Makefile | 13 +
collectd-write_prometheus/DESCR | 1 +
collectd-write_prometheus/Makefile | 12 +
collectd/DESCR | 3 +
collectd/Makefile | 48 ++++
collectd/Makefile.common | 90 +++++++
collectd/PLIST | 88 +++++++
collectd/distinfo | 27 +++
collectd/files/collectd.sh | 26 ++
collectd/files/smf/manifest.xml | 29 +++
collectd/options.mk | 36 +++
collectd/patches/patch-Makefile.am | 46 ++++
collectd/patches/patch-configure.ac | 48 ++++
collectd/patches/patch-src_bind.c | 25 ++
collectd/patches/patch-src_collectd.conf.in | 106 +++++++++
collectd/patches/patch-src_cpu.c | 48 ++++
collectd/patches/patch-src_daemon_collectd.c | 14 ++
collectd/patches/patch-src_daemon_common.h | 17 ++
collectd/patches/patch-src_df.c | 21 ++
collectd/patches/patch-src_disk.c | 208 ++++++++++++++++
collectd/patches/patch-src_entropy.c | 109 +++++++++
collectd/patches/patch-src_irq.c | 101 ++++++++
.../patch-src_libcollectclient_network__buffer.c | 24 ++
collectd/patches/patch-src_lua.c | 47 ++++
collectd/patches/patch-src_memory.c | 126 ++++++++++
collectd/patches/patch-src_netstat__udp.c | 165 +++++++++++++
collectd/patches/patch-src_processes.c | 265 +++++++++++++++++++++
collectd/patches/patch-src_statsd.c | 19 ++
collectd/patches/patch-src_swap.c | 144 +++++++++++
collectd/patches/patch-src_tcpconns.c | 26 ++
collectd/patches/patch-src_utils__dns.c | 19 ++
.../patches/patch-src_utils__format__kairosdb.c | 19 ++
p5-collectd/DESCR | 1 +
p5-collectd/Makefile | 23 ++
py-collectd/DESCR | 1 +
py-collectd/Makefile | 15 ++
62 files changed, 2212 insertions(+)
diffs:
diff --git a/Makefile b/Makefile
index 60d9c40dbf..208d472c36 100644
--- a/Makefile
+++ b/Makefile
@@ -446,11 +446,26 @@ SUBDIR+= cm-unicode-ttf
SUBDIR+= cmetrics
SUBDIR+= coccigrep
SUBDIR+= coccinelle
+SUBDIR+= collectd
SUBDIR+= collectd-CGP
+SUBDIR+= collectd-amqp
+SUBDIR+= collectd-curl
+SUBDIR+= collectd-dbi
+SUBDIR+= collectd-dns
SUBDIR+= collectd-haproxy
+SUBDIR+= collectd-lua
+SUBDIR+= collectd-memcached
+SUBDIR+= collectd-mysql
+SUBDIR+= collectd-network
+SUBDIR+= collectd-notify-email
+SUBDIR+= collectd-postgresql
SUBDIR+= collectd-redis
+SUBDIR+= collectd-riemann
+SUBDIR+= collectd-rrdtool
+SUBDIR+= collectd-snmp
SUBDIR+= collectd-unbound
SUBDIR+= collectd-web
+SUBDIR+= collectd-write_prometheus
SUBDIR+= colm-devel
SUBDIR+= colobot
SUBDIR+= colord
@@ -2707,6 +2722,7 @@ SUBDIR+= p5-XML-DT
SUBDIR+= p5-XML-DTDParser
SUBDIR+= p5-XML-RSS-LibXML
SUBDIR+= p5-XML-Writer-Simple
+SUBDIR+= p5-collectd
SUBDIR+= p5-mha4mysql-manager
SUBDIR+= p5-mha4mysql-node
SUBDIR+= p5-mozldap
@@ -3190,6 +3206,7 @@ SUBDIR+= py-cocos2d
SUBDIR+= py-codecov
SUBDIR+= py-codepy
SUBDIR+= py-cogent
+SUBDIR+= py-collectd
SUBDIR+= py-colorlog
SUBDIR+= py-colormath
SUBDIR+= py-colorpy
diff --git a/collectd-amqp/DESCR b/collectd-amqp/DESCR
new file mode 100644
index 0000000000..a68f324e2c
--- /dev/null
+++ b/collectd-amqp/DESCR
@@ -0,0 +1 @@
+amqp plugin for collectd
diff --git a/collectd-amqp/Makefile b/collectd-amqp/Makefile
new file mode 100644
index 0000000000..8deae584ee
--- /dev/null
+++ b/collectd-amqp/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.6 2020/01/18 21:50:52 jperkin Exp $
+
+COLLECTD_PACKAGE= amqp
+
+COMMENT= Statistics collection daemon - amqp plugin
+PKGREVISION= 3
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-librabbitmq=${BUILDLINK_PREFIX.rabbitmq-c}
+
+.include "../../net/rabbitmq-c/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-curl/DESCR b/collectd-curl/DESCR
new file mode 100644
index 0000000000..d9f5fdb060
--- /dev/null
+++ b/collectd-curl/DESCR
@@ -0,0 +1,2 @@
+CURL-based plugins for collectd (curl, curl_json, curl_xml,
+apache, bind, nginx, write_http).
diff --git a/collectd-curl/Makefile b/collectd-curl/Makefile
new file mode 100644
index 0000000000..db293d5c09
--- /dev/null
+++ b/collectd-curl/Makefile
@@ -0,0 +1,18 @@
+# $NetBSD: Makefile,v 1.26 2020/06/02 08:24:44 adam Exp $
+
+COLLECTD_PACKAGE= curl
+COLLECTD_PLUGINS= curl curl_json curl_xml apache bind nginx write_http
+
+COMMENT= Statistics collection daemon - curl-based plugins
+PKGREVISION= 15
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libcurl=${BUILDLINK_PREFIX.curl}
+CONFIGURE_ARGS+= --with-libyajl=${BUILDLINK_PREFIX.yajl}
+
+.include "../../devel/yajl/buildlink3.mk"
+.include "../../textproc/libxml2/buildlink3.mk"
+.include "../../www/curl/buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-dbi/DESCR b/collectd-dbi/DESCR
new file mode 100644
index 0000000000..952e616801
--- /dev/null
+++ b/collectd-dbi/DESCR
@@ -0,0 +1 @@
+dbi plugin for collectd
diff --git a/collectd-dbi/Makefile b/collectd-dbi/Makefile
new file mode 100644
index 0000000000..5c8a1b9f35
--- /dev/null
+++ b/collectd-dbi/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.3 2019/08/11 13:23:04 wiz Exp $
+
+COLLECTD_PACKAGE= dbi
+
+COMMENT= Statistics collection daemon - dbi plugin
+PKGREVISION= 2
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libdbi=${BUILDLINK_PREFIX.libdbi}
+
+.include "../../databases/libdbi/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-dns/DESCR b/collectd-dns/DESCR
new file mode 100644
index 0000000000..70169d1b9f
--- /dev/null
+++ b/collectd-dns/DESCR
@@ -0,0 +1 @@
+dns plugin for collectd
diff --git a/collectd-dns/Makefile b/collectd-dns/Makefile
new file mode 100644
index 0000000000..190d543bb1
--- /dev/null
+++ b/collectd-dns/Makefile
@@ -0,0 +1,18 @@
+# $NetBSD: Makefile,v 1.5 2020/02/03 09:12:32 triaxx Exp $
+
+COLLECTD_PACKAGE= dns
+
+COMMENT= Statistics collection daemon - dns plugin
+PKGREVISION= 3
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libpcap=${BUILDLINK_PREFIX.libpcap}
+
+# On NetBSD, built-in pcap lacks headers needed
+.if ${OPSYS} == "NetBSD"
+PREFER.libpcap= pkgsrc
+.endif
+
+.include "../../net/libpcap/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-lua/DESCR b/collectd-lua/DESCR
new file mode 100644
index 0000000000..d56f91dfad
--- /dev/null
+++ b/collectd-lua/DESCR
@@ -0,0 +1 @@
+lua plugin for collectd
diff --git a/collectd-lua/Makefile b/collectd-lua/Makefile
new file mode 100644
index 0000000000..bc82242cc7
--- /dev/null
+++ b/collectd-lua/Makefile
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.3 2019/08/11 13:23:04 wiz Exp $
+
+COLLECTD_PACKAGE= lua
+COLLECTD_PLUGINS= lua
+
+COMMENT= Statistics collection daemon - lua plugin
+PKGREVISION= 2
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --enable-lua
+
+.include "../../lang/lua/module.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-memcached/DESCR b/collectd-memcached/DESCR
new file mode 100644
index 0000000000..94f6c5c92d
--- /dev/null
+++ b/collectd-memcached/DESCR
@@ -0,0 +1 @@
+memcached plugin for collectd
diff --git a/collectd-memcached/Makefile b/collectd-memcached/Makefile
new file mode 100644
index 0000000000..3ee3492c71
--- /dev/null
+++ b/collectd-memcached/Makefile
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.3 2019/08/11 13:23:05 wiz Exp $
+
+COLLECTD_PACKAGE= memcached
+COLLECTD_PLUGINS= memcachec memcached
+
+COMMENT= Statistics collection daemon - memcached plugins
+PKGREVISION= 2
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libmemcached=${BUILDLINK_PREFIX.libmemcached}
+
+.include "../../devel/libmemcached/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-mysql/DESCR b/collectd-mysql/DESCR
new file mode 100644
index 0000000000..c2c6232d03
--- /dev/null
+++ b/collectd-mysql/DESCR
@@ -0,0 +1 @@
+mysql plugin for collectd
diff --git a/collectd-mysql/Makefile b/collectd-mysql/Makefile
new file mode 100644
index 0000000000..8858b0a6a2
--- /dev/null
+++ b/collectd-mysql/Makefile
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.3 2019/08/11 13:23:05 wiz Exp $
+
+COLLECTD_PACKAGE= mysql
+
+PKGNAME= ${DISTNAME:S/collectd/collectd-${COLLECTD_PACKAGE}${MYSQL_VERSION}/}
+PKGREVISION= 2
+COMMENT= Statistics collection daemon - mysql plugin
+
+.include "../../sysutils/collectd/Makefile.common"
+
+
+CONFIGURE_ARGS+= --with-libmysql=${BUILDLINK_PREFIX.mysql-client}
+
+.include "../../mk/mysql.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-network/DESCR b/collectd-network/DESCR
new file mode 100644
index 0000000000..796cb01cba
--- /dev/null
+++ b/collectd-network/DESCR
@@ -0,0 +1 @@
+network plugin for collectd
diff --git a/collectd-network/Makefile b/collectd-network/Makefile
new file mode 100644
index 0000000000..ccd7fb5976
--- /dev/null
+++ b/collectd-network/Makefile
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.3 2017/06/14 13:42:53 fhajny Exp $
+
+COLLECTD_PACKAGE= network
+
+COMMENT= Statistics collection daemon - network plugin
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libgcrypt=${BUILDLINK_PREFIX.libgcrypt}/bin/libgcrypt-config
+
+.include "../../security/libgcrypt/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-notify-email/DESCR b/collectd-notify-email/DESCR
new file mode 100644
index 0000000000..05cd73581a
--- /dev/null
+++ b/collectd-notify-email/DESCR
@@ -0,0 +1 @@
+notify-email plugin for collectd
diff --git a/collectd-notify-email/Makefile b/collectd-notify-email/Makefile
new file mode 100644
index 0000000000..582630580e
--- /dev/null
+++ b/collectd-notify-email/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.6 2020/01/18 21:50:53 jperkin Exp $
+
+COLLECTD_PACKAGE= notify-email
+
+COMMENT= Statistics collection daemon - notify_email plugin
+PKGREVISION= 3
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libesmtp=${BUILDLINK_PREFIX.libesmtp}
+
+.include "../../mail/libesmtp/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-postgresql/DESCR b/collectd-postgresql/DESCR
new file mode 100644
index 0000000000..cd20e2db83
--- /dev/null
+++ b/collectd-postgresql/DESCR
@@ -0,0 +1 @@
+postgresql plugin for collectd
diff --git a/collectd-postgresql/Makefile b/collectd-postgresql/Makefile
new file mode 100644
index 0000000000..3d19dd049a
--- /dev/null
+++ b/collectd-postgresql/Makefile
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.7 2019/08/11 13:23:05 wiz Exp $
+
+COLLECTD_PACKAGE= postgresql
+
+PKGNAME= ${DISTNAME:S/collectd/collectd-${COLLECTD_PACKAGE}${PGSQL_VERSION}/}
+PKGREVISION= 2
+COMMENT= Statistics collection daemon - postgresql plugin
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libpq=${PGSQL_PREFIX}
+
+.include "../../mk/pgsql.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-riemann/DESCR b/collectd-riemann/DESCR
new file mode 100644
index 0000000000..6eae0841a9
--- /dev/null
+++ b/collectd-riemann/DESCR
@@ -0,0 +1 @@
+riemann output plugin for collectd
diff --git a/collectd-riemann/Makefile b/collectd-riemann/Makefile
new file mode 100644
index 0000000000..5a630f649e
--- /dev/null
+++ b/collectd-riemann/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.9 2020/05/22 10:56:39 adam Exp $
+
+COLLECTD_PACKAGE= riemann
+COLLECTD_PLUGINS= write_riemann
+
+COMMENT= Statistics collection daemon - riemann plugin
+PKGREVISION= 7
+
+.include "../../sysutils/collectd/Makefile.common"
+
+.include "../../devel/protobuf-c/buildlink3.mk"
+.include "../../sysutils/riemann-client/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-rrdtool/DESCR b/collectd-rrdtool/DESCR
new file mode 100644
index 0000000000..cbe65e7c90
--- /dev/null
+++ b/collectd-rrdtool/DESCR
@@ -0,0 +1 @@
+rrdtool plugin for collectd
diff --git a/collectd-rrdtool/Makefile b/collectd-rrdtool/Makefile
new file mode 100644
index 0000000000..598fb67ba5
--- /dev/null
+++ b/collectd-rrdtool/Makefile
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.17 2020/06/02 08:24:44 adam Exp $
+
+COLLECTD_PACKAGE= rrdtool
+COLLECTD_PLUGINS= rrdtool rrdcached
+
+COMMENT= Statistics collection daemon - rrdtool plugins
+PKGREVISION= 9
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-librrd=${BUILDLINK_PREFIX.rrdtool}
+
+.include "../../databases/rrdtool/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-snmp/DESCR b/collectd-snmp/DESCR
new file mode 100644
index 0000000000..455fd44e66
--- /dev/null
+++ b/collectd-snmp/DESCR
@@ -0,0 +1 @@
+snmp plugin for collectd
diff --git a/collectd-snmp/Makefile b/collectd-snmp/Makefile
new file mode 100644
index 0000000000..72d7848b32
--- /dev/null
+++ b/collectd-snmp/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.6 2020/01/18 21:50:53 jperkin Exp $
+
+COLLECTD_PACKAGE= snmp
+
+COMMENT= Statistics collection daemon - snmp plugin
+PKGREVISION= 3
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --with-libnetsnmp=${BUILDLINK_PREFIX.net-snmp}/bin/net-snmp-config
+
+.include "../../net/net-snmp/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-write_prometheus/DESCR b/collectd-write_prometheus/DESCR
new file mode 100644
index 0000000000..4c7c823f36
--- /dev/null
+++ b/collectd-write_prometheus/DESCR
@@ -0,0 +1 @@
+write_prometheus plugin for collectd
diff --git a/collectd-write_prometheus/Makefile b/collectd-write_prometheus/Makefile
new file mode 100644
index 0000000000..d458301815
--- /dev/null
+++ b/collectd-write_prometheus/Makefile
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.8 2020/05/22 10:56:39 adam Exp $
+
+COLLECTD_PACKAGE= write_prometheus
+
+COMMENT= Statistics collection daemon - write_prometheus plugin
+PKGREVISION= 7
+
+.include "../../sysutils/collectd/Makefile.common"
+
+.include "../../devel/protobuf-c/buildlink3.mk"
+.include "../../www/libmicrohttpd/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd/DESCR b/collectd/DESCR
new file mode 100644
index 0000000000..2fea573116
--- /dev/null
+++ b/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/collectd/Makefile b/collectd/Makefile
new file mode 100644
index 0000000000..caca53e33a
--- /dev/null
+++ b/collectd/Makefile
@@ -0,0 +1,48 @@
+# $NetBSD: Makefile,v 1.26 2020/07/05 13:57:32 he Exp $
+
+.include "../../sysutils/collectd/Makefile.common"
+
+PKGREVISION= 4
+
+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
+
+INSTALL_MAKE_FLAGS+= sysconfdir=${PREFIX}/share/examples/collectd
+
+.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/collectd/Makefile.common b/collectd/Makefile.common
new file mode 100644
index 0000000000..f705923bc7
--- /dev/null
+++ b/collectd/Makefile.common
@@ -0,0 +1,90 @@
+# $NetBSD: Makefile.common,v 1.24 2020/06/02 11:12:05 nia 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/collectd-write_prometheus/Makefile
+# used by sysutils/p5-collectd/Makefile
+# used by sysutils/py-collectd/Makefile
+
+DISTNAME= collectd-5.8.0
+MASTER_SITES= http://collectd.org/files/
+CATEGORIES= sysutils
+EXTRACT_SUFX= .tar.bz2
+EXTRACT_USING= bsdtar
+
+MAINTAINER= pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE= https://collectd.org/
+LICENSE= gnu-gpl-v2
+
+GNU_CONFIGURE= yes
+USE_LIBTOOL= yes
+USE_TOOLS+= autoconf automake 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_TARGET= ${COLLECTD_PLUGINS:S/$/.la/}
+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+= --disable-werror
+CONFIGURE_ARGS+= --localstatedir=${VARBASE}
+CONFIGURE_ARGS+= --with-ltdl-lib=${BUILDLINK_PREFIX.libltdl}/lib
+CONFIGURE_ARGS+= --with-ltdl-include=${BUILDLINK_PREFIX.libltdl}/include
+
+CONFIGURE_ARGS.NetBSD+= ac_cv_func_getfsstat=no
+# aarch64 accidentally had this function for a bit.
+CONFIGURE_ARGS.NetBSD+= c_cv_have_htonll=no
+
+CPPFLAGS.SunOS+= -DSOLARIS2=${OS_VERSION:C/5.//}
+
+SUBST_CLASSES+= ver
+SUBST_MESSAGE.ver= Fixing canonical version number
+SUBST_STAGE.ver= pre-configure
+SUBST_FILES.ver= configure.ac
+SUBST_SED.ver= -e 's,m4_esyscmd(./version-gen.sh),${PKGVERSION_NOREV},'
+
+pre-configure:
+ cd ${WRKSRC} && autoreconf
+
+.include "../../devel/libltdl/buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
diff --git a/collectd/PLIST b/collectd/PLIST
new file mode 100644
index 0000000000..5bf745064c
--- /dev/null
+++ b/collectd/PLIST
@@ -0,0 +1,88 @@
+@comment $NetBSD: PLIST,v 1.8 2017/11/21 15:18:22 fhajny 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
+include/collectd/network_parse.h
+include/collectd/server.h
+include/collectd/types.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.df}lib/collectd/df.la
+${PLIST.disk}lib/collectd/disk.la
+lib/collectd/email.la
+${PLIST.entropy}lib/collectd/entropy.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
+${PLIST.tcpconns}lib/collectd/tcpconns.la
+lib/collectd/teamspeak2.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
+${PLIST.zone}lib/collectd/zone.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-lua.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/collectd/distinfo b/collectd/distinfo
new file mode 100644
index 0000000000..50b0f29b93
--- /dev/null
+++ b/collectd/distinfo
@@ -0,0 +1,27 @@
+$NetBSD: distinfo,v 1.45 2020/07/05 13:57:32 he Exp $
+
+SHA1 (collectd-5.8.0.tar.bz2) = eb3567563de471e1950b7388e8883b911be3756a
+RMD160 (collectd-5.8.0.tar.bz2) = 7b812b1046d57a9047213bb182b8744d98606547
+SHA512 (collectd-5.8.0.tar.bz2) = 1b3d0cc44e2ca54e13eebf292074f1efa8b33d6800d04405e0eaaa2dd1cb2416c6eae580729fb5aead23a5039f41ffe8a9989a907a8c18be8f867f1099fc0008
+Size (collectd-5.8.0.tar.bz2) = 1686017 bytes
+SHA1 (patch-Makefile.am) = 0fb4b20d995cd63943b8a826cc166db1b4f36132
+SHA1 (patch-configure.ac) = a98505a285635e54810597604c610541f4cdb5e3
+SHA1 (patch-src_bind.c) = 4aa7742c8e24ee6bd7293abc56fc95a605d0a2c7
+SHA1 (patch-src_collectd.conf.in) = f0b35085cf0ddfd766e140b145177ab1f1326f5f
+SHA1 (patch-src_cpu.c) = e645ae6b05c051c3c878f88a493fbbd7d548bb66
+SHA1 (patch-src_daemon_collectd.c) = 155da2fde889e961719fe6be47aa7fc25199fbe7
+SHA1 (patch-src_daemon_common.h) = d1ef6a5257156a864bf896629870f0f83a858cff
+SHA1 (patch-src_df.c) = 5c6549cd9ec72efed5cdb7d8dd9297c50491426e
+SHA1 (patch-src_disk.c) = 6b51454f88ef728abd22cdae5fdd7a81289d502c
+SHA1 (patch-src_entropy.c) = f20ad4ce2e968ba0b20bb13aa00771fc424562fd
+SHA1 (patch-src_irq.c) = 18106e9051ec344b0d45a23814eae5ba3be2f908
+SHA1 (patch-src_libcollectclient_network__buffer.c) = a19e1658017279c35fd9860e2ab855081bad8327
+SHA1 (patch-src_lua.c) = 656934889976f489abb80a8244492f845a3bd9f8
+SHA1 (patch-src_memory.c) = 3276b09d0c09e0a9446519bd6c304d95c30b617a
+SHA1 (patch-src_netstat__udp.c) = 30cb12d25f56c60959658dbd181783212e00cc61
+SHA1 (patch-src_processes.c) = a22b1e9d7935c7924b65c57990b4212990acc6b7
+SHA1 (patch-src_statsd.c) = 35f4349d2d2c9bddc0f4770344f969157cd012f6
+SHA1 (patch-src_swap.c) = 98984dc7c6eee4f17b2f291124431172b06aa6c2
+SHA1 (patch-src_tcpconns.c) = 0469ffe477ae96a79e4fd28c4428a1e7682e9461
+SHA1 (patch-src_utils__dns.c) = 68c34489f3c8dca4a57035df9a38076bf35f7c5f
+SHA1 (patch-src_utils__format__kairosdb.c) = 2f7bde47682d2b877f9bd2d2c794a21c297aa9e5
diff --git a/collectd/files/collectd.sh b/collectd/files/collectd.sh
new file mode 100644
index 0000000000..5c7b3b4862
--- /dev/null
+++ b/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/collectd/files/smf/manifest.xml b/collectd/files/smf/manifest.xml
new file mode 100644
index 0000000000..b145e24081
--- /dev/null
+++ b/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/collectd/options.mk b/collectd/options.mk
new file mode 100644
index 0000000000..e43564771f
--- /dev/null
+++ b/collectd/options.mk
@@ -0,0 +1,36 @@
+# $NetBSD: options.mk,v 1.11 2017/11/21 16:02:20 he 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+= swap tcpconns users processes
+PKG_SUGGESTED_OPTIONS.NetBSD+= contextswitch disk entropy irq pf netstat_udp
+PKG_SUGGESTED_OPTIONS.NetBSD+= swap tcpconns users processes
+
+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 zone
+PKG_SUGGESTED_OPTIONS.SunOS+= disk nfs swap users zfs-arc zone
+
+.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 zone
+
+.for option in ${PLIST_VARS}
+. if !empty(PKG_OPTIONS:M${option})
+CONFIGURE_ARGS+= --enable-${option:S/-/_/}
+PLIST.${option}= yes
+. endif
+.endfor
diff --git a/collectd/patches/patch-Makefile.am b/collectd/patches/patch-Makefile.am
new file mode 100644
index 0000000000..b3ad78a069
--- /dev/null
+++ b/collectd/patches/patch-Makefile.am
@@ -0,0 +1,46 @@
+$NetBSD: patch-Makefile.am,v 1.3 2018/01/04 15:42:42 jperkin Exp $
+
+Use other data directory.
+
+--- Makefile.am.orig 2017-11-18 09:03:27.326751649 +0000
++++ Makefile.am
+@@ -165,7 +165,7 @@ AM_CPPFLAGS = \
+ -DPREFIX='"${prefix}"' \
+ -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"' \
+ -DLOCALSTATEDIR='"${localstatedir}"' \
+- -DPKGLOCALSTATEDIR='"${localstatedir}/lib/${PACKAGE_NAME}"' \
++ -DPKGLOCALSTATEDIR='"${localstatedir}/db/${PACKAGE_NAME}"' \
+ -DPLUGINDIR='"${pkglibdir}"' \
+ -DPKGDATADIR='"${pkgdatadir}"'
+
+@@ -1205,6 +1205,12 @@ netlink_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ netlink_la_LIBADD = $(BUILD_WITH_LIBMNL_LIBS)
+ endif
+
++if BUILD_PLUGIN_NETSTAT_UDP
++pkglib_LTLIBRARIES += netstat_udp.la
++netstat_udp_la_SOURCES = src/netstat_udp.c
++netstat_udp_la_LDFLAGS = $(PLUGIN_LDFLAGS)
++endif
++
+ if BUILD_PLUGIN_NETWORK
+ pkglib_LTLIBRARIES += network.la
+ network_la_SOURCES = \
+@@ -1942,6 +1948,8 @@ endif
+ if BUILD_PLUGIN_WRITE_PROMETHEUS
+ BUILT_SOURCES += prometheus.pb-c.c prometheus.pb-c.h
+
++src/write_prometheus.c: prometheus.pb-c.h
++
+ prometheus.pb-c.c prometheus.pb-c.h: $(srcdir)/proto/prometheus.proto
+ $(AM_V_PROTOC_C)$(PROTOC_C) -I$(srcdir)/proto --c_out=$(builddir) $(srcdir)/proto/prometheus.proto
+ endif
+@@ -1964,7 +1972,7 @@ endif
+
+ install-exec-hook:
+ $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run
+- $(mkinstalldirs) $(DESTDIR)$(localstatedir)/lib/$(PACKAGE_NAME)
++ $(mkinstalldirs) $(DESTDIR)$(localstatedir)/db/$(PACKAGE_NAME)
+ $(mkinstalldirs) $(DESTDIR)$(localstatedir)/log
+ $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
+ if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \
diff --git a/collectd/patches/patch-configure.ac b/collectd/patches/patch-configure.ac
new file mode 100644
index 0000000000..bc95f4e66c
--- /dev/null
+++ b/collectd/patches/patch-configure.ac
@@ -0,0 +1,48 @@
+$NetBSD: patch-configure.ac,v 1.12 2020/03/19 06:26:26 rillig 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 2017-11-18 09:03:27.330751467 +0000
++++ configure.ac
+@@ -110,6 +110,7 @@ AM_CONDITIONAL([BUILD_DARWIN], [test "x$
+ AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"])
+ AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
+ AM_CONDITIONAL([BUILD_OPENBSD], [test "x$ac_system" = "xOpenBSD"])
++AM_CONDITIONAL([BUILD_NETBSD], [test "x$ac_system" = "xNetBSD"])
+ AM_CONDITIONAL([BUILD_SOLARIS], [test "x$ac_system" = "xSolaris"])
+
+ if test "x$ac_system" = "xSolaris"; then
+@@ -6136,6 +6137,7 @@ plugin_log_logstash="no"
+ plugin_mcelog="no"
+ plugin_memory="no"
+ plugin_multimeter="no"
++plugin_netstat_udp="no"
+ plugin_nfs="no"
+ plugin_numa="no"
+ plugin_ovs_events="no"
+@@ -6229,6 +6231,7 @@ if test "x$ac_system" = "xNetBSD"; then
+ plugin_entropy="yes"
+ plugin_irq="yes"
+ plugin_processes="yes"
++ plugin_netstat_udp="yes"
+ fi
+
+ # Mac OS X devices
+@@ -6568,6 +6571,7 @@ AC_PLUGIN([multimeter], [$plugi
+ 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])
+@@ -6987,6 +6991,7 @@ AC_MSG_RESULT([ multimeter . . . . .
+ AC_MSG_RESULT([ mysql . . . . . . . . $enable_mysql])
+ AC_MSG_RESULT([ netapp . . . . . . . $enable_netapp])
+ AC_MSG_RESULT([ netlink . . . . . . . $enable_netlink])
++AC_MSG_RESULT([ netstat_udp . . . . . $enable_netstat_udp])
+ AC_MSG_RESULT([ network . . . . . . . $enable_network])
+ AC_MSG_RESULT([ nfs . . . . . . . . . $enable_nfs])
+ AC_MSG_RESULT([ nginx . . . . . . . . $enable_nginx])
diff --git a/collectd/patches/patch-src_bind.c b/collectd/patches/patch-src_bind.c
new file mode 100644
index 0000000000..6edf2ae0dc
--- /dev/null
+++ b/collectd/patches/patch-src_bind.c
@@ -0,0 +1,25 @@
+$NetBSD: patch-src_bind.c,v 1.1 2020/07/05 13:57:32 he Exp $
+
+Also pick out the response time bins from the resolver stats.
+
+--- src/bind.c.orig 2017-11-18 09:03:27.000000000 +0000
++++ src/bind.c
+@@ -228,7 +228,17 @@ static const translation_info_t resstats
+ {"ValAttempt", "dns_resolver", "DNSSEC-attempt"},
+ {"ValOk", "dns_resolver", "DNSSEC-okay"},
+ {"ValNegOk", "dns_resolver", "DNSSEC-negokay"},
+- {"ValFail", "dns_resolver", "DNSSEC-fail"}};
++ {"ValFail", "dns_resolver", "DNSSEC-fail"},
++
++ /* Query RTT information */
++ {"QryRTT10", "dns_resolver", "rtt10"},
++ {"QryRTT100", "dns_resolver", "rtt100"},
++ {"QryRTT500", "dns_resolver", "rtt500"},
++ {"QryRTT800", "dns_resolver", "rtt800"},
++ {"QryRTT1600", "dns_resolver", "rtt1600"},
++ {"QryRTT1600+", "dns_resolver", "rtt1600plus"}
++};
++
+ static int resstats_translation_table_length =
+ STATIC_ARRAY_SIZE(resstats_translation_table);
+ /* }}} */
diff --git a/collectd/patches/patch-src_collectd.conf.in b/collectd/patches/patch-src_collectd.conf.in
new file mode 100644
index 0000000000..8081b1e051
--- /dev/null
+++ b/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/collectd/patches/patch-src_cpu.c b/collectd/patches/patch-src_cpu.c
new file mode 100644
index 0000000000..8773e6c735
--- /dev/null
+++ b/collectd/patches/patch-src_cpu.c
@@ -0,0 +1,48 @@
+$NetBSD: patch-src_cpu.c,v 1.3 2016/12/07 17:28:39 fhajny Exp $
+
+Port this too to NetBSD.
+
+--- src/cpu.c.orig 2016-11-30 08:52:01.308911943 +0000
++++ src/cpu.c
+@@ -81,7 +81,7 @@
+
+ #if HAVE_SYSCTL
+ #if defined(CTL_HW) && defined(HW_NCPU) && defined(CTL_KERN) && \
+- defined(KERN_CPTIME) && defined(CPUSTATES)
++ (defined(KERN_CPTIME) || defined(KERN_CP_TIME)) && defined(CPUSTATES)
+ #define CAN_USE_SYSCTL 1
+ #else
+ #define CAN_USE_SYSCTL 0
+@@ -673,6 +673,24 @@ static int cpu_read(void) {
+
+ memset(cpuinfo, 0, sizeof(cpuinfo));
+
++#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 (int i = 0; i < numcpu; i++) {
+@@ -710,6 +728,7 @@ static int cpu_read(void) {
+ cpuinfo[0][i] = cpuinfo_tmp[i];
+ }
+ }
++#endif /* defined(KERN_CP_TIME) && defined(KERNEL_NETBSD) */
+
+ for (int i = 0; i < numcpu; i++) {
+ cpu_stage(i, COLLECTD_CPU_STATE_USER, (derive_t)cpuinfo[i][CP_USER], now);
diff --git a/collectd/patches/patch-src_daemon_collectd.c b/collectd/patches/patch-src_daemon_collectd.c
new file mode 100644
index 0000000000..9fdb225bd1
--- /dev/null
+++ b/collectd/patches/patch-src_daemon_collectd.c
@@ -0,0 +1,14 @@
+$NetBSD: patch-src_daemon_collectd.c,v 1.1 2017/11/21 15:18:23 fhajny Exp $
+
+Fix missing declaration.
+
+--- src/daemon/collectd.c.orig 2017-11-18 09:03:27.350750556 +0000
++++ src/daemon/collectd.c
+@@ -208,6 +208,7 @@ static int change_basedir(const char *or
+ } /* static int change_basedir (char *dir) */
+
+ #if HAVE_LIBKSTAT
++extern kstat_ctl_t *kc;
+ static void update_kstat(void) {
+ if (kc == NULL) {
+ if ((kc = kstat_open()) == NULL)
diff --git a/collectd/patches/patch-src_daemon_common.h b/collectd/patches/patch-src_daemon_common.h
new file mode 100644
index 0000000000..d2fe6debd3
--- /dev/null
+++ b/collectd/patches/patch-src_daemon_common.h
@@ -0,0 +1,17 @@
+$NetBSD: patch-src_daemon_common.h,v 1.1 2017/11/21 15:18:23 fhajny Exp $
+
+Need kstat.h if available.
+
+--- src/daemon/common.h.orig 2017-11-18 09:03:27.350750556 +0000
++++ src/daemon/common.h
+@@ -32,6 +32,10 @@
+
+ #include "plugin.h"
+
++#if HAVE_KSTAT_H
++#include <kstat.h>
++#endif
++
+ #if HAVE_PWD_H
+ #include <pwd.h>
+ #endif
diff --git a/collectd/patches/patch-src_df.c b/collectd/patches/patch-src_df.c
new file mode 100644
index 0000000000..d2dcc3c169
--- /dev/null
+++ b/collectd/patches/patch-src_df.c
@@ -0,0 +1,21 @@
+$NetBSD: patch-src_df.c,v 1.5 2016/12/07 17:28:39 fhajny Exp $
+
+Older NetBSD doesn't have float_t.
+
+--- src/df.c.orig 2016-11-30 08:52:01.312911569 +0000
++++ src/df.c
+@@ -28,6 +28,14 @@
+ #include "utils_ignorelist.h"
+ #include "utils_mount.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/collectd/patches/patch-src_disk.c b/collectd/patches/patch-src_disk.c
new file mode 100644
index 0000000000..450b65dab4
--- /dev/null
+++ b/collectd/patches/patch-src_disk.c
@@ -0,0 +1,208 @@
+$NetBSD: patch-src_disk.c,v 1.3 2017/11/21 15:18:23 fhajny Exp $
+
+Provide a port to NetBSD.
+
+--- src/disk.c.orig 2017-11-18 09:03:27.354750373 +0000
++++ src/disk.c
+@@ -135,6 +135,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
+@@ -253,7 +282,33 @@ static int disk_init(void) {
+ continue;
+ ksp[numdisk++] = ksp_chain;
+ }
+-#endif /* HAVE_LIBKSTAT */
++/* #endif HAVE_LIBKSTAT */
++
++#elif HAVE_SYSCTL && KERNEL_NETBSD
++ int mib[3];
++ size_t size;
++
++ /* figure out number of drives */
++ mib[0] = CTL_HW;
++ mib[1] = HW_IOSTATS;
++ mib[2] = sizeof(struct io_sysctl);
++ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1) {
++ ERROR ("disk plugin: sysctl for ndrives failed");
++ return -1;
++ }
++ ndrive = size / sizeof(struct io_sysctl);
++
++ if (size == 0 ) {
++ ERROR ("disk plugin: no drives found");
++ return -1;
++ }
++ drives = (struct io_sysctl *)malloc(size);
++ if (drives == NULL) {
++ ERROR ("disk plugin: memory allocation failure");
++ return -1;
++ }
++
++#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
+
+ return 0;
+ } /* int disk_init */
+@@ -1017,7 +1072,129 @@ static int disk_read(void) {
+ 1000000.0;
+ disk_submit(stat_disk[i].name, "disk_time", read_time, write_time);
+ }
+-#endif /* defined(HAVE_PERFSTAT) */
++/* #endif defined(HAVE_PERFSTAT) */
++
++#elif HAVE_SYSCTL && KERNEL_NETBSD
++ int mib[3];
++ size_t size, i, nndrive;
++ diskstats_t *ds, *pre_ds;
++ char *output_name;
++
++ u_int64_t ops;
++ u_int64_t delta_t;
++
++ /* figure out number of drives */
++ mib[0] = CTL_HW;
++ mib[1] = HW_IOSTATS;
++ mib[2] = sizeof(struct io_sysctl);
++ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1) {
++ ERROR ("disk plugin: sysctl for ndrives failed");
++ return -1;
++ }
++ nndrive = size / sizeof(struct io_sysctl);
++
++ if (size == 0 ) {
++ ERROR ("disk plugin: no drives found");
++ return -1;
++ }
++ /* number of drives changed, reallocate buffer */
++ if (nndrive != ndrive) {
++ drives = (struct io_sysctl *)realloc(drives, size);
++ if (drives == NULL) {
++ ERROR ("disk plugin: memory allocation failure");
++ return -1;
++ }
++ ndrive = nndrive;
++ }
++
++ /* get stats for all drives */
++ mib[0] = CTL_HW;
++ mib[1] = HW_IOSTATS;
++ mib[2] = sizeof(struct io_sysctl);
++ if (sysctl(mib, 3, drives, &size, NULL, 0) == -1) {
++ ERROR ("disk plugin: sysctl for drive stats failed");
++ return -1;
++ }
++
++ for (i = 0; i < ndrive; i++) {
++
++ if (drives[i].type != IOSTAT_DISK)
++ continue;
++
++ /* find drive stats, if present */
++ for (ds = disklist, pre_ds = disklist;
++ ds != NULL;
++ pre_ds = ds, ds = ds->next) {
++ if (strcmp (drives[i].name, ds->name) == 0)
++ break;
++ }
++ if (ds == NULL) { /* not found; allocate & link in */
++ if ((ds = calloc(1, sizeof(diskstats_t))) == NULL)
++ continue;
++ if ((ds->name = strdup(drives[i].name)) == NULL) {
++ free(ds);
++ continue;
++ }
++ if (pre_ds == NULL)
++ disklist = ds;
++ else
++ pre_ds->next = ds;
++ }
++
++ ds->poll_count++;
++ if (ds->poll_count <= 2)
++ {
++ DEBUG ("disk plugin: (ds->poll_count = %i) <= "
++ "(min_poll_count = 2); => Not writing.",
++ ds->poll_count);
++ ds->stats = drives[i]; /* but save base values */
++ continue;
++ }
++ ds->read_ops = drives[i].rxfer - ds->stats.rxfer;
++ ds->write_ops = drives[i].wxfer - ds->stats.wxfer;
++ ds->read_bytes = drives[i].rbytes - ds->stats.rbytes;
++ ds->write_bytes = drives[i].wbytes - ds->stats.wbytes;
++
++ /* Need this dance because of unsigned values... */
++ if (drives[i].time_usec < ds->stats.time_usec) {
++ delta_t = ((drives[i].time_sec - 1 -
++ ds->stats.time_sec) * 1000) +
++ ((drives[i].time_usec + 1000000 -
++ ds->stats.time_usec) / 1000);
++ } else {
++ delta_t = ((drives[i].time_sec -
++ ds->stats.time_sec) * 1000) +
++ ((drives[i].time_usec -
++ ds->stats.time_usec) / 1000);
++ }
++
++ ops = ds->read_ops + ds->write_ops;
++ if (ops == 0) {
++ DEBUG ("disk plugin: read + write ops == 0, "
++ "not writing");
++ continue;
++ }
++
++ ds->avg_io_time = delta_t / ops;
++
++ output_name = drives[i].name;
++
++ if ((ds->read_bytes != 0) || (ds->write_bytes != 0))
++ disk_submit (output_name, "disk_octets",
++ ds->read_bytes, ds->write_bytes);
++
++ if ((ds->read_ops != 0) || (ds->write_ops != 0))
++ disk_submit (output_name, "disk_ops",
++ ds->read_ops, ds->write_ops);
++
++ if (ds->avg_io_time != 0)
++ disk_submit (output_name, "disk_time",
++ ds->avg_io_time, ds->avg_io_time);
++
++ ds->stats = drives[i];
++ }
++
++#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
+
+ return 0;
+ } /* int disk_read */
diff --git a/collectd/patches/patch-src_entropy.c b/collectd/patches/patch-src_entropy.c
new file mode 100644
index 0000000000..16106cfa95
--- /dev/null
+++ b/collectd/patches/patch-src_entropy.c
@@ -0,0 +1,109 @@
+$NetBSD: patch-src_entropy.c,v 1.10 2017/11/21 15:18:23 fhajny Exp $
+
+Provide a NetBSD implementation for graphing available entropy.
+This version tries to keep /dev/urandom open (for repeated use),
+instead of constantly re-opening/closing it, since the latter will
+needlessly reduce the kernel's entropy estimate.
+
+--- src/entropy.c.orig 2017-11-18 09:03:27.354750373 +0000
++++ src/entropy.c
+@@ -29,23 +29,16 @@
+ #include "common.h"
+ #include "plugin.h"
+
+-#if !KERNEL_LINUX
++static void entropy_submit (value_t);
++static int entropy_read (void);
++
++#if !KERNEL_LINUX && !KERNEL_NETBSD
+ #error "No applicable input method."
+ #endif
+
++#if KERNEL_LINUX
+ #define ENTROPY_FILE "/proc/sys/kernel/random/entropy_avail"
+
+-static void entropy_submit(value_t value) {
+- value_list_t vl = VALUE_LIST_INIT;
+-
+- vl.values = &value;
+- vl.values_len = 1;
+- sstrncpy(vl.plugin, "entropy", sizeof(vl.plugin));
+- sstrncpy(vl.type, "entropy", sizeof(vl.type));
+-
+- plugin_dispatch_values(&vl);
+-}
+-
+ static int entropy_read(void) {
+ value_t v;
+ if (parse_value_file(ENTROPY_FILE, &v, DS_TYPE_GAUGE) != 0) {
+@@ -56,6 +49,70 @@ static int entropy_read(void) {
+ entropy_submit(v);
+ 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)
++{
++ value_t v;
++ rndpoolstat_t rs;
++ static int fd;
++ char buf[30];
++
++ 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;
++ }
++ snprintf(buf, sizeof(buf), "%ju", (uintmax_t)rs.curentropy);
++ if (parse_value(buf, &v, DS_TYPE_GAUGE) != 0) {
++ ERROR("entropy plugin: Parsing \"%s\" failed.", buf);
++ return (-1);
++ }
++
++ entropy_submit (v);
++
++ return 0;
++}
++
++#endif /* KERNEL_NETBSD */
++
++static void entropy_submit(value_t value) {
++ value_list_t vl = VALUE_LIST_INIT;
++
++ vl.values = &value;
++ vl.values_len = 1;
++ sstrncpy(vl.plugin, "entropy", sizeof(vl.plugin));
++ sstrncpy(vl.type, "entropy", sizeof(vl.type));
++
++ plugin_dispatch_values(&vl);
++}
+
+ void module_register(void) {
+ plugin_register_read("entropy", entropy_read);
diff --git a/collectd/patches/patch-src_irq.c b/collectd/patches/patch-src_irq.c
new file mode 100644
index 0000000000..79634a5d80
--- /dev/null
+++ b/collectd/patches/patch-src_irq.c
@@ -0,0 +1,101 @@
+$NetBSD: patch-src_irq.c,v 1.5 2017/11/21 15:18:23 fhajny Exp $
+
+Provide a port to NetBSD.
+
+--- src/irq.c.orig 2017-11-18 09:03:27.354750373 +0000
++++ src/irq.c
+@@ -27,10 +27,20 @@
+ #include "plugin.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
+ */
+@@ -75,6 +85,7 @@ static void irq_submit(const char *irq_n
+ plugin_dispatch_values(&vl);
+ } /* void irq_submit */
+
++#if KERNEL_LINUX
+ static int irq_read(void) {
+ FILE *fh;
+ char buffer[1024];
+@@ -167,6 +178,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) {
+ plugin_register_config("irq", irq_config, config_keys, config_keys_num);
diff --git a/collectd/patches/patch-src_libcollectclient_network__buffer.c b/collectd/patches/patch-src_libcollectclient_network__buffer.c
new file mode 100644
index 0000000000..92db7ddf01
--- /dev/null
+++ b/collectd/patches/patch-src_libcollectclient_network__buffer.c
@@ -0,0 +1,24 @@
+$NetBSD: patch-src_libcollectclient_network__buffer.c,v 1.4 2017/11/21 15:18:23 fhajny Exp $
+
+Need the workaround on at least SunOS too.
+
+--- src/libcollectdclient/network_buffer.c.orig 2017-11-18 09:03:27.358750191 +0000
++++ src/libcollectdclient/network_buffer.c
+@@ -36,7 +36,7 @@
+ #include <pthread.h>
+
+ #if HAVE_GCRYPT_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
+@@ -49,7 +49,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/collectd/patches/patch-src_lua.c b/collectd/patches/patch-src_lua.c
new file mode 100644
index 0000000000..68f768ec4f
--- /dev/null
+++ b/collectd/patches/patch-src_lua.c
@@ -0,0 +1,47 @@
+$NetBSD: patch-src_lua.c,v 1.2 2017/11/21 15:18:23 fhajny Exp $
+
+Make it possible to register more than one reader/writer.
+Upstream request: https://github.com/collectd/collectd/pull/2379
+
+--- src/lua.c.orig 2017-11-18 09:03:27.358750191 +0000
++++ src/lua.c
+@@ -281,9 +281,6 @@ static int lua_cb_register_read(lua_Stat
+
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+
+- char function_name[DATA_MAX_NAME_LEN];
+- snprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
+-
+ int callback_id = clua_store_callback(L, 1);
+ if (callback_id < 0)
+ return luaL_error(L, "%s", "Storing callback function failed");
+@@ -298,6 +295,9 @@ static int lua_cb_register_read(lua_Stat
+ if (cb == NULL)
+ return luaL_error(L, "%s", "calloc failed");
+
++ char function_name[DATA_MAX_NAME_LEN];
++ snprintf(function_name, sizeof(function_name), "lua/%p", thread);
++
+ cb->lua_state = thread;
+ cb->callback_id = callback_id;
+ cb->lua_function_name = strdup(function_name);
+@@ -325,9 +325,6 @@ static int lua_cb_register_write(lua_Sta
+
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+
+- char function_name[DATA_MAX_NAME_LEN] = "";
+- snprintf(function_name, sizeof(function_name), "lua/%s", lua_tostring(L, 1));
+-
+ int callback_id = clua_store_callback(L, 1);
+ if (callback_id < 0)
+ return luaL_error(L, "%s", "Storing callback function failed");
+@@ -342,6 +339,9 @@ static int lua_cb_register_write(lua_Sta
+ if (cb == NULL)
+ return luaL_error(L, "%s", "calloc failed");
+
++ char function_name[DATA_MAX_NAME_LEN];
++ snprintf(function_name, sizeof(function_name), "lua/%p", thread);
++
+ cb->lua_state = thread;
+ cb->callback_id = callback_id;
+ cb->lua_function_name = strdup(function_name);
diff --git a/collectd/patches/patch-src_memory.c b/collectd/patches/patch-src_memory.c
new file mode 100644
index 0000000000..19397ca059
--- /dev/null
+++ b/collectd/patches/patch-src_memory.c
@@ -0,0 +1,126 @@
+$NetBSD: patch-src_memory.c,v 1.5 2017/11/21 15:18:23 fhajny Exp $
+
+Add a port for NetBSD using VM_UVMEXP2, and preferring
+sysctl over sysctlbyname.
+
+--- src/memory.c.orig 2017-11-18 09:03:27.358750191 +0000
++++ src/memory.c
+@@ -66,6 +66,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 */
+@@ -80,10 +84,6 @@ static kstat_t *ksp;
+ static kstat_t *ksz;
+ /* #endif HAVE_LIBKSTAT */
+
+-#elif HAVE_SYSCTL
+-static int pagesize;
+-/* #endif HAVE_SYSCTL */
+-
+ #elif HAVE_LIBSTATGRAB
+ /* no global variables */
+ /* endif HAVE_LIBSTATGRAB */
+@@ -94,6 +94,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;
+
+@@ -120,6 +124,14 @@ static int memory_init(void) {
+ host_page_size(port_host, &pagesize);
+ /* #endif HAVE_HOST_STATISTICS */
+
++#elif HAVE_SYSCTL
++ pagesize = getpagesize();
++ if (pagesize <= 0) {
++ ERROR("memory plugin: Invalid pagesize: %i", pagesize);
++ return (-1);
++ }
++/* #endif HAVE_SYSCTL */
++
+ #elif HAVE_SYSCTLBYNAME
+ /* no init stuff */
+ /* #endif HAVE_SYSCTLBYNAME */
+@@ -142,14 +154,6 @@ static int memory_init(void) {
+
+ /* #endif HAVE_LIBKSTAT */
+
+-#elif HAVE_SYSCTL
+- pagesize = getpagesize();
+- if (pagesize <= 0) {
+- ERROR("memory plugin: Invalid pagesize: %i", pagesize);
+- return -1;
+- }
+-/* #endif HAVE_SYSCTL */
+-
+ #elif HAVE_LIBSTATGRAB
+ /* no init stuff */
+ /* #endif HAVE_LIBSTATGRAB */
+@@ -221,6 +225,46 @@ static int memory_read_internal(value_li
+ /* #endif HAVE_HOST_STATISTICS */
+
+ #elif HAVE_SYSCTLBYNAME
++
++#if HAVE_SYSCTL && defined(KERNEL_NETBSD)
++ int mib[] = {CTL_VM, VM_UVMEXP2};
++ struct uvmexp_sysctl uvmexp;
++ gauge_t mem_active;
++ gauge_t mem_inactive;
++ gauge_t mem_free;
++ gauge_t mem_wired;
++ gauge_t mem_kernel;
++ size_t size;
++
++ 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
+@@ -259,6 +303,8 @@ static int memory_read_internal(value_li
+ (gauge_t)sysctl_vals[3], "active", (gauge_t)sysctl_vals[4],
+ "inactive", (gauge_t)sysctl_vals[5], "cache",
+ (gauge_t)sysctl_vals[6]);
++
++#endif /* HAVE_SYSCTL && KERNEL_NETBSD */
+ /* #endif HAVE_SYSCTLBYNAME */
+
+ #elif KERNEL_LINUX
diff --git a/collectd/patches/patch-src_netstat__udp.c b/collectd/patches/patch-src_netstat__udp.c
new file mode 100644
index 0000000000..e65c4f904a
--- /dev/null
+++ b/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/collectd/patches/patch-src_processes.c b/collectd/patches/patch-src_processes.c
new file mode 100644
index 0000000000..a61690e77e
--- /dev/null
+++ b/collectd/patches/patch-src_processes.c
@@ -0,0 +1,265 @@
+$NetBSD: patch-src_processes.c,v 1.8 2017/11/21 16:02:20 he Exp $
+
+Add a port to NetBSD.
+
+--- src/processes.c.orig 2017-06-06 18:13:54.693164693 +0000
++++ src/processes.c
+@@ -97,14 +97,16 @@
+ /* #endif KERNEL_LINUX */
+
+ #elif HAVE_LIBKVM_GETPROCS && \
+- (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++ (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
+ #include <kvm.h>
+ #include <sys/param.h>
+ #include <sys/proc.h>
+ #include <sys/sysctl.h>
++#if defined(__FreeBSD__) || defined(__DragonFly__)
+ #include <sys/user.h>
++#endif
+ /* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD ||
+- * HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++ * HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
+
+ #elif HAVE_PROCINFO_H
+ #include <procinfo.h>
+@@ -286,10 +288,15 @@ static void ps_fill_details(const procst
+ /* #endif KERNEL_LINUX */
+
+ #elif HAVE_LIBKVM_GETPROCS && \
+- (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++ (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
+ static int pagesize;
++
++#if KERNEL_NETBSD
++int maxslp;
++#endif
++
+ /* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD ||
+- * HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++ * HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
+
+ #elif HAVE_PROCINFO_H
+ static struct procentry64 procentry[MAXPROCENTRY];
+@@ -673,10 +680,21 @@ static int ps_init(void) {
+ /* #endif KERNEL_LINUX */
+
+ #elif HAVE_LIBKVM_GETPROCS && \
+- (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
++ (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD)
++#if KERNEL_NETBSD
++ int mib[2];
++ size_t size;
++
++ mib[0] = CTL_VM;
++ mib[1] = VM_MAXSLP;
++ size = sizeof(maxslp);
++ if (sysctl(mib, 2, &maxslp, &size, NULL, 0) == -1)
++ maxslp = 20; /* reasonable default? */
++#endif
++
+ pagesize = getpagesize();
+ /* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD ||
+- * HAVE_STRUCT_KINFO_PROC_OPENBSD) */
++ * HAVE_STRUCT_KINFO_PROC_OPENBSD || HAVE_STRUCT_KINFO_PROC2_NETBSD) */
+
+ #elif HAVE_PROCINFO_H
+ pagesize = getpagesize();
+@@ -2074,6 +2092,197 @@ 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;
++ process_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) */
++
++ memset(&pse, 0, sizeof(pse));
++ pse.id = procs[i].p_pid;
++
++ 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_counter = procs[i].p_uru_minflt;
++ pse.vmem_majflt_counter = procs[i].p_uru_majflt;
++
++ pse.cpu_user_counter = 0;
++ pse.cpu_system_counter = 0;
++ /* context switch counters not implemented */
++ pse.cswitch_vol = -1;
++ pse.cswitch_invol = -1;
++
++ /*
++ * 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;
++
++ /* file descriptor count not implemented */
++ pse.num_fd = 0;
++
++ /* Number of memory mappings */
++ pse.num_maps = 0;
++
++ /* context switch counters not implemented */
++ pse.cswitch_vol = -1;
++ pse.cswitch_invol = -1;
++
++ 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/collectd/patches/patch-src_statsd.c b/collectd/patches/patch-src_statsd.c
new file mode 100644
index 0000000000..1ce2b17fdc
--- /dev/null
+++ b/collectd/patches/patch-src_statsd.c
@@ -0,0 +1,19 @@
+$NetBSD: patch-src_statsd.c,v 1.1 2017/01/19 17:20:42 he Exp $
+
+Insert workaround for possibly missing nearbyint().
+(Could be more specific, but test would be ... complicated.)
+
+--- src/statsd.c.orig 2017-01-19 16:24:15.000000000 +0000
++++ src/statsd.c
+@@ -48,6 +48,11 @@
+ #define STATSD_DEFAULT_SERVICE "8125"
+ #endif
+
++#ifdef __NetBSD__
++/* May not have this, could be more specific... */
++#define nearbyint(v) rint((v))
++#endif
++
+ enum metric_type_e { STATSD_COUNTER, STATSD_TIMER, STATSD_GAUGE, STATSD_SET };
+ typedef enum metric_type_e metric_type_t;
+
diff --git a/collectd/patches/patch-src_swap.c b/collectd/patches/patch-src_swap.c
new file mode 100644
index 0000000000..7eba7bf5e4
--- /dev/null
+++ b/collectd/patches/patch-src_swap.c
@@ -0,0 +1,144 @@
+$NetBSD: patch-src_swap.c,v 1.5 2017/11/21 15:18:23 fhajny Exp $
+
+Extend support for NetBSD, and add per-swap-device
+reporting for HAVE_SWAPCTL_THREE_ARGS.
+
+--- src/swap.c.orig 2017-11-18 09:03:27.366749826 +0000
++++ src/swap.c
+@@ -78,9 +78,12 @@ static _Bool report_bytes = 0;
+ static _Bool report_by_device = 0;
+ /* #endif KERNEL_LINUX */
+
+-#elif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS
++#elif HAVE_SWAPCTL && (HAVE_SWAPCTL_TWO_ARGS || HAVE_SWAPCTL_THREE_ARGS)
+ #define SWAP_HAVE_REPORT_BY_DEVICE 1
+ 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 */
+
+@@ -118,7 +121,7 @@ static int swap_config(oconfig_item_t *c
+ for (int i = 0; i < ci->children_num; i++) {
+ oconfig_item_t *child = ci->children + i;
+ if (strcasecmp("ReportBytes", child->key) == 0)
+-#if KERNEL_LINUX
++#if KERNEL_LINUX || KERNEL_NETBSD
+ cf_util_get_boolean(child, &report_bytes);
+ #else
+ WARNING("swap plugin: The \"ReportBytes\" option "
+@@ -152,7 +155,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 */
+@@ -210,7 +213,7 @@ static void swap_submit_usage(char const
+ free, other_name, other_value, NULL);
+ } /* }}} void swap_submit_usage */
+
+-#if KERNEL_LINUX || HAVE_PERFSTAT
++#if KERNEL_LINUX || HAVE_PERFSTAT || KERNEL_NETBSD
+ __attribute__((nonnull(1))) static void
+ swap_submit_derive(char const *type_instance, /* {{{ */
+ derive_t value) {
+@@ -577,6 +580,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;
+@@ -615,12 +655,32 @@ static int swap_read(void) /* {{{ */
+ /* TODO: Report per-device stats. The path name is available from
+ * swap_entries[i].se_path */
+ for (int i = 0; i < swap_num; i++) {
++ char path[PATH_MAX];
++ gauge_t this_used;
++ gauge_t this_total;
++
+ if ((swap_entries[i].se_flags & SWF_ENABLE) == 0)
+ continue;
+
+- 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(
+@@ -631,8 +691,15 @@ static int swap_read(void) /* {{{ */
+ }
+
+ swap_submit_usage(NULL, used, total - used, NULL, NAN);
++ /* If the "separate" option was specified (report_by_device == 1), all
++ * values have already been dispatched from within the loop. */
++ if (!report_by_device)
++ swap_submit_usage (NULL, used, total - used, NULL, NAN);
+
+ 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/collectd/patches/patch-src_tcpconns.c b/collectd/patches/patch-src_tcpconns.c
new file mode 100644
index 0000000000..a669589c8c
--- /dev/null
+++ b/collectd/patches/patch-src_tcpconns.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-src_tcpconns.c,v 1.7 2017/11/21 15:18:23 fhajny Exp $
+
+Include <sys/param.h>
+Re-order to fix build on NetBSD.
+
+--- src/tcpconns.c.orig 2017-11-18 09:03:27.370749644 +0000
++++ src/tcpconns.c
+@@ -128,9 +128,9 @@
+ #include <net/route.h>
+ #include <netdb.h>
+ #include <netinet/in.h>
++#include <netinet/ip.h>
+ #include <netinet/in_pcb.h>
+ #include <netinet/in_systm.h>
+-#include <netinet/ip.h>
+ #include <netinet/ip_var.h>
+ #include <netinet/tcp.h>
+ #include <netinet/tcp_timer.h>
+@@ -897,6 +897,7 @@ static int conn_init(void) {
+ return 0;
+ } /* int conn_init */
+
++#include <sys/param.h>
+ static int conn_read(void) {
+ struct inpcbtable table;
+ #if !defined(__OpenBSD__) && \
diff --git a/collectd/patches/patch-src_utils__dns.c b/collectd/patches/patch-src_utils__dns.c
new file mode 100644
index 0000000000..8643e9c3bd
--- /dev/null
+++ b/collectd/patches/patch-src_utils__dns.c
@@ -0,0 +1,19 @@
+$NetBSD: patch-src_utils__dns.c,v 1.3 2020/02/03 09:12:32 triaxx Exp $
+
+Resolve conflict with pkgsrc PCAP on NetBSD 7 and 8.
+
+--- src/utils_dns.c.orig 2017-11-18 09:03:27.370749644 +0000
++++ src/utils_dns.c
+@@ -91,6 +91,12 @@
+ #endif
+
+ #if HAVE_PCAP_H
++# if defined(DLT_MATCHING_MAX)
++# undef DLT_MATCHING_MAX
++# endif
++# if defined(DLT_IEEE802_15_4)
++# undef DLT_IEEE802_15_4
++# endif
+ #include <pcap.h>
+ #endif
+
diff --git a/collectd/patches/patch-src_utils__format__kairosdb.c b/collectd/patches/patch-src_utils__format__kairosdb.c
new file mode 100644
index 0000000000..a1d8eec823
--- /dev/null
+++ b/collectd/patches/patch-src_utils__format__kairosdb.c
@@ -0,0 +1,19 @@
+$NetBSD: patch-src_utils__format__kairosdb.c,v 1.4 2017/01/19 17:20:42 he Exp $
+
+Cast arguments to isalnum() and tolower() to "unsigned char" to
+squelch warnings.
+
+--- src/utils_format_kairosdb.c.orig 2016-11-30 08:52:01.000000000 +0000
++++ src/utils_format_kairosdb.c
+@@ -80,9 +80,9 @@ static int kairosdb_escape_string(char *
+ /* authorize -_. and alpha num but also escapes " */
+ BUFFER_ADD('"');
+ for (size_t src_pos = 0; string[src_pos] != 0; src_pos++) {
+- if (isalnum(string[src_pos]) || 0x2d == string[src_pos] ||
++ if (isalnum((unsigned char)string[src_pos]) || 0x2d == string[src_pos] ||
+ 0x2e == string[src_pos] || 0x5f == string[src_pos])
+- BUFFER_ADD(tolower(string[src_pos]));
++ BUFFER_ADD(tolower((unsigned char)string[src_pos]));
+ } /* for */
+ BUFFER_ADD('"');
+ buffer[dst_pos] = 0;
diff --git a/p5-collectd/DESCR b/p5-collectd/DESCR
new file mode 100644
index 0000000000..54908dda05
--- /dev/null
+++ b/p5-collectd/DESCR
@@ -0,0 +1 @@
+perl plugin for collectd
diff --git a/p5-collectd/Makefile b/p5-collectd/Makefile
new file mode 100644
index 0000000000..6c83d8832a
--- /dev/null
+++ b/p5-collectd/Makefile
@@ -0,0 +1,23 @@
+# $NetBSD: Makefile,v 1.9 2019/08/11 13:23:15 wiz Exp $
+
+PKGNAME= p5-${DISTNAME}
+PKGREVISION= 2
+COLLECTD_PACKAGE= perl
+
+COMMENT= Statistics collection daemon - perl plugin
+
+.include "../../sysutils/collectd/Makefile.common"
+
+USE_TOOLS+= perl
+
+PERL5_CONFIGURE= no
+PERL5_PACKLIST+= auto/Collectd/.packlist
+
+CONFIGURE_ARGS+= --with-libperl=${BUILDLINK_PREFIX.perl}
+CONFIGURE_ARGS+= --with-perl-bindings=${MAKE_PARAMS:Q}
+
+BUILD_TARGET+= perl
+INSTALL_TARGET+= install-exec-local
+
+.include "../../lang/perl5/module.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/py-collectd/DESCR b/py-collectd/DESCR
new file mode 100644
index 0000000000..9119bdd8fa
--- /dev/null
+++ b/py-collectd/DESCR
@@ -0,0 +1 @@
+python plugin for collectd
diff --git a/py-collectd/Makefile b/py-collectd/Makefile
new file mode 100644
index 0000000000..cd27b4d906
--- /dev/null
+++ b/py-collectd/Makefile
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.4 2019/08/11 13:23:16 wiz Exp $
+
+PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
+PKGREVISION= 2
+COLLECTD_PACKAGE= python
+
+COMMENT= Statistics collection daemon - python plugin
+
+.include "../../sysutils/collectd/Makefile.common"
+
+CONFIGURE_ARGS+= --enable-python
+CONFIGURE_ENV+= PYTHON_CONFIG=${PREFIX}/bin/python${PYVERSSUFFIX}-config
+
+.include "../../lang/python/application.mk"
+.include "../../mk/bsd.pkg.mk"
Home |
Main Index |
Thread Index |
Old Index