#!/bin/bash set -Eeuo pipefail if [ "$EUID" != "0" ]; then echo "This script must be run as root!" exit 1 fi declare -r ZFS_POOL_NAME=test declare -r -a ZFS_DEVICES=( "/dev/disk/by-id/nvme-SAMSUNG_MZPLJ6T4HALA-00007_S55KNG0R100367" "/dev/disk/by-id/nvme-SAMSUNG_MZPLJ6T4HALA-00AMV_S5XENE0N808577" "/dev/disk/by-id/nvme-SAMSUNG_MZPLJ6T4HALA-00007_S55KNG0R100244" ) # Data gathered from /proc/stat. See proc(5) for the meaning of those variables. # From left to right: user nice system idle iowait irq softirq steal guest guest_nice declare -a last_cpu_stats=( 0 0 0 0 0 0 0 0 0 0 ) declare -a cpu_usage=( 0 0 0 0 0 0 0 0 0 0 ) function gather_cpu_usage () { local cpu_stats=( $(read head numbers < /proc/stat; echo "$numbers") ) local i for i in ${!cpu_usage[@]}; do cpu_usage[$i]=$((cpu_stats[$i] - last_cpu_stats[$i])) done last_cpu_stats=( ${cpu_stats[@]} ) } function destroy_zfs_pool () { echo "Destroying ZFS pool $ZFS_POOL_NAME..." zpool destroy -f "$ZFS_POOL_NAME" for device in "${ZFS_DEVICES[@]}"; do device="$(readlink -f "$device")" echo "Cleaning up device $device..." wipefs -af "${device}p1" wipefs -af "${device}p9" echo -e "g\nw\n" | fdisk "$device" done } destroy_zfs_pool #gather_cpu_usage #sleep 2 #gather_cpu_usage #echo "${cpu_usage[@]}"