Sha256: 522b3e2c65cde7a4e77f9fe1007fb237fed882c3f51b5817ec6b25039eb49b17

Contents?: true

Size: 622 Bytes

Versions: 1

Compression:

Stored size: 622 Bytes

Contents

module Nagios
  module ZFS
    class Zpool
      KNOWN_POOL_HEALTHS = %(ONLINE DEGRADED FAULTED)

      attr_reader :name

      def initialize(name)
        raise 'missing pool name' if [nil, ''].include?(name)
        @name = name
      end

      def capacity
        query.split("\t").last[/^(\d+)/,1].to_i
      end

      def query
        @query ||= `zpool list -H -o name,cap #{name}`
      end

      def health
        @health ||= `zpool list -H -o health #{name}`.strip
        raise "unknown health: #{@health}" unless
          KNOWN_POOL_HEALTHS.include?(@health)
        @health
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nagios-zfs-0.2.0 lib/nagios/zfs/zpool.rb