Page MenuHomeDevCentral
Paste P362

/opt/phpfpm_exporter/run.sh
ActivePublic

Authored by dereckson on Thu, Oct 10, 23:37.
Tags
None
Referenced Files
F3644054: /opt/phpfpm_exporter/run.sh
Thu, Oct 10, 23:37
Subscribers
None
#!/bin/sh
# -------------------------------------------------------------
# Run php-fpm metrics exporter
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: BSD-2-Clause
# -------------------------------------------------------------
set -e
# -------------------------------------------------------------
# Ensure user is root
#
# Note: POSIX shells don't always define $UID or $EUID.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# shellcheck disable=SC3028
if [ "${EUID:-$(id -u)}" -ne 0 ]; then
echo "This command must be run as root." >&2
exit 1
fi
# -------------------------------------------------------------
# Service configuration
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PHP_FPM_SOCKETS_ROOT=/var/run/web
PHP_FPM_SOCKETS_PATTERN="php-fpm.sock"
BIND_ADDRESS="127.0.0.1:9253"
BIND_ADDRESS="172.27.27.35:9253"
# -------------------------------------------------------------
# Run service
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SOCKET_PATHS=$(find "$PHP_FPM_SOCKETS_ROOT" -type s -name "$PHP_FPM_SOCKETS_PATTERN" -print0 | xargs -0 -n1 echo --phpfpm.socket-paths | paste -sd " " -)
# shellcheck disable=SC2086
echo sudo -u web-admin phpfpm_exporter --web.listen-address="$BIND_ADDRESS" --phpfpm.status-path="/php-fpm-status" $SOCKET_PATHS