Skip to content

Commit

Permalink
net-mgmt/ping_exporter: Update to 1.0.0
Browse files Browse the repository at this point in the history
 - Switched to GO_MODULE
 - Fixed "Run as non-root user"
( czerwonk/ping_exporter#56 ) by setuid bit
 - Added ping_exporter_syslog_output_* params to rc-script for syslog
   output tuning

ChangeLog:
https://github.com/czerwonk/ping_exporter/releases/tag/1.0.0

PR:		264048
Approved by:	maintainer timeout > 1 month
  • Loading branch information
drTr0jan authored and nunotexbsd committed Jul 14, 2022
1 parent b8dee5b commit c15d387
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
23 changes: 9 additions & 14 deletions net-mgmt/ping_exporter/Makefile
@@ -1,35 +1,30 @@
PORTNAME= ping_exporter
DISTVERSION= 0.44
PORTREVISION= 5
DISTVERSION= 1.0.0
CATEGORIES= net-mgmt
MASTER_SITES= https://raw.githubusercontent.com/czerwonk/ping_exporter/${DISTVERSIONFULL}/:gomod
DISTFILES= go.mod:gomod

MAINTAINER= jp+ports@supplntr.io
COMMENT= Prometheus exporter for ICMP echo requests

LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE

USES= go
USES= go:modules
USE_GITHUB= yes
GH_ACCOUNT= czerwonk
GH_TUPLE= golang:net:83d349e8ac1a:golang_net/vendor/golang.org/x/net_83d349e8ac1a \
golang:sys:fead79001313:golang_sys/vendor/golang.org/x/sys_fead79001313

GO_PKGNAME= github.com/${GH_ACCOUNT}/${PORTNAME}
GO_TARGET= github.com/${GH_ACCOUNT}/${PORTNAME}

USE_RC_SUBR= ping_exporter
SUB_FILES= pkg-message

pre-build:
${RM} -r ${WRKSRC}/vendor/golang.org/x/net ${WRKSRC}/vendor/golang.org/x/sys
${MV} ${WRKSRC}/vendor/golang.org/x/net_83d349e8ac1a ${WRKSRC}/vendor/golang.org/x/net
${MV} ${WRKSRC}/vendor/golang.org/x/sys_fead79001313 ${WRKSRC}/vendor/golang.org/x/sys
GO_MODULE= github.com/czerwonk/ping_exporter

SUB_FILES= pkg-message

post-install:
${INSTALL_DATA} ${PATCHDIR}/ping_exporter.yml.sample \
${STAGEDIR}${PREFIX}/etc/ping_exporter.yml.sample
${MKDIR} ${STAGEDIR}${DATADIR}/syslog.d \
${STAGEDIR}${DATADIR}/newsyslog.conf.d
${STAGEDIR}${DATADIR}/newsyslog.conf.d
${INSTALL_DATA} ${PATCHDIR}/ping_exporter.syslog \
${STAGEDIR}${DATADIR}/syslog.d/ping_exporter.conf
${INSTALL_DATA} ${PATCHDIR}/ping_exporter.newsyslog \
Expand Down
12 changes: 5 additions & 7 deletions net-mgmt/ping_exporter/distinfo
@@ -1,7 +1,5 @@
TIMESTAMP = 1580722648
SHA256 (czerwonk-ping_exporter-0.44_GH0.tar.gz) = 03d0c825fdb8d3c8701743897726ad7960879211238135363879161bbdcd06a7
SIZE (czerwonk-ping_exporter-0.44_GH0.tar.gz) = 4595291
SHA256 (golang-net-83d349e8ac1a_GH0.tar.gz) = 5752c376bc6383bf2055281336101c062b881f17ded2e960d718c8256023f9c7
SIZE (golang-net-83d349e8ac1a_GH0.tar.gz) = 1103298
SHA256 (golang-sys-fead79001313_GH0.tar.gz) = c8e102db152c51438f426a92b338f924827b960e75bd9d871ae9438135366073
SIZE (golang-sys-fead79001313_GH0.tar.gz) = 1258330
TIMESTAMP = 1657786078
SHA256 (go/net-mgmt_ping_exporter/czerwonk-ping_exporter-1.0.0_GH0/go.mod) = 6bae8443b4cf3cfff123661b0d1fdabdad086f427ed52efc12d8bfca46524775
SIZE (go/net-mgmt_ping_exporter/czerwonk-ping_exporter-1.0.0_GH0/go.mod) = 1034
SHA256 (go/net-mgmt_ping_exporter/czerwonk-ping_exporter-1.0.0_GH0/czerwonk-ping_exporter-1.0.0_GH0.tar.gz) = 30587533f09e38db73873b77de5f476066cb87102c951a699bd418cdcfac94bb
SIZE (go/net-mgmt_ping_exporter/czerwonk-ping_exporter-1.0.0_GH0/czerwonk-ping_exporter-1.0.0_GH0.tar.gz) = 31406
51 changes: 38 additions & 13 deletions net-mgmt/ping_exporter/files/ping_exporter.in
Expand Up @@ -7,18 +7,27 @@
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# ping_exporter_enable (bool): Set to NO by default.
# ping_exporter_enable (bool): Set to NO by default.
# Set it to YES to enable ping_exporter.
# ping_exporter_user (string): Set user that ping_exporter will run under
# ping_exporter_user (string): Set user that ping_exporter will run under
# Default is "nobody".
# ping_exporter_group (string): Set group that ping_exporter will run under
# ping_exporter_group (string): Set group that ping_exporter will run under
# Default is "nobody".
# ping_exporter_args (string): Set extra arguments to pass to ping_exporter
# ping_exporter_args (string): Set extra arguments to pass to ping_exporter
# Default is "".
# ping_exporter_listen_address (string):Set ip:port that ping_exporter will listen on
# ping_exporter_listen_address (string): Set ip:port that ping_exporter will listen on
# Default is "localhost:9427".
# ping_exporter_config (string): Set configuration file of ping_exporter
# ping_exporter_config (string): Set configuration file of ping_exporter
# Default is "%%PREFIX%%/etc/ping_exporter.yml".
# ping_exporter_syslog_output_enable (bool): Set to YES to enable syslog output
# Default is "YES". See daemon(8).
# ping_exporter_syslog_output_tag (str): Set syslog tag if syslog enabled.
# Default is "ping_exporter". See daemon(8).
# ping_exporter_syslog_output_priority (str): Set syslog priority if syslog enabled.
# Default is "notice". See daemon(8).
# ping_exporter_syslog_output_facility (str): Set to YES to enable syslog output
# Default is "daemon". See daemon(8).


. /etc/rc.subr

Expand All @@ -33,19 +42,35 @@ load_rc_config $name
: ${ping_exporter_group:=nobody}
: ${ping_exporter_listen_address=localhost:9427}
: ${ping_exporter_config="%%PREFIX%%/etc/ping_exporter.yml"}
: ${ping_exporter_syslog_output_enable:="YES"}

start_precmd=ping_exporter_startprecmd

if checkyesno ping_exporter_syslog_output_enable; then
if [ -n "${ping_exporter_syslog_output_tag}" ]; then
ping_exporter_syslog_output_flags="-T ${ping_exporter_syslog_output_tag}"
else
ping_exporter_syslog_output_flags="-T ${name}"
fi
if [ -n "${ping_exporter_syslog_output_priority}" ]; then
ping_exporter_syslog_output_flags="${ping_exporter_syslog_output_flags} -s ${ping_exporter_syslog_output_priority}"
fi
if [ -n "${ping_exporter_syslog_output_facility}" ]; then
ping_exporter_syslog_output_flags="${ping_exporter_syslog_output_flags} -l ${ping_exporter_syslog_output_facility}"
fi
fi

required_files="${ping_exporter_config}"
pidfile=/var/run/ping_exporter.pid
command=/usr/sbin/daemon
procname="%%PREFIX%%/bin/ping_exporter"
command_args="-p ${pidfile} -t ${name} -T ${name} -S \
required_files="${ping_exporter_config}"

command=/usr/sbin/daemon
command_args="-p ${pidfile} -t ${name} ${ping_exporter_syslog_output_flags} -S \
/usr/bin/env ${procname} \
-web.listen-address ${ping_exporter_listen_address} \
-config.path ${ping_exporter_config} \
--web.listen-address=${ping_exporter_listen_address} \
--config.path=${ping_exporter_config} \
${ping_exporter_args} 2>&1"

start_precmd=ping_exporter_startprecmd

ping_exporter_startprecmd()
{
if [ ! -e ${pidfile} ]; then
Expand Down
2 changes: 2 additions & 0 deletions net-mgmt/ping_exporter/pkg-plist
@@ -1,4 +1,6 @@
@mode 4755
bin/ping_exporter
@mode
@sample %%ETCDIR%%.yml.sample
%%DATADIR%%/newsyslog.conf.d/ping_exporter.conf
%%DATADIR%%/syslog.d/ping_exporter.conf

0 comments on commit c15d387

Please sign in to comment.