aboutsummaryrefslogtreecommitdiff
path: root/text_collector_examples
diff options
context:
space:
mode:
authorMatt Bostock <matt@mattbostock.com>2017-08-31 17:00:42 +0100
committerBen Kochie <superq@gmail.com>2017-08-31 18:00:42 +0200
commit89a2f21f45fbfac3dd329afb4b515b4d923fa778 (patch)
treeb6eaef53a93f40f7d2296540e3bf528c1f34a84c /text_collector_examples
parentf9a2388c6059341ef391199fec567fc40179e6ff (diff)
downloadprometheus_node_collector-89a2f21f45fbfac3dd329afb4b515b4d923fa778.tar.bz2
prometheus_node_collector-89a2f21f45fbfac3dd329afb4b515b4d923fa778.tar.xz
prometheus_node_collector-89a2f21f45fbfac3dd329afb4b515b4d923fa778.zip
Always try to return smartmon_device_info metric (#663)
* Always try to return smartmon_device_info metric Sometimes the 'model family' field is not returned by `smartctl' because a disk is not in the disk database for the version of smartmontools installed on the system. In those cases, the device model and serial number is still returned (at least as far as I have observed. Re-work the logic to prefer the 'vendor' field first, and if not present, always output a `smartmon_device_info` metric even if some labels have empty values. On the box I'm testing this on, where previously no metric was returned, it now returns: # HELP smartmon_device_info SMART metric device_info # TYPE smartmon_device_info gauge smartmon_device_info{disk="/dev/sda",type="sat",model_family="",device_model="INTEL REDACTED",serial_number="REDACTED",firmware_version="REDACTED"} 1 smartmon_device_info{disk="/dev/sdb",type="sat",model_family="",device_model="INTEL REDACTED",serial_number="REDACTED",firmware_version="REDACTED"} 1 smartmon_device_info{disk="/dev/sdc",type="sat",model_family="",device_model="INTEL REDACTED",serial_number="REDACTED",firmware_version="REDACTED"} 1 smartmon_device_info{disk="/dev/sdd",type="sat",model_family="",device_model="INTEL REDACTED",serial_number="REDACTED",firmware_version="REDACTED"} 1 smartmon_device_info{disk="/dev/sde",type="sat",model_family="",device_model="INTEL REDACTED",serial_number="REDACTED",firmware_version="REDACTED"} 1 smartmon_device_info{disk="/dev/sdf",type="sat",model_family="",device_model="INTEL REDACTED",serial_number="REDACTED",firmware_version="REDACTED"} 1 * Add trailing newline Because POSIX: https://stackoverflow.com/a/729795
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-xtext_collector_examples/smartmon.sh8
1 files changed, 4 insertions, 4 deletions
diff --git a/text_collector_examples/smartmon.sh b/text_collector_examples/smartmon.sh
index cd121b8..5c8077f 100755
--- a/text_collector_examples/smartmon.sh
+++ b/text_collector_examples/smartmon.sh
@@ -102,10 +102,10 @@ parse_smartctl_info() {
102 esac 102 esac
103 fi 103 fi
104 done 104 done
105 if [[ -n "${model_family}" ]] ; then 105 if [[ -n "${vendor}" ]] ; then
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"
107 elif [[ -n "${vendor}" ]] ; then
108 echo "device_info{disk=\"${disk}\",type=\"${disk_type}\",vendor=\"${vendor}\",product=\"${product}\",revision=\"${revision}\",lun_id=\"${lun_id}\"} 1" 106 echo "device_info{disk=\"${disk}\",type=\"${disk_type}\",vendor=\"${vendor}\",product=\"${product}\",revision=\"${revision}\",lun_id=\"${lun_id}\"} 1"
107 else
108 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"
109 fi 109 fi
110 echo "device_smart_available{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_available}" 110 echo "device_smart_available{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_available}"
111 echo "device_smart_enabled{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_enabled}" 111 echo "device_smart_enabled{disk=\"${disk}\",type=\"${disk_type}\"} ${smart_enabled}"
@@ -146,4 +146,4 @@ for device in ${device_list}; do
146 /usr/sbin/smartctl -i -H -d "${type}" "${disk}" | parse_smartctl_info "${disk}" "${type}" 146 /usr/sbin/smartctl -i -H -d "${type}" "${disk}" | parse_smartctl_info "${disk}" "${type}"
147 # Get the SMART attributes 147 # Get the SMART attributes
148 /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}"
149done | format_output \ No newline at end of file 149done | format_output