Class: Diskstats
- Inherits:
-
Object
- Object
- Diskstats
- Includes:
- Enumerable
- Defined in:
- lib/check-disk-io_gem.rb
Constant Summary collapse
- COLUMNS =
[ :major, :minor, :device_name, :reads_success, :reads_merged, :sectors_read, :read_time_ms, :writes_success, :writes_merged, :sectors_written, :write_time_ms, :current_ios, :io_time_ms, :weightd_io_time_ms ]
Instance Attribute Summary collapse
-
#later ⇒ Object
readonly
Returns the value of attribute later.
-
#now ⇒ Object
readonly
Returns the value of attribute now.
-
#raw_stats ⇒ Object
readonly
Returns the value of attribute raw_stats.
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(stats) ⇒ Diskstats
constructor
A new instance of Diskstats.
- #rows ⇒ Object
Constructor Details
#initialize(stats) ⇒ Diskstats
Returns a new instance of Diskstats.
51 52 53 |
# File 'lib/check-disk-io_gem.rb', line 51 def initialize(stats) @raw_stats = stats end |
Instance Attribute Details
#later ⇒ Object (readonly)
Returns the value of attribute later.
49 50 51 |
# File 'lib/check-disk-io_gem.rb', line 49 def later @later end |
#now ⇒ Object (readonly)
Returns the value of attribute now.
49 50 51 |
# File 'lib/check-disk-io_gem.rb', line 49 def now @now end |
#raw_stats ⇒ Object (readonly)
Returns the value of attribute raw_stats.
49 50 51 |
# File 'lib/check-disk-io_gem.rb', line 49 def raw_stats @raw_stats end |
Class Method Details
.from_proc ⇒ Object
65 66 67 |
# File 'lib/check-disk-io_gem.rb', line 65 def self.from_proc new(File.read('/proc/diskstats')) end |
Instance Method Details
#each(&block) ⇒ Object
61 62 63 |
# File 'lib/check-disk-io_gem.rb', line 61 def each(&block) rows.each(&block) end |
#rows ⇒ Object
55 56 57 58 59 |
# File 'lib/check-disk-io_gem.rb', line 55 def rows @rows ||= raw_stats.lines.map do |line| OpenStruct.new(Hash[COLUMNS.zip(line.strip.split)]) end end |