aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/victoria-metrics/files/vmagent.in
diff options
context:
space:
mode:
Diffstat (limited to 'net-mgmt/victoria-metrics/files/vmagent.in')
-rw-r--r--net-mgmt/victoria-metrics/files/vmagent.in65
1 files changed, 65 insertions, 0 deletions
diff --git a/net-mgmt/victoria-metrics/files/vmagent.in b/net-mgmt/victoria-metrics/files/vmagent.in
new file mode 100644
index 000000000000..b07a662486a9
--- /dev/null
+++ b/net-mgmt/victoria-metrics/files/vmagent.in
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# PROVIDE: victoria_vmagent
+# REQUIRE: NETWORK
+# BEFORE: DAEMON
+
+. /etc/rc.subr
+
+name="victoria_vmagent"
+desc="Fast, cost-effective, and scalable time series database"
+rcvar="victoria_vmagent_enable"
+pidfile="/var/run/${name}.pid"
+daemon_pidfile="/var/run/${name}-daemon.pid"
+logdir="/var/log/${name}"
+logfile="${logdir}/victoria_vmagent.log"
+command="%%PREFIX%%/bin/vmagent"
+victoria_vmagent_args=${cbsd_mq_router_config-"--remoteWrite.tmpDataPath=/tmp --promscrape.config=%%PREFIX%%/etc/prometheus/prometheus.yml --remoteWrite.url=http://127.0.0.1:8429/api/v1/write -httpListenAddr=:9429 --memory.allowedPercent=80"}
+victoria_vmagent_user="%%VICTORIA_USER%%"
+load_rc_config ${name}
+
+start_cmd="start"
+stop_cmd="stop"
+status_cmd="status"
+
+start()
+{
+ [ ! -d ${logdir} ] && mkdir -p ${logdir}
+ touch ${logfile}
+ chown ${victoria_vmagent_user} ${logdir} ${logfile}
+ /usr/sbin/daemon -u ${victoria_vmagent_user} -f -R5 -p ${pidfile} -P ${daemon_pidfile} -o ${logfile} ${command} ${victoria_vmagent_args}
+}
+
+stop()
+{
+ if [ -f "${daemon_pidfile}" ]; then
+ pids=$( pgrep -F ${daemon_pidfile} 2>&1 )
+ _err=$?
+ [ ${_err} -eq 0 ] && kill -9 ${pids} && /bin/rm -f ${daemon_pidfile}
+ fi
+ if [ -f "${pidfile}" ]; then
+ pids=$( pgrep -F ${pidfile} 2>&1 )
+ _err=$?
+ [ ${_err} -eq 0 ] && kill -9 ${pids} && /bin/rm -f ${pidfile}
+ fi
+}
+
+status()
+{
+ if [ -f "${pidfile}" ]; then
+ pids=$( pgrep -F ${pidfile} 2>&1 )
+ _err=$?
+ if [ ${_err} -eq 0 ]; then
+ echo "${name} is running as pid ${pids}"
+ exit 0
+ else
+ echo "wrong pid: ${pids}"
+ exit 1
+ fi
+ else
+ echo "no pidfile $pidfile"
+ exit 1
+ fi
+}
+
+run_rc_command "$1"