summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-10-24 11:01:04 -0700
committerTim Smith <tsmith@chef.io>2018-03-19 10:06:13 -0700
commit928f0cba152bf9589973b4a8e03a62decf30b624 (patch)
tree6af9d5681f803144ca3e1960bde0ddccc623f173
parent6ead80e151e28378081eb9f1f58498691f33f25e (diff)
downloadohai-fail_less.tar.gz
Don't stacktrace if we can't shell_out to zpoolfail_less
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/zpools.rb35
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/ohai/plugins/zpools.rb b/lib/ohai/plugins/zpools.rb
index ca2aa093..6bbb9259 100644
--- a/lib/ohai/plugins/zpools.rb
+++ b/lib/ohai/plugins/zpools.rb
@@ -28,21 +28,26 @@ Ohai.plugin(:Zpools) do
def gather_pool_info
pools = Mash.new
- # Grab ZFS zpools overall health and attributes
- so = shell_out("zpool list -H -o name,size,alloc,free,cap,dedup,health,version")
- so.stdout.lines do |line|
- case line
- when /^([-_0-9A-Za-z]*)\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+(\d+%)\s+([.0-9]+x)\s+([-_0-9A-Za-z]+)\s+(\d+|-)$/
- logger.trace("Plugin Zpools: Parsing zpool list line: #{line.chomp}")
- pools[$1] = Mash.new
- pools[$1][:pool_size] = sanitize_value($2)
- pools[$1][:pool_allocated] = sanitize_value($3)
- pools[$1][:pool_free] = sanitize_value($4)
- pools[$1][:capacity_used] = sanitize_value($5)
- pools[$1][:dedup_factor] = sanitize_value($6)
- pools[$1][:health] = sanitize_value($7)
- pools[$1][:zpool_version] = sanitize_value($8)
+ begin
+ # Grab ZFS zpools overall health and attributes
+ so = shell_out("zpool list -H -o name,size,alloc,free,cap,dedup,health,version")
+ so.stdout.lines do |line|
+ case line
+ when /^([-_0-9A-Za-z]*)\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+([.0-9]+[MGTPE])\s+(\d+%)\s+([.0-9]+x)\s+([-_0-9A-Za-z]+)\s+(\d+|-)$/
+ Ohai::Log.debug("Plugin Zpools: Parsing zpool list line: #{line.chomp}")
+ pools[$1] = Mash.new
+ pools[$1][:pool_size] = sanitize_value($2)
+ pools[$1][:pool_allocated] = sanitize_value($3)
+ pools[$1][:pool_free] = sanitize_value($4)
+ pools[$1][:capacity_used] = sanitize_value($5)
+ pools[$1][:dedup_factor] = sanitize_value($6)
+ pools[$1][:health] = sanitize_value($7)
+ pools[$1][:zpool_version] = sanitize_value($8)
+ end
end
+
+ rescue Ohai::Exceptions::Exec
+ Ohai::Log.debug('Plugin Zpools: Could not shell_out "zpool list -H -o name,size,alloc,free,cap,dedup,health,version". Skipping plugin.')
end
pools
end
@@ -82,6 +87,6 @@ Ohai.plugin(:Zpools) do
end
# Set the zpools data
- zpools pools
+ zpools pools unless pools.empty?
end
end