mirror of
https://github.com/masonr/yet-another-bench-script.git
synced 2025-11-09 00:30:06 +05:30
Add VM Type in Basic Info
Add Virtualization type in basic info. Inspired from bench.sh
This commit is contained in:
parent
0a0358dd53
commit
dc86201120
1 changed files with 71 additions and 0 deletions
71
yabs.sh
71
yabs.sh
|
|
@ -58,6 +58,75 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Functions to identify virtualization type of host system
|
||||
_exists() {
|
||||
local cmd="$1"
|
||||
if eval type type > /dev/null 2>&1; then
|
||||
eval type "$cmd" > /dev/null 2>&1
|
||||
elif command > /dev/null 2>&1; then
|
||||
command -v "$cmd" > /dev/null 2>&1
|
||||
else
|
||||
which "$cmd" > /dev/null 2>&1
|
||||
fi
|
||||
local rt=$?
|
||||
return ${rt}
|
||||
}
|
||||
check_virt() {
|
||||
_exists "dmesg" && virtualx="$(dmesg 2>/dev/null)"
|
||||
if _exists "dmidecode"; then
|
||||
sys_manu="$(dmidecode -s system-manufacturer 2>/dev/null)"
|
||||
sys_product="$(dmidecode -s system-product-name 2>/dev/null)"
|
||||
sys_ver="$(dmidecode -s system-version 2>/dev/null)"
|
||||
else
|
||||
sys_manu=""
|
||||
sys_product=""
|
||||
sys_ver=""
|
||||
fi
|
||||
if grep -qa docker /proc/1/cgroup; then
|
||||
VIRT="Docker"
|
||||
elif grep -qa lxc /proc/1/cgroup; then
|
||||
VIRT="LXC"
|
||||
elif grep -qa container=lxc /proc/1/environ; then
|
||||
VIRT="LXC"
|
||||
elif [[ -f /proc/user_beancounters ]]; then
|
||||
VIRT="OpenVZ"
|
||||
elif [[ "${virtualx}" == *kvm-clock* ]]; then
|
||||
VIRT="KVM"
|
||||
elif [[ "${sys_product}" == *KVM* ]]; then
|
||||
VIRT="KVM"
|
||||
elif [[ "${cname}" == *KVM* ]]; then
|
||||
VIRT="KVM"
|
||||
elif [[ "${cname}" == *QEMU* ]]; then
|
||||
VIRT="KVM"
|
||||
elif [[ "${virtualx}" == *"VMware Virtual Platform"* ]]; then
|
||||
VIRT="VMware"
|
||||
elif [[ "${sys_product}" == *"VMware Virtual Platform"* ]]; then
|
||||
VIRT="VMware"
|
||||
elif [[ "${virtualx}" == *"Parallels Software International"* ]]; then
|
||||
VIRT="Parallels"
|
||||
elif [[ "${virtualx}" == *VirtualBox* ]]; then
|
||||
VIRT="VirtualBox"
|
||||
elif [[ -e /proc/xen ]]; then
|
||||
if grep -q "control_d" "/proc/xen/capabilities" 2>/dev/null; then
|
||||
VIRT="Xen-Dom0"
|
||||
else
|
||||
VIRT="Xen-DomU"
|
||||
fi
|
||||
elif [ -f "/sys/hypervisor/type" ] && grep -q "xen" "/sys/hypervisor/type"; then
|
||||
VIRT="Xen"
|
||||
elif [[ "${sys_manu}" == *"Microsoft Corporation"* ]]; then
|
||||
if [[ "${sys_product}" == *"Virtual Machine"* ]]; then
|
||||
if [[ "${sys_ver}" == *"7.0"* || "${sys_ver}" == *"Hyper-V" ]]; then
|
||||
VIRT="Hyper-V"
|
||||
else
|
||||
VIRT="Microsoft Virtual Machine"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
VIRT="Dedicated"
|
||||
fi
|
||||
}
|
||||
|
||||
# flags to skip certain performance tests
|
||||
unset PREFER_BIN SKIP_FIO SKIP_IPERF SKIP_GEEKBENCH PRINT_HELP REDUCE_NET GEEKBENCH_4 GEEKBENCH_5 DD_FALLBACK IPERF_DL_FAIL JSON JSON_SEND JSON_RESULT JSON_FILE
|
||||
GEEKBENCH_5="True" # gb5 test enabled by default
|
||||
|
|
@ -242,6 +311,8 @@ DISTRO=$(grep 'PRETTY_NAME' /etc/os-release | cut -d '"' -f 2 )
|
|||
echo -e "Distro : $DISTRO"
|
||||
KERNEL=$(uname -r)
|
||||
echo -e "Kernel : $KERNEL"
|
||||
check_virt
|
||||
echo -e "VM Type : $VIRT"
|
||||
|
||||
# Function to get information from IP Address using ip-api.com free API
|
||||
function ip_info() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue