Added Ceph RBD support and made not found message.

This commit is contained in:
2024-12-12 21:48:11 -05:00
parent 4f8c5f1bc9
commit d523cc5c5c

View File

@ -117,51 +117,61 @@ get_drive_info() {
fi fi
} }
# Show NVMe Drives with enhanced info # Initialize array for "not found" messages
not_found=()
# Show NVMe Drives only if present
nvme_drives=$(sudo nvme list | grep "^/dev")
if [ -n "$nvme_drives" ]; then
echo -e "\n=== NVMe Drives ===\n" echo -e "\n=== NVMe Drives ===\n"
printf "%-15s %-10s %-10s %-20s\n" "DEVICE" "SIZE" "TYPE" "MODEL" printf "%-15s %-10s %-10s %-20s\n" "DEVICE" "SIZE" "TYPE" "MODEL"
echo "------------------------------------------------------------" echo "------------------------------------------------------------"
nvme_drives=$(sudo nvme list | grep "^/dev")
if [ -n "$nvme_drives" ]; then
echo "$nvme_drives" | awk '{printf "%-15s %-10s %-10s %-20s\n", $1, $6, "NVMe", $3}' echo "$nvme_drives" | awk '{printf "%-15s %-10s %-10s %-20s\n", $1, $6, "NVMe", $3}'
else else
echo "No NVMe drives found" not_found+=("NVMe drives")
fi fi
# Show MMC Drives # Show MMC Drives only if present
mmc_output=$(lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | grep "mmcblk" | sort)
if [ -n "$mmc_output" ]; then
echo -e "\n=== MMC Drives ===\n" echo -e "\n=== MMC Drives ===\n"
printf "%-15s %-10s %-10s %-20s\n" "DEVICE" "SIZE" "TYPE" "MOUNTPOINT" printf "%-15s %-10s %-10s %-20s\n" "DEVICE" "SIZE" "TYPE" "MOUNTPOINT"
echo "------------------------------------------------------------" echo "------------------------------------------------------------"
mmc_output=$(lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | grep "mmcblk")
if [ -n "$mmc_output" ]; then
echo "$mmc_output" echo "$mmc_output"
else
echo "No MMC drives found"
fi fi
# Show SATA/Other Drives # Show SATA Drives only if present
echo -e "\n=== SATA/Block Drives ===\n" sata_output=$(lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | grep "disk" | grep -v "mmcblk" | grep -v "rbd" | sort)
if [ -n "$sata_output" ]; then
echo -e "\n=== SATA Drives ===\n"
printf "%-15s %-10s %-10s %-20s\n" "DEVICE" "SIZE" "TYPE" "MOUNTPOINT" printf "%-15s %-10s %-10s %-20s\n" "DEVICE" "SIZE" "TYPE" "MOUNTPOINT"
echo "------------------------------------------------------------" echo "------------------------------------------------------------"
sata_output=$(lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | grep "disk" | grep -v "mmcblk")
if [ -n "$sata_output" ]; then
echo "$sata_output" echo "$sata_output"
else
echo "No SATA drives found"
fi fi
# Add RAID Detection # Show Ceph RBD Devices only if present
echo -e "\n=== RAID Configuration ===" rbd_output=$(lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | grep "rbd" | sort -V)
if [ -f /proc/mdstat ]; then if [ -n "$rbd_output" ]; then
cat /proc/mdstat echo -e "\n=== Ceph RBD Devices ===\n"
printf "%-15s %-10s %-10s %-20s\n" "DEVICE" "SIZE" "TYPE" "MOUNTPOINT"
echo "------------------------------------------------------------"
echo "$rbd_output"
else else
echo "No software RAID detected" not_found+=("RBD devices")
fi fi
# Add ZFS Detection # Check RAID
echo -e "\n=== ZFS Pools ===" if ! [ -f /proc/mdstat ] || ! grep -q "active" /proc/mdstat; then
if command -v zpool >/dev/null 2>&1; then not_found+=("Software RAID")
sudo zpool status fi
else
echo "ZFS not installed" # Check ZFS
if ! command -v zpool >/dev/null 2>&1 || [ -z "$(sudo zpool status 2>/dev/null)" ]; then
not_found+=("ZFS pools")
fi
# Display consolidated "not found" messages at the end
if [ ${#not_found[@]} -gt 0 ]; then
echo -e "\n=== Not Found ===\n"
printf "%s\n" "${not_found[@]}"
fi fi