File: postgres_exporter.rc

package info (click to toggle)
prometheus-postgres-exporter 0.4.7%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 352 kB
  • sloc: sh: 380; makefile: 100
file content (89 lines) | stat: -rw-r--r-- 3,196 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh

# PROVIDE: postgres_exporter
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# rc-script for postgres_exporter 
#
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# postgres_exporter_enable (bool):          Set to NO by default.
#               Set it to YES to enable postgres_exporter.
# postgres_exporter_user (string):          Set user that postgres_exporter will run under
#               Default is "nobody".
# postgres_exporter_group (string):         Set group that postgres_exporter will run under
#               Default is "nobody".
# postgres_exporter_args (string):          Set extra arguments to pass to postgres_exporter
#               Default is "".
# postgres_exporter_listen_address (string):Set ip:port to listen on for web interface and telemetry.
#		Defaults to ":9187"
# postgres_exporter_pg_user (string):	    Set the Postgres database user
#		Defaults to "postgres_exporter"
# postgres_exporter_pg_pass (string):	    Set the Postgres datase password
#		Default is empty
# postgres_exporter_pg_host (string):	    Set the Postgres database server
#		Defaults to "localhost"
# postgres_exporter_pg_port (string):  	    Set the Postgres database port
#		Defaults to "5432"

# Add extra arguments via "postgres_exporter_args" which could be choosen from:
# (see $ postgres_exporter --help)
#
#  -dumpmaps
#    	Do not run, simply dump the maps.
#  -extend.query-path string
#    	Path to custom queries to run.
#  -log.level value
#    	Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].
#  -version
#    	print version and exit
#  -web.telemetry-path string
#    	Path under which to expose metrics. (default "/metrics")
#  -log.format value
#    	If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.
#  -extend.query-path string
#    	Path to custom queries to run.


. /etc/rc.subr

name=postgres_exporter
rcvar=postgres_exporter_enable

load_rc_config $name

: ${postgres_exporter_enable:="NO"}
: ${postgres_exporter_user:="nobody"}
: ${postgres_exporter_group:="nobody"}
: ${postgres_exporter_args:=""}
: ${postgres_exporter_listen_address:=":9187"}
: ${postgres_exporter_pg_user:="postgres_exporter"}
: ${postgres_exporter_pg_pass:=""}
: ${postgres_exporter_pg_host:="localhost"}
: ${postgres_exporter_pg_port:="5432"}

postgres_exporter_data_source_name="postgresql://${postgres_exporter_pg_user}:${postgres_exporter_pg_pass}@${postgres_exporter_pg_host}:${postgres_exporter_pg_port}/postgres?sslmode=disable"


pidfile=/var/run/postgres_exporter.pid
command="/usr/sbin/daemon"
procname="/usr/local/bin/postgres_exporter"
command_args="-p ${pidfile} /usr/bin/env DATA_SOURCE_NAME="${postgres_exporter_data_source_name}" ${procname} \
    -web.listen-address=${postgres_exporter_listen_address} \
    ${postgres_exporter_args}"

start_precmd=postgres_exporter_startprecmd

postgres_exporter_startprecmd()
{
    if [ ! -e ${pidfile} ]; then
        install -o ${postgres_exporter_user} -g ${postgres_exporter_group} /dev/null ${pidfile};
    fi
}

load_rc_config $name
run_rc_command "$1"