Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6e068fa68 | ||
|
|
63f93b092e | ||
|
|
9b7c4c6499 | ||
|
|
9b30296f44 |
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=S.M.A.R.T Monitor script
|
||||||
|
Wants=smartmonitor.timer
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/bin/bash /root/smart-check.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=S.M.A.R.T script timer
|
||||||
|
Requires=smartmonitor.service
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=15min
|
||||||
|
OnUnitActiveSec=24h
|
||||||
|
Unit=smartmonitor.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Loading…
Reference in New Issue