mirror of
https://github.com/masonr/yet-another-bench-script.git
synced 2025-11-08 08:20:07 +05:30
Add Basic Network Info
Added a function to display basic details from IP Address lookup. Use ip-api.com free API for this.
This commit is contained in:
parent
7aa3b79530
commit
0a0358dd53
1 changed files with 61 additions and 2 deletions
63
yabs.sh
Executable file → Normal file
63
yabs.sh
Executable file → Normal file
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Yet Another Bench Script by Mason Rowe
|
||||
# Initial Oct 2019; Last update Dec 2022
|
||||
# Initial Oct 2019; Last update Jan 2023
|
||||
|
||||
# Disclaimer: This project is a work in progress. Any errors or suggestions should be
|
||||
# relayed to me via the GitHub project page linked below.
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
# performance via fio. The script is designed to not require any dependencies
|
||||
# - either compiled or installed - nor admin privileges to run.
|
||||
#
|
||||
YABS_VERSION="v2022-12-29"
|
||||
YABS_VERSION="v2023-01-21"
|
||||
|
||||
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
||||
echo -e '# Yet-Another-Bench-Script #'
|
||||
|
|
@ -243,6 +243,65 @@ echo -e "Distro : $DISTRO"
|
|||
KERNEL=$(uname -r)
|
||||
echo -e "Kernel : $KERNEL"
|
||||
|
||||
# Function to get information from IP Address using ip-api.com free API
|
||||
function ip_info() {
|
||||
local net_type="$(wget -qO- http://ip6.me/api/ | cut -d, -f1)"
|
||||
local net_ip="$(wget -qO- http://ip6.me/api/ | cut -d, -f2)"
|
||||
|
||||
local response=$(wget -qO- http://ip-api.com/json/$net_ip)
|
||||
|
||||
local country=$(echo "$response" | grep -Po '"country": *\K"[^"]*"')
|
||||
local country=${country//\"}
|
||||
|
||||
local region=$(echo "$response" | grep -Po '"regionName": *\K"[^"]*"')
|
||||
local region=${region//\"}
|
||||
|
||||
local region_code=$(echo "$response" | grep -Po '"region": *\K"[^"]*"')
|
||||
local region_code=${region_code//\"}
|
||||
|
||||
local city=$(echo "$response" | grep -Po '"city": *\K"[^"]*"')
|
||||
local city=${city//\"}
|
||||
|
||||
local isp=$(echo "$response" | grep -Po '"isp": *\K"[^"]*"')
|
||||
local isp=${isp//\"}
|
||||
|
||||
local org=$(echo "$response" | grep -Po '"org": *\K"[^"]*"')
|
||||
local org=${org//\"}
|
||||
|
||||
local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"')
|
||||
local as=${as//\"}
|
||||
|
||||
|
||||
if [[ -n "$net_type" ]]; then
|
||||
echo "Protocol : $net_type"
|
||||
fi
|
||||
if [[ -z "$net_type" ]]; then
|
||||
echo "Network : Unknown"
|
||||
fi
|
||||
if [[ -n "$isp" && -n "$as" ]]; then
|
||||
echo "ISP : $isp"
|
||||
echo "ASN : $as"
|
||||
fi
|
||||
if [[ -n "$org" ]]; then
|
||||
echo "Host : $org"
|
||||
fi
|
||||
if [[ -n "$city" && -n "$region" ]]; then
|
||||
echo "Location : $city, $region ($region_code)"
|
||||
fi
|
||||
if [[ -n "$country" ]]; then
|
||||
echo "Country : $country"
|
||||
fi
|
||||
if [[ -z "$org" ]]; then
|
||||
echo "Host : No ISP detected"
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e
|
||||
echo -e "Basic Network Information:"
|
||||
echo -e "---------------------------------"
|
||||
ip_info
|
||||
|
||||
|
||||
if [ ! -z $JSON ]; then
|
||||
UPTIME_S=$(awk '{print $1}' /proc/uptime)
|
||||
IPV4=$([ ! -z $IPV4_CHECK ] && echo "true" || echo "false")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue