class Fluent::Plugin::NodeExporter::VmstatMetricsCollector

Constants

VMSTAT_ENTRIES_REGEX

Public Class Methods

new(config={}) click to toggle source
# File lib/fluent/plugin/node_exporter/vmstat_collector.rb, line 27
def initialize(config={})
  super(config)

  @metrics = {}
  vmstat_path = File.join(@procfs_path, "vmstat")
  File.readlines(vmstat_path).each do |line|
    if VMSTAT_ENTRIES_REGEX.match?(line)
      key, _ = line.split(' ', 2)
      @untyped = CMetrics::Untyped.new
      @untyped.create("node", "vmstat", key, "#{vmstat_path} information field #{key}.")
      @metrics[key.intern] = @untyped
    end
  end
end

Public Instance Methods

cmetrics() click to toggle source
# File lib/fluent/plugin/node_exporter/vmstat_collector.rb, line 56
def cmetrics
  @metrics
end
run() click to toggle source
# File lib/fluent/plugin/node_exporter/vmstat_collector.rb, line 42
def run
  vmstat_update
end
vmstat_update() click to toggle source
# File lib/fluent/plugin/node_exporter/vmstat_collector.rb, line 46
def vmstat_update
  vmstat_path = File.join(@procfs_path, "vmstat")
  File.readlines(vmstat_path).each do |line|
    if VMSTAT_ENTRIES_REGEX.match?(line)
      key, value = line.split(' ', 2)
      @metrics[key.intern].set(value.to_f)
    end
  end
end