Compare commits

..

5 Commits

Author SHA1 Message Date
Mason Rowe
3474d82f83 shellcheck fix on line 804 (SC2086) 2026-07-03 22:05:37 -04:00
Michael Hohl
6ea1d66e0f Fix: iperf_test latency measurement ignores IPv4/IPv6 (#126)
`iperf_test` only calls `ping -c1 $URL` right now, not passing IPv4 or IPv6 parameters to ping. It thus doesn't differentiate between IPv4 and IPv6 latency at all.
2026-07-03 21:15:30 -04:00
Mason Rowe
3125fedff1 correction for fio's kilobyte vs kibibyte for disk speeds (#120) 2026-07-03 21:02:43 -04:00
Mason Rowe
97b5ec226f fix for bad uptime calculation (#92) 2026-05-19 21:55:39 -04:00
Mason Rowe
d79e781ca3 fix for zfs fs disk calculation (#118) 2026-05-19 21:50:33 -04:00

41
yabs.sh
View File

@@ -1,7 +1,7 @@
#!/bin/bash
# Yet Another Bench Script by Mason Rowe
# Initial Oct 2019; Last update May 2026
# Initial Oct 2019; Last update Jul 2026
# Disclaimer: This project is a work in progress. Any errors or suggestions should be
# relayed to me via the GitHub project page linked below.
@@ -12,7 +12,7 @@
# performance via fio. The script is designed to not require any dependencies
# - either compiled or installed - nor admin privileges to run.
YABS_VERSION="v2026-05-11"
YABS_VERSION="v2026-07-03"
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
echo -e '# Yet-Another-Bench-Script #'
@@ -235,7 +235,7 @@ function format_size {
echo -e
echo -e "Basic System Information:"
echo -e "---------------------------------"
UPTIME=$(uptime | awk -F'( |,|:)+' '{d=h=m=0; if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes"}')
UPTIME=$(uptime | awk -F'( |,|:)+' '{d=h=m=0; if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6; if ($9~/^min/) m=$8; else {h=$8;m=$9}} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes"}')
echo -e "Uptime : $UPTIME"
# check for local lscpu installs
if command -v lscpu >/dev/null 2>&1; then
@@ -383,16 +383,18 @@ function catch_abort() {
# format_speed
# Purpose: This method is a convenience function to format the output of the fio disk tests which
# always returns a result in KB/s. If result is >= 1 GB/s, use GB/s. If result is < 1 GB/s
# and >= 1 MB/s, then use MB/s. Otherwise, use KB/s.
# always returns a result in KiB/s (fio terse v3 bandwidth fields are always KiB/s regardless
# of --kb_base setting). Converts KiB/s to decimal units (KB/s, MB/s, GB/s) for display.
# Conversion: multiply KiB/s by 1024 to get bytes/s, then divide by 1000, 1000000, or
# 1000000000 to get KB/s, MB/s, or GB/s respectively.
# Thresholds (in KiB/s): >= 976563 -> GB/s, >= 977 -> MB/s, otherwise -> KB/s
# Parameters:
# 1. RAW - the raw disk speed result (in KB/s)
# 1. RAW - the raw disk speed result (in KiB/s)
# Returns:
# Formatted disk speed in GB/s, MB/s, or KB/s
function format_speed {
RAW=$1 # disk speed in KB/s
RAW=$1 # disk speed in KiB/s
RESULT=$RAW
local DENOM=1
local UNIT="KB/s"
# ensure raw value is not null, if it is, return blank
@@ -401,18 +403,19 @@ function format_speed {
return 0
fi
# check if disk speed >= 1 GB/s
if [ "$RAW" -ge 1000000 ]; then
DENOM=1000000
# check if disk speed >= 1 GB/s (976563 KiB/s = 1,000,000,000 bytes/s)
if [ "$RAW" -ge 976563 ]; then
UNIT="GB/s"
# check if disk speed < 1 GB/s && >= 1 MB/s
elif [ "$RAW" -ge 1000 ]; then
DENOM=1000
RESULT=$(awk -v a="$RAW" 'BEGIN { print a * 1024 / 1000000000 }')
# check if disk speed >= 1 MB/s (977 KiB/s ~ 1,000,000 bytes/s)
elif [ "$RAW" -ge 977 ]; then
UNIT="MB/s"
RESULT=$(awk -v a="$RAW" 'BEGIN { print a * 1024 / 1000000 }')
else
# convert KiB/s to KB/s (multiply by 1.024)
RESULT=$(awk -v a="$RAW" 'BEGIN { print a * 1024 / 1000 }')
fi
# divide the raw result to get the corresponding formatted result (based on determined unit)
RESULT=$(awk -v a="$RESULT" -v b="$DENOM" 'BEGIN { print a / b }')
# shorten the formatted result to two decimal places (i.e. x.xx)
RESULT=$(echo "$RESULT" | awk -F. '{ printf "%0.2f",$1"."substr($2,1,2) }')
# concat formatted result value with units and return result
@@ -569,9 +572,9 @@ elif [ -z "$SKIP_FIO" ]; then
# Proceed only if a relevant ZFS path was found
if [[ -n "$long" ]]; then
# Get the 'Avail' space directly for the detected path and explicitly for ZFS type
# The 'Avail' column is the 4th field in `df -Th` output
# The 'Avail' column is the 5th field in `df -Th` output (-T adds a Type column, shifting fields right)
# Example: '7.3T', '104G', '17G'
avail_space_with_unit=$(df -Th | grep -w "$long" | awk '$2 == "zfs" {print $4; exit}')
avail_space_with_unit=$(df -Th | grep -w "$long" | awk '$2 == "zfs" {print $5; exit}')
# If a valid free space value was extracted
if [[ -n "$avail_space_with_unit" ]]; then
@@ -798,7 +801,7 @@ function iperf_test {
done
# Run a latency test via ping -c1 command -> will return "xx.x ms"
[[ -n $LOCAL_PING ]] && LATENCY_RUN="$(ping -c1 "$URL" 2>/dev/null | grep -o 'time=.*' | sed s/'time='//)"
[[ -n $LOCAL_PING ]] && LATENCY_RUN="$(ping "$FLAGS" -c1 "$URL" 2>/dev/null | grep -o 'time=.*' | sed 's/time=//')"
[[ -z $LATENCY_RUN ]] && LATENCY_RUN="--"
# parse the resulting send and receive speed results