# Get only replica lines and format as node:lag
replica_lags=$(patronictl -c /etc/patroni.yml list | awk '$3 == "Replica" {print $1 ":" $(NF)}')
# Pass this variable to Amelia or write it to a temp file for JS to read
echo "$replica_lags"
// Input from shell (e.g., via Amelia automation)
const replicaLagsRaw = `replica1:0
replica2:120`;
const replicaLags = replicaLagsRaw.trim().split('\n');
for (const entry of replicaLags) {
const [nodeName, lagStr] = entry.split(':');
const lag = parseInt(lagStr, 10);
if (lag > 100) {
console.log(`High lag detected on ${nodeName}: ${lag} MB`);
// Trigger your automation or alert
} else {
console.log(`Lag on ${nodeName} is acceptable: ${lag} MB`);
}
}





0 comments:
Post a Comment