working smartmon node exporter script for sd/nvme
This commit is contained in:
1 parent
01ab319eea
commit
044fbd81ad
1 file changed
+19
-10
@@ -6,17 +6,26 @@ OUT="/docker/monitoring/node_exporter/textfile_collector/smart_selftest.prom"
|
|||||||
|
|
||||||
for dev in $(smartctl --scan-open | awk '{print $1}'); do
|
for dev in $(smartctl --scan-open | awk '{print $1}'); do
|
||||||
name=$(basename "$dev")
|
name=$(basename "$dev")
|
||||||
LAST=$(smartctl -l selftest "$dev" 2>/dev/null \
|
LAST=0
|
||||||
| grep "Completed" \
|
if [[ "$dev" == *nvme* ]]; then
|
||||||
| head -1 \
|
# POWER_ON=$(smartctl -a "$dev" | awk -F': *' '/Power On Hours:/ {print $2}')
|
||||||
| awk '{print $(NF-1)}')
|
LAST=$(smartctl -l selftest "$dev" 2>/dev/null \
|
||||||
|
| grep "Completed" \
|
||||||
|
| head -1 \
|
||||||
|
| awk '{print $(NF-5)}')
|
||||||
|
elif [[ "$dev" == *sd* ]]; then
|
||||||
|
# POWER_ON=$(smartctl -a "$dev" | awk '/Power_On_Hours/ {print $10}')
|
||||||
|
LAST=$(smartctl -l selftest "$dev" 2>/dev/null \
|
||||||
|
| grep "Completed" \
|
||||||
|
| head -1 \
|
||||||
|
| awk '{print $(NF-1)}')
|
||||||
|
else
|
||||||
|
POWER_ON=99999999999
|
||||||
|
echo $dev
|
||||||
|
fi
|
||||||
|
|
||||||
# Skip devices without self-test history
|
# Skip devices without self-test history
|
||||||
if [[ "${LAST}" == "-" ]]; then
|
echo $name: ${LAST}
|
||||||
HOURS=$(smartctl -a "$DEV" 2>/dev/null | awk '/Power_On_Hours/ {print $10}')
|
|
||||||
LAST=${HOURS:- -1}
|
|
||||||
fi
|
|
||||||
echo $name: $LAST
|
|
||||||
echo "smart_last_selftest_poweron_hours{device=\"$name\"} $LAST" >> "$OUT"
|
echo "smart_last_selftest_poweron_hours{device=\"$name\"} $LAST" >> "$OUT"
|
||||||
|
|
||||||
done
|
done
|
||||||
Reference in new issue
Block a user