1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-21 04:06:46 +00:00

net-mgmt/prometheus2: Update 2.2.1 -> 2.3.1

Port changes:
* Add syslogs and newsyslog config files
* Add USE_SYSLOG option

PR:		228185
Submitted by:	David O'Rourke <dor.bsd@xm0.uk> (maintainer)
This commit is contained in:
Yuri Victorovich 2018-07-01 07:16:50 +00:00
parent 53cdbb8290
commit 9334941dd1
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=473656
6 changed files with 120 additions and 39 deletions

View File

@ -2,7 +2,7 @@
PORTNAME= prometheus
DISTVERSIONPREFIX= v
DISTVERSION= 2.2.1
DISTVERSION= 2.3.1
CATEGORIES= net-mgmt
MAINTAINER= dor.bsd@xm0.uk
@ -16,22 +16,57 @@ GO_PKGNAME= github.com/${GH_ACCOUNT}/${GH_PROJECT}
USE_GITHUB= yes
USE_RC_SUBR= prometheus
USERS= prometheus
GROUPS= prometheus
OPTIONS_DEFINE= USE_SYSLOG
OPTIONS_DEFAULT= USE_SYSLOG
USE_SYSLOG_DESC= Install configuration files for syslog and newsyslog
OPTIONS_SUB= yes
PROMETHEUS_USER?= prometheus
PROMETHEUS_GROUP?= prometheus
USERS= ${PROMETHEUS_USER}
GROUPS= ${PROMETHEUS_GROUP}
PROMETHEUS_BINARIES= prometheus promtool
PROMETHEUS_SHARE_DIR= ${DATADIR}
PROMETHEUS_CONSOLES_DIR= ${PROMETHEUS_SHARE_DIR}/consoles
PROMETHEUS_CONSOLE_LIBRARIES_DIR= ${PROMETHEUS_SHARE_DIR}/console_libraries
PROMETHEUS_DB_DIR= /var/db/${PORTNAME}
PROMETHEUS_LOG_DIR= /var/log/prometheus
PROMETHEUS_LOG_FILE= ${PROMETHEUS_LOG_DIR}/prometheus.log
SUB_FILES= prometheus \
newsyslog.conf \
syslog.d.conf
SUB_LIST+= PROMETHEUS_USER=${PROMETHEUS_USER} \
PROMETHEUS_GROUP=${PROMETHEUS_GROUP} \
PROMETHEUS_CONSOLE_LIBRARIES_DIR=${PROMETHEUS_CONSOLE_LIBRARIES_DIR} \
PROMETHEUS_CONSOLES_DIR=${PROMETHEUS_CONSOLES_DIR} \
PROMETHEUS_DB_DIR=${PROMETHEUS_DB_DIR} \
PROMETHEUS_LOG_DIR=${PROMETHEUS_LOG_DIR} \
PROMETHEUS_LOG_FILE=${PROMETHEUS_LOG_FILE} \
PROMETHEUS_SHARE_DIR=${PROMETHEUS_SHARE_DIR}
PLIST_SUB+= PORTNAME=${PORTNAME} \
PROMETHEUS_CONSOLE_LIBRARIES_DIR=${PROMETHEUS_CONSOLE_LIBRARIES_DIR} \
PROMETHEUS_CONSOLES_DIR=${PROMETHEUS_CONSOLES_DIR} \
PROMETHEUS_DB_DIR=${PROMETHEUS_DB_DIR} \
PROMETHEUS_LOG_DIR=${PROMETHEUS_LOG_DIR}
BUILD_USER?= ${USER}
LD_FLAG_X_PREFIX= -X ${GO_PKGNAME}/vendor/${GO_PKGNAME:H}/common/version
LD_FLAG_STRING= -s \
${LD_FLAG_X_PREFIX}.Version=${PORTVERSION} \
${LD_FLAG_X_PREFIX}.Revision=${PORTREVISION} \
${LD_FLAG_X_PREFIX}.Branch=release-${PORTVERSION:R} \
${LD_FLAG_X_PREFIX}.BuildUser=${BUILD_USER}
PROMETHEUS_BINARIES= prometheus promtool
${LD_FLAG_X_PREFIX}.Version=${PORTVERSION} \
${LD_FLAG_X_PREFIX}.Revision=${PORTREVISION} \
${LD_FLAG_X_PREFIX}.Branch=release-${PORTVERSION:R} \
${LD_FLAG_X_PREFIX}.BuildUser=${BUILD_USER}
do-build:
.for bin in ${PROMETHEUS_BINARIES}
( cd ${GO_WRKSRC}/cmd/${bin} ; \
${SETENV} ${MAKE_ENV} ${GO_ENV} go install -ldflags "${LD_FLAG_STRING}" )
${SETENV} ${MAKE_ENV} ${GO_ENV} \
${GO_CMD} install -v -ldflags "${LD_FLAG_STRING}" )
.endfor
do-install:
@ -41,7 +76,24 @@ do-install:
${INSTALL_DATA} \
${WRKSRC}/documentation/examples/prometheus.yml \
${STAGEDIR}${LOCALBASE}/etc/prometheus.yml.sample
@${MKDIR} ${STAGEDIR}${DESTDIR}${PROMETHEUS_DB_DIR}
@${MKDIR} ${STAGEDIR}${DESTDIR}${PROMETHEUS_CONSOLES_DIR}
@${MKDIR} ${STAGEDIR}${DESTDIR}${PROMETHEUS_CONSOLE_LIBRARIES_DIR}
@${MKDIR} ${STAGEDIR}${PROMETHEUS_LOG_DIR}
( cd ${WRKSRC}/console_libraries \
&& ${COPYTREE_SHARE} . ${STAGEDIR}${PROMETHEUS_CONSOLE_LIBRARIES_DIR} \
)
( cd ${WRKSRC}/consoles \
&& ${COPYTREE_SHARE} . ${STAGEDIR}${PROMETHEUS_CONSOLES_DIR} \
)
${MKDIR} ${STAGEDIR}${DESTDIR}/var/db/prometheus
post-install-USE_SYSLOG-on:
@${MKDIR} ${STAGEDIR}${ETCDIR}
${INSTALL_DATA} \
${WRKDIR}/syslog.d.conf \
${STAGEDIR}${ETCDIR}/syslog.d.conf.sample
${INSTALL_DATA} \
${WRKDIR}/newsyslog.conf \
${STAGEDIR}${ETCDIR}/newsyslog.conf.sample
.include <bsd.port.mk>

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1523391674
SHA256 (prometheus-prometheus-v2.2.1_GH0.tar.gz) = 4f75427449bb72d1886f6cd46f752fe6300242da48b8bb870dbbd7ffc879ed92
SIZE (prometheus-prometheus-v2.2.1_GH0.tar.gz) = 5629500
TIMESTAMP = 1529852060
SHA256 (prometheus-prometheus-v2.3.1_GH0.tar.gz) = 3aab85d3cb59540b6b43f5a80b14d13937fc0d51e8e82a29f0efebf6addd5f75
SIZE (prometheus-prometheus-v2.3.1_GH0.tar.gz) = 6175030

