aboutsummaryrefslogtreecommitdiff
path: root/text_collector_examples
diff options
context:
space:
mode:
authorBen Kochie <superq@gmail.com>2018-01-22 16:51:20 +0100
committerGitHub <noreply@github.com>2018-01-22 16:51:20 +0100
commit1ad5ba4dc7e188329b77bc48a28fbd89bc2aae38 (patch)
tree333056cb73b3996b1324e87a7b83e4a35387b905 /text_collector_examples
parent6cac74f0e0462aa8a4bbba9f6758b7bbb80774be (diff)
downloadprometheus_node_collector-1ad5ba4dc7e188329b77bc48a28fbd89bc2aae38.tar.bz2
prometheus_node_collector-1ad5ba4dc7e188329b77bc48a28fbd89bc2aae38.tar.xz
prometheus_node_collector-1ad5ba4dc7e188329b77bc48a28fbd89bc2aae38.zip
Fix smartmon.sh bugs (#792)
* Fix smartmon.sh info label consistency. * Fix parsing of SMART-ID attributes <= 99.
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-xtext_collector_examples/smartmon.sh9
1 files changed, 3 insertions, 6 deletions
diff --git a/text_collector_examples/smartmon.sh b/text_collector_examples/smartmon.sh
index ad133bf..ad6182e 100755
--- a/text_collector_examples/smartmon.sh
+++ b/text_collector_examples/smartmon.sh
@@ -8,7 +8,7 @@
8# http://arstechnica.com/civis/viewtopic.php?p=22062211 8# http://arstechnica.com/civis/viewtopic.php?p=22062211
9 9
10parse_smartctl_attributes_awk="$(cat << 'SMARTCTLAWK' 10parse_smartctl_attributes_awk="$(cat << 'SMARTCTLAWK'
11$1 ~ /^[0-9]+$/ && $2 ~ /^[a-zA-Z0-9_-]+$/ { 11$1 ~ /^ *[0-9]+$/ && $2 ~ /^[a-zA-Z0-9_-]+$/ {
12 gsub(/-/, "_"); 12 gsub(/-/, "_");
13 printf "%s_value{%s,smart_id=\"%s\"} %d\n", $2, labels, $1, $4 13 printf "%s_value{%s,smart_id=\"%s\"} %d\n", $2, labels, $1, $4
14 printf "%s_worst{%s,smart_id=\"%s\"} %d\n", $2, labels, $1, $5 14 printf "%s_worst{%s,smart_id=\"%s\"} %d\n", $2, labels, $1, $5
@@ -71,6 +71,7 @@ parse_smartctl_attributes() {
71parse_smartctl_info() { 71parse_smartctl_info() {
72 local -i smart_available=0 smart_enabled=0 smart_healthy=0 72 local -i smart_available=0 smart_enabled=0 smart_healthy=0
73 local disk="$1" disk_type="$2" 73 local disk="$1" disk_type="$2"
74 local model_family='' device_model='' serial_number='' fw_version='' vendor='' product='' revision='' lun_id=''
74 while read line ; do 75 while read line ; do
75 info_type="$(echo "${line}" | cut -f1 -d: | tr ' ' '_')" 76 info_type="$(echo "${line}" | cut -f1 -d: | tr ' ' '_')"
76 info_value="$(echo "${line}" | cut -f2- -d: | sed 's/^ \+//g')" 77 info_value="$(echo "${line}" | cut -f2- -d: | sed 's/^ \+//g')"
@@ -101,11 +102,7 @@ parse_smartctl_info() {
101 esac 102 esac
102 fi 103 fi
103 done 104 done
104 if [[ -n "${vendor}" ]] ; then 105 echo "device_info{disk=\"${disk}\",type=\"${disk_type}\",vendor=\"${vendor}\",product=\"${product}\",revision=\"${revision}\",lun_id=\"${lun_id}\",model_family=\"${model_family}\",device_model=\"${device_model}\",serial_number=\"${serial_number}\",firmware_version=\"${fw_version}\"} 1"
105 echo "device_info{disk=\"${disk}\",type=\"${disk_type}\",vendor=\"${vendor}\",product=\"${product}\",revision=\"${revision}\",lun_id=\"${lun_id}\"} 1"
106 else
107 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"
108 fi
109 echo "device_smart_available{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_available}" 106 echo "device_smart_available{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_available}"
110 echo "device_smart_enabled{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_enabled}" 107 echo "device_smart_enabled{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_enabled}"
111 echo "device_smart_healthy{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_healthy}" 108 echo "device_smart_healthy{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_healthy}"