git: 4f4643368e25 - main - databases/py-powa-collector: New port

From: Palle Girgensohn <girgen_at_FreeBSD.org>
Date: Tue, 05 Nov 2024 20:56:37 UTC
The branch main has been updated by girgen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4f4643368e25ed7c025c9b0688856a1105db0558

commit 4f4643368e25ed7c025c9b0688856a1105db0558
Author:     Palle Girgensohn <girgen@FreeBSD.org>
AuthorDate: 2024-11-05 20:41:26 +0000
Commit:     Palle Girgensohn <girgen@FreeBSD.org>
CommitDate: 2024-11-05 20:55:02 +0000

    databases/py-powa-collector: New port
    
    PoWA (PostgreSQL Workload Analyzer) is a performance tool for PostgreSQL
    9.4 and newer allowing to collect, aggregate and purge statistics on
    multiple PostgreSQL instances from various Stats Extensions.
    
    PoWA-collector is the daemon that gather performance metrics from remote
    PostgreSQL instances (optional) on a dedicated repository server.
---
 databases/Makefile                                 |  1 +
 databases/py-powa-collector/Makefile               | 31 +++++++++++++++++
 databases/py-powa-collector/distinfo               |  3 ++
 .../files/patch-powa_collector__options.py         | 11 ++++++
 .../py-powa-collector/files/powa-collector.in      | 40 ++++++++++++++++++++++
 databases/py-powa-collector/pkg-descr              |  6 ++++
 6 files changed, 92 insertions(+)

diff --git a/databases/Makefile b/databases/Makefile
index 20b509de290d..e6a3650e68df 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -806,6 +806,7 @@
     SUBDIR += py-pickleshare
     SUBDIR += py-pony
     SUBDIR += py-postgresql
+    SUBDIR += py-powa-collector
     SUBDIR += py-psycogreen
     SUBDIR += py-psycopg
     SUBDIR += py-psycopg-c
diff --git a/databases/py-powa-collector/Makefile b/databases/py-powa-collector/Makefile
new file mode 100644
index 000000000000..d7c0bcb2e566
--- /dev/null
+++ b/databases/py-powa-collector/Makefile
@@ -0,0 +1,31 @@
+PORTNAME=	powa-collector
+DISTVERSION=	1.3.0
+CATEGORIES=	databases python
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	girgen@FreeBSD.org
+COMMENT=	Performs powa snapshots for remote servers
+WWW=		https://powa.readthedocs.io/en/stable/components/powa-collector/
+
+LICENSE=	PostgreSQL
+LICENSE_FILE=   ${WRKSRC}/LICENSE
+
+RUN_DEPENDS=	${PYTHON_SITELIBDIR}/psycopg2/__init__.py:databases/py-psycopg2@${PY_FLAVOR}
+
+USES=		python
+USE_PYTHON=	distutils autoplist
+NO_ARCH=	yes
+
+USE_GITHUB=     yes
+GH_ACCOUNT=     powa-team
+
+PLIST_FILES=	"@sample etc/powa-collector.conf.sample"
+USE_RC_SUBR=	${PORTNAME}
+
+post-patch:
+		@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/powa_collector/options.py
+
+post-install:
+		${INSTALL_DATA} ${WRKSRC}/powa-collector.conf-dist ${STAGEDIR}${PREFIX}/etc/powa-collector.conf.sample
+
+.include <bsd.port.mk>
diff --git a/databases/py-powa-collector/distinfo b/databases/py-powa-collector/distinfo
new file mode 100644
index 000000000000..f7400b0ed2ee
--- /dev/null
+++ b/databases/py-powa-collector/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1730822338
+SHA256 (powa-team-powa-collector-1.3.0_GH0.tar.gz) = 793464ad0fae41edd8b40f81376e7d050ffcdd8a4a76453bf94319cfecca595d
+SIZE (powa-team-powa-collector-1.3.0_GH0.tar.gz) = 22279
diff --git a/databases/py-powa-collector/files/patch-powa_collector__options.py b/databases/py-powa-collector/files/patch-powa_collector__options.py
new file mode 100644
index 000000000000..98135fe474ba
--- /dev/null
+++ b/databases/py-powa-collector/files/patch-powa_collector__options.py
@@ -0,0 +1,11 @@
+--- powa_collector/options.py.orig	2024-11-03 01:42:37 UTC
++++ powa_collector/options.py
+@@ -18,7 +18,7 @@ CONF_LOCATIONS = [
+ """
+ 
+ CONF_LOCATIONS = [
+-    '/etc/powa-collector.conf',
++    '/usr/local/etc/powa-collector.conf',
+     os.path.expanduser('~/.config/powa-collector.conf'),
+     os.path.expanduser('~/.powa-collector.conf'),
+     './powa-collector.conf'
diff --git a/databases/py-powa-collector/files/powa-collector.in b/databases/py-powa-collector/files/powa-collector.in
new file mode 100644
index 000000000000..c1c63b1528b4
--- /dev/null
+++ b/databases/py-powa-collector/files/powa-collector.in
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# PROVIDE: powa-collector
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+# Add the following lines to /etc/rc.conf to enable fluent-bit:
+#
+# powa_collector_enable (bool):	Set to YES to enable fluent-bit
+# 				Default: NO
+# powa_collector_config (str):	config files to use
+#				Default: %%ETCDIR%%/fluent-bit.conf
+# powa_collector_flags (str):	Extra flags passed to fluent-bit
+
+. /etc/rc.subr
+
+name="powa_collector"
+rcvar=${name}_enable
+load_rc_config $name
+
+: ${powa_collector_enable:="NO"}
+: ${powa_collector_user:="nobody"}
+: ${powa_collector_group:="nogroup"}
+
+pidfile=/var/run/${name}.pid
+procname="%%PREFIX%%/bin/powa-collector.py"
+command="/usr/sbin/daemon"
+command_args="-H -p ${pidfile} -o /var/log/${name}/${name}.log ${procname}"
+
+start_precmd=powa_collector_startprecmd
+
+powa_collector_startprecmd()
+{
+	install -o ${powa_collector_user} -g ${powa_collector_group} -d /var/log/${name}
+	if [ ! -e ${pidfile} ]; then
+		install -o ${powa_collector_user} -g ${powa_collector_group} /dev/null ${pidfile};
+	fi
+}
+
+run_rc_command "$1"
diff --git a/databases/py-powa-collector/pkg-descr b/databases/py-powa-collector/pkg-descr
new file mode 100644
index 000000000000..6fd27cc5029b
--- /dev/null
+++ b/databases/py-powa-collector/pkg-descr
@@ -0,0 +1,6 @@
+PoWA (PostgreSQL Workload Analyzer) is a performance tool for PostgreSQL
+allowing to collect, aggregate and purge statistics on multiple PostgreSQL
+instances from various Stats Extensions.
+
+PoWA-collector is the daemon that gather performance metrics from remote
+PostgreSQL instances (optional) on a dedicated repository server.