#!/bin/bash #VERSION="v2026051100" # initiale Erstellung VERSION="v2026051200" # erweitert uptime # KeepaliveD prüfen service keepalived status >/dev/null && echo "OK: KeepaliveD läuft" || echo "CRIT: KeepaliveD ist tot" # IP + VIP ip a | grep -F 'inet 10.145.43.3' echo "#------------------------------------------------------------------------------#" # PostgreSQL Commits pg_isready -q && sudo -u postgres psql -t -c "SELECT 'commits=' || SUM(xact_commit) || ', rollbacks=' || SUM(xact_rollback) FROM pg_stat_database;" || echo Replica # Active Connections pg_isready -q && sudo -u postgres psql -t -c "SELECT COUNT(*) || ' active connections' FROM pg_stat_activity WHERE state='active';" # HAProxy abfragen echo "#------------------------------------------------------------------------------#" #links -ssl.certificates 0 -dump http://admin:admin@localhost:8404/stats curl -s "http://admin:admin@localhost:8404/stats;csv" | grep -E 'pg_leader|pg_replica' | awk -F',' '{print $2, $18, $56}' # Patroni abfragen patronictl -c /etc/patroni/config.yml list # EtcD abfragen etcdctl --endpoints="http://pg-knoten-01:2379,http://pg-knoten-02:2379,http://pg-knoten-03:2379" endpoint health # Patroni abfragen #echo "#------------------------------------------------------------------------------#" #curl -i http://localhost:8008/leader ; echo # for HIP in 10.145.43.31 10.145.43.32 10.145.43.33 do echo "#------------------------------------------------------------------------------#" #curl -i http://${HIP}:8008/leader curl -s http://${HIP}:8008/leader | jq . | grep -E 'state|postmaster_start_time|role|scope|name' done echo "#------------------------------------------------------------------------------#" pg_isready -q && echo "SELECT name, setting, unit, SOURCE, sourcefile, sourceline FROM pg_settings WHERE name IN ( 'autovacuum_work_mem', 'effective_cache_size', 'maintenance_work_mem', 'max_connections', 'shared_buffers', 'work_mem' );" | sudo -u postgres psql