git: 54f43c5ad4b8 - main - sysutils/mongodb_exporter: Add new port
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 25 Jan 2025 19:30:42 UTC
The branch main has been updated by dutra:
URL: https://cgit.FreeBSD.org/ports/commit/?id=54f43c5ad4b8d4df0bcc6c72b110adb790bf673c
commit 54f43c5ad4b8d4df0bcc6c72b110adb790bf673c
Author: Gabriel M. Dutra <dutra@FreeBSD.org>
AuthorDate: 2025-01-25 19:24:31 +0000
Commit: Gabriel M. Dutra <dutra@FreeBSD.org>
CommitDate: 2025-01-25 19:26:32 +0000
sysutils/mongodb_exporter: Add new port
Prometheus exporter for MongoDB
---
sysutils/Makefile | 1 +
sysutils/mongodb_exporter/Makefile | 26 +++++++++
sysutils/mongodb_exporter/distinfo | 5 ++
.../mongodb_exporter/files/mongodb_exporter.in | 65 ++++++++++++++++++++++
sysutils/mongodb_exporter/pkg-descr | 10 ++++
sysutils/mongodb_exporter/pkg-message | 11 ++++
6 files changed, 118 insertions(+)
diff --git a/sysutils/Makefile b/sysutils/Makefile
index ea6c85907285..86a1f25ea593 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -716,6 +716,7 @@
SUBDIR += modman
SUBDIR += modules
SUBDIR += mog
+ SUBDIR += mongodb_exporter
SUBDIR += monit
SUBDIR += monitord
SUBDIR += monitorix
diff --git a/sysutils/mongodb_exporter/Makefile b/sysutils/mongodb_exporter/Makefile
new file mode 100644
index 000000000000..2c4ad478f7f1
--- /dev/null
+++ b/sysutils/mongodb_exporter/Makefile
@@ -0,0 +1,26 @@
+PORTNAME= mongodb_exporter
+DISTVERSIONPREFIX= v
+DISTVERSION= 0.43.1
+CATEGORIES= sysutils
+
+MAINTAINER= dutra@FreeBSD.org
+COMMENT= Prometheus exporter for MongoDB
+WWW= https://github.com/percona/mongodb_exporter
+
+LICENSE= APACHE20
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+USES= go:1.23,modules
+USE_RC_SUBR= mongodb_exporter
+
+GO_MODULE= github.com/percona/mongodb_exporter
+
+GO_BUILDFLAGS= -ldflags='\
+ -s -w \
+ -X main.version=${DISTVERSIONPREFIX}${DISTVERSION} \
+ -X main.GitCommit=${GITID} \
+ -X main.GoVersion=${GO_DEFAULT_VERSION}'
+
+PLIST_FILES= bin/${PORTNAME}
+
+.include <bsd.port.mk>
diff --git a/sysutils/mongodb_exporter/distinfo b/sysutils/mongodb_exporter/distinfo
new file mode 100644
index 000000000000..5724aaa42386
--- /dev/null
+++ b/sysutils/mongodb_exporter/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1737831232
+SHA256 (go/sysutils_mongodb_exporter/mongodb_exporter-v0.43.1/v0.43.1.mod) = 7fe7669bea7f38065cc6026ba4cdcedca007688f62115f4968dd93cf326ed121
+SIZE (go/sysutils_mongodb_exporter/mongodb_exporter-v0.43.1/v0.43.1.mod) = 3102
+SHA256 (go/sysutils_mongodb_exporter/mongodb_exporter-v0.43.1/v0.43.1.zip) = b0f84af41aaa30a021e8dae13fd259c239fb0c8855fa85b0f2ec83835622666e
+SIZE (go/sysutils_mongodb_exporter/mongodb_exporter-v0.43.1/v0.43.1.zip) = 181105
diff --git a/sysutils/mongodb_exporter/files/mongodb_exporter.in b/sysutils/mongodb_exporter/files/mongodb_exporter.in
new file mode 100644
index 000000000000..3cbfc0c09e21
--- /dev/null
+++ b/sysutils/mongodb_exporter/files/mongodb_exporter.in
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# PROVIDE: mongodb_exporter
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# mongodb_exporter_enable (bool): Set to NO by default.
+# Set it to YES to enable mongodb_exporter.
+# mongodb_exporter_user (string): Set user that mongodb_exporter will run under
+# Default is "nobody".
+# mongodb_exporter_group (string): Set group that mongodb_exporter will run under
+# Default is "nobody".
+# mongodb_exporter_args (string): Set extra arguments to pass to mongodb_exporter
+# Default is "".
+# mongodb_exporter_listen_address (string):Set ip:port that mongodb_exporter will listen on
+# Default is ":9216".
+# mongodb_exporter_textfile_dir (string): Set directory that mongodb_exporter will watch
+# Default is "/var/tmp/mongodb_exporter".
+
+. /etc/rc.subr
+
+name=mongodb_exporter
+rcvar=mongodb_exporter_enable
+
+load_rc_config $name
+
+: ${mongodb_exporter_enable:="NO"}
+: ${mongodb_exporter_user:="nobody"}
+: ${mongodb_exporter_group:="nobody"}
+: ${mongodb_exporter_args:=""}
+: ${mongodb_exporter_listen_address:=":9216"}
+
+pidfile=/var/run/mongodb_exporter.pid
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/bin/mongodb_exporter"
+command_args="-f -p ${pidfile} -T ${name} \
+ /usr/bin/env ${procname} \
+ --web.listen-address=${mongodb_exporter_listen_address} \
+ ${mongodb_exporter_args}"
+
+start_precmd=mongodb_exporter_startprecmd
+
+mongodb_exporter_startprecmd()
+{
+ if [ ! -e ${pidfile} ]; then
+ install \
+ -o ${mongodb_exporter_user} \
+ -g ${mongodb_exporter_group} \
+ /dev/null ${pidfile};
+ fi
+ if [ ! -d ${mongodb_exporter_textfile_dir} ]; then
+ install \
+ -d \
+ -o ${mongodb_exporter_user} \
+ -g ${mongodb_exporter_group} \
+ -m 1755 \
+ ${mongodb_exporter_textfile_dir}
+ fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/sysutils/mongodb_exporter/pkg-descr b/sysutils/mongodb_exporter/pkg-descr
new file mode 100644
index 000000000000..118b76cf78e0
--- /dev/null
+++ b/sysutils/mongodb_exporter/pkg-descr
@@ -0,0 +1,10 @@
+Prometheus exporter for MongoDB including sharding, replication
+and storage engines.
+
+these metric sources are implemented:
+ - $collStats
+ - $indexStats
+ - getDiagnosticData
+ - replSetGetStatus
+ - replSetGetConfig
+ - serverStatus
diff --git a/sysutils/mongodb_exporter/pkg-message b/sysutils/mongodb_exporter/pkg-message
new file mode 100644
index 000000000000..72cd8c6c7778
--- /dev/null
+++ b/sysutils/mongodb_exporter/pkg-message
@@ -0,0 +1,11 @@
+[
+{
+ type: install
+ message: <<EOM
+ The exporter works with Percona Server for MongoDB and MongoDB Community
+ or Enterprise Edition versions 4.4 and newer.
+
+ Older versions might also work but are not tested anymore.
+EOM
+}
+]