Last active
July 17, 2017 15:50
-
-
Save Slach/7b8553cc3a116116e4ed1f6b9b8342bd to your computer and use it in GitHub Desktop.
Install pgbouncer templates for monitoring under Ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x pipefail | |
# run it under root | |
cd /opt/ | |
rm -rf zabbix-extensions | |
git clone https://github.com/lesovsky/zabbix-extensions.git | |
cp -fv /opt/zabbix-extensions/files/pgbouncer/pgbouncer.conf /etc/zabbix/zabbix_agentd.conf.d/pgbouncer.conf | |
sed -i 's/\/usr\/libexec\/zabbix-extensions\/scripts/\/opt\/zabbix-extensions\/files\/pgbouncer\/scripts/g' /etc/zabbix/zabbix_agentd.conf.d/pgbouncer.conf | |
echo localhost:6432:pgbouncer:stats:stats > /opt/zabbix-extensions/files/pgbouncer/.pgpass | |
chown -v zabbix:zabbix /opt/zabbix-extensions/files/pgbouncer/.pgpass | |
chmod -v 0600 /opt/zabbix-extensions/files/pgbouncer/.pgpass | |
sed -i -e '$a\' -e '"stats" "md5a57ebe01934de43865125819a3c4af74"' -e '/"stats" "md5a57ebe01934de43865125819a3c4af74"/d' /etc/pgbouncer/userlist.txt | |
sed -i -e '$a\' -e 'stats_users = stats' -e '/stats_users = stats/d' /etc/pgbouncer/pgbouncer.ini | |
service pgbouncer reload | |
find /opt/zabbix-extensions/files/pgbouncer/scripts -type f -exec sed -i 's/\~zabbix\/\.pgpass/\/opt\/zabbix-extensions\/files\/pgbouncer\/.pgpass/g' {} + | |
find /opt/zabbix-extensions/files/pgbouncer/scripts -type f -exec sed -i 's/psql /PGPASSFILE\=\/opt\/zabbix-extensions\/files\/pgbouncer\/.pgpass psql /g' {} + | |
find /opt/zabbix-extensions/files/pgbouncer/scripts -type f -exec sed -i 's/\$PSQL /PGPASSFILE\=\/opt\/zabbix-extensions\/files\/pgbouncer\/.pgpass \$PSQL /g' {} + | |
find /opt/zabbix-extensions/files/pgbouncer/scripts -type f -exec sed -i 's/ltAF/tAF/g' {} + | |
# check all working | |
sudo -H -u zabbix /opt/zabbix-extensions/files/pgbouncer/scripts/pgbouncer.pool.discovery.sh | |
sudo -H -u zabbix /opt/zabbix-extensions/files/pgbouncer/scripts/pgbouncer.stat.sh total_avg_req | |
service zabbix-agent restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment