/usr/lib/ruby/vendor_ruby/ohai/plugins/solaris2/zpools.rb is in ohai 6.14.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #
# Author:: Jason J. W. Williams (williamsjj@digitar.com)
# Copyright:: Copyright (c) 2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
provides "zpools"
pools = Mash.new
# Grab ZFS zpools overall health and attributes
popen4("zpool list -H -o name,size,alloc,free,cap,dedup,health,version") do |pid, stdin, stdout, stderr|
stdin.close
stdout.each 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+)$/
pools[$1] = Mash.new
pools[$1][:pool_size] = $2
pools[$1][:pool_allocated] = $3
pools[$1][:pool_free] = $4
pools[$1][:capacity_used] = $5
pools[$1][:dedup_factor] = $6
pools[$1][:health] = $7
pools[$1][:zpool_version] = $8
end
end
end
# Grab individual health for devices in the zpools
for pool in pools.keys
pools[pool][:devices] = Mash.new
# Run "zpool status" as non-root user (adm) so that
# the command won't try to open() each device which can
# hang the command if any of the disks are bad.
popen4("su adm -c \"zpool status #{pool}\"") do |pid, stdin, stdout, stderr|
stdin.close
stdout.each do |line|
case line
when /^\s+(c[-_a-zA-Z0-9]+)\s+([-_a-zA-Z0-9]+)\s+(\d+)\s+(\d+)\s+(\d+)$/
pools[pool][:devices][$1] = Mash.new
pools[pool][:devices][$1][:state] = $2
pools[pool][:devices][$1][:errors] = Mash.new
pools[pool][:devices][$1][:errors][:read] = $3
pools[pool][:devices][$1][:errors][:write] = $4
pools[pool][:devices][$1][:errors][:checksum] = $5
end
end
end
end
# Set the zpools data
zpools pools
|