diff options
author | Ben Kochie <superq@gmail.com> | 2017-10-18 07:37:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-18 07:37:47 +0200 |
commit | 1824ac3b9e5b5c810d88a9f0fb5e0aabfa1727ee (patch) | |
tree | ee48e6225d5f4cd241b10395c41f106cf24dbd04 /text_collector_examples | |
parent | f3a70226025bf81e55eaf9d7386f9f7b3a267694 (diff) | |
download | prometheus_node_collector-1824ac3b9e5b5c810d88a9f0fb5e0aabfa1727ee.tar.bz2 prometheus_node_collector-1824ac3b9e5b5c810d88a9f0fb5e0aabfa1727ee.tar.xz prometheus_node_collector-1824ac3b9e5b5c810d88a9f0fb5e0aabfa1727ee.zip |
Fix smartmon.sh textfile script (#700)
When there are no SMART compatible devices (Raspberry Pi for example) an
error is returned, but the return code is still 0.
`# scan_smart_devices: glob(3) aborted matching pattern /dev/discs/disc*`
* Remove unused `disks` variable.
* Filter for only valid `/dev` devices.
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-x | text_collector_examples/smartmon.sh | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/text_collector_examples/smartmon.sh b/text_collector_examples/smartmon.sh index 5c8077f..a54f0ca 100755 --- a/text_collector_examples/smartmon.sh +++ b/text_collector_examples/smartmon.sh | |||
@@ -7,8 +7,6 @@ | |||
7 | # data in them than you'd think. | 7 | # data in them than you'd think. |
8 | # http://arstechnica.com/civis/viewtopic.php?p=22062211 | 8 | # http://arstechnica.com/civis/viewtopic.php?p=22062211 |
9 | 9 | ||
10 | disks="$(/usr/sbin/smartctl --scan | awk '{print $1 "|" $3}')" | ||
11 | |||
12 | parse_smartctl_attributes_awk="$(cat << 'SMARTCTLAWK' | 10 | parse_smartctl_attributes_awk="$(cat << 'SMARTCTLAWK' |
13 | $1 ~ /^[0-9]+$/ && $2 ~ /^[a-zA-Z0-9_-]+$/ { | 11 | $1 ~ /^[0-9]+$/ && $2 ~ /^[a-zA-Z0-9_-]+$/ { |
14 | gsub(/-/, "_"); | 12 | gsub(/-/, "_"); |
@@ -136,7 +134,7 @@ if [[ "$(expr "${smartctl_version}" : '\([0-9]*\)\..*')" -lt 6 ]] ; then | |||
136 | exit | 134 | exit |
137 | fi | 135 | fi |
138 | 136 | ||
139 | device_list="$(/usr/sbin/smartctl --scan-open | awk '{print $1 "|" $3}')" | 137 | device_list="$(/usr/sbin/smartctl --scan-open | awk '/^\/dev/{print $1 "|" $3}')" |
140 | 138 | ||
141 | for device in ${device_list}; do | 139 | for device in ${device_list}; do |
142 | disk="$(echo ${device} | cut -f1 -d'|')" | 140 | disk="$(echo ${device} | cut -f1 -d'|')" |