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
49
bench.sh
49
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,10 +81,21 @@ 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]*$//'
|
||||||
|
}
|
||||||
|
|
||||||
|
calc_disk() {
|
||||||
|
local total_size=0
|
||||||
|
local array=$1
|
||||||
|
for size in ${array[@]}
|
||||||
|
do
|
||||||
|
size_t=`echo ${size:0:${#size}-1}`
|
||||||
|
[ "`echo ${size:(-1)}`" == "M" ] && size=$( awk 'BEGIN{print '$size_t' / 1024}' ) || size=${size_t}
|
||||||
|
total_size=$( awk 'BEGIN{print '$total_size' + '$size'}' )
|
||||||
|
done
|
||||||
|
echo ${total_size}
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -e '/usr/bin/wget' ]; then
|
|
||||||
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
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 )
|
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
|
||||||
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
|
||||||
@ -93,14 +109,23 @@ if [ -e '/usr/bin/wget' ]; then
|
|||||||
host=$( hostname )
|
host=$( hostname )
|
||||||
kern=$( uname -r )
|
kern=$( uname -r )
|
||||||
ipv6=$( wget -qO- -t1 -T2 ipv6.icanhazip.com )
|
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 )
|
||||||
|
|
||||||
clear
|
clear
|
||||||
next
|
next
|
||||||
echo "CPU model : $cname"
|
echo "CPU model : $cname"
|
||||||
echo "Number of cores : $cores"
|
echo "Number of cores : $cores"
|
||||||
echo "CPU frequency : $freq MHz"
|
echo "CPU frequency : $freq MHz"
|
||||||
echo "Total amount of ram : $tram MB"
|
echo "Total size of Disk : $disk_total_size GB"
|
||||||
echo "Total amount of swap : $swap MB"
|
echo "Used size of Disk : $disk_used_size GB"
|
||||||
|
echo "Avail size of Disk : $disk_avail_size GB"
|
||||||
|
echo "Total amount of Mem : $tram MB"
|
||||||
|
echo "Total amount of Swap : $swap MB"
|
||||||
echo "System uptime : $up"
|
echo "System uptime : $up"
|
||||||
echo "Load average : $load"
|
echo "Load average : $load"
|
||||||
echo "OS : $opsy"
|
echo "OS : $opsy"
|
||||||
@ -114,10 +139,6 @@ if [ -e '/usr/bin/wget' ]; then
|
|||||||
echo -e "Node Name\t\t\tIPv6 address\t\tDownload Speed"
|
echo -e "Node Name\t\t\tIPv6 address\t\tDownload Speed"
|
||||||
speed_v6 && next
|
speed_v6 && next
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "Error: wget command not found. You must be install wget command at first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
io1=$( io_test )
|
io1=$( io_test )
|
||||||
echo "I/O speed(1st run) : $io1"
|
echo "I/O speed(1st run) : $io1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user