Class: Fluent::Plugin::TDMonitorAgentInput::DiskStat

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/in_td_monitor_agent.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ DiskStat

Returns a new instance of DiskStat.



338
339
340
341
# File 'lib/fluent/plugin/in_td_monitor_agent.rb', line 338

def initialize(paths)
  mounts = mount_points
  @targets = paths.map { |path| select_mount(path, mounts) }.sort.uniq
end

Instance Method Details

#statsObject



343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/fluent/plugin/in_td_monitor_agent.rb', line 343

def stats
  res = {}
  `df -B G -P`.each_line.with_index { |line, i|
    if i.nonzero?
      columns = line.strip.split(' ')
      mount = columns[-1].strip
      if @targets.include?(mount)
        usage = columns[-2].chop.to_i
        res[mount] = usage
      end
    end
  }
  res
end