summaryrefslogtreecommitdiff
path: root/sysutils/beats7/files/metricbeat.in
blob: 270966c4f6693a97d73d0d670a4d05dba54e759f (plain)
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
#!/bin/sh

# PROVIDE: metricbeat
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable metricbeat:
#
# metricbeat_enable (bool):	Set to YES to enable metricbeat
# 				Default: NO
# metricbeat_flags (str):	Extra flags passed to metricbeat
# metricbeat_config (str):	metricbeat configuration directory
#				Default: ${PREFIX}/etc/beats
# metricbeat_conffile (str):	metricbeat configuration file
#				relative to ${metricbeat_conf}
#				Default: metricbeat.yml

. /etc/rc.subr

name="metricbeat"
rcvar=${name}_enable
load_rc_config $name

: ${metricbeat_enable:="NO"}
: ${metricbeat_config:="%%ETCDIR%%"}
: ${metricbeat_conffile:="metricbeat.yml"}
: ${metricbeat_home:="%%DATADIR%%/metricbeat"}
: ${metricbeat_logs:="/var/log/beats"}
: ${metricbeat_data:="/var/db/beats/metricbeat"}

# daemon
start_precmd=metricbeat_prestart
command=/usr/sbin/daemon
pidfile="/var/run/${name}"
command_args="-frP ${pidfile} %%PREFIX%%/sbin/${name} ${metricbeat_flags} --path.config ${metricbeat_config} --path.home ${metricbeat_home} --path.data ${metricbeat_data} --path.logs ${metricbeat_logs} -c ${metricbeat_conffile}"

metricbeat_prestart() {
# Have to empty rc_flags so they don't get passed to daemon(8)
	rc_flags=""
}

# metricbeat will refuse to quit if linprocfs is mounted, and sadly requires -9
[ -f /compat/linux/proc/cpuinfo ] && stop_cmd=metricbeat_stop

metricbeat_stop() {
	pkill -9 -F ${pidfile} > /dev/null 2>&1
	pkill -9 -F ${pidfile}.child > /dev/null 2>&1
}

run_rc_command "$1"