|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 | 3 | # Yet Another Bench Script by Mason Rowe
|
4 |
| -# Initial Oct 2019; Last update Dec 2022 |
| 4 | +# Initial Oct 2019; Last update Jan 2023 |
5 | 5 |
|
6 | 6 | # Disclaimer: This project is a work in progress. Any errors or suggestions should be
|
7 | 7 | # relayed to me via the GitHub project page linked below.
|
|
12 | 12 | # performance via fio. The script is designed to not require any dependencies
|
13 | 13 | # - either compiled or installed - nor admin privileges to run.
|
14 | 14 | #
|
15 |
| -YABS_VERSION="v2022-12-29" |
| 15 | +YABS_VERSION="v2023-02-03" |
16 | 16 |
|
17 | 17 | echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
18 | 18 | echo -e '# Yet-Another-Bench-Script #'
|
@@ -242,6 +242,65 @@ DISTRO=$(grep 'PRETTY_NAME' /etc/os-release | cut -d '"' -f 2 )
|
242 | 242 | echo -e "Distro : $DISTRO"
|
243 | 243 | KERNEL=$(uname -r)
|
244 | 244 | echo -e "Kernel : $KERNEL"
|
| 245 | +VIRT=$(systemd-detect-virt) |
| 246 | +VIRT=${VIRT^^} || VIRT="UNKNOWN" |
| 247 | +echo -e "VM Type : $VIRT" |
| 248 | +
|
| 249 | +# Function to get information from IP Address using ip-api.com free API |
| 250 | +function ip_info() { |
| 251 | + local net_type="$(wget -qO- http://ip6.me/api/ | cut -d, -f1)" |
| 252 | + local net_ip="$(wget -qO- http://ip6.me/api/ | cut -d, -f2)" |
| 253 | +
|
| 254 | + local response=$(wget -qO- http://ip-api.com/json/$net_ip) |
| 255 | +
|
| 256 | + local country=$(echo "$response" | grep -Po '"country": *\K"[^"]*"') |
| 257 | + local country=${country//\"} |
| 258 | +
|
| 259 | + local region=$(echo "$response" | grep -Po '"regionName": *\K"[^"]*"') |
| 260 | + local region=${region//\"} |
| 261 | +
|
| 262 | + local region_code=$(echo "$response" | grep -Po '"region": *\K"[^"]*"') |
| 263 | + local region_code=${region_code//\"} |
| 264 | +
|
| 265 | + local city=$(echo "$response" | grep -Po '"city": *\K"[^"]*"') |
| 266 | + local city=${city//\"} |
| 267 | +
|
| 268 | + local isp=$(echo "$response" | grep -Po '"isp": *\K"[^"]*"') |
| 269 | + local isp=${isp//\"} |
| 270 | +
|
| 271 | + local org=$(echo "$response" | grep -Po '"org": *\K"[^"]*"') |
| 272 | + local org=${org//\"} |
| 273 | +
|
| 274 | + local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"') |
| 275 | + local as=${as//\"} |
| 276 | + |
| 277 | +
|
| 278 | + if [[ -n "$net_type" ]]; then |
| 279 | + echo "Protocol : $net_type" |
| 280 | + fi |
| 281 | + if [[ -z "$net_type" ]]; then |
| 282 | + echo "Protocol : Unknown" |
| 283 | + fi |
| 284 | + if [[ -n "$isp" && -n "$as" ]]; then |
| 285 | + echo "ISP : $isp" |
| 286 | + echo "ASN : $as" |
| 287 | + fi |
| 288 | + if [[ -n "$org" ]]; then |
| 289 | + echo "Host : $org" |
| 290 | + fi |
| 291 | + if [[ -n "$city" && -n "$region" ]]; then |
| 292 | + echo "Location : $city, $region ($region_code)" |
| 293 | + fi |
| 294 | + if [[ -n "$country" ]]; then |
| 295 | + echo "Country : $country" |
| 296 | + fi |
| 297 | +} |
| 298 | +
|
| 299 | +echo -e |
| 300 | +echo -e "Basic Network Information:" |
| 301 | +echo -e "---------------------------------" |
| 302 | +ip_info |
| 303 | +
|
245 | 304 |
|
246 | 305 | if [ ! -z $JSON ]; then
|
247 | 306 | UPTIME_S=$(awk '{print $1}' /proc/uptime)
|
|
0 commit comments