-
Notifications
You must be signed in to change notification settings - Fork 0
/
disk_wearout
33 lines (23 loc) · 1.1 KB
/
disk_wearout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# check the wearout of Crucial SSDs
echo '<<<disk_wearout:sep(59)>>>'
# for every mounted SDD
for D in /dev/sd?; do
smartres=$(smartctl -a "$D")
# check if the "percent_lifetime_remain" option exists in the smartctl output
line=$(grep "Percent_Lifetime_Remain" <<< "$smartres")
if ! test -z "$line"; then
# get wearout %
wearout=$(grep "Percent_Lifetime_Remain" <<< "$smartres" | awk '{print $10}')
# get device model
model=$(grep "Device Model:" <<< "$smartres" | awk '{print $3}')
# get serial number
serial=$(grep "Serial Number:" <<< "$smartres" | awk '{print $3}')
# get unused reserved block count
unused=$(grep "Unused_Reserve_NAND_Blk" <<< "$smartres" | awk '{print $10}')
# get RAIN successful recovery page count
rain=$(grep "Success_RAIN_Recov_Cnt" <<< "$smartres" | awk '{print $10}')
fi
# send the raw data to checkmk
echo "$D;$model;$serial;$wearout;$unused;$rain"
done