aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt
diff options
context:
space:
mode:
authorAlexey Dokuchaev <danfe@FreeBSD.org>2021-06-04 06:32:48 +0000
committerAlexey Dokuchaev <danfe@FreeBSD.org>2021-06-04 06:38:01 +0000
commit662fb5c9e3a1a9bb12e402b0e8f8f17ba12d08cd (patch)
tree83760f2bdac1ea3b1eacd186a8381c1d1b594c89 /net-mgmt
parentd72610436b184005299bb627c7af9a41026c87e6 (diff)
downloadports-662fb5c9e3a1a9bb12e402b0e8f8f17ba12d08cd.tar.gz
ports-662fb5c9e3a1a9bb12e402b0e8f8f17ba12d08cd.zip
net-mgmt/vmutils: the port had been improved (+)
- Drop needless `victoria_' prefix from the startup script name and various related variables; this helps readability - Introduce checkconfig() function and hook it as [re]start commands prerequisite command - Install sample scrape configuration file Submitted by: Oleg Ginzburg
Diffstat (limited to 'net-mgmt')
-rw-r--r--net-mgmt/victoria-metrics/files/prometheus.yml.sample17
-rw-r--r--net-mgmt/victoria-metrics/files/vmagent.in34
-rw-r--r--net-mgmt/vmutils/Makefile5
-rw-r--r--net-mgmt/vmutils/pkg-plist1
4 files changed, 48 insertions, 9 deletions
diff --git a/net-mgmt/victoria-metrics/files/prometheus.yml.sample b/net-mgmt/victoria-metrics/files/prometheus.yml.sample
new file mode 100644
index 000000000000..bc0ffde40d9c
--- /dev/null
+++ b/net-mgmt/victoria-metrics/files/prometheus.yml.sample
@@ -0,0 +1,17 @@
+# Global configuration.
+global:
+ scrape_interval: 15s
+ evaluation_interval: 15s
+
+# A scrape configuration containing exactly one endpoint to scrape:
+# the vmagent itself.
+scrape_configs:
+ - job_name: vmagent
+ scrape_interval: 60s
+ scrape_timeout: 30s
+ metrics_path: "/metrics"
+ static_configs:
+ - targets:
+ - 127.0.0.1:8429
+ labels:
+ project: vmagent
diff --git a/net-mgmt/victoria-metrics/files/vmagent.in b/net-mgmt/victoria-metrics/files/vmagent.in
index 06cf5ecbf26d..df1fb5a9d6dd 100644
--- a/net-mgmt/victoria-metrics/files/vmagent.in
+++ b/net-mgmt/victoria-metrics/files/vmagent.in
@@ -1,34 +1,50 @@
#!/bin/sh
-# PROVIDE: victoria_vmagent
+# PROVIDE: vmagent
# REQUIRE: NETWORK
# BEFORE: DAEMON
. /etc/rc.subr
-name="victoria_vmagent"
+name="vmagent"
desc="Fast, cost-effective, and scalable time series database"
-rcvar="victoria_vmagent_enable"
+rcvar="vmagent_enable"
pidfile="/var/run/${name}.pid"
daemon_pidfile="/var/run/${name}-daemon.pid"
logdir="/var/log/${name}"
-logfile="${logdir}/victoria_vmagent.log"
+logfile="${logdir}/vmagent.log"
command="%%PREFIX%%/bin/vmagent"
-victoria_vmagent_args=${victoria_vmagent_args-"--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%%"
+vmagent_args=${vmagent_args-"--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"}
+vmagent_user="%%VICTORIA_USER%%"
load_rc_config ${name}
+restart_precmd="checkconfig"
+start_precmd="checkconfig"
+checkconfig_cmd="checkconfig"
start_cmd="start"
stop_cmd="stop"
status_cmd="status"
-extra_commands="reload"
+extra_commands="checkconfig reload"
+
+checkconfig()
+{
+ local _ret
+
+ /usr/bin/su -m ${vmagent_user} -c "${command} ${vmagent_args} -promscrape.config.dryRun" > /dev/null 2>&1
+ _ret=$?
+ if [ ${_ret} -ne 0 ]; then
+ echo "${name} checkconfig failed:"
+ echo "/usr/bin/su -m ${vmagent_user} -c \"${command} ${vmagent_args} -promscrape.config.dryRun\""
+ exit ${_ret}
+ fi
+}
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}
+ chown ${vmagent_user} ${logdir} ${logfile}
+ /usr/sbin/daemon -u ${vmagent_user} -f -R5 -p ${pidfile} -P ${daemon_pidfile} -o ${logfile} ${command} ${vmagent_args}
}
stop()
diff --git a/net-mgmt/vmutils/Makefile b/net-mgmt/vmutils/Makefile
index ee41121132de..cb0c6e580113 100644
--- a/net-mgmt/vmutils/Makefile
+++ b/net-mgmt/vmutils/Makefile
@@ -1,6 +1,8 @@
# Created by: Alexey Dokuchaev <danfe@FreeBSD.org>
PORTNAME= vmutils
+PORTREVISION= 1
+
COMMENT= Ancillary utilities and agent for VictoriaMetrics
USE_RC_SUBR= vmagent
@@ -13,6 +15,9 @@ do-install:
${INSTALL_PROGRAM} ${WRKSRC}/bin/vm${p}-pure \
${STAGEDIR}${PREFIX}/bin/vm${p}
.endfor
+ @${MKDIR} ${STAGEDIR}${PREFIX}/etc/prometheus
+ ${INSTALL_DATA} ${FILESDIR}/prometheus.yml.sample \
+ ${STAGEDIR}${PREFIX}/etc/prometheus
do-install-DOCS-on:
@${MKDIR} ${STAGEDIR}${DOCSDIR}
diff --git a/net-mgmt/vmutils/pkg-plist b/net-mgmt/vmutils/pkg-plist
index 658c55bab447..04166109880a 100644
--- a/net-mgmt/vmutils/pkg-plist
+++ b/net-mgmt/vmutils/pkg-plist
@@ -4,6 +4,7 @@ bin/vmauth
bin/vmbackup
bin/vmctl
bin/vmrestore
+@sample etc/prometheus/prometheus.yml.sample
%%PORTDOCS%%%%DOCSDIR%%/vmagent.md
%%PORTDOCS%%%%DOCSDIR%%/vmagent.png
%%PORTDOCS%%%%DOCSDIR%%/vmalert.md