check_sip_connected_peers: fix division by zero problem

This commit is contained in:
Benjamin Renard 2022-05-19 12:11:20 +02:00
parent fd9559312e
commit 8253e3e1bc

View file

@ -102,8 +102,12 @@ do
fi fi
done done
debug "Nb connected peers : $nb_connected" debug "Nb connected peers : $nb_connected"
avg_latency=0
if [[ $nb_connected -gt 0 ]]
then
let avg_latency=sum_latency/nb_connected let avg_latency=sum_latency/nb_connected
debug "Average latency of connected peers : $avg_latency ($sum_latency / $nb_connected)" debug "Average latency of connected peers : $avg_latency ($sum_latency / $nb_connected)"
fi
STATE=OK STATE=OK
MSG="$nb_connected peer(s) connected on $SITE_NAME with an average latency of $avg_latency ms|'connected peers':$nb_connected;$WARNING_PEER_NUMBER;$CRITICAL_PEER_NUMBER;0;0 'average latency':$avg_latency;$WARNING_LATENCY;$CRITICAL_LATENCY;0;0" MSG="$nb_connected peer(s) connected on $SITE_NAME with an average latency of $avg_latency ms|'connected peers':$nb_connected;$WARNING_PEER_NUMBER;$CRITICAL_PEER_NUMBER;0;0 'average latency':$avg_latency;$WARNING_LATENCY;$CRITICAL_LATENCY;0;0"