sysutils/mongodb_exporter: Add new port

Prometheus exporter for MongoDB
This commit is contained in:
Gabriel M. Dutra 2025-01-25 20:24:31 +01:00
parent 7212f4b898
commit 54f43c5ad4
6 changed files with 118 additions and 0 deletions

View file

@ -716,6 +716,7 @@
SUBDIR += modman SUBDIR += modman
SUBDIR += modules SUBDIR += modules
SUBDIR += mog SUBDIR += mog
SUBDIR += mongodb_exporter
SUBDIR += monit SUBDIR += monit
SUBDIR += monitord SUBDIR += monitord
SUBDIR += monitorix SUBDIR += monitorix

View file

@ -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>

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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
}
]