From owner-dev-commits-ports-all@freebsd.org Fri Jun 4 06:42:27 2021 Return-Path: Delivered-To: dev-commits-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3606648947; Fri, 4 Jun 2021 06:42:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FxCql4b68z4S3V; Fri, 4 Jun 2021 06:42:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 85A4E18727; Fri, 4 Jun 2021 06:42:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1546gR04097486; Fri, 4 Jun 2021 06:42:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1546gRjk097485; Fri, 4 Jun 2021 06:42:27 GMT (envelope-from git) Date: Fri, 4 Jun 2021 06:42:27 GMT Message-Id: <202106040642.1546gRjk097485@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Alexey Dokuchaev Subject: git: 662fb5c9e3a1 - main - net-mgmt/vmutils: the port had been improved (+) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: danfe X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 662fb5c9e3a1a9bb12e402b0e8f8f17ba12d08cd Auto-Submitted: auto-generated X-BeenThere: dev-commits-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the ports repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jun 2021 06:42:27 -0000 The branch main has been updated by danfe: URL: https://cgit.FreeBSD.org/ports/commit/?id=662fb5c9e3a1a9bb12e402b0e8f8f17ba12d08cd commit 662fb5c9e3a1a9bb12e402b0e8f8f17ba12d08cd Author: Alexey Dokuchaev AuthorDate: 2021-06-04 06:32:48 +0000 Commit: Alexey Dokuchaev CommitDate: 2021-06-04 06:38:01 +0000 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 --- .../victoria-metrics/files/prometheus.yml.sample | 17 +++++++++++ net-mgmt/victoria-metrics/files/vmagent.in | 34 ++++++++++++++++------ net-mgmt/vmutils/Makefile | 5 ++++ net-mgmt/vmutils/pkg-plist | 1 + 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 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