Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: postgres_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 |
# postgres_exporter_enable (bool): Set to NO by default. |
11 |
# Set it to YES to enable postgres_exporter. |
12 |
# postgres_exporter_config_file (string): Set the configuration file. |
13 |
# Default is "%%PREFIX%%/etc/postgres_exporter.yml". |
14 |
# postgres_exporter_user (string): Set user that postgres_exporter will run under |
15 |
# Default is "nobody". |
16 |
# postgres_exporter_group (string): Set group that postgres_exporter will run under |
17 |
# Default is "nobody". |
18 |
# postgres_exporter_args (string): Set extra arguments to pass to postgres_exporter |
19 |
# Default is "". |
20 |
# postgres_exporter_listen_address (string):Set ip:port that postgres_exporter will listen on |
21 |
# Default is "localhost:9187". |
22 |
# postgres_exporter_syslog_output_tag (str): Set syslog tag. |
23 |
# Default is "postgres_exporter". See daemon(8). |
24 |
# postgres_exporter_syslog_output_priority (str): Set syslog priority. |
25 |
# Default is "notice". See daemon(8). |
26 |
# postgres_exporter_syslog_output_facility (str): Set syslog facility. |
27 |
# Default is "daemon". See daemon(8). |
28 |
|
29 |
|
30 |
. /etc/rc.subr |
31 |
|
32 |
name=postgres_exporter |
33 |
rcvar=postgres_exporter_enable |
34 |
|
35 |
load_rc_config $name |
36 |
|
37 |
: ${postgres_exporter_enable:="NO"} |
38 |
: ${postgres_exporter_config_file:="%%PREFIX%%/etc/postgres_exporter.yml"} |
39 |
: ${postgres_exporter_user:="nobody"} |
40 |
: ${postgres_exporter_group:="nobody"} |
41 |
: ${postgres_exporter_args:=""} |
42 |
: ${postgres_exporter_listen_address:="localhost:9187"} |
43 |
: ${postgres_exporter_syslog_output_tag=${name}} |
44 |
: ${postgres_exporter_syslog_output_priority=notice} |
45 |
: ${postgres_exporter_syslog_output_facility=daemon} |
46 |
|
47 |
pidfile=/var/run/postgres_exporter.pid |
48 |
command="/usr/sbin/daemon" |
49 |
procname="%%PREFIX%%/bin/postgres_exporter" |
50 |
command_args="-f -p ${pidfile} -t ${name} \ |
51 |
-T ${postgres_exporter_syslog_output_tag} \ |
52 |
-s ${postgres_exporter_syslog_output_priority} \ |
53 |
-l ${postgres_exporter_syslog_output_facility} \ |
54 |
/usr/bin/env ${procname} \ |
55 |
--web.listen-address=${postgres_exporter_listen_address} \ |
56 |
--config.file=${postgres_exporter_config_file} \ |
57 |
${postgres_exporter_args}" |
58 |
|
59 |
start_precmd=postgres_exporter_startprecmd |
60 |
|
61 |
postgres_exporter_startprecmd() |
62 |
{ |
63 |
if [ ! -e ${pidfile} ]; then |
64 |
install \ |
65 |
-o ${postgres_exporter_user} \ |
66 |
-g ${postgres_exporter_group} \ |
67 |
/dev/null ${pidfile}; |
68 |
fi |
69 |
} |
70 |
|
71 |
load_rc_config $name |
72 |
run_rc_command "$1" |
73 |
|