Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: node_exporter |
4 |
# REQUIRE: LOGIN |
5 |
# KEYWORD: shutdown |
6 |
# |
7 |
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf |
8 |
# to enable this service: |
9 |
# |
10 |
# node_exporter_enable (bool): Set to NO by default. |
11 |
# Set it to YES to enable node_exporter. |
12 |
# node_exporter_user (string): Set user that node_exporter will run under |
13 |
# Default is "nobody". |
14 |
# node_exporter_group (string): Set group that node_exporter will run under |
15 |
# Default is "nobody". |
16 |
# node_exporter_args (string): Set extra arguments to pass to node_exporter |
17 |
# Default is "". |
18 |
# node_exporter_listen_address (string):Set ip:port that node_exporter will listen on |
19 |
# Default is ":9100". |
20 |
# node_exporter_textfile_dir (string): Set directory that node_exporter will watch |
21 |
# Default is "/var/tmp/node_exporter". |
22 |
|
23 |
. /etc/rc.subr |
24 |
|
25 |
name=node_exporter |
26 |
rcvar=node_exporter_enable |
27 |
|
28 |
load_rc_config $name |
29 |
|
30 |
: ${node_exporter_enable:="NO"} |
31 |
: ${node_exporter_user:="nobody"} |
32 |
: ${node_exporter_group:="nobody"} |
33 |
: ${node_exporter_args:=""} |
34 |
: ${node_exporter_listen_address:=":9100"} |
35 |
: ${node_exporter_textfile_dir:="/var/tmp/node_exporter"} |
36 |
|
37 |
|
38 |
pidfile=/var/run/node_exporter.pid |
39 |
command="/usr/sbin/daemon" |
40 |
procname="%%PREFIX%%/bin/node_exporter" |
41 |
command_args="-p ${pidfile} /usr/bin/env ${procname} \ |
42 |
-web.listen-address=${node_exporter_listen_address} \ |
43 |
-collector.textfile.directory=${node_exporter_textfile_dir} \ |
44 |
${node_exporter_args}" |
45 |
|
46 |
start_precmd=node_exporter_startprecmd |
47 |
|
48 |
node_exporter_startprecmd() |
49 |
{ |
50 |
if [ ! -e ${pidfile} ]; then |
51 |
install -o ${node_exporter_user} -g ${node_exporter_group} /dev/null ${pidfile}; |
52 |
fi |
53 |
if [ ! -d ${node_exporter_textfile_dir} ]; then |
54 |
install -d -o ${node_exporter_user} -g ${node_exporter_group} -m 1755 ${node_exporter_textfile_dir} |
55 |
fi |
56 |
} |
57 |
|
58 |
load_rc_config $name |
59 |
run_rc_command "$1" |