Created
April 27, 2024 23:26
-
-
Save siagimir/b82b4ccf38a7b0560cbffb88e3002357 to your computer and use it in GitHub Desktop.
Basic ZFS check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This bash script does a basic information dump about the current ZFS setup. | |
# The output is also written into a log file in the subfolder ./logs. | |
# Define color variables | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
# Define the log file directory and file | |
LOG_DIR="./logs" | |
LOG_FILE="$LOG_DIR/$(date +'%Y-%m-%d_%H-%M-%S').log" | |
# Ensure log directory exists | |
mkdir -p $LOG_DIR | |
# Function to print section headers | |
print_header() { | |
echo -e "${GREEN}$1${NC}" | |
} | |
# Clear the screen for a clean display | |
clear | |
{ | |
print_header "### ZPOOL STATUS ###" | |
sudo zpool status || { echo "${RED}Failed to get zpool status${NC}"; exit 1; } | |
echo "" | |
print_header "### ZFS DATASETS LIST ###" | |
zfs list || { echo "${RED}Failed to list ZFS datasets${NC}"; exit 1; } | |
# Dynamically find all datasets | |
zfs_datasets=$(zfs list -H -o name) | |
echo "" | |
for dataset in $zfs_datasets; do | |
print_header "### SPACE & COMPRESSION for $dataset ###" | |
zfs list -o space $dataset | |
zfs get compression,compressratio $dataset | |
echo "" | |
done | |
print_header "### ARC STATISTICS ###" | |
python3 -W ignore /usr/sbin/arcstat 1 5 || { echo "${RED}ARC stats not available${NC}"; } | |
echo "" | |
print_header "### ZPOOL IOSTAT (7 seconds) ###" | |
timeout 7 zpool iostat -v 2 -l || true | |
} | tee "$LOG_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment