Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Created September 11, 2017 14:13
Show Gist options
  • Save tobiastom/e4ab2d54b4cb4936fc547b7b0f8ca6df to your computer and use it in GitHub Desktop.
Save tobiastom/e4ab2d54b4cb4936fc547b7b0f8ca6df to your computer and use it in GitHub Desktop.
Consul Exporter Port
#!/bin/sh
# $FreeBSD: head/sysutils/consul/files/consul.in 438846 2017-04-19 14:32:23Z swills $
#
# PROVIDE: consul_exporter
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# consul_exporter_enable (bool): Set to NO by default.
# Set it to YES to enable consul exporter.
# consul_exporter_env (string): Set environment variables used with consul exporter.
# Default is "".
# consul_exporter_args (string): Set flags used with consul-exporter.
# Default is "".
. /etc/rc.subr
name=consul_exporter
rcvar=consul_exporter_enable
extra_commands="reload"
load_rc_config $name
: ${consul_exporter_enable:="NO"}
: ${consul_exporter_env:=""}
: ${consul_exporter_args:=""}
pidfile=/var/run/consul_exporter.pid
procname="%%PREFIX%%/bin/consul_exporter"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} /usr/bin/env ${consul_env} ${procname} ${consul_exporter_args}"
run_rc_command "$1"
TIMESTAMP = 1504964932
SHA256 (prometheus-consul_exporter-v0.3.0_GH0.tar.gz) = 621a7fd6f50b59d6c10f2325dafcffa95ab7b1491514c1f801485b4b037e9428
SIZE (prometheus-consul_exporter-v0.3.0_GH0.tar.gz) = 1031879
# $FreeBSD: head/sysutils/consul/Makefile 449361 2017-09-06 20:00:22Z swills $
PORTNAME= consul_exporter
PORTVERSION= 0.3.0
DISTVERSIONPREFIX= v
CATEGORIES= sysutils
MAINTAINER= swills@FreeBSD.org
COMMENT= Exporter for Consul metrics
LICENSE= APACHE20
BUILD_DEPENDS= ${LOCALBASE}/bin/go:lang/go
USES= compiler
USE_GITHUB= yes
GH_ACCOUNT= prometheus
GH_SUBDIR= src/github.com/${GH_ACCOUNT}/consul_exporter
USE_RC_SUBR= consul_exporter
PLIST_FILES= bin/consul_exporter
post-extract:
@${MV} ${WRKSRC}/vendor/ ${WRKSRC}/src/
do-build:
@cd ${WRKSRC}/src/github.com/prometheus/consul_exporter; ${SETENV} CGO_ENABLED=0 ${BUILD_ENV} GOPATH=${WRKSRC} go build \
-ldflags "\
-X github.com/prometheus/consul_exporter/version.Version=${PORTVERSION} \
-X github.com/prometheus/consul_exporter/version.VersionPrerelease= \
-X github.com/prometheus/consul_exporter/version.GitDescribe=v${PORTVERSION} \
" \
-o bin/consul_exporter
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/src/github.com/prometheus/consul_exporter/bin/consul_exporter ${STAGEDIR}${PREFIX}/bin/consul_exporter
.include <bsd.port.pre.mk>
# golang assumes that if clang is in use, it is called "clang" and not "cc". If
# it's called "cc", go fails.
.if ${COMPILER_TYPE} == clang
BUILD_ENV= CC=clang
.endif
.include <bsd.port.post.mk>
Export Consul service health to Prometheus.
WWW: https://github.com/prometheus/consul_exporter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment