Files
ports/sysutils/beats8/files/metricbeat.in
Juraj Lutter c7e874cca9 sysutils/beats8: New port
Add sysutils/beats8, beats component for ELK 8.x.

There are many breaking changes in 8.x versions, see
https://www.elastic.co/guide/en/beats/libbeat/8.5/breaking-changes-8.0.html
for details.

Release notes for ELK 8.x are located here:
https://www.elastic.co/guide/en/beats/libbeat/8.5/release-notes.html
2022-11-26 22:03:17 +01:00

52 lines
1.5 KiB
Bash

#!/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"