]> git.somenet.org - root/pub/somesible.git/blob - roles/base/munin-node/files/default/plugins.somesible/smart_rw
[roles/base/munin-node] munin node + async proxy setup
[root/pub/somesible.git] / roles / base / munin-node / files / default / plugins.somesible / smart_rw
1 #!/bin/bash
2 ################################################
3 ### Managed by someone's ansible provisioner ###
4 ################################################
5 # Part of: https://git.somenet.org/root/pub/somesible.git
6 # 2017-2024 by someone <someone@somenet.org>
7 #
8
9
10 if [ "$1" = "autoconf" ]; then
11     echo "yes"
12     exit 0
13 fi
14
15
16 if [ "$1" = "config" ]; then
17     echo "graph_title Lifetime bytes read and written"
18     echo "graph_info This graph shows the bytes read and written per disk as reported by SMART"
19     echo "graph_category disk"
20     echo "graph_vlabel Lifetime bytes read (-) / written (+)"
21     cd /sys/block/
22     for f in *; do
23         HD_NAME=$(lsblk -S "/dev/$f" -o MODEL,SERIAL | tail -q -n-1 | sed -Ee 's#-#_#g' -e's# #-#g')
24         if [ "-${HD_NAME}-" != "--" ]; then
25             echo "${HD_NAME}_r.draw LINE2"
26             echo "${HD_NAME}_r.min 0"
27             echo "${HD_NAME}_r.label ${HD_NAME} not displayed"
28             echo "${HD_NAME}_r.graph no"
29             echo "${HD_NAME}_w.draw LINE2"
30             echo "${HD_NAME}_w.min 0"
31             echo "${HD_NAME}_w.label /dev/${f}"
32             echo "${HD_NAME}_w.negative ${HD_NAME}_r"
33         fi
34     done
35 #    echo "graph_printf %.0lf"
36 #    echo "graph_scale no"
37     echo "graph_args -l 0"
38     exit 0
39 fi
40
41
42 cd /sys/block/
43 for f in *; do
44     HD_NAME=$(lsblk -S "/dev/$f" -o MODEL,SERIAL | tail -q -n-1 | sed -Ee 's#-#_#g' -e's# #-#g')
45     if [ "-${HD_NAME}-" != "--" ]; then
46         echo "${HD_NAME}_w.value $(tail -q -n-1 "/var/lib/smartmontools/attrlog.${HD_NAME}.ata.csv" 2>/dev/null | sed -Ee 's/^.*\t241;[0-9]+;([0-9]+);.*$/\1*512/' | bc)"
47         echo "${HD_NAME}_r.value $(tail -q -n-1 "/var/lib/smartmontools/attrlog.${HD_NAME}.ata.csv" 2>/dev/null | sed -Ee 's/^.*\t242;[0-9]+;([0-9]+);.*$/\1*512/' | bc)"
48     fi
49 done
50 exit 0