diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2018-04-04 03:48:51 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2018-04-04 03:50:32 +0200 |
commit | 3b5a75f9855f432d9201bd3b3a1bb1f7c4b6b7d2 (patch) | |
tree | 23d9c6b55f728de6e68a4255d84b5152080f085a /app-metrics/mysqld_exporter/files | |
parent | app-metrics/collectd: Move package from app-admin/collectd (diff) | |
download | gentoo-3b5a75f9855f432d9201bd3b3a1bb1f7c4b6b7d2.tar.gz gentoo-3b5a75f9855f432d9201bd3b3a1bb1f7c4b6b7d2.tar.bz2 gentoo-3b5a75f9855f432d9201bd3b3a1bb1f7c4b6b7d2.zip |
app-metrics/mysqld_exporter: Move package from app-metrics/prometheus-mysqld_exporter
Package-Manager: Portage-2.3.26, Repoman-2.3.7
Diffstat (limited to 'app-metrics/mysqld_exporter/files')
3 files changed, 104 insertions, 0 deletions
diff --git a/app-metrics/mysqld_exporter/files/mysqld_exporter-r1.initd b/app-metrics/mysqld_exporter/files/mysqld_exporter-r1.initd new file mode 100644 index 000000000000..0aecd1025b82 --- /dev/null +++ b/app-metrics/mysqld_exporter/files/mysqld_exporter-r1.initd @@ -0,0 +1,73 @@ +#!/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:-"mysqld_exporter"} +EXPORTER_GROUP=${EXPORTER_GROUP:-"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 + use mysql +} + +start_pre() { + if [ "${RC_CMD}" != "restart" ]; then + configtest || return 1 + fi +} + +start_post() { + service_set_value retry "${EXPORTER_TERMTIMEOUT}" +} diff --git a/app-metrics/mysqld_exporter/files/mysqld_exporter.confd b/app-metrics/mysqld_exporter/files/mysqld_exporter.confd new file mode 100644 index 000000000000..249ed7ea4aa4 --- /dev/null +++ b/app-metrics/mysqld_exporter/files/mysqld_exporter.confd @@ -0,0 +1,26 @@ +# /etc/conf.d/mysqld_exporter + +# PID file +#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="mysqld_exporter" + +# User group to run exporter as +#EXPORTER_GROUP="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 `mysqld_exporter --help` for more details +EXPORTER_FLAGS="-log.level=info" +#EXPORTER_FLAGS="${EXPORTER_FLAGS} -yourAdditionalFlag" diff --git a/app-metrics/mysqld_exporter/files/mysqld_exporter.logrotate b/app-metrics/mysqld_exporter/files/mysqld_exporter.logrotate new file mode 100644 index 000000000000..ec360d7ab4cd --- /dev/null +++ b/app-metrics/mysqld_exporter/files/mysqld_exporter.logrotate @@ -0,0 +1,5 @@ +/var/log/mysqld_exporter/*.log { + missingok + notifempty + size 30k +} |