Class: SensuPluginsZFS::ZPool

Inherits:
Object
  • Object
show all
Defined in:
lib/sensu-plugins-zfs/zpool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ZPool

Returns a new instance of ZPool.



15
16
17
18
19
20
# File 'lib/sensu-plugins-zfs/zpool.rb', line 15

def initialize(name)
  @name = name
  @state = `sudo zpool status #{name} | grep '^ state: ' | cut -d ' ' -f 3`.strip
  @capacity = `sudo zpool get -H capacity #{@name} | awk '{print $3}' | cut -d '%' -f1`.strip.to_i
  @vdevs = create_vdevs name
end

Instance Attribute Details

#capacityObject (readonly)

Returns the value of attribute capacity.



13
14
15
# File 'lib/sensu-plugins-zfs/zpool.rb', line 13

def capacity
  @capacity
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/sensu-plugins-zfs/zpool.rb', line 13

def name
  @name
end

#stateObject (readonly)

Returns the value of attribute state.



13
14
15
# File 'lib/sensu-plugins-zfs/zpool.rb', line 13

def state
  @state
end

#vdevsObject (readonly)

Returns the value of attribute vdevs.



13
14
15
# File 'lib/sensu-plugins-zfs/zpool.rb', line 13

def vdevs
  @vdevs
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/sensu-plugins-zfs/zpool.rb', line 22

def ok?
  @state == 'ONLINE'
end

#scrubbed_atObject



26
27
28
29
30
# File 'lib/sensu-plugins-zfs/zpool.rb', line 26

def scrubbed_at
  return Time.at(0) if never_scrubbed?
  return Time.now if scrub_in_progress?
  Time.parse `sudo zpool status #{@name} | grep '^  scan: scrub' | awk '{print $11" "$12" "$13" "$14" "$15}'`.strip # rubocop:disable
end