pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Add collectd-unbound dated 20150830, a collectd plugin to handle the output from "unbound-control stats". Based on the code from
Module Name: pkgsrc-wip
Committed By: Havard Eidnes <he%NetBSD.org@localhost>
Pushed By: he
Date: Thu Jan 19 18:30:43 2017 +0100
Changeset: 9b0b879ea1b0cc14268ff7eb8082be4496ac8cea
Added Files:
collectd-unbound/DESCR
collectd-unbound/Makefile
collectd-unbound/PLIST
collectd-unbound/distinfo
collectd-unbound/patches/patch-collectd-unbound.go
Log Message:
Add collectd-unbound dated 20150830, a collectd plugin to handle
the output from "unbound-control stats". Based on the code from
https://github.com/falzm/collectd-unbound
but chenaged from requiring unbound be configured with
statistics-cumulative: no
to instead requiring
statistics-cumulative: yes
...and we want all the stats to be collected, and some
of those are counters and some are gauges.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=9b0b879ea1b0cc14268ff7eb8082be4496ac8cea
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
collectd-unbound/DESCR | 15 +++++
collectd-unbound/Makefile | 24 ++++++++
collectd-unbound/PLIST | 2 +
collectd-unbound/distinfo | 6 ++
collectd-unbound/patches/patch-collectd-unbound.go | 64 ++++++++++++++++++++++
5 files changed, 111 insertions(+)
diffs:
diff --git a/collectd-unbound/DESCR b/collectd-unbound/DESCR
new file mode 100644
index 0000000..8febc1f
--- /dev/null
+++ b/collectd-unbound/DESCR
@@ -0,0 +1,15 @@
+This utility allows you to access Unbound statistics from collectd
+using the exec plugin. It hasn't been thoroughly tested, use it at
+your own risk...
+
+Once the collectd-unbound binary is compiled, copy it wherever you
+want and add the following lines to you collectd configuration:
+
+LoadPlugin exec
+<Plugin "exec">
+ Exec "unbound" "/usr/pkg/bin/collectd-unbound"
+</Plugin>
+
+Note: the utility executes the command unbound-control stats to
+fetch the statistics: make sure the user specified in your exec
+plugin block has the permissions to execute the command.
diff --git a/collectd-unbound/Makefile b/collectd-unbound/Makefile
new file mode 100644
index 0000000..f1eee89
--- /dev/null
+++ b/collectd-unbound/Makefile
@@ -0,0 +1,24 @@
+# $NetBSD$
+#
+
+DISTNAME= collectd-unbound
+PKGNAME= ${DISTNAME}-20150830
+CATEGORIES= sysutils
+MASTER_SITES= ${MASTER_SITE_GITHUB:=falzm/}
+GITHUB_PROJECT= ${DISTNAME}
+GITHUB_TAG= e751f86301
+
+MAINTAINER= pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE= https://github.com/falzm/collectd-unbound
+COMMENT= Collectd plugin for submitting unbound statistics
+LICENSE= modified-bsd
+
+GO_SRCPATH= github.com/falzm/collectd-unbound
+GO_DIST_BASE= ${DISTNAME}-${GITHUB_TAG}*
+
+DEPENDS+= go-collectd-[0-9]*:../../sysutils/go-collectd
+DEPENDS+= collectd-[0-9]*:../../sysutils/collectd
+
+.include "../../sysutils/go-collectd/buildlink3.mk"
+.include "../../lang/go/go-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/collectd-unbound/PLIST b/collectd-unbound/PLIST
new file mode 100644
index 0000000..067548b
--- /dev/null
+++ b/collectd-unbound/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD$
+bin/collectd-unbound
diff --git a/collectd-unbound/distinfo b/collectd-unbound/distinfo
new file mode 100644
index 0000000..266dc71
--- /dev/null
+++ b/collectd-unbound/distinfo
@@ -0,0 +1,6 @@
+$NetBSD$
+
+SHA1 (collectd-unbound-e751f86301.tar.gz) = 5de9eb486314f28f789f79fb69fa464409ea1ce1
+RMD160 (collectd-unbound-e751f86301.tar.gz) = ecb3b6e4e858de57c7913dba3617bf468611ddf1
+Size (collectd-unbound-e751f86301.tar.gz) = 2639 bytes
+SHA1 (patch-collectd-unbound.go) = 8c9b7aee55b78897fe49bdec46a28020ee409071
diff --git a/collectd-unbound/patches/patch-collectd-unbound.go b/collectd-unbound/patches/patch-collectd-unbound.go
new file mode 100644
index 0000000..34b118b
--- /dev/null
+++ b/collectd-unbound/patches/patch-collectd-unbound.go
@@ -0,0 +1,64 @@
+$NetBSD$
+
+Change from requiring unbound be configured with
+
+ statistics-cumulative: no
+
+to instead requiring
+
+ statistics-cumulative: yes
+
+...and we want all the stats to be collected, and some
+of those are counters and some are gauges.
+
+--- collectd-unbound.go.orig 2015-03-21 07:56:41.000000000 +0000
++++ collectd-unbound.go
+@@ -33,7 +33,8 @@ func unboundStats(interval time.Duration
+ scanner := bufio.NewScanner(buf)
+ for scanner.Scan() {
+ line := scanner.Text()
+- if !strings.HasPrefix(line, "total.") {
++ // Skip per-thread statistics:
++ if strings.HasPrefix(line, "thread") {
+ continue
+ }
+
+@@ -43,7 +44,6 @@ func unboundStats(interval time.Duration
+ }
+
+ metric := fields[0]
+- metric = strings.TrimPrefix(metric, "total.")
+ metric = strings.Replace(metric, ".", "_", -1)
+
+ value, err := strconv.ParseFloat(fields[1], 64)
+@@ -51,19 +51,28 @@ func unboundStats(interval time.Duration
+ log.Printf("error: unable to parse metric value: %v", err)
+ continue
+ }
++ vartype := "counter"
++ if strings.Contains(fields[1], ".") {
++ vartype = "gauge"
++ }
++ if strings.HasPrefix(metric, "total_requestlist") {
++ vartype = "gauge"
++ }
++ if strings.HasPrefix(metric, "total_recursion") {
++ vartype = "gauge"
++ }
+
+ vl := api.ValueList{
+ Identifier: api.Identifier{
+ Host: exec.Hostname(),
+ Plugin: "unbound",
+- Type: "gauge",
++ Type: vartype,
+ TypeInstance: metric,
+ },
+ Time: now,
+ Interval: interval,
+ Values: []api.Value{api.Gauge(value)},
+ }
+-
+ exec.Putval.Write(vl)
+ }
+ }
Home |
Main Index |
Thread Index |
Old Index