Last active
October 14, 2023 15:23
-
-
Save jkwmoore/3a01ec705c5b07936f83d5b13373f32f to your computer and use it in GitHub Desktop.
The script serves as a simple way to verify the ZED (ZFS Event Daemon) email notification system by simulating a scrub operation.
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 script creates a sparse ZFS filesystem with a random pool name, scrubs it, and removes it to test ZED email notifications. | |
# Generate a random pool name | |
pool_name="test_$(date +%s | sha256sum | base64 | head -c 10)" | |
# Generate a random filename for the sparse file | |
sparse_file_path="/tmp/sparse_file_$(date +%s | sha256sum | base64 | head -c 10)" | |
# Create a sparse file with a size of 512MB | |
dd if=/dev/zero of="$sparse_file_path" bs=1 count=0 seek=512M | |
# Create a ZFS pool with the generated pool name using the generated sparse file as the storage device | |
zpool create "$pool_name" "$sparse_file_path" | |
# Initiate a ZFS scrub on the created pool. | |
# After the scrub is completed, ZED (ZFS Event Daemon) will send an email notification. | |
zpool scrub "$pool_name" | |
sleep 2 | |
# Export (unmount) the created ZFS pool, making it no longer available | |
zpool export "$pool_name" | |
# Remove the generated sparse file to clean up | |
rm "$sparse_file_path" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment