diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2018-03-27 00:38:59 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2018-03-27 00:39:16 +0200 |
commit | 101f87f123cbab566f5986c4f056a1c39f41e273 (patch) | |
tree | 0be135920a6e92300065c2eca755c9613f4f4313 /app-metrics | |
parent | dev-python/brython: version bump. (diff) | |
download | gentoo-101f87f123cbab566f5986c4f056a1c39f41e273.tar.gz gentoo-101f87f123cbab566f5986c4f056a1c39f41e273.tar.bz2 gentoo-101f87f123cbab566f5986c4f056a1c39f41e273.zip |
app-metrics/prometheus-mysqld_exporter: Initial version
Package-Manager: Portage-2.3.24, Repoman-2.3.6
Diffstat (limited to 'app-metrics')
6 files changed, 174 insertions, 0 deletions
diff --git a/app-metrics/prometheus-mysqld_exporter/Manifest b/app-metrics/prometheus-mysqld_exporter/Manifest new file mode 100644 index 000000000000..fe49b6e44fd9 --- /dev/null +++ b/app-metrics/prometheus-mysqld_exporter/Manifest @@ -0,0 +1 @@ +DIST prometheus-mysqld_exporter-0.10.0.tar.gz 971604 BLAKE2B ec077b7b6a15f6173e5cc04e741c51c4d26a214601da8eb1aede49ee325f52bea2140b8e5b3bdbc2a1e527e40c95099dca2a57501d44a26e787cdc330f4aa8b8 SHA512 0a7b0ff537ad59a9b64aa18dfe1d1eb9253b12ae566d5c151555fbd4457b7e65890b6569632b452ae317b3acbfa94c12d96f6fb6e4f982b9b2161fc4747330f5 diff --git a/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.confd b/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.confd new file mode 100644 index 000000000000..f55143b944e9 --- /dev/null +++ b/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.confd @@ -0,0 +1,28 @@ +# /etc/conf.d/prometheus-mysqld_exporter + +# PID file +# If you should ever change this, remember to update +# "/etc/logrotate.d/rsyslog", too. +#EXPORTER_PIDFILE="/run/${RC_SVCNAME}.pid" + +# The termination timeout (start-stop-daemon parameter "retry") ensures +# that the service will be terminated within a given time (60 + 5 seconds +# per default) when you are stopping the service. +#EXPORTER_TERMTIMEOUT="TERM/60/KILL/5" + +# User to run exporter as +#EXPORTER_USER="prometheus-mysqld_exporter" + +# User group to run exporter as +#EXPORTER_GROUP="prometheus-mysqld_exporter" + +# You can use this configuration option to pass additional options to the +# start-stop-daemon, see start-stop-daemon(8) for more details. +# Per default we wait 1000ms after we have started the service to ensure +# that the daemon is really up and running. +#EXPORTER_SSDARGS="--wait 1000" + +# Exporter flags +# See `prometheus-mysqld-exporter --help` for more details +EXPORTER_FLAGS="-log.level=info" +#EXPORTER_FLAGS="${EXPORTER_FLAGS} -yourAdditionalFlag" diff --git a/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.initd b/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.initd new file mode 100644 index 000000000000..10a7ac1f1ab3 --- /dev/null +++ b/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.initd @@ -0,0 +1,68 @@ +#!/sbin/openrc-run +# Copyright 2016-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Prometheus exporter for MySQL server metrics" + +EXPORTER_FLAGS=${EXPORTER_FLAGS:-""} +EXPORTER_USER=${EXPORTER_USER:-"prometheus-mysqld_exporter"} +EXPORTER_GROUP=${EXPORTER_GROUP:-prometheus-mysqld_exporter} +EXPORTER_PIDFILE=${EXPORTER_PIDFILE:-"/run/${RC_SVCNAME}.pid"} +EXPORTER_SSDARGS=${EXPORTER_SSDARGS:-"--wait 1000"} +EXPORTER_TERMTIMEOUT=${EXPORTER_TERMTIMEOUT:-"TERM/60/KILL/5"} + +command="/usr/bin/mysqld_exporter" +command_args="${EXPORTER_FLAGS}" +command_background="true" +start_stop_daemon_args="${EXPORTER_SSDARGS}" +start_stop_daemon_args="${start_stop_daemon_args} --user ${EXPORTER_USER}" +start_stop_daemon_args="${start_stop_daemon_args} --group ${EXPORTER_GROUP}" + +# We are forcing log files because upstream is going to remove syslog support :/ +start_stop_daemon_args="${start_stop_daemon_args} --stdout /var/log/mysqld_exporter/${RC_SVCNAME}.log" +start_stop_daemon_args="${start_stop_daemon_args} --stderr /var/log/mysqld_exporter/${RC_SVCNAME}.log" + +getconfig() { + local key="$1" + local value_default="$2" + local value= + + if service_started; then + value="$(service_get_value "${key}")" + fi + + if [ -z "${value}" ]; then + # Value not explicitly set + echo "${value_default}" + else + echo "${value}" + fi + + return 0 +} + +pidfile="$(getconfig pidfile ${EXPORTER_PIDFILE})" +retry="$(getconfig retry ${EXPORTER_TERMTIMEOUT})" + +configtest() { + if test "${command_args#*config\.my-cnf}" = "${command_args}"; then + local _default_config_file="/var/lib/mysqld_exporter/.my.cnf" + if [ ! -s "${_default_config_file}" ]; then + eerror "No MySQL credentials found in \"${_default_config_file}\"!" + eerror "Either create that file and add credentials or specify another file via \"-config.my-cnf\" flag." + return 1 + fi + fi + + return 0 +} + +depend() { + after net +} + +start_pre() { + if [ "${RC_CMD}" != "restart" ]; then + configtest || return 1 + fi +} diff --git a/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.logrotate b/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.logrotate new file mode 100644 index 000000000000..ec360d7ab4cd --- /dev/null +++ b/app-metrics/prometheus-mysqld_exporter/files/prometheus-mysqld_exporter.logrotate @@ -0,0 +1,5 @@ +/var/log/mysqld_exporter/*.log { + missingok + notifempty + size 30k +} diff --git a/app-metrics/prometheus-mysqld_exporter/metadata.xml b/app-metrics/prometheus-mysqld_exporter/metadata.xml new file mode 100644 index 000000000000..adebc721a7e3 --- /dev/null +++ b/app-metrics/prometheus-mysqld_exporter/metadata.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>whissi@gentoo.org</email> + <name>Thomas Deutschmann</name> + </maintainer> + <upstream> + <remote-id type="github">prometheus/mysqld_exporter</remote-id> + </upstream> +</pkgmetadata> diff --git a/app-metrics/prometheus-mysqld_exporter/prometheus-mysqld_exporter-0.10.0.ebuild b/app-metrics/prometheus-mysqld_exporter/prometheus-mysqld_exporter-0.10.0.ebuild new file mode 100644 index 000000000000..c7e66857e6ad --- /dev/null +++ b/app-metrics/prometheus-mysqld_exporter/prometheus-mysqld_exporter-0.10.0.ebuild @@ -0,0 +1,61 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI="6" +inherit user golang-build golang-vcs-snapshot + +EGO_PN="github.com/prometheus/mysqld_exporter" +EGIT_COMMIT="v${PV/_rc/-rc.}" +MYSQLD_EXPORTER_COMMIT="8068006" +ARCHIVE_URI="https://${EGO_PN}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz" +KEYWORDS="~amd64" + +DESCRIPTION="Prometheus exporter for MySQL server metrics" +HOMEPAGE="https://github.com/prometheus/mysqld_exporter" +SRC_URI="${ARCHIVE_URI}" +LICENSE="Apache-2.0" +SLOT="0" +IUSE="" + +DEPEND="dev-util/promu" + +pkg_setup() { + enewgroup ${PN} + enewuser ${PN} -1 -1 /var/lib/mysqld_exporter ${PN} +} + +src_prepare() { + default + sed -i -e "s/{{.Revision}}/${MYSQLD_EXPORTER_COMMIT}/" src/${EGO_PN}/.promu.yml || die +} + +src_compile() { + pushd src/${EGO_PN} || die + mkdir -p bin || die + GOPATH="${S}" promu build -v --prefix mysqld_exporter || die + popd || die +} + +src_install() { + pushd src/${EGO_PN} || die + dobin mysqld_exporter/mysqld_exporter + dodoc {README,CHANGELOG,CONTRIBUTING}.md + popd || die + + keepdir /var/lib/mysqld_exporter /var/log/mysqld_exporter + fowners ${PN}:${PN} /var/lib/mysqld_exporter /var/log/mysqld_exporter + fperms 0770 /var/lib/mysqld_exporter + + newinitd "${FILESDIR}"/${PN}.initd ${PN} + newconfd "${FILESDIR}"/${PN}.confd ${PN} + + insinto /etc/logrotate.d/ + newins "${FILESDIR}"/${PN}.logrotate ${PN} +} + +pkg_postinst() { + if [[ -z "${REPLACING_VERSIONS}" ]]; then + # This is a new installation + elog "Create \"${EROOT%/}/var/lib/mysqld_exporter/.my.cnf\" to read MySQL credentials from file." + fi +} |