Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2019 14:34:57 +0000 (UTC)
From:      Ryan Steinmetz <zi@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r494056 - in head/net-mgmt: . nsd_exporter nsd_exporter/files
Message-ID:  <201902271434.x1REYv9B018841@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zi
Date: Wed Feb 27 14:34:57 2019
New Revision: 494056
URL: https://svnweb.freebsd.org/changeset/ports/494056

Log:
  New port: net-mgmt/nsd_exporter:
  
  nsd_exporter is a prometheus exporter for nsd metrics
  
  WWW: https://github.com/optix2000/nsd_exporter

Added:
  head/net-mgmt/nsd_exporter/
  head/net-mgmt/nsd_exporter/Makefile   (contents, props changed)
  head/net-mgmt/nsd_exporter/distinfo   (contents, props changed)
  head/net-mgmt/nsd_exporter/files/
  head/net-mgmt/nsd_exporter/files/nsd_exporter.in   (contents, props changed)
  head/net-mgmt/nsd_exporter/files/patch-nsd__exporter.go   (contents, props changed)
  head/net-mgmt/nsd_exporter/pkg-descr   (contents, props changed)
  head/net-mgmt/nsd_exporter/pkg-message   (contents, props changed)
Modified:
  head/net-mgmt/Makefile

Modified: head/net-mgmt/Makefile
==============================================================================
--- head/net-mgmt/Makefile	Wed Feb 27 14:00:43 2019	(r494055)
+++ head/net-mgmt/Makefile	Wed Feb 27 14:34:57 2019	(r494056)
@@ -204,6 +204,7 @@
     SUBDIR += nsca27
     SUBDIR += nsca27-client
     SUBDIR += nstat
+    SUBDIR += nsd_exporter
     SUBDIR += nstreams
     SUBDIR += nvidia_gpu_prometheus_exporter
     SUBDIR += observium

Added: head/net-mgmt/nsd_exporter/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/nsd_exporter/Makefile	Wed Feb 27 14:34:57 2019	(r494056)
@@ -0,0 +1,54 @@
+# Created by: Ryan Steinmetz <zi@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME=	nsd_exporter
+PORTVERSION=	0.1.0
+CATEGORIES=	net-mgmt
+
+MAINTAINER=	zi@FreeBSD.org
+COMMENT=	Prometheus exporter for nsd metrics
+
+LICENSE=	BSD3CLAUSE
+
+USES=		go
+USE_GITHUB=	yes
+
+GH_ACCOUNT=	optix2000
+GH_TUPLE=	prometheus:client_golang:v0.8.0:client_golang \
+		prometheus:client_model:5c3871d:client_model \
+		prometheus:procfs:ae68e2d:procfs \
+		prometheus:common:7600349:common \
+		beorn7:perks:3a771d9:perks \
+		golang:protobuf:70b3af3:protobuf \
+		matttproud:golang_protobuf_extensions:c12348c:golang_protobuf_extensions \
+		optix2000:go-nsdctl:ce14b32:go_nsdctl \
+		go-yaml:yaml:7f97868:go_yaml
+
+GO_PKGNAME=	github.com/${GH_ACCOUNT}/${PORTNAME}
+GO_TARGET=	github.com/${GH_ACCOUNT}/${PORTNAME}
+
+PLIST_FILES=	bin/nsd_exporter
+
+USE_RC_SUBR=	nsd_exporter
+
+post-patch:
+	${REINPLACE_CMD} -e 's|"/etc|"${LOCALBASE}/etc|g' ${WRKSRC_go_nsdctl}/nsdctl.go
+
+pre-build:
+	${MKDIR} ${GO_WRKDIR_SRC}/github.com/prometheus ${GO_WRKDIR_SRC}/gopkg.in \
+		${GO_WRKDIR_SRC}/github.com/beorn7 ${GO_WRKDIR_SRC}/github.com/golang \
+		${GO_WRKDIR_SRC}/github.com/matttproud ${GO_WRKDIR_SRC}/github.com/optix2000
+	${MV} ${WRKSRC_golang_protobuf_extensions} ${GO_WRKDIR_SRC}/github.com/matttproud/golang_protobuf_extensions
+	${MV} ${WRKSRC_go_nsdctl} ${GO_WRKDIR_SRC}/github.com/optix2000/go-nsdctl
+	${MV} ${WRKSRC_client_golang} ${GO_WRKDIR_SRC}/github.com/prometheus/client_golang
+	${MV} ${WRKSRC_client_model} ${GO_WRKDIR_SRC}/github.com/prometheus/client_model
+	${MV} ${WRKSRC_procfs} ${GO_WRKDIR_SRC}/github.com/prometheus/procfs
+	${MV} ${WRKSRC_common} ${GO_WRKDIR_SRC}/github.com/prometheus/common
+	${MV} ${WRKSRC_protobuf} ${GO_WRKDIR_SRC}/github.com/golang/protobuf
+	${MV} ${WRKSRC_go_yaml} ${GO_WRKDIR_SRC}/gopkg.in/yaml.v2
+	${MV} ${WRKSRC_perks} ${GO_WRKDIR_SRC}/github.com/beorn7/perks
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKDIR}/bin/nsd_exporter ${STAGEDIR}${PREFIX}/bin
+
+.include <bsd.port.mk>

