Compare commits

...

4 Commits

Author SHA1 Message Date
Adam Han
14867e7a78
Merge 092a53720959859b8f1a71913c0fb4f3d9c89cbb into 6711d6e2e93d89cb43d0eafb7813d91b1c2238c9 2024-04-17 17:16:48 +09:00
vvto33
6711d6e2e9
Update function check_virt (#121)
Adjusted to recognize 'KVM' when 'sys_manu' contains 'QEMU'.
(Detection was failing on BuyVM.net's KVM VPS)
2024-04-17 17:16:00 +09:00
Seamile
1050224c16
Fixed function io_test adapt to the Chinese environment (#124) 2024-04-17 17:14:22 +09:00
meliber
092a537209 bench.sh: minor fix, pass multiple arguments instead of one string to calc_sum 2023-11-11 23:07:24 -06:00

View File

@ -90,7 +90,7 @@ speed() {
} }
io_test() { io_test() {
(LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count="$1" conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' (LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count="$1" conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F '[,]' '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
} }
calc_size() { calc_size() {
@ -159,6 +159,8 @@ check_virt() {
virt="KVM" virt="KVM"
elif [[ "${sys_product}" == *KVM* ]]; then elif [[ "${sys_product}" == *KVM* ]]; then
virt="KVM" virt="KVM"
elif [[ "${sys_manu}" == *QEMU* ]]; then
virt="KVM"
elif [[ "${cname}" == *KVM* ]]; then elif [[ "${cname}" == *KVM* ]]; then
virt="KVM" virt="KVM"
elif [[ "${cname}" == *QEMU* ]]; then elif [[ "${cname}" == *QEMU* ]]; then
@ -308,14 +310,14 @@ get_system_info() {
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $2 }' df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $2 }'
) )
swap_total_size=$(free -k | grep Swap | awk '{print $2}') swap_total_size=$(free -k | grep Swap | awk '{print $2}')
zfs_total_size=$(to_kibyte "$(calc_sum "$(zpool list -o size -Hp 2> /dev/null)")") zfs_total_size=$(to_kibyte "$(calc_sum $(zpool list -o size -Hp 2> /dev/null))")
disk_total_size=$(calc_size $((swap_total_size + in_kernel_no_swap_total_size + zfs_total_size))) disk_total_size=$(calc_size $((swap_total_size + in_kernel_no_swap_total_size + zfs_total_size)))
in_kernel_no_swap_used_size=$( in_kernel_no_swap_used_size=$(
LANG=C LANG=C
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $3 }' df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $3 }'
) )
swap_used_size=$(free -k | grep Swap | awk '{print $3}') swap_used_size=$(free -k | grep Swap | awk '{print $3}')
zfs_used_size=$(to_kibyte "$(calc_sum "$(zpool list -o allocated -Hp 2> /dev/null)")") zfs_used_size=$(to_kibyte "$(calc_sum $(zpool list -o allocated -Hp 2> /dev/null))")
disk_used_size=$(calc_size $((swap_used_size + in_kernel_no_swap_used_size + zfs_used_size))) disk_used_size=$(calc_size $((swap_used_size + in_kernel_no_swap_used_size + zfs_used_size)))
tcpctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}') tcpctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}')
} }
@ -373,11 +375,11 @@ print_io_test() {
io3=$(io_test ${writemb}) io3=$(io_test ${writemb})
echo " I/O Speed(3rd run) : $(_yellow "$io3")" echo " I/O Speed(3rd run) : $(_yellow "$io3")"
ioraw1=$(echo "$io1" | awk 'NR==1 {print $1}') ioraw1=$(echo "$io1" | awk 'NR==1 {print $1}')
[ "$(echo "$io1" | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw1=$(awk 'BEGIN{print '"$ioraw1"' * 1024}') [[ "$(echo "$io1" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw1=$(awk 'BEGIN{print '"$ioraw1"' * 1024}')
ioraw2=$(echo "$io2" | awk 'NR==1 {print $1}') ioraw2=$(echo "$io2" | awk 'NR==1 {print $1}')
[ "$(echo "$io2" | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw2=$(awk 'BEGIN{print '"$ioraw2"' * 1024}') [[ "$(echo "$io2" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw2=$(awk 'BEGIN{print '"$ioraw2"' * 1024}')
ioraw3=$(echo "$io3" | awk 'NR==1 {print $1}') ioraw3=$(echo "$io3" | awk 'NR==1 {print $1}')
[ "$(echo "$io3" | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw3=$(awk 'BEGIN{print '"$ioraw3"' * 1024}') [[ "$(echo "$io3" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw3=$(awk 'BEGIN{print '"$ioraw3"' * 1024}')
ioall=$(awk 'BEGIN{print '"$ioraw1"' + '"$ioraw2"' + '"$ioraw3"'}') ioall=$(awk 'BEGIN{print '"$ioraw1"' + '"$ioraw2"' + '"$ioraw3"'}')
ioavg=$(awk 'BEGIN{printf "%.1f", '"$ioall"' / 3}') ioavg=$(awk 'BEGIN{printf "%.1f", '"$ioall"' / 3}')
echo " I/O Speed(average) : $(_yellow "$ioavg MB/s")" echo " I/O Speed(average) : $(_yellow "$ioavg MB/s")"