Class: OsCtl::Lib::Zfs::ObjsetStats::Objset

Inherits:
Object
  • Object
show all
Defined in:
lib/libosctl/zfs/objset_stats/objset.rb

Defined Under Namespace

Classes: AggregatedStats

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObjset

Returns a new instance of Objset.



13
14
15
16
17
18
19
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 13

def initialize
  @write_ios = 0
  @write_bytes = 0
  @read_ios = 0
  @read_bytes = 0
  @subdatasets = []
end

Instance Attribute Details

#dataset_nameObject

Returns the value of attribute dataset_name.



10
11
12
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 10

def dataset_name
  @dataset_name
end

#read_bytesObject

Returns the value of attribute read_bytes.



10
11
12
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 10

def read_bytes
  @read_bytes
end

#read_iosObject

Returns the value of attribute read_ios.



10
11
12
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 10

def read_ios
  @read_ios
end

#subdatasetsObject (readonly)

Returns the value of attribute subdatasets.



11
12
13
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 11

def subdatasets
  @subdatasets
end

#write_bytesObject

Returns the value of attribute write_bytes.



10
11
12
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 10

def write_bytes
  @write_bytes
end

#write_iosObject

Returns the value of attribute write_ios.



10
11
12
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 10

def write_ios
  @write_ios
end

Instance Method Details

#aggregate_stats(into: nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/libosctl/zfs/objset_stats/objset.rb', line 21

def aggregate_stats(into: nil)
  st =
    if into
      into.write_ios += write_ios
      into.write_bytes += write_bytes
      into.read_ios += read_ios
      into.read_bytes += read_bytes
      into
    else
      AggregatedStats.new(write_ios, write_bytes, read_ios, read_bytes)
    end

  subdatasets.each do |subset|
    subset.aggregate_stats(into: st)
  end

  st
end