Skip to content

Instantly share code, notes, and snippets.

@JanThiel
Last active January 16, 2023 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JanThiel/a9567e1622525376598a74e4c56b8355 to your computer and use it in GitHub Desktop.
Save JanThiel/a9567e1622525376598a74e4c56b8355 to your computer and use it in GitHub Desktop.
Generates the datadog config file for php_fpm based on ISPConfig created FPM Pool configs
#!/bin/bash
read -r -d '' TEMPLATE << EOM
- status_url: unix:///var/lib/php-fpm/{{web}}.sock/status
ping_url: unix:///var/lib/php-fpm/{{web}}.sock/ping
use_fastcgi: true
ping_reply: pong
tags:
- website.domain:{{domain}}
EOM
grep -srnw /etc/opt/remi/php*/php-fpm.d/* -e 'webmaster' | while read -r SITE; do
WEB=$( echo $SITE | sed -r 's/.*(web[0-9]+)\.conf.*webmaster\@([^"]+)"$/\1/')
DOMAIN=$( echo $SITE | sed -r 's/.*(web[0-9]+)\.conf.*webmaster\@([^"]+)"$/\2/')
TPL=$( sed -e "s/{{web}}/$WEB/g" -e "s/{{domain}}/$DOMAIN/g" <<< "$TEMPLATE")
#echo "WEB: $WEB | DOMAIN: $DOMAIN";
echo " $TPL"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment