pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/databases/mysqld_exporter mysqld_exporter: Import vers...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/9d11c1c6660d
branches:  trunk
changeset: 446620:9d11c1c6660d
user:      jperkin <jperkin%pkgsrc.org@localhost>
date:      Thu Feb 11 13:54:29 2021 +0000

description:
mysqld_exporter: Import version 0.12.1.

This is a MySQL metric exporter for Prometheus.

I've had this sitting in my tree since pkgsrc-2019Q4, it currently only has
SMF support, someone is more than welcome to add an rc.d script for it.

diffstat:

 databases/mysqld_exporter/DESCR                        |   1 +
 databases/mysqld_exporter/MESSAGE.smf                  |   9 ++++
 databases/mysqld_exporter/Makefile                     |  37 ++++++++++++++++++
 databases/mysqld_exporter/PLIST                        |   3 +
 databases/mysqld_exporter/distinfo                     |   6 ++
 databases/mysqld_exporter/files/env.conf               |  15 +++++++
 databases/mysqld_exporter/files/smf/manifest.xml       |  31 +++++++++++++++
 databases/mysqld_exporter/files/smf/mysqld_exporter.sh |  27 +++++++++++++
 8 files changed, 129 insertions(+), 0 deletions(-)

diffs (161 lines):

diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/DESCR   Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,1 @@
+A MySQL metric exporter for Prometheus.
diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/MESSAGE.smf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/MESSAGE.smf     Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,9 @@
+===========================================================================
+$NetBSD: MESSAGE.smf,v 1.1 2021/02/11 13:54:29 jperkin Exp $
+
+To configure mysqld_exporter adjust the environment variables in:
+
+       ${PKG_SYSCONFDIR}/env.conf
+
+Ensure this file retains appropriately secure permissions.
+===========================================================================
diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/Makefile        Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,37 @@
+# $NetBSD: Makefile,v 1.1 2021/02/11 13:54:29 jperkin Exp $
+
+DISTNAME=      mysqld_exporter-0.12.1
+MASTER_SITES=  ${MASTER_SITE_GITHUB:=prometheus/}
+CATEGORIES=    databases
+GITHUB_TAG=    v${PKGVERSION_NOREV}
+
+MAINTAINER=    pkgsrc-users%pkgsrc.org@localhost
+HOMEPAGE=      https://github.com/prometheus/mysqld_exporter
+COMMENT=       MySQL metric exporter for Prometheus
+LICENSE=       apache-2.0
+
+GO_DIST_BASE=  ${DISTNAME}
+GO_SRCPATH=    github.com/prometheus/mysqld_exporter
+
+SMF_METHODS=   ${PKGBASE}
+
+EGDIR=                 share/examples/${PKGBASE}
+PKG_SYSCONFSUBDIR=     ${PKGBASE}
+
+INSTALLATION_DIRS=     bin ${EGDIR}
+
+CONF_FILES_PERMS+=     ${EGDIR}/env.conf ${PKG_SYSCONFDIR}/env.conf \
+                       ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 600
+
+post-build:
+       ${SED} -e 's,@PKG_SYSCONFDIR@,${PKG_SYSCONFDIR},g' \
+           ${FILESDIR}/env.conf >${WRKDIR}/.env.conf
+
+do-install:
+       ${INSTALL_PROGRAM} ${WRKDIR}/bin/mysqld_exporter \
+           ${DESTDIR}${PREFIX}/bin
+       ${INSTALL_DATA} ${WRKDIR}/.env.conf \
+           ${DESTDIR}${PREFIX}/share/examples/${PKGBASE}/env.conf
+
+.include "../../lang/go/go-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/PLIST   Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1 2021/02/11 13:54:29 jperkin Exp $
+bin/mysqld_exporter
+share/examples/mysqld_exporter/env.conf
diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/distinfo
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/distinfo        Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,6 @@
+$NetBSD: distinfo,v 1.1 2021/02/11 13:54:29 jperkin Exp $
+
+SHA1 (mysqld_exporter-0.12.1.tar.gz) = 5a12a0aa6c4f18028281569d34adf3c1d9899c7b
+RMD160 (mysqld_exporter-0.12.1.tar.gz) = 77caebfc31a4ab79e16f5c36b648e90c5b1265b1
+SHA512 (mysqld_exporter-0.12.1.tar.gz) = a655a9ad4b5bc6e7840df68bee934d55485d3a04a7dc8186c8f9d224eb33b0e1d98de3db78a0c7d92f9b3d6ca06ead2d609cf2cfa99e584635f0339984e60629
+Size (mysqld_exporter-0.12.1.tar.gz) = 1910780 bytes
diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/files/env.conf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/files/env.conf  Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,15 @@
+#
+# Configuration file for mysqld_exporter.  This file is sourced by the SMF
+# method script, allowing usernames and passwords to be stored here and
+# protected by standard UNIX permissions.
+#
+
+DATA_SOURCE_NAME="user:password@(hostname:3306)/"
+export DATA_SOURCE_NAME
+
+#
+# Additional flags for mysqld_exporter.  You will likely need to set at least
+# "--config.my-cnf /path/to/my.cnf" here.
+#
+MYSQLD_EXPORTER_FLAGS=""
+export MYSQLD_EXPORTER_FLAGS
diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/files/smf/manifest.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/files/smf/manifest.xml  Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<service_bundle type="manifest" name="export">
+  <service name="@SMF_PREFIX@/@SMF_NAME@" type="service" version="1">
+    <create_default_instance enabled="false"/>
+    <single_instance/>
+    <dependency name="network" grouping="require_all" restart_on="error" type="service">
+      <service_fmri value="svc:/milestone/network:default"/>
+    </dependency>
+    <dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
+      <service_fmri value="svc:/system/filesystem/local"/>
+    </dependency>
+    <method_context>
+      <method_environment>
+        <envvar name="PATH" value="@PREFIX@/sbin:@PREFIX@/bin:/sbin:/usr/sbin:/usr/bin"/>
+      </method_environment>
+    </method_context>
+    <exec_method type="method" name="start" exec="@PREFIX@/@SMF_METHOD_FILE.mysqld_exporter@ start" timeout_seconds="60"/>
+    <exec_method type="method" name="refresh" exec=":kill -HUP" timeout_seconds="60"/>
+    <exec_method type="method" name="stop" exec=":kill" timeout_seconds="60"/>
+    <property_group name="startd" type="framework">
+      <propval name="duration" type="astring" value="child"/>
+      <propval name="ignore_error" type="astring" value="core,signal"/>
+    </property_group>
+    <template>
+      <common_name>
+        <loctext xml:lang="C">Prometheus exporter for MySQL server metrics</loctext>
+      </common_name>
+    </template>
+  </service>
+</service_bundle>
diff -r d6dba5d2ee40 -r 9d11c1c6660d databases/mysqld_exporter/files/smf/mysqld_exporter.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/mysqld_exporter/files/smf/mysqld_exporter.sh    Thu Feb 11 13:54:29 2021 +0000
@@ -0,0 +1,27 @@
+#!@SMF_METHOD_SHELL@
+#
+# $NetBSD: mysqld_exporter.sh,v 1.1 2021/02/11 13:54:29 jperkin Exp $
+#
+# Init script for mysqld_exporter.  This is non-standard, but required so
+# that we can source a configuration file and pass environment variables that
+# include the database password to the program.
+#
+# As we need to use it anyway, we use it for everything, rather than splitting
+# configuration between the config file and SMF variables.
+#
+
+. /lib/svc/share/smf_include.sh
+
+. @PKG_SYSCONFDIR@/env.conf
+
+case "$1" in
+start)
+       @LOCALBASE@/bin/mysqld_exporter ${MYSQLD_EXPORTER_FLAGS}
+       ;;
+*)
+       echo "Usage: $0 start" >&2
+       exit 1
+       ;;
+esac
+
+exit ${SMF_EXIT_OK}



Home | Main Index | Thread Index | Old Index