Skip to content

Commit b12011d

Browse files
Added preconfig drive metric gathering script (not production ready yet) and fixed minor bug in healthcheck script.
1 parent 5b6d63e commit b12011d

2 files changed

Lines changed: 162 additions & 2 deletions

File tree

health-check.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ collect_from_all_hosts "ip route show default" "default_route"
176176
collect_from_all_hosts "cat /etc/os-release" "linux_distribution"
177177
collect_from_all_hosts "last reboot" "reboot_history"
178178
collect_from_all_hosts "systemctl status winbind" "winbind_status"
179-
collect_from_all_hosts "apt list --upgradable" "updates"
180-
179+
if [[ -f /etc/debian_version ]]; then
180+
collect_from_all_hosts "apt list --upgradable" "updates"
181+
fi
181182
ceph -s > "$out_dir/ceph_status.txt" 2>/dev/null
182183

183184
collect_from_all_hosts '
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/usr/bin/env bash
2+
3+
########## THIS IS A WORK IN PROGRESS; NOT READY FOR PRODUCTION YET. DON'T USE ON CUSTOMER SYSTEMS YET ##########
4+
# Curtis LeBlanc
5+
# Date created: 17 November 2025
6+
# 45Drives
7+
# Rev 0.1.0
8+
# This script uses fio to gather performance metrics on empty drives. Currently, it checks random read, sequential read, and sequential write performance.
9+
# Intended for checking drives before configuration to verify they're operating at expected parameters.
10+
11+
OUTPUT_DIR="/var/log/storage_bench"
12+
JSON_OUTPUT="$OUTPUT_DIR/results.json"
13+
14+
mkdir -p "$OUTPUT_DIR"
15+
16+
###############################################
17+
# Determine all devices used by the boot/root
18+
###############################################
19+
get_boot_disks() {
20+
(
21+
# Direct mountpoints (/, /boot, /boot/efi)
22+
lsblk -no PKNAME "$(findmnt -no SOURCE / 2>/dev/null)" 2>/dev/null
23+
lsblk -no PKNAME "$(findmnt -no SOURCE /boot 2>/dev/null)" 2>/dev/null
24+
lsblk -no PKNAME "$(findmnt -no SOURCE /boot/efi 2>/dev/null)" 2>/dev/null
25+
26+
# If PKNAME empty, fall back to base device
27+
lsblk -no NAME "$(findmnt -no SOURCE / 2>/dev/null)" 2>/dev/null
28+
lsblk -no NAME "$(findmnt -no SOURCE /boot 2>/dev/null)" 2>/dev/null
29+
lsblk -no NAME "$(findmnt -no SOURCE /boot/efi 2>/dev/null)" 2>/dev/null
30+
31+
# If LVM is used for root, include PVs
32+
pvs --no-headings -o pv_name 2>/dev/null | sed 's/[0-9]*$//' | sed 's|/dev/||'
33+
34+
) | sed 's/^\s*//;s/\s*$//' | sort -u | grep -v '^$'
35+
}
36+
37+
BOOT_DISKS=$(get_boot_disks)
38+
39+
###############################################
40+
# Detect non-boot block devices
41+
###############################################
42+
get_devices() {
43+
lsblk -dn -o NAME,TYPE | while read -r name type; do
44+
[[ "$type" != "disk" ]] && continue
45+
46+
# Skip boot disks
47+
if echo "$BOOT_DISKS" | grep -qw "$name"; then
48+
continue
49+
fi
50+
51+
echo "/dev/$name"
52+
done
53+
}
54+
55+
###############################################
56+
# FIO test (read-only)
57+
###############################################
58+
run_fio_test() {
59+
local dev="$1"
60+
local log="$2"
61+
62+
echo "Running fio benchmark on $dev" | tee -a "$log"
63+
64+
fio --name=randread \
65+
--filename="$dev" \
66+
--direct=1 \
67+
--rw=randread \
68+
--bs=4k \
69+
--iodepth=32 \
70+
--numjobs=1 \
71+
--size=4G \
72+
--runtime=20 \
73+
--time_based \
74+
--ioengine=libaio \
75+
--group_reporting >> "$log" 2>&1
76+
}
77+
78+
###############################################
79+
# Parse FIO result
80+
###############################################
81+
append_json() {
82+
local dev="$1"
83+
local log="$2"
84+
85+
local iops=$(grep -m1 "IOPS=" "$log" | sed 's/.*IOPS=\([0-9\.kK]\+\).*/\1/')
86+
local bw=$(grep -m1 "BW=" "$log" | sed 's/.*BW=\([0-9A-Za-z\/]\+\).*/\1/')
87+
88+
jq -n \
89+
--arg dev "$dev" \
90+
--arg iops "$iops" \
91+
--arg bw "$bw" \
92+
'{
93+
device: $dev,
94+
benchmark: {
95+
read_iops: $iops,
96+
read_bandwidth: $bw
97+
}
98+
}'
99+
}
100+
101+
###############################################
102+
# MAIN
103+
###############################################
104+
echo "[" > "$JSON_OUTPUT"
105+
FIRST=1
106+
107+
echo "Boot devices detected and skipped:"
108+
echo "$BOOT_DISKS" | sed 's/^/ - /'
109+
110+
for dev in $(get_devices); do
111+
log="$OUTPUT_DIR/$(basename $dev).log"
112+
113+
echo "===============================================" | tee "$log"
114+
echo "Benchmarking raw device: $dev" | tee -a "$log"
115+
echo "Log: $log" | tee -a "$log"
116+
echo "===============================================" | tee -a "$log"
117+
118+
run_fio_test "$dev" "$log"
119+
120+
###############################################
121+
# Sequential READ
122+
###############################################
123+
echo "Running sequential READ benchmark on $dev" | tee -a "$log"
124+
fio --name=seqread \
125+
--filename="$dev" \
126+
--rw=read \
127+
--bs=128k \
128+
--iodepth=32 \
129+
--ioengine=libaio \
130+
--numjobs=1 \
131+
--direct=1 \
132+
--runtime=20 \
133+
--time_based=1 >> "$log" 2>&1
134+
135+
###############################################
136+
# Sequential WRITE
137+
###############################################
138+
echo "Running sequential WRITE benchmark on $dev" | tee -a "$log"
139+
fio --name=seqwrite \
140+
--filename="$dev" \
141+
--rw=write \
142+
--bs=128k \
143+
--iodepth=32 \
144+
--ioengine=libaio \
145+
--numjobs=1 \
146+
--direct=1 \
147+
--runtime=20 \
148+
--time_based=1 >> "$log" 2>&1
149+
150+
if [[ $FIRST -eq 0 ]]; then echo "," >> "$JSON_OUTPUT"; fi
151+
FIRST=0
152+
153+
append_json "$dev" "$log" >> "$JSON_OUTPUT"
154+
done
155+
156+
echo "]" >> "$JSON_OUTPUT"
157+
158+
echo "All tests complete."
159+
echo "JSON written to: $JSON_OUTPUT"

0 commit comments

Comments
 (0)