diff options
author | Bernd Müller <mueller@b1-systems.de> | 2018-07-04 00:30:20 +0200 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2018-07-04 00:30:20 +0200 |
commit | ee1e1997bcd04c4a2b23380204a92029a85c6e56 (patch) | |
tree | 468419c73baf3dfb7007512a36f07c5b90952794 | |
parent | ae90bac5b89fa3b65a4dd24131dbd41842c11083 (diff) | |
download | prometheus_node_collector-ee1e1997bcd04c4a2b23380204a92029a85c6e56.tar.bz2 prometheus_node_collector-ee1e1997bcd04c4a2b23380204a92029a85c6e56.tar.xz prometheus_node_collector-ee1e1997bcd04c4a2b23380204a92029a85c6e56.zip |
Add scsi smart data to prometheus exporter (#862)
Add scsi smart data to prometheus exporter
Signed-off-by: mueller <mueller@b1-systems.de>
-rwxr-xr-x | text_collector_examples/smartmon.sh | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/text_collector_examples/smartmon.sh b/text_collector_examples/smartmon.sh index cca3478..9b0c7d4 100755 --- a/text_collector_examples/smartmon.sh +++ b/text_collector_examples/smartmon.sh | |||
@@ -70,6 +70,26 @@ parse_smartctl_attributes() { | |||
70 | | grep -E "(${smartmon_attrs})" | 70 | | grep -E "(${smartmon_attrs})" |
71 | } | 71 | } |
72 | 72 | ||
73 | parse_smartctl_scsi_attributes() { | ||
74 | local disk="$1" | ||
75 | local disk_type="$2" | ||
76 | local labels="disk=\"${disk}\",type=\"${disk_type}\"" | ||
77 | while read line ; do | ||
78 | attr_type="$(echo "${line}" | tr '=' ':' | cut -f1 -d: | sed 's/^ \+//g' | tr ' ' '_')" | ||
79 | attr_value="$(echo "${line}" | tr '=' ':' | cut -f2 -d: | sed 's/^ \+//g')" | ||
80 | case "${attr_type}" in | ||
81 | number_of_hours_powered_up_) power_on="$( echo "${attr_value}" | awk '{ printf "%e\n", $1 }')" ;; | ||
82 | Current_Drive_Temperature) temp_cel="$(echo ${attr_value} | cut -f1 -d' ' | awk '{ printf "%e\n", $1 }')" ;; | ||
83 | Blocks_read_from_cache_and_sent_to_initiator_) lbas_read="$(echo ${attr_value} | awk '{ printf "%e\n", $1 }')" ;; | ||
84 | Accumulated_start-stop_cycles) power_cycle="$(echo ${attr_value} | awk '{ printf "%e\n", $1 }')" ;; | ||
85 | esac | ||
86 | done | ||
87 | echo "power_on_hours_raw_value{"${labels}",smart_id=\"9\"} ${power_on}" | ||
88 | echo "temperature_celsius_raw_value{"${labels}",smart_id=\"194\"} ${temp_cel}" | ||
89 | echo "total_lbas_read_raw_value{"${labels}",smart_id=\"242\"} ${lbas_read}" | ||
90 | echo "power_cycle_count_raw_value{"${labels}",smart_id=\"12\"} ${power_cycle}" | ||
91 | } | ||
92 | |||
73 | parse_smartctl_info() { | 93 | parse_smartctl_info() { |
74 | local -i smart_available=0 smart_enabled=0 smart_healthy=0 | 94 | local -i smart_available=0 smart_enabled=0 smart_healthy=0 |
75 | local disk="$1" disk_type="$2" | 95 | local disk="$1" disk_type="$2" |
@@ -143,5 +163,9 @@ for device in ${device_list}; do | |||
143 | # Get the SMART information and health | 163 | # Get the SMART information and health |
144 | /usr/sbin/smartctl -i -H -d "${type}" "${disk}" | parse_smartctl_info "${disk}" "${type}" | 164 | /usr/sbin/smartctl -i -H -d "${type}" "${disk}" | parse_smartctl_info "${disk}" "${type}" |
145 | # Get the SMART attributes | 165 | # Get the SMART attributes |
146 | /usr/sbin/smartctl -A -d "${type}" "${disk}" | parse_smartctl_attributes "${disk}" "${type}" | 166 | case ${type} in |
167 | sat) /usr/sbin/smartctl -A -d "${type}" "${disk}" | parse_smartctl_attributes "${disk}" "${type}" ;; | ||
168 | scsi) /usr/sbin/smartctl -A -d "${type}" "${disk}" | parse_smartctl_scsi_attributes "${disk}" "${type}" ;; | ||
169 | *) echo "disk type is not sat or scsi, ${type}"; exit ;; | ||
170 | esac | ||
147 | done | format_output | 171 | done | format_output |