[Demo Code] Watch the witness node latency in docker

in #witness7 days ago
#!/bin/bash

container_name=$1
delay_config=$2

if [[ "${container_name}" = "" ]]; then
        container_name=witness
fi

if [[ "${delay_config}" = "" ]]; then
        delay_config=300
fi

msg_queue=()
count=0

alert() {
    msg_queue+=("$1")
    ((count++))
    if ((count % 5 == 0)); then
        echo "${msg_queue[@]}"
        msg_queue=()
    fi
}

while read line; do
        username=`echo $line | awk '{print $12}'`
        delay=`echo $line | awk '{print $17}'`
        # If the delay is higher than delay_config, it will report.
        if (( delay > ${delay_config} )); then
                alert "$username, $delay"
        fi
done < <(docker logs -f --tail 1 ${container_name})

Coin Marketplace

STEEM 0.19
TRX 0.18
JST 0.033
BTC 87757.32
ETH 3103.63
USDT 1.00
SBD 2.75