ncc.zabbix_templates

Yohn Y. 2023-12-09 Parent:ca9cdec2f51e

15:d9c6b29affc6 Go to Latest

ncc.zabbix_templates/pgBouncer/res/pgbouncer.sh

. Переименование параметра пользовательского окружения в более подходящее системное

History
1 #!/bin/sh
2 # devel.a0fs.ru -- ncc.zabbix_templates/pgbouncer/res/pgbouncer.sh -- v0.r202310.1 #
4 export HOME=/etc/zabbix/scripts-data/pgbouncer
6 PGBOUNCER_HOST=$(head -n 1 /etc/zabbix/scripts-data/pgbouncer/.pgpass |cut -d: -f1)
7 PGBOUNCER_PORT=$(head -n 1 /etc/zabbix/scripts-data/pgbouncer/.pgpass |cut -d: -f2)
8 MON_USER=$(head -n 1 /etc/zabbix/scripts-data/pgbouncer/.pgpass |cut -d: -f4)
10 COMMAND=$1
11 #USER=$3
12 #DB=$2
14 if [ "x$COMMAND" = "xdiscover" ]
15 then
16 # discovery bases and users
17 psql -h $PGBOUNCER_HOST -p $PGBOUNCER_PORT -U $MON_USER pgbouncer -t -c 'show pools;' \
18 | awk -F'|' 'BEGIN { printf "{\"data\":["; n=0; }
19 /\|/ { if (n != 0)
20 printf ",";
21 gsub(" ", "", $1);
22 gsub(" ", "", $2);
23 printf "{\"{#PGBOUNCER_DATABASE}\": \"" $1 "\", \"{#PGBOUNCER_USER}\": \"" $2 "\"}";
24 n++; }
25 END { printf "]}"; }'
26 elif [ "x$COMMAND" = "xtotals" ]
27 then
28 # get total statistic
29 psql -h $PGBOUNCER_HOST -p $PGBOUNCER_PORT -U $MON_USER pgbouncer -t -c 'show totals;'
31 elif [ "x$COMMAND" = "xstats" ]
32 then
33 # get statistic per db
34 psql -h $PGBOUNCER_HOST -p $PGBOUNCER_PORT -U $MON_USER pgbouncer -t -c 'show stats;'
36 elif [ "x$COMMAND" = "xlists" ]
37 then
38 # get internal information
39 psql -h $PGBOUNCER_HOST -p $PGBOUNCER_PORT -U $MON_USER pgbouncer -t -c 'show lists;'
41 elif [ "x$COMMAND" = "xpools" ]
42 then
43 # get pools statistic
44 psql -h $PGBOUNCER_HOST -p $PGBOUNCER_PORT -U $MON_USER pgbouncer -t -c 'show pools;'
46 fi