Skip to content

Commit 983c294

Browse files
committed
Get pool data however the state (resp. status)
This commits substitutes 'zpool iostat' for 'zpool status' to fix improper parsing due to the variety of states and statuses.
1 parent 6e85d0e commit 983c294

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/puppet/provider/zpool/zpool.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,21 @@ def process_zpool_data(pool_array)
6262
end
6363

6464
def get_pool_data
65-
# https://docs.oracle.com/cd/E19082-01/817-2271/gbcve/index.html
66-
# we could also use zpool iostat -v mypool for a (little bit) cleaner output
65+
# https://openzfs.github.io/openzfs-docs/msg/index.html
66+
# https://docs.oracle.com/cd/E19120-01/open.solaris/817-2271/gbcve/index.html
6767
zpool_opts = case Facter.value(:kernel)
68-
# use full device names ("-P") on Linux/ZOL to prevent
68+
# Do not use the 'scripted mode' ("-H") to maintain
69+
# compatibility with non-OpenZFS targets.
70+
#
71+
# Use full device names ("-P") on OpenZFS to prevent
6972
# mismatches between creation and display paths:
7073
when 'Linux'
7174
'-P'
7275
else
7376
''
7477
end
75-
out = execute("zpool status #{zpool_opts} #{@resource[:pool]}", failonfail: false, combine: false)
76-
zpool_data = out.lines.select { |line| line.index("\t") == 0 }.map { |l| l.strip.split("\s")[0] }
77-
zpool_data.shift
78+
out = execute("zpool iostat -v #{zpool_opts} #{@resource[:pool]}", failonfail: false, combine: false)
79+
zpool_data = out.lines[3..-2].map { |line| line.strip.split("\s")[0] }
7880
zpool_data
7981
end
8082

0 commit comments

Comments
 (0)