Added: head/net-mgmt/nsd_exporter/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/nsd_exporter/distinfo	Wed Feb 27 14:34:57 2019	(r494056)
@@ -0,0 +1,21 @@
+TIMESTAMP = 1551277938
+SHA256 (optix2000-nsd_exporter-0.1.0_GH0.tar.gz) = 7fb9fae9f434e904e79eceaef9e5640e8be66d57384f87a9a6a85ab663dcf51c
+SIZE (optix2000-nsd_exporter-0.1.0_GH0.tar.gz) = 8144
+SHA256 (prometheus-client_golang-v0.8.0_GH0.tar.gz) = 88b0040393276116f848de5bdd636717d339667273cfc45a4edda40b5e5682bd
+SIZE (prometheus-client_golang-v0.8.0_GH0.tar.gz) = 75593
+SHA256 (prometheus-client_model-5c3871d_GH0.tar.gz) = 5decfffcc4a7cfbce4214e42aaf0e3af9acdadf5d3f3ef6733868314171fd2f0
+SIZE (prometheus-client_model-5c3871d_GH0.tar.gz) = 57126
+SHA256 (prometheus-procfs-ae68e2d_GH0.tar.gz) = d2ef0107607a9e0fcfccbe7d0a364ea04de741d464b244994fb579f2610dfb4f
+SIZE (prometheus-procfs-ae68e2d_GH0.tar.gz) = 57790
+SHA256 (prometheus-common-7600349_GH0.tar.gz) = 428d2301007b765ae36a64114b2f4806556c602dba34c011a10caaae76cbb433
+SIZE (prometheus-common-7600349_GH0.tar.gz) = 77805
+SHA256 (beorn7-perks-3a771d9_GH0.tar.gz) = b7a0faebca98ebd5e7546403b4cdea9dc77f865f0623d04efbad33e984297cc9
+SIZE (beorn7-perks-3a771d9_GH0.tar.gz) = 10800
+SHA256 (golang-protobuf-70b3af3_GH0.tar.gz) = fd81970d30eba8f3d49c5b27eb80728060f022bb391515e8d79724d5b39dc1f9
+SIZE (golang-protobuf-70b3af3_GH0.tar.gz) = 329777
+SHA256 (matttproud-golang_protobuf_extensions-c12348c_GH0.tar.gz) = da165c9275b77a0994b815bc7d761dcb2e4799a90fe49eec08d8bdff3a683f48
+SIZE (matttproud-golang_protobuf_extensions-c12348c_GH0.tar.gz) = 37200
+SHA256 (optix2000-go-nsdctl-ce14b32_GH0.tar.gz) = 4474f6e9f18d08035f36ef60dc25b97c7c5528ab99f59cf7f94854613d73b239
+SIZE (optix2000-go-nsdctl-ce14b32_GH0.tar.gz) = 4038
+SHA256 (go-yaml-yaml-7f97868_GH0.tar.gz) = b0215657c82db81fa1e10f73fb1df3db12715ec68a14ab555e7f40d1d174132d
+SIZE (go-yaml-yaml-7f97868_GH0.tar.gz) = 69163

