mirror of
https://github.com/teddysun/across.git
synced 2025-01-19 06:19:35 +08:00
Add Disk information
This commit is contained in:
parent
f1dceef971
commit
ed5df590f0
107
bench.sh
107
bench.sh
@ -6,6 +6,11 @@
|
|||||||
# Visit: https://teddysun.com #
|
# Visit: https://teddysun.com #
|
||||||
#==============================================================#
|
#==============================================================#
|
||||||
|
|
||||||
|
if [ ! -e '/usr/bin/wget' ]; then
|
||||||
|
echo "Error: wget command not found. You must be install wget command at first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
get_opsy() {
|
get_opsy() {
|
||||||
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
|
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
|
||||||
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
|
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
|
||||||
@ -17,9 +22,9 @@ next() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
speed_test() {
|
speed_test() {
|
||||||
speedtest=$(wget -4O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
|
local speedtest=$(wget -4O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
|
||||||
ipaddress=$(ping -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
|
local ipaddress=$(ping -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
|
||||||
nodeName=$2
|
local nodeName=$2
|
||||||
if [ "${#nodeName}" -lt "8" ]; then
|
if [ "${#nodeName}" -lt "8" ]; then
|
||||||
echo -e "\e[33m$2\e[0m\t\t\t\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
|
echo -e "\e[33m$2\e[0m\t\t\t\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
|
||||||
elif [ "${#nodeName}" -lt "13" ]; then
|
elif [ "${#nodeName}" -lt "13" ]; then
|
||||||
@ -32,9 +37,9 @@ speed_test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
speed_test_v6() {
|
speed_test_v6() {
|
||||||
speedtest=$(wget -6O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
|
local speedtest=$(wget -6O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
|
||||||
ipaddress=$(ping6 -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
|
local ipaddress=$(ping6 -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
|
||||||
nodeName=$2
|
local nodeName=$2
|
||||||
if [ "${#nodeName}" -lt "8" -a "${#ipaddress}" -eq "13" ]; then
|
if [ "${#nodeName}" -lt "8" -a "${#ipaddress}" -eq "13" ]; then
|
||||||
echo -e "\e[33m$2\e[0m\t\t\t\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
|
echo -e "\e[33m$2\e[0m\t\t\t\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
|
||||||
elif [ "${#nodeName}" -lt "13" -a "${#ipaddress}" -eq "13" ]; then
|
elif [ "${#nodeName}" -lt "13" -a "${#ipaddress}" -eq "13" ]; then
|
||||||
@ -76,47 +81,63 @@ speed_v6() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
io_test() {
|
io_test() {
|
||||||
(LANG=en_US 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]*$//'
|
(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]*$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -e '/usr/bin/wget' ]; then
|
calc_disk() {
|
||||||
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
local total_size=0
|
||||||
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
|
local array=$1
|
||||||
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
for size in ${array[@]}
|
||||||
tram=$( free -m | awk '/Mem/ {print $2}' )
|
do
|
||||||
swap=$( free -m | awk '/Swap/ {print $2}' )
|
size_t=`echo ${size:0:${#size}-1}`
|
||||||
up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60;d=$1%60} {printf("%ddays, %d:%d:%d\n",a,b,c,d)}' /proc/uptime )
|
[ "`echo ${size:(-1)}`" == "M" ] && size=$( awk 'BEGIN{print '$size_t' / 1024}' ) || size=${size_t}
|
||||||
load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
total_size=$( awk 'BEGIN{print '$total_size' + '$size'}' )
|
||||||
opsy=$( get_opsy )
|
done
|
||||||
arch=$( uname -m )
|
echo ${total_size}
|
||||||
lbit=$( getconf LONG_BIT )
|
}
|
||||||
host=$( hostname )
|
|
||||||
kern=$( uname -r )
|
|
||||||
ipv6=$( wget -qO- -t1 -T2 ipv6.icanhazip.com )
|
|
||||||
|
|
||||||
clear
|
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
next
|
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
|
||||||
echo "CPU model : $cname"
|
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
echo "Number of cores : $cores"
|
tram=$( free -m | awk '/Mem/ {print $2}' )
|
||||||
echo "CPU frequency : $freq MHz"
|
swap=$( free -m | awk '/Swap/ {print $2}' )
|
||||||
echo "Total amount of ram : $tram MB"
|
up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60;d=$1%60} {printf("%ddays, %d:%d:%d\n",a,b,c,d)}' /proc/uptime )
|
||||||
echo "Total amount of swap : $swap MB"
|
load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
echo "System uptime : $up"
|
opsy=$( get_opsy )
|
||||||
echo "Load average : $load"
|
arch=$( uname -m )
|
||||||
echo "OS : $opsy"
|
lbit=$( getconf LONG_BIT )
|
||||||
echo "Arch : $arch ($lbit Bit)"
|
host=$( hostname )
|
||||||
echo "Kernel : $kern"
|
kern=$( uname -r )
|
||||||
next
|
ipv6=$( wget -qO- -t1 -T2 ipv6.icanhazip.com )
|
||||||
|
disk_size1=($( df -ahPl | grep -wvE '\-|none|Filesystem' | awk '{print $2}' ))
|
||||||
|
disk_size2=($( df -ahPl | grep -wvE '\-|none|Filesystem' | awk '{print $3}' ))
|
||||||
|
disk_size3=($( df -ahPl | grep -wvE '\-|none|Filesystem' | awk '{print $4}' ))
|
||||||
|
disk_total_size=$( calc_disk $disk_size1 )
|
||||||
|
disk_used_size=$( calc_disk $disk_size2 )
|
||||||
|
disk_avail_size=$( calc_disk $disk_size3 )
|
||||||
|
|
||||||
echo -e "Node Name\t\t\tIPv4 address\t\tDownload Speed"
|
clear
|
||||||
speed && next
|
next
|
||||||
if [[ "$ipv6" != "" ]]; then
|
echo "CPU model : $cname"
|
||||||
echo -e "Node Name\t\t\tIPv6 address\t\tDownload Speed"
|
echo "Number of cores : $cores"
|
||||||
speed_v6 && next
|
echo "CPU frequency : $freq MHz"
|
||||||
fi
|
echo "Total size of Disk : $disk_total_size GB"
|
||||||
else
|
echo "Used size of Disk : $disk_used_size GB"
|
||||||
echo "Error: wget command not found. You must be install wget command at first."
|
echo "Avail size of Disk : $disk_avail_size GB"
|
||||||
exit 1
|
echo "Total amount of Mem : $tram MB"
|
||||||
|
echo "Total amount of Swap : $swap MB"
|
||||||
|
echo "System uptime : $up"
|
||||||
|
echo "Load average : $load"
|
||||||
|
echo "OS : $opsy"
|
||||||
|
echo "Arch : $arch ($lbit Bit)"
|
||||||
|
echo "Kernel : $kern"
|
||||||
|
next
|
||||||
|
|
||||||
|
echo -e "Node Name\t\t\tIPv4 address\t\tDownload Speed"
|
||||||
|
speed && next
|
||||||
|
if [[ "$ipv6" != "" ]]; then
|
||||||
|
echo -e "Node Name\t\t\tIPv6 address\t\tDownload Speed"
|
||||||
|
speed_v6 && next
|
||||||
fi
|
fi
|
||||||
|
|
||||||
io1=$( io_test )
|
io1=$( io_test )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user