aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/blackbox_exporter/files/blackbox_exporter.in
blob: 97beba8b28ae4c5deca7fdcd8a73e76084889303 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: blackbox_exporter
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# blackbox_exporter_enable (bool):          Set to NO by default.
#               Set it to YES to enable blackbox_exporter.
# blackbox_exporter_user (string):          Set user that blackbox_exporter will run under
#               Default is "prometheus".
# blackbox_exporter_group (string):         Set group that blackbox_exporter will run under
#               Default is "prometheus".
# blackbox_exporter_args (string):          Set extra arguments to pass to blackbox_exporter
#               Default is "".
# blackbox_exporter_listen_address (string):Set ip:port that blackbox_exporter will listen on
#               Default is "localhost:9115".
# blackbox_exporter_config (string):        Set configuration file of blackbox_exporter
#               Default is "%%PREFIX%%/etc/blackbox_exporter.yml".

. /etc/rc.subr

name=blackbox_exporter
desc="Blackbox exporter for use with Prometheus"
rcvar=blackbox_exporter_enable

load_rc_config $name

: ${blackbox_exporter_enable:=NO}
: ${blackbox_exporter_user:=prometheus}
: ${blackbox_exporter_group:=prometheus}
: ${blackbox_exporter_listen_address=localhost:9115}
: ${blackbox_exporter_config="%%PREFIX%%/etc/blackbox_exporter.yml"}

pidfile=/var/run/blackbox_exporter.pid
command=/usr/sbin/daemon
procname="%%PREFIX%%/bin/blackbox_exporter"
command_args="-p ${pidfile} -t ${name} -T ${name} -S \
    /usr/bin/env ${procname} \
    --web.listen-address=${blackbox_exporter_listen_address} \
    --config.file=${blackbox_exporter_config} \
    ${blackbox_exporter_args} 2>&1"

start_precmd=blackbox_exporter_startprecmd

blackbox_exporter_startprecmd()
{
    if [ ! -e ${pidfile} ]; then
        install \
            -o ${blackbox_exporter_user} \
            -g ${blackbox_exporter_group} \
            /dev/null ${pidfile};
    else
        chown ${blackbox_exporter_user}:${blackbox_exporter_group} ${pidfile};
    fi
}

run_rc_command "$1"