Update plugins/wireguard/wireguard_

Co-authored-by: Pim <pimlie@hotmail.com>
This commit is contained in:
Artem Zavyalov 2024-03-21 15:30:26 -07:00 committed by GitHub
parent 7ff94424c0
commit bb26f900b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 9 deletions

View File

@ -169,16 +169,13 @@ EOF
echo "multigraph wireguard_peercount"
for iface in $(wg_interfaces); do
threshold=$(date --date="10 min ago" +%s)
isactive=0
for line in $(wg_peers "$iface"); do
handshake=$(echo "$line" | tr ';' ' ' | awk '{print $5}')
if [[ "handshake" -gt "threshold" ]]; then
isactive=$((isactive + 1))
fi
done
iface_peers=$(wg_peers "$iface")
echo "pc_on_$iface.value $(wg show "$iface" peers | wc -l)"
echo "pc_on_active_$iface.value $isactive"
peer_count=$(wc -l <<< "$iface_peers")
active_peer_count=$(awk -F";" -v threshold=$active_threshold '$5 > threshold' <<< "$iface_peers" | wc -l)
echo "pc_on_$iface.value $peer_count"
echo "pc_active_on_$iface.value $active_peer_count"
done
echo ""