-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport-zfs-status.sh
More file actions
executable file
·70 lines (61 loc) · 1.85 KB
/
report-zfs-status.sh
File metadata and controls
executable file
·70 lines (61 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -e
LIST_ALL_SNAPSHOTS=false
print_core_status() {
zpool status -v &&
echo "----------------------" &&
zpool list -v &&
echo "----------------------" &&
zfs list
}
print_drive_temps() {
echo "----------------------"
echo "Drive temperatures (in Celsius):"
echo "/dev/sdb: $(sudo smartctl -A /dev/sdb | grep "Temperature_Celsius" | awk '{print $4}' | sed 's/^0*//')"
echo "/dev/sdc: $(sudo smartctl -A /dev/sdc | grep "Temperature_Celsius" | awk '{print $4}' | sed 's/^0*//')"
echo "/dev/sdd: $(sudo smartctl -A /dev/sdd | grep "Temperature_Celsius" | awk '{print $4}' | sed 's/^0*//')"
echo "/dev/sde: $(sudo smartctl -A /dev/sde | grep "Temperature_Celsius" | awk '{print $4}' | sed 's/^0*//')"
echo "/dev/sdf: $(sudo smartctl -A /dev/sdf | grep "Temperature_Celsius" | awk '{print $4}' | sed 's/^0*//')"
}
print_snapshot_status() {
echo "----------------------"
if [ "$LIST_ALL_SNAPSHOTS" = true ]; then
zfs list -t snapshot
else
zfs list -t snapshot -o name |
tail -n+2 |
cut -d '@' -f 2 |
sort |
uniq |
while read -r snapshot; do
echo "@$snapshot"
done
fi
}
print_usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --snapshots List all snapshots instead of a summary"
echo " -h, --help Display this help message and exit"
}
for arg in "$@"; do
case "$arg" in
--snapshots)
LIST_ALL_SNAPSHOTS=true
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "Unknown option: $arg" >&2
print_usage >&2
exit 1
;;
esac
done
if [ "$LIST_ALL_SNAPSHOTS" = false ]; then
print_core_status
print_drive_temps
fi
print_snapshot_status