Add smart-script.sh
This commit is contained in:
parent
f2638bcccd
commit
9b30296f44
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
date=$(date -u +%Y-%m-%d--%H:%M)
|
||||
|
||||
if sudo true
|
||||
then
|
||||
true
|
||||
else
|
||||
echo 'Root privileges required'
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for drive in /dev/sd[a-z] /dev/sd[a-z][a-z] /dev/nvme[0-9]n[0-9]
|
||||
do
|
||||
if [[ ! -e $drive ]]; then continue ; fi
|
||||
|
||||
echo -n "$drive "
|
||||
echo -e "\n"
|
||||
|
||||
smart=$(
|
||||
sudo smartctl -i $drive |grep Serial
|
||||
sudo smartctl -A $drive |grep -E "^ "9"" |awk -F" " '{ print $2,$10 }'
|
||||
sudo smartctl -A $drive |grep -E "^ "5"" |awk -F" " '{ print $2,$10 }'
|
||||
sudo smartctl -A $drive |grep -E "Current_Pending_Sector" |awk -F" " '{ print $2,$10 }'
|
||||
sudo smartctl -A $drive |grep -E "Offline_Uncorrectable" |awk -F" " '{ print $2,$10 }'
|
||||
)
|
||||
|
||||
echo -e "$smart\n" >> /var/log/smart-check/smart-check$date.log
|
||||
|
||||
|
||||
done
|
||||
tmonitor.timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash /root/smart-check.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Reference in New Issue