Update comments

Get more system information

Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
Teddysun 2020-07-28 17:17:30 +09:00
parent 3edb641707
commit 9012079a90
No known key found for this signature in database
GPG Key ID: 09BD4C080AD6C46D

174
bench.sh
View File

@ -2,24 +2,39 @@
#
# Description: Auto test download & I/O speed script
#
# Copyright (C) 2015 - 2019 Teddysun <i@teddysun.com>
#
# Copyright (C) 2015 - 2020 Teddysun <i@teddysun.com>
# Thanks: LookBack <admin@dwhd.org>
#
# URL: https://teddysun.com/444.html
#
if [ ! -e '/usr/bin/wget' ]; then
echo "Error: wget command not found. You must be install wget command at first."
exit 1
fi
_red() {
printf '\033[0;31;31m%b\033[0m' "$1"
}
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;36m'
PLAIN='\033[0m'
_green() {
printf '\033[0;31;32m%b\033[0m' "$1"
}
_yellow() {
printf '\033[0;31;33m%b\033[0m' "$1"
}
_blue() {
printf '\033[0;31;36m%b\033[0m' "$1"
}
_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}
}
get_opsy() {
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
@ -36,15 +51,7 @@ speed_test_v4() {
local speedtest=$(printf '%s' "$output" | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local ipaddress=$(printf '%s' "$output" | awk -F'|' '/Connecting to .*\|([^\|]+)\|/ {print $2}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}" "${ipaddress}" "${speedtest}"
}
speed_test_v6() {
local output=$(LANG=C wget -6O /dev/null -T300 $1 2>&1)
local speedtest=$(printf '%s' "$output" | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
local ipaddress=$(printf '%s' "$output" | awk -F'|' '/Connecting to .*\|([^\|]+)\|/ {print $2}')
local nodeName=$2
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodeName}" "${ipaddress}" "${speedtest}"
printf "\033[0;33m%-32s\033[0;32m%-24s\033[0;31m%-14s\033[0m\n" "${nodeName}" "${ipaddress}" "${speedtest}"
}
speed_v4() {
@ -53,27 +60,14 @@ speed_v4() {
speed_test_v4 'http://speedtest.singapore.linode.com/100MB-singapore.bin' 'Linode, Singapore, SG'
speed_test_v4 'http://speedtest.london.linode.com/100MB-london.bin' 'Linode, London, UK'
speed_test_v4 'http://speedtest.frankfurt.linode.com/100MB-frankfurt.bin' 'Linode, Frankfurt, DE'
speed_test_v4 'http://speedtest.fremont.linode.com/100MB-fremont.bin' 'Linode, Fremont, CA'
speed_test_v4 'http://speedtest.dal05.softlayer.com/downloads/test100.zip' 'Softlayer, Dallas, TX'
speed_test_v4 'http://speedtest.sea01.softlayer.com/downloads/test100.zip' 'Softlayer, Seattle, WA'
speed_test_v4 'http://speedtest.fremont.linode.com/100MB-fremont.bin' 'Linode, Fremont, US'
speed_test_v4 'http://speedtest.dal05.softlayer.com/downloads/test100.zip' 'Softlayer, Dallas, US'
speed_test_v4 'http://speedtest.sea01.softlayer.com/downloads/test100.zip' 'Softlayer, Seattle, US'
speed_test_v4 'http://speedtest.fra02.softlayer.com/downloads/test100.zip' 'Softlayer, Frankfurt, DE'
speed_test_v4 'http://speedtest.sng01.softlayer.com/downloads/test100.zip' 'Softlayer, Singapore, SG'
speed_test_v4 'http://speedtest.hkg02.softlayer.com/downloads/test100.zip' 'Softlayer, HongKong, CN'
}
speed_v6() {
speed_test_v6 'http://speedtest.atlanta.linode.com/100MB-atlanta.bin' 'Linode, Atlanta, GA'
speed_test_v6 'http://speedtest.dallas.linode.com/100MB-dallas.bin' 'Linode, Dallas, TX'
speed_test_v6 'http://speedtest.newark.linode.com/100MB-newark.bin' 'Linode, Newark, NJ'
speed_test_v6 'http://speedtest.singapore.linode.com/100MB-singapore.bin' 'Linode, Singapore, SG'
speed_test_v6 'http://speedtest.tokyo2.linode.com/100MB-tokyo2.bin' 'Linode, Tokyo2, JP'
speed_test_v6 'http://speedtest.sjc03.softlayer.com/downloads/test100.zip' 'Softlayer, San Jose, CA'
speed_test_v6 'http://speedtest.wdc01.softlayer.com/downloads/test100.zip' 'Softlayer, Washington, WA'
speed_test_v6 'http://speedtest.par01.softlayer.com/downloads/test100.zip' 'Softlayer, Paris, FR'
speed_test_v6 'http://speedtest.sng01.softlayer.com/downloads/test100.zip' 'Softlayer, Singapore, SG'
speed_test_v6 'http://speedtest.tok02.softlayer.com/downloads/test100.zip' 'Softlayer, Tokyo, JP'
}
io_test() {
(LANG=C dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
}
@ -93,9 +87,68 @@ calc_disk() {
echo ${total_size}
}
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 [[ "${cname}" == *KVM* ]]; then
virt="KVM"
elif [[ "${cname}" == *QEMU* ]]; then
virt="KVM"
elif [[ "${virtualx}" == *"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
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
}
ipv4_info() {
local org="$(wget -qO- ipinfo.io/org)"
local city="$(wget -qO- ipinfo.io/city)"
local country="$(wget -qO- ipinfo.io/country)"
local region="$(wget -qO- ipinfo.io/region)"
[[ -n "$org" ]] && echo "Organization : $(_blue "$org")"
[[ -n "$city" && -n "country" ]] && echo "Location : $(_blue "$city / $country")"
[[ -n "$region" ]] && echo "Region : $(_blue "$region")"
}
! _exists "wget" && _red "Error: wget command not found. You must be install wget command at first.\n" && exit 1
# Get System information
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
freq=$( awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo )
corescache=$( awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
tram=$( free -m | awk '/Mem/ {print $2}' )
uram=$( free -m | awk '/Mem/ {print $3}' )
swap=$( free -m | awk '/Swap/ {print $2}' )
@ -106,32 +159,36 @@ opsy=$( get_opsy )
arch=$( uname -m )
lbit=$( getconf LONG_BIT )
kern=$( uname -r )
#ipv6=$( wget -qO- -t1 -T2 ipv6.icanhazip.com )
disk_size1=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem|udev|docker' | awk '{print $2}' ))
disk_size2=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem|udev|docker' | awk '{print $3}' ))
disk_total_size=$( calc_disk "${disk_size1[@]}" )
disk_used_size=$( calc_disk "${disk_size2[@]}" )
tcpctrl=$( sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}' )
check_virt
clear
next
echo -e "CPU model : ${BLUE}$cname${PLAIN}"
echo -e "Number of cores : ${BLUE}$cores${PLAIN}"
echo -e "CPU frequency : ${BLUE}$freq MHz${PLAIN}"
echo -e "Total size of Disk : ${BLUE}$disk_total_size GB ($disk_used_size GB Used)${PLAIN}"
echo -e "Total amount of Mem : ${BLUE}$tram MB ($uram MB Used)${PLAIN}"
echo -e "Total amount of Swap : ${BLUE}$swap MB ($uswap MB Used)${PLAIN}"
echo -e "System uptime : ${BLUE}$up${PLAIN}"
echo -e "Load average : ${BLUE}$load${PLAIN}"
echo -e "OS : ${BLUE}$opsy${PLAIN}"
echo -e "Arch : ${BLUE}$arch ($lbit Bit)${PLAIN}"
echo -e "Kernel : ${BLUE}$kern${PLAIN}"
echo "CPU Model : $(_blue "$cname")"
echo "CPU Cores : $(_blue "$cores")"
echo "CPU Frequency : $(_blue "$freq MHz")"
echo "CPU Cache : $(_blue "$corescache")"
echo "Total Disk : $(_blue "$disk_total_size GB ($disk_used_size GB Used)")"
echo "Total Mem : $(_blue "$tram MB ($uram MB Used)")"
echo "Total Swap : $(_blue "$swap MB ($uswap MB Used)")"
echo "System uptime : $(_blue "$up")"
echo "Load average : $(_blue "$load")"
echo "OS : $(_blue "$opsy")"
echo "Arch : $(_blue "$arch ($lbit Bit)")"
echo "Kernel : $(_blue "$kern")"
echo "TCP CC : $(_blue "$tcpctrl")"
echo "Virtualization : $(_blue "$virt")"
ipv4_info
next
io1=$( io_test )
echo -e "I/O speed(1st run) : ${YELLOW}$io1${PLAIN}"
echo "I/O Speed(1st run) : $(_yellow "$io1")"
io2=$( io_test )
echo -e "I/O speed(2nd run) : ${YELLOW}$io2${PLAIN}"
echo "I/O Speed(2nd run) : $(_yellow "$io2")"
io3=$( io_test )
echo -e "I/O speed(3rd run) : ${YELLOW}$io3${PLAIN}"
echo "I/O Speed(3rd run) : $(_yellow "$io3")"
ioraw1=$( echo $io1 | awk 'NR==1 {print $1}' )
[ "`echo $io1 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' )
ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' )
@ -140,11 +197,8 @@ ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' )
[ "`echo $io3 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' )
ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' )
ioavg=$( awk 'BEGIN{printf "%.1f", '$ioall' / 3}' )
echo -e "Average I/O speed : ${YELLOW}$ioavg MB/s${PLAIN}"
echo -e "Average I/O speed : $(_yellow "$ioavg MB/s")"
next
printf "%-32s%-24s%-14s\n" "Node Name" "IPv4 address" "Download Speed"
speed_v4 && next
#if [[ "$ipv6" != "" ]]; then
# printf "%-32s%-24s%-14s\n" "Node Name" "IPv6 address" "Download Speed"
# speed_v6 && next
#fi
speed_v4
next