Auto-update: Tue Aug 6 12:59:05 PDT 2024
This commit is contained in:
parent
ec6e3781b6
commit
2ea87f5ff8
1 changed files with 41 additions and 18 deletions
53
vitals
53
vitals
|
@ -1,9 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
tailscale='/Applications/Tailscale.app/Contents/MacOS/Tailscale'
|
adguard_test_domain='check.adguard.test'
|
||||||
|
adguard_home_ip='100.64.64.15'
|
||||||
|
|
||||||
# Get local IP
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
|
# macOS
|
||||||
|
local_ip=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | head -n1)
|
||||||
|
uptime=$(uptime | awk '{print $3}' | sed 's/,//')
|
||||||
|
else
|
||||||
|
# Linux
|
||||||
local_ip=$(hostname -I | awk '{print $1}')
|
local_ip=$(hostname -I | awk '{print $1}')
|
||||||
|
uptime=$(uptime -p)
|
||||||
|
fi
|
||||||
|
|
||||||
wan_info=$(curl -s --max-time 10 https://am.i.mullvad.net/json)
|
wan_info=$(curl -s --max-time 10 https://am.i.mullvad.net/json)
|
||||||
wan_connected=false
|
wan_connected=false
|
||||||
if [ ! -z "$wan_info" ]; then
|
if [ ! -z "$wan_info" ]; then
|
||||||
|
@ -16,11 +25,11 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if Tailscale is installed and get IP
|
# Check if Tailscale is installed and get IP
|
||||||
if command -v $tailscale &> /dev/null; then
|
if command -v tailscale &> /dev/null; then
|
||||||
has_tailscale=true
|
has_tailscale=true
|
||||||
tailscale_ip=$($tailscale ip -4)
|
tailscale_ip=$(tailscale ip -4)
|
||||||
# Get Tailscale exit-node information
|
# Get Tailscale exit-node information
|
||||||
ts_exitnode_output=$($tailscale exit-node list)
|
ts_exitnode_output=$(tailscale exit-node list)
|
||||||
# Parse exit node hostname
|
# Parse exit node hostname
|
||||||
if echo "$ts_exitnode_output" | grep -q 'selected'; then
|
if echo "$ts_exitnode_output" | grep -q 'selected'; then
|
||||||
mullvad_exitnode=true
|
mullvad_exitnode=true
|
||||||
|
@ -39,25 +48,34 @@ fi
|
||||||
|
|
||||||
nextdns_info=$(curl -sL --max-time 10 https://test.nextdns.io)
|
nextdns_info=$(curl -sL --max-time 10 https://test.nextdns.io)
|
||||||
if [ -z "$nextdns_info" ]; then
|
if [ -z "$nextdns_info" ]; then
|
||||||
echo "Failed to fetch NextDNS status or no internet connection."
|
echo "Failed to fetch NextDNS status or no internet connection." >&2
|
||||||
else
|
|
||||||
nextdns_status=$(echo "$nextdns_info" | jq -r '.status')
|
|
||||||
if [ "$nextdns_status" = "unconfigured" ]; then
|
|
||||||
echo "You are not using NextDNS."
|
|
||||||
nextdns_connected=false
|
nextdns_connected=false
|
||||||
nextdns_protocol=""
|
nextdns_protocol=""
|
||||||
nextdns_client=""
|
nextdns_client=""
|
||||||
else
|
else
|
||||||
|
nextdns_status=$(echo "$nextdns_info" | jq -r '.status')
|
||||||
|
if [ "$nextdns_status" = "ok" ]; then
|
||||||
nextdns_connected=true
|
nextdns_connected=true
|
||||||
nextdns_protocol=$(echo "$nextdns_info" | jq -r '.protocol')
|
nextdns_protocol=$(echo "$nextdns_info" | jq -r '.protocol')
|
||||||
nextdns_client=$(echo "$nextdns_info" | jq -r '.clientName')
|
nextdns_client=$(echo "$nextdns_info" | jq -r '.clientName')
|
||||||
echo "Connected to NextDNS via $nextdns_protocol. Client: $nextdns_client."
|
else
|
||||||
|
nextdns_connected=false
|
||||||
|
nextdns_protocol=""
|
||||||
|
nextdns_client=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# read uptime_seconds _ < /proc/uptime
|
# Check AdGuard Home DNS
|
||||||
# uptime_days=$(echo "$uptime_seconds / 86400" | bc -l)
|
resolved_ip=$(dig +short $adguard_test_domain)
|
||||||
# uptime_rounded=$(printf "%.2f" $uptime_days)
|
if [ "$resolved_ip" = "$adguard_home_ip" ]; then
|
||||||
|
adguard_connected=true
|
||||||
|
adguard_protocol="AdGuard Home"
|
||||||
|
adguard_client="$adguard_home_ip"
|
||||||
|
else
|
||||||
|
adguard_connected=false
|
||||||
|
adguard_protocol=""
|
||||||
|
adguard_client=""
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
{
|
{
|
||||||
|
@ -73,5 +91,10 @@ cat <<EOF
|
||||||
"nextdns_connected": $nextdns_connected,
|
"nextdns_connected": $nextdns_connected,
|
||||||
"nextdns_protocol": "$nextdns_protocol",
|
"nextdns_protocol": "$nextdns_protocol",
|
||||||
"nextdns_client": "$nextdns_client",
|
"nextdns_client": "$nextdns_client",
|
||||||
"uptime": ""
|
"adguard_connected": $adguard_connected,
|
||||||
|
"adguard_protocol": "$adguard_protocol",
|
||||||
|
"adguard_client": "$adguard_client",
|
||||||
|
"uptime": "$uptime"
|
||||||
}
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue