mirror of
https://github.com/AuxXxilium/yet-another-bench-script.git
synced 2024-11-23 14:51:02 +07:00
Add Basic Network Info and VM Type (#56)
* Add Basic Network Info Added a function to display basic details from IP Address lookup. Use ip-api.com free API for this. * Add VM Type in Basic Info Add Virtualization type in basic info. Inspired from bench.sh * Suppress Error messages on VM check * Better way to find virtualization Most modern Linux systems use systemd as the system and service manager. The systemd package ships with the systemd-detect-virt utility, which we can use to detect a virtualization technology.
This commit is contained in:
parent
7aa3b79530
commit
f075baf59c
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-02-03"
|
||||
|
||||
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
||||
echo -e '# Yet-Another-Bench-Script #'
|
||||
@ -242,6 +242,65 @@ DISTRO=$(grep 'PRETTY_NAME' /etc/os-release | cut -d '"' -f 2 )
|
||||
echo -e "Distro : $DISTRO"
|
||||
KERNEL=$(uname -r)
|
||||
echo -e "Kernel : $KERNEL"
|
||||
VIRT=$(systemd-detect-virt)
|
||||
VIRT=${VIRT^^} || VIRT="UNKNOWN"
|
||||
echo -e "VM Type : $VIRT"
|
||||
|
||||
# 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 "Protocol : 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
|
||||
}
|
||||
|
||||
echo -e
|
||||
echo -e "Basic Network Information:"
|
||||
echo -e "---------------------------------"
|
||||
ip_info
|
||||
|
||||
|
||||
if [ ! -z $JSON ]; then
|
||||
UPTIME_S=$(awk '{print $1}' /proc/uptime)
|
||||
|
Loading…
Reference in New Issue
Block a user