mirror of
git://f0xx.org/ac/ac-deploy
synced 2026-07-29 04:19:00 +03:00
added 'monitoring' path - ask devs why it's there
This commit is contained in:
53
monitoring/artc0/mysqld-exporter-docker.sh
Normal file
53
monitoring/artc0/mysqld-exporter-docker.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# Deploy mysqld_exporter as Docker container on artc0
|
||||
# Run once as root / sudo after creating the MariaDB monitoring user below.
|
||||
#
|
||||
# PREREQUISITE — run in mysql:
|
||||
# CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'ExporterPass2026!' WITH MAX_USER_CONNECTIONS 3;
|
||||
# GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
|
||||
# FLUSH PRIVILEGES;
|
||||
#
|
||||
# Then run this script.
|
||||
|
||||
set -e
|
||||
|
||||
CONTAINER_NAME="mysqld_exporter"
|
||||
CNF_FILE="/etc/mysqld-exporter.cnf"
|
||||
|
||||
# Write config file if not present
|
||||
if [ ! -f "$CNF_FILE" ]; then
|
||||
cat > "$CNF_FILE" << 'EOF'
|
||||
[client]
|
||||
user=exporter
|
||||
password=ExporterPass2026!
|
||||
socket=/run/mysqld/mysqld.sock
|
||||
EOF
|
||||
chmod 644 "$CNF_FILE"
|
||||
fi
|
||||
|
||||
# Get socket GID to allow container user to access it
|
||||
SOCK_GID=$(stat -c '%g' /run/mysqld/mysqld.sock)
|
||||
|
||||
# Stop existing container if running
|
||||
docker stop "$CONTAINER_NAME" 2>/dev/null || true
|
||||
docker rm "$CONTAINER_NAME" 2>/dev/null || true
|
||||
|
||||
# Run with Unix socket mount — MariaDB uses skip-networking (no TCP)
|
||||
docker run -d \
|
||||
--name "$CONTAINER_NAME" \
|
||||
--restart unless-stopped \
|
||||
--user "65534:${SOCK_GID}" \
|
||||
-v "${CNF_FILE}:/etc/.my.cnf:ro" \
|
||||
-v "/run/mysqld/mysqld.sock:/run/mysqld/mysqld.sock:ro" \
|
||||
-p 9104:9104 \
|
||||
prom/mysqld-exporter:latest \
|
||||
--config.my-cnf=/etc/.my.cnf \
|
||||
--collect.info_schema.innodb_metrics \
|
||||
--collect.global_status \
|
||||
--collect.global_variables \
|
||||
--web.listen-address=":9104"
|
||||
|
||||
echo "mysqld_exporter started, listening on :9104"
|
||||
sleep 3
|
||||
docker logs "$CONTAINER_NAME" 2>&1 | tail -5
|
||||
curl -s http://localhost:9104/metrics | grep 'mysql_up'
|
||||
Reference in New Issue
Block a user