git: 45ba01cf1b21 - main - sysutils/py-prometheus-zfs: New port

From: Mateusz Piotrowski <0mp_at_FreeBSD.org>
Date: Tue, 05 Oct 2021 16:00:14 UTC
The branch main has been updated by 0mp:

URL: https://cgit.FreeBSD.org/ports/commit/?id=45ba01cf1b21db5d3e8ebba6aad68d76f5792612

commit 45ba01cf1b21db5d3e8ebba6aad68d76f5792612
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2021-10-05 15:57:28 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2021-10-05 15:59:26 +0000

    sysutils/py-prometheus-zfs: New port
    
    Prometheus exporter for ZFS statistics using py-libzfs.
    
    WWW: https://github.com/matusnovak/prometheus-zfs
---
 sysutils/Makefile                           |  1 +
 sysutils/py-prometheus-zfs/Makefile         | 34 +++++++++++++++++++++++++++++
 sysutils/py-prometheus-zfs/distinfo         |  3 +++
 sysutils/py-prometheus-zfs/files/zfsprom.in | 29 ++++++++++++++++++++++++
 sysutils/py-prometheus-zfs/pkg-descr        |  5 +++++
 5 files changed, 72 insertions(+)

diff --git a/sysutils/Makefile b/sysutils/Makefile
index 1265c07d472d..e0dbc39b49a8 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -1052,6 +1052,7 @@
     SUBDIR += py-ploy_ezjail
     SUBDIR += py-plumbum
     SUBDIR += py-power
+    SUBDIR += py-prometheus-zfs
     SUBDIR += py-psutil
     SUBDIR += py-psutil121
     SUBDIR += py-ptyprocess
diff --git a/sysutils/py-prometheus-zfs/Makefile b/sysutils/py-prometheus-zfs/Makefile
new file mode 100644
index 000000000000..5d73ec7f132e
--- /dev/null
+++ b/sysutils/py-prometheus-zfs/Makefile
@@ -0,0 +1,34 @@
+# Created by: Mateusz Piotrowski <0mp@FreeBSD.org>
+
+PORTNAME=	prometheus-zfs
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.0.3
+CATEGORIES=	sysutils python
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	0mp@FreeBSD.org
+COMMENT=	Prometheus exporter for ZFS statistics using py-libzfs
+
+LICENSE=	UNLICENSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}libzfs>=0:devel/py-libzfs@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}prometheus-client>=0:net-mgmt/py-prometheus-client@${PY_FLAVOR}
+
+USES=		python:3.6+ shebangfix
+USE_GITHUB=	yes
+GH_ACCOUNT=	matusnovak
+USE_RC_SUBR=	zfsprom
+SHEBANG_FILES=	zfsprom.py
+
+NO_ARCH=	yes
+NO_BUILD=	yes
+
+SUB_LIST=	PYTHON_CMD=${PYTHON_CMD}
+
+PLIST_FILES=	sbin/zfsprom.py
+
+do-install:
+	${INSTALL_SCRIPT} ${WRKSRC}/zfsprom.py ${STAGEDIR}${PREFIX}/sbin
+
+.include <bsd.port.mk>
diff --git a/sysutils/py-prometheus-zfs/distinfo b/sysutils/py-prometheus-zfs/distinfo
new file mode 100644
index 000000000000..4090a4cb3280
--- /dev/null
+++ b/sysutils/py-prometheus-zfs/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1633446717
+SHA256 (matusnovak-prometheus-zfs-v1.0.3_GH0.tar.gz) = 6d3c1e0100a85aecd94a32c2ff94552d7f4a52197c563bb9af20ab39be890bbb
+SIZE (matusnovak-prometheus-zfs-v1.0.3_GH0.tar.gz) = 3921
diff --git a/sysutils/py-prometheus-zfs/files/zfsprom.in b/sysutils/py-prometheus-zfs/files/zfsprom.in
new file mode 100644
index 000000000000..b4943811d22b
--- /dev/null
+++ b/sysutils/py-prometheus-zfs/files/zfsprom.in
@@ -0,0 +1,29 @@
+#! /bin/sh -
+#
+# SPDX-License-Identifier: (BSD-2-Clause or Unlicense)
+#
+# Copyright (c) 2021 Mateusz Piotrowski <0mp@FreeBSD.org>
+#
+
+# Add the following lines to rc.conf(5) to configure the zfsprom service:
+#
+# zfsprom_enable (bool):	Set to "YES" to enable the service.
+#				Default: "NO".
+
+# PROVIDE: zfsprom
+# REQUIRE: DAEMON
+
+. /etc/rc.subr
+
+name="zfsprom"
+rcvar="zfsprom_enable"
+
+load_rc_config "${name}"
+
+pidfile="/var/run/${name}.pid"
+procname="%%PREFIX%%/sbin/zfsprom.py"
+command_interpreter="%%PYTHON_CMD%%"
+command="/usr/sbin/daemon"
+command_args="-o /var/log/${name}.log -p ${pidfile} -- ${procname}"
+
+run_rc_command "$1"
diff --git a/sysutils/py-prometheus-zfs/pkg-descr b/sysutils/py-prometheus-zfs/pkg-descr
new file mode 100644
index 000000000000..168ce78e6a76
--- /dev/null
+++ b/sysutils/py-prometheus-zfs/pkg-descr
@@ -0,0 +1,5 @@
+This is a simple exporter for the Prometheus metrics for ZFS using
+py-libzfs. It comes with a zfsprom service that can be run in the
+background as an HTTP server.
+
+WWW: https://github.com/matusnovak/prometheus-zfs