Added: head/net-mgmt/nsd_exporter/files/nsd_exporter.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/nsd_exporter/files/nsd_exporter.in	Wed Feb 27 14:34:57 2019	(r494056)
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# PROVIDE: nsd_exporter
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# nsd_exporter_enable (bool):          Set to NO by default.
+#               Set it to YES to enable nsd_exporter.
+# nsd_exporter_user (string):          Set user that nsd_exporter will run under
+#               Default is "nobody".
+# nsd_exporter_group (string):         Set group that nsd_exporter will run under
+#               Default is "nobody".
+# nsd_exporter_args (string):          Set extra arguments to pass to nsd_exporter
+#               Default is "".
+# nsd_exporter_listen_address (string):Set ip:port that nsd_exporter will listen on
+#               Default is ":9132".
+
+. /etc/rc.subr
+
+name=nsd_exporter
+rcvar=nsd_exporter_enable
+
+load_rc_config $name
+
+: ${nsd_exporter_enable:="NO"}
+: ${nsd_exporter_user:="nobody"}
+: ${nsd_exporter_group:="nobody"}
+: ${nsd_exporter_args:=""}
+: ${nsd_exporter_listen_address:=":9132"}
+: ${nsd_exporter_control_cert:="%%LOCALBASE%%/etc/nsd/nsd_control.pem"}
+: ${nsd_exporter_control_ca:="%%LOCALBASE%%/etc/nsd/nsd_server.pem"}
+: ${nsd_exporter_control_key:="%%LOCALBASE%%/etc/nsd/nsd_control.key"}
+: ${nsd_exporter_nsd_address:="127.0.0.1:8952"}
+: ${nsd_exporter_restart_delay:="10"}
+
+
+pidfile=/var/run/nsd_exporter.pid
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/bin/nsd_exporter"
+command_args="-rp ${pidfile} -S -R ${nsd_exporter_restart_delay} \
+    -T ${name} ${procname} \
+    -cert ${nsd_exporter_control_cert} \
+    -ca ${nsd_exporter_control_ca} \
+    -key ${nsd_exporter_control_key} \
+    -nsd-address ${nsd_exporter_nsd_address} \
+    -listen-address ${nsd_exporter_listen_address} \
+    ${nsd_exporter_args}"
+required_files="${nsd_exporter_control_cert} ${nsd_exporter_control_ca} ${nsd_exporter_control_key}"
+
+start_precmd=nsd_exporter_startprecmd
+
+nsd_exporter_startprecmd()
+{
+    if [ ! -e ${pidfile} ]; then
+        install -o ${nsd_exporter_user} -g ${nsd_exporter_group} /dev/null ${pidfile};
+    fi
+}
+
+load_rc_config $name
+run_rc_command "$1"

Added: head/net-mgmt/nsd_exporter/files/patch-nsd__exporter.go
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/nsd_exporter/files/patch-nsd__exporter.go	Wed Feb 27 14:34:57 2019	(r494056)
@@ -0,0 +1,20 @@
+--- nsd_exporter.go.orig	2018-02-08 23:45:14 UTC
++++ nsd_exporter.go
+@@ -19,7 +19,7 @@ import (
+ var listenAddr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.")
+ var metricPath = flag.String("metric-path", "/metrics", "The path to export Prometheus metrocs to.")
+ var metricConfigPath = flag.String("metric-config", "", "Mapping file for metrics. Defaults to built in file for NSD 4.1.x. This allows you to add or change any metrics that this scrapes")
+-var nsdConfig = flag.String("config-file", "/etc/nsd/nsd.conf", "Configuration file for nsd/unbound to autodetect configuration from. Defaults to /etc/nsd/nsd.conf. Mutually exclusive with -nsd-address, -cert, -key and -ca")
++var nsdConfig = flag.String("config-file", "/usr/local/etc/nsd/nsd.conf", "Configuration file for nsd/unbound to autodetect configuration from. Defaults to /usr/local/etc/nsd/nsd.conf. Mutually exclusive with -nsd-address, -cert, -key and -ca")
+ var nsdType = flag.String("type", "nsd", "What nsd-like daemon to scrape (nsd or unbound). Defaults to nsd")
+ var cert = flag.String("cert", "", "Client cert file location. Mutually exclusive with -config-file.")
+ var key = flag.String("key", "", "Client key file location. Mutually exclusive with -config-file.")
+@@ -58,7 +58,7 @@ func (c *NSDCollector) Collect(ch chan<-
+ 	s := bufio.NewScanner(r)
+ 	for s.Scan() {
+ 		line := strings.Split(s.Text(), "=")
+-		metricName := line[0]
++		metricName := strings.TrimSpace(line[0])
+ 		m, ok := c.metrics[metricName]
+ 		if !ok {
+ 			log.Println("Unknown Metric ", metricName, ". Skipping.")

Added: head/net-mgmt/nsd_exporter/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/nsd_exporter/pkg-descr	Wed Feb 27 14:34:57 2019	(r494056)
@@ -0,0 +1,3 @@
+nsd_exporter is a prometheus exporter for nsd metrics
+
+WWW: https://github.com/optix2000/nsd_exporter

Added: head/net-mgmt/nsd_exporter/pkg-message
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/nsd_exporter/pkg-message	Wed Feb 27 14:34:57 2019	(r494056)
@@ -0,0 +1,11 @@
+=========================================================================
+Don't forget to run nsd-control-setup to generate the required
+certificates and then ensure the user this process runs as can read them.
+
+The default user is nobody.  You can change the user (or group) by running:
+% sysrc nsd_exporter_user="user"
+% sysrc nsd_exporter_group="group"
+
+Be aware that any user with access to the certificates can run all of the
+nsd-control commands.
+=========================================================================



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902271434.x1REYv9B018841>