mirror of
https://git.freebsd.org/ports.git
synced 2025-07-12 06:49:18 -04:00
expose their metrics to Prometheus. Since these kinds of jobs may not exist long enough to be scraped, they can instead push their metrics to a Pushgateway. The Pushgateway then exposes these metrics to Prometheus. WWW: https://github.com/prometheus/pushgateway PR: 216882 Submitted by: Athanasios Douitsis <aduitsis@cpan.org>
66 lines
2 KiB
Bash
66 lines
2 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
|
|
# PROVIDE: pushgateway
|
|
# REQUIRE: LOGIN
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
|
# to enable this service:
|
|
#
|
|
# pushgateway_enable (bool): Set to NO by default
|
|
# Set it to YES to enable pushgateway
|
|
# pushgateway_user (string): Set user to run pushgateway
|
|
# Default is "prometheus"
|
|
# pushgateway_group (string): Set group to run pushgateway
|
|
# Default is "prometheus"
|
|
# pushgateway_data_dir (string): Set dir to run pushgateway in
|
|
# Default is "/var/db/pushgateway"
|
|
# pushgateway_persistence_file (string): Set file in which the pushed
|
|
# metrics will be persisted
|
|
# Default is "${pushgateway_data_dir}/persistent.data"
|
|
# pushgateway_log_file (string): Set file that pushgateway will log to
|
|
# Default is "/var/log/pushgateway.log"
|
|
# pushgateway_args (string): Set additional command line arguments
|
|
# Default is ""
|
|
|
|
. /etc/rc.subr
|
|
|
|
name=pushgateway
|
|
rcvar=pushgateway_enable
|
|
|
|
load_rc_config $name
|
|
|
|
: ${pushgateway_enable:=NO}
|
|
: ${pushgateway_user:=prometheus}
|
|
: ${pushgateway_group:=prometheus}
|
|
: ${pushgateway_data_dir=/var/db/pushgateway}
|
|
: ${pushgateway_persistence_file=${pushgateway_data_dir}/persistent.data}
|
|
: ${pushgateway_log_file=/var/log/pushgateway.log}
|
|
|
|
pidfile=/var/run/pushgateway.pid
|
|
command=/usr/sbin/daemon
|
|
procname="%%PREFIX%%/bin/pushgateway"
|
|
sig_reload=HUP
|
|
extra_commands=reload
|
|
command_args="-p ${pidfile} /usr/bin/env ${procname} \
|
|
-persistence.file=${pushgateway_persistence_file} \
|
|
${pushgateway_args} > ${pushgateway_log_file} 2>&1"
|
|
|
|
start_precmd=pushgateway_startprecmd
|
|
|
|
pushgateway_startprecmd()
|
|
{
|
|
if [ ! -e ${pidfile} ]; then
|
|
install -o ${pushgateway_user} -g ${pushgateway_group} /dev/null ${pidfile};
|
|
fi
|
|
if [ ! -f "${pushgateway_log_file}" ]; then
|
|
install -o ${pushgateway_user} -g ${pushgateway_group} -m 640 /dev/null ${pushgateway_log_file};
|
|
fi
|
|
if [ ! -d ${pushgateway_data_dir} ]; then
|
|
install -d -o ${pushgateway_user} -g ${pushgateway_group} -m 750 ${pushgateway_data_dir}
|
|
fi
|
|
}
|
|
|
|
run_rc_command "$1"
|