summaryrefslogtreecommitdiff
path: root/sysutils/beats6/files/metricbeat.in
blob: 9ec75b1759d1156805eefec30a92b3bd968a5c5e (plain) (blame)
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
#!/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_conf (str):	metricbeat configuration metric
#				Default: ${PREFIX}/etc/metricbeat.yml

. /etc/rc.subr

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

: ${metricbeat_enable:="NO"}
: ${metricbeat_config:="-path.home /var/db/beats/${name} -path.config %%PREFIX%%/etc"}

# daemon
start_precmd=metricbeat_prestart
command=/usr/sbin/daemon
pidfile="/var/run/${name}"
command_args="-rfP ${pidfile} -p ${pidfile}.child %%PREFIX%%/sbin/${name} ${metricbeat_config}"

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"