Class: SensuPluginsZFS::ZPool
- Inherits:
-
Object
- Object
- SensuPluginsZFS::ZPool
- Defined in:
- lib/sensu-plugins-zfs/zpool.rb
Instance Attribute Summary collapse
-
#capacity ⇒ Object
readonly
Returns the value of attribute capacity.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#vdevs ⇒ Object
readonly
Returns the value of attribute vdevs.
Instance Method Summary collapse
-
#initialize(name) ⇒ ZPool
constructor
A new instance of ZPool.
- #ok? ⇒ Boolean
- #scrubbed_at ⇒ Object
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
#capacity ⇒ Object (readonly)
Returns the value of attribute capacity.
13 14 15 |
# File 'lib/sensu-plugins-zfs/zpool.rb', line 13 def capacity @capacity end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/sensu-plugins-zfs/zpool.rb', line 13 def name @name end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
13 14 15 |
# File 'lib/sensu-plugins-zfs/zpool.rb', line 13 def state @state end |
#vdevs ⇒ Object (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
22 23 24 |
# File 'lib/sensu-plugins-zfs/zpool.rb', line 22 def ok? @state == 'ONLINE' end |
#scrubbed_at ⇒ Object
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 |