mirror of
https://github.com/masonr/yet-another-bench-script.git
synced 2025-04-19 00:45:22 +00:00
skip net info if no response; fix virt detect output
This commit is contained in:
parent
e597a7b2b9
commit
436a951537
16
yabs.sh
16
yabs.sh
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Yet Another Bench Script by Mason Rowe
|
# Yet Another Bench Script by Mason Rowe
|
||||||
# Initial Oct 2019; Last update Feb 2023
|
# Initial Oct 2019; Last update Mar 2023
|
||||||
|
|
||||||
# Disclaimer: This project is a work in progress. Any errors or suggestions should be
|
# Disclaimer: This project is a work in progress. Any errors or suggestions should be
|
||||||
# relayed to me via the GitHub project page linked below.
|
# relayed to me via the GitHub project page linked below.
|
||||||
@ -250,7 +250,7 @@ DISTRO=$(grep 'PRETTY_NAME' /etc/os-release | cut -d '"' -f 2 )
|
|||||||
echo -e "Distro : $DISTRO"
|
echo -e "Distro : $DISTRO"
|
||||||
KERNEL=$(uname -r)
|
KERNEL=$(uname -r)
|
||||||
echo -e "Kernel : $KERNEL"
|
echo -e "Kernel : $KERNEL"
|
||||||
VIRT=$(systemd-detect-virt)
|
VIRT=$(systemd-detect-virt 2>/dev/null)
|
||||||
VIRT=${VIRT^^} || VIRT="UNKNOWN"
|
VIRT=${VIRT^^} || VIRT="UNKNOWN"
|
||||||
echo -e "VM Type : $VIRT"
|
echo -e "VM Type : $VIRT"
|
||||||
|
|
||||||
@ -265,6 +265,11 @@ function ip_info() {
|
|||||||
|
|
||||||
local response=$($DL_CMD http://ip-api.com/json/$net_ip)
|
local response=$($DL_CMD http://ip-api.com/json/$net_ip)
|
||||||
|
|
||||||
|
# if no response, skip output
|
||||||
|
if [[ -z $response ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
local country=$(echo "$response" | grep -Po '"country": *\K"[^"]*"')
|
local country=$(echo "$response" | grep -Po '"country": *\K"[^"]*"')
|
||||||
local country=${country//\"}
|
local country=${country//\"}
|
||||||
|
|
||||||
@ -285,6 +290,10 @@ function ip_info() {
|
|||||||
|
|
||||||
local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"')
|
local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"')
|
||||||
local as=${as//\"}
|
local as=${as//\"}
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Basic Network Information:"
|
||||||
|
echo "---------------------------------"
|
||||||
|
|
||||||
if [[ -n "$net_type" ]]; then
|
if [[ -n "$net_type" ]]; then
|
||||||
echo "Protocol : $net_type"
|
echo "Protocol : $net_type"
|
||||||
@ -308,9 +317,6 @@ function ip_info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [ -z $SKIP_NET ]; then
|
if [ -z $SKIP_NET ]; then
|
||||||
echo -e
|
|
||||||
echo -e "Basic Network Information:"
|
|
||||||
echo -e "---------------------------------"
|
|
||||||
ip_info
|
ip_info
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user