sysutils/node_exporter: Add tests, docs and examples

- Define LICENSE_FILE.
- Sort variables.
- Add a do-test target and prepare a testing environment.  One test is
  skipped at the moment due to a problem with detecting procfs(5) on
  FreeBSD.
- Install documentation and examples.
- Change pkg-descr to better match upstream's README.

PR:		234791
Reviewed by:	mat
Approved by:	mat (mentor), maintainer timeout
Sponsored by:	BALLY WULFF Games & Entertainment GmbH
Differential Revision:	https://reviews.freebsd.org/D18792
This commit is contained in:
Mateusz Piotrowski 2019-01-28 09:16:24 +00:00
parent 3164cff536
commit 4427f94f9f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=491463
3 changed files with 64 additions and 6 deletions

View File

@ -4,24 +4,34 @@
PORTNAME= node_exporter
PORTVERSION= 0.17.0
DISTVERSIONPREFIX=v
PORTREVISION= 1
CATEGORIES= sysutils
MAINTAINER= ports@ecadlabs.com
COMMENT= Prometheus exporter for machine metrics
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= go
TEST_DEPENDS= promtool:net-mgmt/prometheus2 \
bash:shells/bash \
gsed:textproc/gsed
USES= gmake go shebangfix
USE_GITHUB= yes
GH_ACCOUNT= prometheus
USE_RC_SUBR= node_exporter
# The ttar script is used to run the tests.
SHEBANG_FILES= ttar
GO_PKGNAME= github.com/${GH_ACCOUNT}/${PORTNAME}
GO_TARGET= github.com/${GH_ACCOUNT}/${PORTNAME}
PLIST_FILES= bin/node_exporter
# A "checkrules" target is being added in >0.17.0.
TEST_TARGET= test
USE_RC_SUBR= node_exporter
TEST_ENV= PROMTOOL=${LOCALBASE}/bin/promtool
BUILD_USER?= ${USER}
LD_FLAG_X_PREFIX= -X ${GO_PKGNAME}/vendor/${GO_PKGNAME:H}/common/version
@ -32,7 +42,38 @@ LD_FLAG_STRING= -s \
${LD_FLAG_X_PREFIX}.BuildUser=${BUILD_USER}
GO_BUILDFLAGS= -v -ldflags "${LD_FLAG_STRING}"
OPTIONS_DEFINE= DOCS EXAMPLES
do-install:
${INSTALL_PROGRAM} ${WRKDIR}/bin/node_exporter ${STAGEDIR}${PREFIX}/bin
post-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
cd ${WRKSRC}/docs && \
${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR}
post-install-EXAMPLES-on:
${MKDIR} ${STAGEDIR}${EXAMPLESDIR}/text_collector_examples
cd ${WRKSRC} && ${COPYTREE_SHARE} ./text_collector_examples ${STAGEDIR}${EXAMPLESDIR}
# TestFileDescriptorLeak is being skipped at the moment because procfs(5) is
# not properly detected.
pre-test:
# Prevent Go from attempting to use Git to redownload its dependencies.
# They are already present in ${WRKSRC}/vendor.
${RM} ${WRKSRC}/go.mod
${REINPLACE_CMD} -e 's|sed|${LOCALBASE}/bin/gsed|g' ${WRKSRC}/ttar
${RM} -r ${WRKDIR}/src
${LN} -sf ${WRKSRC}/vendor ${WRKDIR}/src
${MKDIR} ${WRKSRC}/vendor/${GO_PKGNAME}
${LN} -sf ${WRKSRC}/collector ${WRKSRC}/vendor/${GO_PKGNAME}/collector
# GOPATH has to have exactly one element in order to have the test
# suite detect the node_exporter binary. "-v" is added here for us to
# see skipped tests.
${REINPLACE_CMD} -E 's|(\$$\(GO\) test)|env GOPATH="${WRKDIR}" \1 -v|g' ${WRKSRC}/Makefile
.include <bsd.port.mk>

View File

@ -1,4 +1,4 @@
node_exporter is a prometheus exporter for machine metrics, written in Go
with pluggable metric collectors.
Node exporter is a Prometheus exporter for hardware and OS metrics, written in
Go with pluggable metric collectors.
WWW: https://github.com/prometheus/node_exporter

View File

@ -0,0 +1,17 @@
bin/node_exporter
%%PORTDOCS%%%%DOCSDIR%%/README.md
%%PORTDOCS%%%%DOCSDIR%%/TIME.md
%%PORTDOCS%%%%DOCSDIR%%/V0_16_UPGRADE_GUIDE.md
%%PORTDOCS%%%%DOCSDIR%%/example-16-compatibility-rules-new-to-old.yml
%%PORTDOCS%%%%DOCSDIR%%/example-16-compatibility-rules.yml
%%PORTDOCS%%%%DOCSDIR%%/example-17-compatibility-rules-new-to-old.yml
%%PORTDOCS%%%%DOCSDIR%%/example-17-compatibility-rules.yml
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/README.md
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/apt.sh
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/deleted_libraries.py
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/directory-size.sh
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/ipmitool
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/md_info.sh
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/ntpd_metrics.py
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/smartmon.sh
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_collector_examples/storcli.py