aboutsummaryrefslogtreecommitdiff
path: root/sysutils/snmp_exporter/files/snmp_exporter.in
blob: 544dd3f5488b94860469df48520932e786305b76 (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
#!/bin/sh

# $FreeBSD$

# PROVIDE: snmp_exporter
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# snmp_exporter_enable (bool):          Set to NO by default.
#               Set it to YES to enable snmp_exporter.
# snmp_exporter_user (string):          Set user that snmp_exporter will run under
#               Default is "nobody".
# snmp_exporter_group (string):         Set group that snmp_exporter will run under
#               Default is "nobody".
# snmp_exporter_args (string):          Set extra arguments to pass to snmp_exporter
#               Default is "".
# snmp_exporter_listen_address (string):Set ip:port that snmp_exporter will listen on
#               Default is ":9116".
# snmp_exporter_config_file (string)    Set the location of the snmp_exporter config
#                                       configuration file.
#               Default is "%%PREFIX%%/etc/snmp_exporter/snmp.yml"

. /etc/rc.subr

name=snmp_exporter
rcvar=snmp_exporter_enable

load_rc_config $name

: ${snmp_exporter_enable:="NO"}
: ${snmp_exporter_user:="nobody"}
: ${snmp_exporter_group:="nobody"}
: ${snmp_exporter_args:=""}
: ${snmp_exporter_listen_address:=":9116"}
: ${snmp_exporter_config_file:="%%PREFIX%%/etc/snmp_exporter/snmp.yml"}

pidfile=/var/run/snmp_exporter.pid
command="/usr/sbin/daemon"
procname="%%PREFIX%%/bin/snmp_exporter"
command_args="-p ${pidfile} -T ${name} \
    /usr/bin/env ${procname} \
    --web.listen-address=${snmp_exporter_listen_address} \
    --config.file=${snmp_exporter_config_file} \
    ${snmp_exporter_args}"

start_precmd=snmp_exporter_startprecmd

snmp_exporter_startprecmd()
{
    if [ ! -e ${pidfile} ]; then
        install -o ${snmp_exporter_user} -g ${snmp_exporter_group} /dev/null ${pidfile};
    fi
}

load_rc_config $name
run_rc_command "$1"