aboutsummaryrefslogtreecommitdiff
path: root/text_collector_examples
diff options
context:
space:
mode:
authorWilliam Cooley <wcooley@textwise.com>2017-04-05 10:51:58 -0400
committerWilliam Cooley <wcooley@textwise.com>2017-04-05 10:51:58 -0400
commit977aa94bd3fdff249f0b584b2daa747df2377405 (patch)
treed2997382d6080def6d762798c8434aaf47e92ff9 /text_collector_examples
parent41a44a4d24a8115e47d7b339440bd598445be348 (diff)
downloadprometheus_node_collector-977aa94bd3fdff249f0b584b2daa747df2377405.tar.bz2
prometheus_node_collector-977aa94bd3fdff249f0b584b2daa747df2377405.tar.xz
prometheus_node_collector-977aa94bd3fdff249f0b584b2daa747df2377405.zip
Added metric for overall health status check to smartmon.sh example script
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-xtext_collector_examples/smartmon.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/text_collector_examples/smartmon.sh b/text_collector_examples/smartmon.sh
index ed50c87..cd121b8 100755
--- a/text_collector_examples/smartmon.sh
+++ b/text_collector_examples/smartmon.sh
@@ -70,7 +70,7 @@ parse_smartctl_attributes() {
70} 70}
71 71
72parse_smartctl_info() { 72parse_smartctl_info() {
73 local -i smart_available=0 smart_enabled=0 73 local -i smart_available=0 smart_enabled=0 smart_healthy=0
74 local disk="$1" disk_type="$2" 74 local disk="$1" disk_type="$2"
75 while read line ; do 75 while read line ; do
76 info_type="$(echo "${line}" | cut -f1 -d: | tr ' ' '_')" 76 info_type="$(echo "${line}" | cut -f1 -d: | tr ' ' '_')"
@@ -92,6 +92,15 @@ parse_smartctl_info() {
92 Unavail) smart_available=0 ;; 92 Unavail) smart_available=0 ;;
93 esac 93 esac
94 fi 94 fi
95 if [[ "${info_type}" == 'SMART_overall-health_self-assessment_test_result' ]] ; then
96 case "${info_value:0:6}" in
97 PASSED) smart_healthy=1 ;;
98 esac
99 elif [[ "${info_type}" == 'SMART_Health_Status' ]] ; then
100 case "${info_value:0:2}" in
101 OK) smart_healthy=1 ;;
102 esac
103 fi
95 done 104 done
96 if [[ -n "${model_family}" ]] ; then 105 if [[ -n "${model_family}" ]] ; then
97 echo "device_info{disk=\"${disk}\",type=\"${disk_type}\",model_family=\"${model_family}\",device_model=\"${device_model}\",serial_number=\"${serial_number}\",firmware_version=\"${fw_version}\"} 1" 106 echo "device_info{disk=\"${disk}\",type=\"${disk_type}\",model_family=\"${model_family}\",device_model=\"${device_model}\",serial_number=\"${serial_number}\",firmware_version=\"${fw_version}\"} 1"
@@ -100,6 +109,7 @@ parse_smartctl_info() {
100 fi 109 fi
101 echo "device_smart_available{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_available}" 110 echo "device_smart_available{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_available}"
102 echo "device_smart_enabled{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_enabled}" 111 echo "device_smart_enabled{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_enabled}"
112 echo "device_smart_healthy{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_healthy}"
103} 113}
104 114
105output_format_awk="$(cat << 'OUTPUTAWK' 115output_format_awk="$(cat << 'OUTPUTAWK'
@@ -132,8 +142,8 @@ for device in ${device_list}; do
132 disk="$(echo ${device} | cut -f1 -d'|')" 142 disk="$(echo ${device} | cut -f1 -d'|')"
133 type="$(echo ${device} | cut -f2 -d'|')" 143 type="$(echo ${device} | cut -f2 -d'|')"
134 echo "smartctl_run{disk=\"${disk}\",type=\"${type}\"}" $(TZ=UTC date '+%s') 144 echo "smartctl_run{disk=\"${disk}\",type=\"${type}\"}" $(TZ=UTC date '+%s')
135 # Get the SMART information 145 # Get the SMART information and health
136 /usr/sbin/smartctl -i -d "${type}" "${disk}" | parse_smartctl_info "${disk}" "${type}" 146 /usr/sbin/smartctl -i -H -d "${type}" "${disk}" | parse_smartctl_info "${disk}" "${type}"
137 # Get the SMART attributes 147 # Get the SMART attributes
138 /usr/sbin/smartctl -A -d "${type}" "${disk}" | parse_smartctl_attributes "${disk}" "${type}" 148 /usr/sbin/smartctl -A -d "${type}" "${disk}" | parse_smartctl_attributes "${disk}" "${type}"
139done | format_output 149done | format_output \ No newline at end of file