[Demo Code] Watch the witness node latency in docker

in #witness2 months 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.24
TRX 0.25
JST 0.040
BTC 93863.56
ETH 3421.99
USDT 1.00
SBD 3.30