add smartctl-test-disks
This commit is contained in:
parent
12928b3f3c
commit
1633bb7970
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 [short|long]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" != "short" ] && [ "$1" != "long" ]; then
|
||||
echo "Invalid argument: $1"
|
||||
echo "Usage: $0 [short|long]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the list of all physical disks
|
||||
declare -a disks
|
||||
for disk in $(lsblk -ido KNAME | grep -v -e loop -e KNAME); do
|
||||
disks+=("$disk")
|
||||
done
|
||||
|
||||
# Run a SMART test on all disks
|
||||
for disk in "${disks[@]}"; do
|
||||
echo "Running $1 test on /dev/$disk"
|
||||
if [ "$1" == "short" ]; then
|
||||
sudo smartctl -t short /dev/$disk > /dev/null
|
||||
elif [ "$1" == "long" ]; then
|
||||
sudo smartctl -t long /dev/$disk > /dev/null
|
||||
else
|
||||
echo "Invalid argument: $1"
|
||||
echo "Usage: $0 [short|long]"
|
||||
exit 1
|
||||
fi
|
||||
done
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Smartctl Run Short Test
|
||||
|
||||
[Service]
|
||||
User=nagios
|
||||
ExecStart=/opt/icinga2-checks/Other/smartctl-test-disks.sh long
|
||||
SyslogIdentifier=smartctl-test-disks
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Smartctl Run Short Test every week
|
||||
|
||||
[Timer]
|
||||
OnBootSec=monthly
|
||||
OnUnitActiveSec=monthly
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Smartctl Run Short Test
|
||||
|
||||
[Service]
|
||||
User=nagios
|
||||
ExecStart=/opt/icinga2-checks/Other/smartctl-test-disks.sh short
|
||||
SyslogIdentifier=smartctl-test-disks
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Smartctl Run Short Test every week
|
||||
|
||||
[Timer]
|
||||
OnBootSec=weekly
|
||||
OnUnitActiveSec=weekly
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in New Issue