pangolin_exporter
/
postgres_exporter.rc
74 строки · 2.5 Кб
1#!/bin/sh
2
3# PROVIDE: postgres_exporter
4# REQUIRE: LOGIN
5# KEYWORD: shutdown
6#
7# rc-script for postgres_exporter
8#
9#
10# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
11# to enable this service:
12#
13# postgres_exporter_enable (bool): Set to NO by default.
14# Set it to YES to enable postgres_exporter.
15# postgres_exporter_user (string): Set user that postgres_exporter will run under
16# Default is "nobody".
17# postgres_exporter_group (string): Set group that postgres_exporter will run under
18# Default is "nobody".
19# postgres_exporter_args (string): Set extra arguments to pass to postgres_exporter
20# Default is "".
21# postgres_exporter_listen_address (string):Set ip:port to listen on for web interface and telemetry.
22# Defaults to ":9187"
23# postgres_exporter_pg_user (string): Set the Postgres database user
24# Defaults to "postgres_exporter"
25# postgres_exporter_pg_pass (string): Set the Postgres datase password
26# Default is empty
27# postgres_exporter_pg_host (string): Set the Postgres database server
28# Defaults to "localhost"
29# postgres_exporter_pg_port (string): Set the Postgres database port
30# Defaults to "5432"
31
32# Add extra arguments via "postgres_exporter_args"
33# (see $ postgres_exporter --help)
34
35
36. /etc/rc.subr
37
38name=postgres_exporter
39rcvar=postgres_exporter_enable
40
41load_rc_config $name
42
43: ${postgres_exporter_enable:="NO"}
44: ${postgres_exporter_user:="nobody"}
45: ${postgres_exporter_group:="nobody"}
46: ${postgres_exporter_args:=""}
47: ${postgres_exporter_listen_address:=":9187"}
48: ${postgres_exporter_pg_user:="postgres_exporter"}
49: ${postgres_exporter_pg_pass:=""}
50: ${postgres_exporter_pg_host:="localhost"}
51: ${postgres_exporter_pg_port:="5432"}
52
53postgres_exporter_data_source_name="postgresql://${postgres_exporter_pg_user}:${postgres_exporter_pg_pass}@${postgres_exporter_pg_host}:${postgres_exporter_pg_port}/postgres?sslmode=disable"
54
55
56pidfile=/var/run/postgres_exporter.pid
57command="/usr/sbin/daemon"
58procname="/usr/local/bin/postgres_exporter"
59command_args="-f -p ${pidfile} -T ${name} \
60/usr/bin/env DATA_SOURCE_NAME="${postgres_exporter_data_source_name}" ${procname} \
61--web.listen-address=${postgres_exporter_listen_address} \
62${postgres_exporter_args}"
63
64start_precmd=postgres_exporter_startprecmd
65
66postgres_exporter_startprecmd()
67{
68if [ ! -e ${pidfile} ]; then
69install -o ${postgres_exporter_user} -g ${postgres_exporter_group} /dev/null ${pidfile};
70fi
71}
72
73load_rc_config $name
74run_rc_command "$1"
75