The command-line tools wrap Kafka 129 's Admin API, which every client library exposes, so a health probe can check what matters: every broker registered, no under-replicated partitions. This one uses confluent-kafka 2.15.1 (librdkafka 2.15.1) from the host, through broker 4's published port.
"""cluster_info.py [BOOTSTRAP]: check a cluster through the Admin API."""
import sys
from confluent_kafka.admin import AdminClient
bootstrap = sys.argv[1] if len(sys.argv) > 1 else "localhost:33194" # broker 4
admin = AdminClient({"bootstrap.servers": bootstrap})
cluster = admin.describe_cluster().result(timeout=10)
print("cluster", cluster.cluster_id, "| controller", cluster.controller.id,
"| brokers", sorted(node.id for node in cluster.nodes))
metadata = admin.list_topics(timeout=10)
for name in sorted(t for t in metadata.topics if not t.startswith("__")):
parts = metadata.topics[name].partitions.values()
lagging = sum(len(p.isrs) < len(p.replicas) for p in parts)
print(f"{name:<26} partitions {len(parts)} under-replicated {lagging}")Output
cluster Wb96LW2BRGSHe9VjFRvWOA | controller 5 | brokers [4, 5, 6] booknest.order-events partitions 3 under-replicated 0
The reported controller changes between runs: clients cannot reach KRaft controllers, so brokers answer with a random live broker. kafka-metadata-quorum.sh --bootstrap-controller shows the real one (The KRaft Metadata Quorum).