View File

@ -0,0 +1,6 @@
# newsyslog(8) file for net-mgmt/prometheus2
# See newsyslog.conf(5) for details.
#
# Log file will be rotated daily, and we'll keep 15 days of logs matching the
# default Prometheus TSDB retention time.
%%PROMETHEUS_LOG_FILE%% 640 15 * @T00 JC

View File

@ -7,18 +7,27 @@
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# prometheus_enable (bool): Set to NO by default
# Set it to YES to enable prometheus
# prometheus_user (string): Set user to run prometheus
# Default is "prometheus"
# prometheus_group (string): Set group to run prometheus
# Default is "prometheus"
# prometheus_data_dir (string): Set dir to run prometheus in
# Default is "/var/db/prometheus"
# prometheus_log_file (string): Set file that prometheus will log to
# Default is "/var/log/prometheus.log"
# prometheus_args (string): Set additional command line arguments
# Default is ""
# prometheus_enable (bool)
# Set to NO by default
# Set it to YES to enable prometheus
# prometheus_user (string)
# Set user to run prometheus
# Default is "%%PROMETHEUS_USER%%"
# prometheus_group (string)
# Set group to run prometheus
# Default is "%%PROMETHEUS_GROUP%%"
# prometheus_data_dir (string)
# Set dir to run prometheus in
# Default is "%%PROMETHEUS_DB_DIR%%"
# prometheus_consoles (string)
# Set dir that contains Prometheus consoles
# Default is "%%PROMETHEUS_CONSOLES_DIR%%"
# prometheus_console_libraries (string)
# Set dir containing Prometheus console libraries
# Default is "%%PROMETHEUS_CONSOLE_LIBRARIES_DIR%%"
# prometheus_args (string)
# Set additional command line arguments
# Default is ""
. /etc/rc.subr
@ -28,11 +37,12 @@ rcvar=prometheus_enable
load_rc_config $name
: ${prometheus_enable:="NO"}
: ${prometheus_user:="prometheus"}
: ${prometheus_group:="prometheus"}
: ${prometheus_user:="%%PROMETHEUS_USER%%"}
: ${prometheus_group:="%%PROMETHEUS_GROUP%%"}
: ${prometheus_config:="%%PREFIX%%/etc/prometheus.yml"}
: ${prometheus_data_dir:="/var/db/prometheus"}
: ${prometheus_log_file:="/var/log/prometheus.log"}
: ${prometheus_data_dir:="%%PROMETHEUS_DB_DIR%%"}
: ${prometheus_consoles_dir:="%%PROMETHEUS_CONSOLES_DIR%%"}
: ${prometheus_console_libraries_dir:="%%PROMETHEUS_CONSOLE_LIBRARIES_DIR%%"}
: ${prometheus_args:=""}
pidfile="/var/run/${name}.pid"
@ -41,10 +51,13 @@ command="/usr/sbin/daemon"
procname="%%PREFIX%%/bin/${name}"
sig_reload="HUP"
extra_commands="reload"
command_args="-p ${pidfile} /usr/bin/env ${procname} \
command_args="-p ${pidfile} -m 3 -T ${name} \
/usr/bin/env ${procname} \
--config.file=${prometheus_config} \
--storage.tsdb.path=${prometheus_data_dir} \
${prometheus_args} >> ${prometheus_log_file} 2>&1"
--web.console.templates=${prometheus_consoles_dir} \
--web.console.libraries=${prometheus_console_libraries_dir} \
${prometheus_args}"
start_precmd=prometheus_startprecmd
@ -73,13 +86,6 @@ prometheus_startprecmd()
-g ${prometheus_group} \
/dev/null ${pidfile};
fi
if [ ! -f "${prometheus_log_file}" ]; then
install \
-o ${prometheus_user} \
-g ${prometheus_group} \
-m 640 \
/dev/null ${prometheus_log_file};
fi
if [ ! -d ${prometheus_data_dir} ]; then
install \
-d \

