Last active
January 16, 2025 03:47
-
-
Save manesec/9854551b706b675926350bffd55858ff to your computer and use it in GitHub Desktop.
Use for Ping Monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| interface="$(ip tuntap show | cut -d : -f1 | head -n 1)" | |
| gatewayip=`ip -j route list table all | jq -r '.[] | select(.dev=="'$interface'") | .gateway' | grep -v null | head -n 1` | |
| localip=`ip -j route list table all | jq -r '.[] | select(.dev=="'$interface'") | .prefsrc' | grep -v null | head -n 1` | |
| delay=`ping $gatewayip -W 1 -c 1| awk -F'/' 'END{ print (/^rtt/? ""$5" ms":"") }'` | |
| if [[ $interface == '' ]]; then | |
| echo "" ; | |
| else | |
| echo "$localip - $delay" ; | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment