Created
January 6, 2024 07:07
-
-
Save x-magic/f0992bc69b738edd8320020a6cae4a81 to your computer and use it in GitHub Desktop.
Script to show SSD lifespan information on a UniFi Cloud Key Gen2 Plus (over SSH)
This file contains hidden or 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 | |
# Set up the target drive path and the number of LBA (I know this can be read from SMART...) | |
TARGETDRIVE="/dev/sda" | |
LBAS="7814037168" | |
# In case a different drive shall be selected | |
#read -rep $'Which drive to check? [/dev/sda]\n' USERTARGETDRIVE | |
#if [[ $USERTARGETDRIVE ]]; then | |
# TARGETDRIVE=$USERTARGETDRIVE | |
#fi | |
echo "" | |
echo "===== For $TARGETDRIVE:" | |
echo -n "Power-on hours: " | |
smartctl -A /dev/sda | awk '/^ 9/{printf $10}' | |
echo " ("$(smartctl -A /dev/sda | awk '/^ 12/{printf $10}')" power cycles)" | |
echo -n " Wear level: " | |
smartctl -A /dev/sda | awk '/^177/{perc=$4+0;printf perc}' | |
echo "% (average "$(smartctl -A /dev/sda | awk '/^177/{printf $10}')" cycles per block)" | |
echo -n " Total write: " | |
smartctl -A /dev/sda | awk '/^241/{printf $10*512/(1024*1024*1024*1024)}' | |
echo "TBW ($(smartctl -A /dev/sda | awk -vlbas=${LBAS} '/^241/{printf $10/lbas}') FDWs)" | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment