Sha256: c7a7b499e6a6282f14dd048404d7f9389540d4743aad8025bfb63ddcfa75b1ad
Contents?: true
Size: 868 Bytes
Versions: 2
Compression:
Stored size: 868 Bytes
Contents
#!/usr/bin/env ruby -w require 'nagiosplugin' class ZFS < NagiosPlugin::Plugin def zpools out = `zpool list -H -o name,health 2>&1` raise out unless $?.success? out.split("\n") end def health_by_pool @health_by_pool ||= zpools.inject({}) do |pools,line| name, health = line.split("\t") pools[name] = health pools end end def pools(health = nil) (health && health_by_pool.select { |p,h| h == health.to_s.upcase } ) || health_by_pool end def critical? !pools(:faulted).empty? end def warning? !pools(:degraded).empty? end def ok? pools(:online).count == pools.count end def output s = [] [:faulted, :degraded, :online].each do |health| s << "#{pools(health).count} #{health.to_s.upcase}" unless pools(health).empty? end s.join(", ") end end ZFS.check!
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
check_zfs-0.1.1 | bin/check_zfs |
check_zfs-0.1.0 | bin/check_zfs |