View File

@ -0,0 +1,5 @@
# syslogd(8) configuration file for net-mgmt/prometheus2
#
# See syslog.conf(5) for details.
!prometheus
daemon.* %%PROMETHEUS_LOG_FILE%%

View File

@ -1,4 +1,16 @@
bin/prometheus
bin/promtool
%%USE_SYSLOG%%@sample %%ETCDIR%%/newsyslog.conf.sample etc/newsyslog.conf.d/%%PORTNAME%%.conf
%%USE_SYSLOG%%@sample %%ETCDIR%%/syslog.d.conf.sample /etc/syslog.d/%%PORTNAME%%.conf
%%PROMETHEUS_CONSOLE_LIBRARIES_DIR%%/menu.lib
%%PROMETHEUS_CONSOLE_LIBRARIES_DIR%%/prom.lib
%%PROMETHEUS_CONSOLES_DIR%%/index.html.example
%%PROMETHEUS_CONSOLES_DIR%%/node-cpu.html
%%PROMETHEUS_CONSOLES_DIR%%/node-disk.html
%%PROMETHEUS_CONSOLES_DIR%%/node-overview.html
%%PROMETHEUS_CONSOLES_DIR%%/node.html
%%PROMETHEUS_CONSOLES_DIR%%/prometheus-overview.html
%%PROMETHEUS_CONSOLES_DIR%%/prometheus.html
@sample etc/prometheus.yml.sample
@dir(prometheus,prometheus) /var/db/prometheus
@dir(prometheus,prometheus) %%PROMETHEUS_DB_DIR%%
@dir(root,root) %%PROMETHEUS_LOG_DIR%%