#!/bin/bash if [[ "$(systemctl show --value --property UnitFileState patroni)" == "enabled" ]]; then filter="WHERE slot_name like 'pitr%'" fi /usr/bin/sudo -u postgres /usr/bin/psql -p $1 -Atc "select slot_name from pg_replication_slots $filter" |awk 'BEGIN{printf "{\"data\":["}; {printf c"{\"{#SLOT}\":\""$1"\"}";c=","}; END{print "]}"}'