git: f9b0b82aa759 - main - sysutils/nut_exporter: new port
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 28 Dec 2022 16:31:31 UTC
The branch main has been updated by ronald: URL: https://cgit.FreeBSD.org/ports/commit/?id=f9b0b82aa7592800fed91b535cab58c02f911316 commit f9b0b82aa7592800fed91b535cab58c02f911316 Author: Jony Hudson <jonyepsilon@google.com> AuthorDate: 2022-12-27 14:16:26 +0000 Commit: Ronald Klop <ronald@FreeBSD.org> CommitDate: 2022-12-28 16:31:05 +0000 sysutils/nut_exporter: new port Add a port for https://github.com/DRuggeri/nut_exporter which is a Prometheus (net-mgmt/prometheus2) exporter for the "Network UPS tools" (sysutils/nut). PR: 267485 Approved by: pkubaj (mentor) Differential Revision: https://reviews.freebsd.org/D37883 --- sysutils/Makefile | 1 + sysutils/nut_exporter/Makefile | 38 +++++++++++++++ sysutils/nut_exporter/distinfo | 37 +++++++++++++++ sysutils/nut_exporter/files/nut_exporter.in | 73 +++++++++++++++++++++++++++++ sysutils/nut_exporter/pkg-descr | 4 ++ 5 files changed, 153 insertions(+) diff --git a/sysutils/Makefile b/sysutils/Makefile index 4cd767fcd00e..47749e02700f 100644 --- a/sysutils/Makefile +++ b/sysutils/Makefile @@ -829,6 +829,7 @@ SUBDIR += ntpstat SUBDIR += nut SUBDIR += nut-devel + SUBDIR += nut_exporter SUBDIR += nvclock SUBDIR += nvimpager SUBDIR += nvme-cli diff --git a/sysutils/nut_exporter/Makefile b/sysutils/nut_exporter/Makefile new file mode 100644 index 000000000000..8d38fa288e0a --- /dev/null +++ b/sysutils/nut_exporter/Makefile @@ -0,0 +1,38 @@ +PORTNAME= nut_exporter +DISTVERSIONPREFIX= v +DISTVERSION= 2.5.0 +CATEGORIES= sysutils + +MAINTAINER= bsd@j-star.org +COMMENT= Prometheus exporter for the Network UPS Tools server +WWW= https://github.com/DRuggeri/nut_exporter + +LICENSE= APACHE20 +LICENSE_FILE= ${WRKSRC}/LICENSE + +USES= go:modules +USE_GITHUB= yes +GH_ACCOUNT= DRuggeri +GH_TUPLE= \ + alecthomas:kingpin:v2.2.6:alecthomas_kingpin/vendor/gopkg.in/alecthomas/kingpin.v2 \ + alecthomas:template:fb15b899a751:alecthomas_template/vendor/github.com/alecthomas/template \ + alecthomas:units:f65c72e2690d:alecthomas_units/vendor/github.com/alecthomas/units \ + beorn7:perks:v1.0.1:beorn7_perks/vendor/github.com/beorn7/perks \ + cespare:xxhash:v2.1.1:cespare_xxhash_v2/vendor/github.com/cespare/xxhash/v2 \ + go-kit:log:v0.2.0:go_kit_log/vendor/github.com/go-kit/log \ + go-logfmt:logfmt:v0.5.1:go_logfmt_logfmt/vendor/github.com/go-logfmt/logfmt \ + golang:protobuf:v1.4.3:golang_protobuf/vendor/github.com/golang/protobuf \ + golang:sys:ebe580a85c40:golang_sys/vendor/golang.org/x/sys \ + matttproud:golang_protobuf_extensions:v1.0.1:matttproud_golang_protobuf_extensions/vendor/github.com/matttproud/golang_protobuf_extensions \ + pkg:errors:v0.9.1:pkg_errors/vendor/github.com/pkg/errors \ + prometheus:client_golang:v1.11.0:prometheus_client_golang/vendor/github.com/prometheus/client_golang \ + prometheus:client_model:v0.2.0:prometheus_client_model/vendor/github.com/prometheus/client_model \ + prometheus:common:v0.32.1:prometheus_common/vendor/github.com/prometheus/common \ + prometheus:procfs:v0.6.0:prometheus_procfs/vendor/github.com/prometheus/procfs \ + protocolbuffers:protobuf-go:v1.26.0-rc.1:protocolbuffers_protobuf_go/vendor/google.golang.org/protobuf \ + robbiet480:go.nut:bd8f121e1fa1:robbiet480_go_nut/vendor/github.com/robbiet480/go.nut + +USE_RC_SUBR= nut_exporter +PLIST_FILES= bin/nut_exporter + +.include <bsd.port.mk> diff --git a/sysutils/nut_exporter/distinfo b/sysutils/nut_exporter/distinfo new file mode 100644 index 000000000000..9c15907679fa --- /dev/null +++ b/sysutils/nut_exporter/distinfo @@ -0,0 +1,37 @@ +TIMESTAMP = 1671310398 +SHA256 (DRuggeri-nut_exporter-v2.5.0_GH0.tar.gz) = 676591c3ea30dd716aac9697ced083d49f9bc6350cdeeb1e8e03819bebacd8a2 +SIZE (DRuggeri-nut_exporter-v2.5.0_GH0.tar.gz) = 200768 +SHA256 (alecthomas-kingpin-v2.2.6_GH0.tar.gz) = 4624eae43489de8a71ea60efaf6744c581b6bd62909f7514c484c1ea0efaba5a +SIZE (alecthomas-kingpin-v2.2.6_GH0.tar.gz) = 44383 +SHA256 (alecthomas-template-fb15b899a751_GH0.tar.gz) = 2e2a44375eca48ce941182504b5d13aa98182b9a3f64ace33bfda52208bd0f5e +SIZE (alecthomas-template-fb15b899a751_GH0.tar.gz) = 55339 +SHA256 (alecthomas-units-f65c72e2690d_GH0.tar.gz) = ece06024b01821e013bd7158dfe8ec8cc697f586ce8d3cfaa22edde8c2f022c3 +SIZE (alecthomas-units-f65c72e2690d_GH0.tar.gz) = 4925 +SHA256 (beorn7-perks-v1.0.1_GH0.tar.gz) = 98db84bb0224a26094e6adba91b7ee7a1a7ace28cb648d818f8e779e6a19f825 +SIZE (beorn7-perks-v1.0.1_GH0.tar.gz) = 10867 +SHA256 (cespare-xxhash-v2.1.1_GH0.tar.gz) = 0ee31178d2c5a1249be4e26294a2f428008dc4e1ecbbfbe47f74e41026df1148 +SIZE (cespare-xxhash-v2.1.1_GH0.tar.gz) = 9292 +SHA256 (go-kit-log-v0.2.0_GH0.tar.gz) = 5dfaf2a831debe95b84ce6e9c889a9cff162720a73fd0ab61cb151d2cc649b5c +SIZE (go-kit-log-v0.2.0_GH0.tar.gz) = 29069 +SHA256 (go-logfmt-logfmt-v0.5.1_GH0.tar.gz) = a9a93f7cbb92a53a587fda196bc040264a625e76064495e95cb3e907f9a93499 +SIZE (go-logfmt-logfmt-v0.5.1_GH0.tar.gz) = 12115 +SHA256 (golang-protobuf-v1.4.3_GH0.tar.gz) = 5736f943f8647362f5559689df6154f3c85d261fb088867c8a68494e2a767610 +SIZE (golang-protobuf-v1.4.3_GH0.tar.gz) = 171969 +SHA256 (golang-sys-ebe580a85c40_GH0.tar.gz) = b70e2301ad08c3ae255b004b8160f866798b95c0c1f88f12641343ed81ce523b +SIZE (golang-sys-ebe580a85c40_GH0.tar.gz) = 1197502 +SHA256 (matttproud-golang_protobuf_extensions-v1.0.1_GH0.tar.gz) = 2def0ee6f6b12b1efc0e3007d89f598608a072610e805c3655ea9d13c3ead49b +SIZE (matttproud-golang_protobuf_extensions-v1.0.1_GH0.tar.gz) = 37184 +SHA256 (pkg-errors-v0.9.1_GH0.tar.gz) = 56bfd893023daa498508bfe161de1be83299fcf15376035e7df79cbd7d6fa608 +SIZE (pkg-errors-v0.9.1_GH0.tar.gz) = 13415 +SHA256 (prometheus-client_golang-v1.11.0_GH0.tar.gz) = a3bc3312bde4182e507042ca0e7ca88aac6656bbf8d516d732e34c3f14bb612a +SIZE (prometheus-client_golang-v1.11.0_GH0.tar.gz) = 168706 +SHA256 (prometheus-client_model-v0.2.0_GH0.tar.gz) = 4ab1be9cdfa702d7f49beeb09a256bcc6a2aad55e8a0a37e7732a46934264e12 +SIZE (prometheus-client_model-v0.2.0_GH0.tar.gz) = 10986 +SHA256 (prometheus-common-v0.32.1_GH0.tar.gz) = de06f354e24dec3bfeba9a3bd43bd3170b4231dfff3cd338b688a6e8c8050af6 +SIZE (prometheus-common-v0.32.1_GH0.tar.gz) = 146585 +SHA256 (prometheus-procfs-v0.6.0_GH0.tar.gz) = 6ad7a23cf4db9fa5dbf2c5d8fbd0fbf5ffe48e3ddb7bf15f9359813d764ce73c +SIZE (prometheus-procfs-v0.6.0_GH0.tar.gz) = 169898 +SHA256 (protocolbuffers-protobuf-go-v1.26.0-rc.1_GH0.tar.gz) = a2b3581fb291ffdfe080cc16eb7b0b13295105a441fc0554a105368b7e208e66 +SIZE (protocolbuffers-protobuf-go-v1.26.0-rc.1_GH0.tar.gz) = 1270311 +SHA256 (robbiet480-go.nut-bd8f121e1fa1_GH0.tar.gz) = 1f8427de879e5d5804292b54d97ffce5c8c5eb94669a4447380cb90a7539a64d +SIZE (robbiet480-go.nut-bd8f121e1fa1_GH0.tar.gz) = 6790 diff --git a/sysutils/nut_exporter/files/nut_exporter.in b/sysutils/nut_exporter/files/nut_exporter.in new file mode 100644 index 000000000000..ddd72731cf05 --- /dev/null +++ b/sysutils/nut_exporter/files/nut_exporter.in @@ -0,0 +1,73 @@ +#!/bin/sh + +# PROVIDE: nut_exporter +# REQUIRE: LOGIN +# KEYWORD: shutdown + +# Add the following lines to /etc/rc.conf to enable nut_exporter: +# nut_exporter_enable="YES" +# +# nut_exporter_enable (bool): +# Set it to YES to enable nut_exporter. +# Set to NO by default. +# nut_exporter_listen_address (string): +# IP address and port to listen on. +# Default is ":9199". +# nut_exporter_user (string): +# User to run as. +# Default is "www". +# nut_exporter_metrics_namespace (string): +# Metrics namespace. +# Default is "network_ups_tools". +# nut_exporter_tls_cert_file (string): +# Path to a file that contains the TLS certificate (PEM format). +# Default is "". +# nut_exporter_tls_key_file (string): +# Path to a file that contains the TLS private key (PEM format). +# Default is "". + +. /etc/rc.subr + +name=nut_exporter +rcvar=nut_exporter_enable + +load_rc_config $name + +nut_exporter_enable=${nut_exporter_enable:-"NO"} +nut_exporter_listen_address=${nut_exporter_listen_address:-":9199"} +nut_exporter_user=${nut_exporter_user:-"www"} +nut_exporter_metrics_namespace=${nut_exporter_metrics_namespace:-"network_ups_tools"} +nut_exporter_tls_cert_file=${nut_exporter_tls_cert_file:-""} +nut_exporter_tls_key_file=${nut_exporter_tls_key_file:-""} + +pidfile="/var/run/${name}/${name}.pid" + +if [ -z ${nut_exporter_tls_cert_file} ] ; then + cert_arg="" +else + cert_arg="--web.tls.cert_file=${nut_exporter_tls_cert_file}" +fi +if [ -z ${nut_exporter_tls_key_file} ] ; then + key_arg="" +else + key_arg="--web.tls.key_file=${nut_exporter_tls_key_file}" +fi + +procname=%%PREFIX%%/bin/nut_exporter +command=/usr/sbin/daemon +command_args="-p ${pidfile} -t ${name} -T ${name} ${procname} \ + --web.listen-address=${nut_exporter_listen_address} \ + --metrics.namespace=${nut_exporter_metrics_namespace} \ + ${cert_arg} ${key_arg}" + +start_precmd=start_precmd +start_precmd() +{ + if [ ! -e "/var/run/${name}" ] ; then + # Note that ownership of the pidfile determines the user daemon runs under. + install -d -o ${nut_exporter_user} /var/run/${name}; + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/sysutils/nut_exporter/pkg-descr b/sysutils/nut_exporter/pkg-descr new file mode 100644 index 000000000000..e70d77f476fb --- /dev/null +++ b/sysutils/nut_exporter/pkg-descr @@ -0,0 +1,4 @@ +A Prometheus exporter for the Network UPS Tools server. +The exporter is written in a way to permit an administrator to scrape one or +many UPS devices visible to a NUT client as well as one or all NUT variables. +A single instance of this exporter can scrape one or many NUT servers.