class Fluent::Plugin::NodeExporter::StatMetricsCollector
Public Class Methods
new(config={})
click to toggle source
Calls superclass method
Fluent::Plugin::NodeExporter::MetricsCollector::new
# File lib/fluent/plugin/node_exporter/stat_collector.rb, line 24 def initialize(config={}) super(config) @intr_total = CMetrics::Counter.new @intr_total.create("node", "", "intr_total", "Total number of interrupts serviced.") @context_switches_total = CMetrics::Counter.new @context_switches_total.create("node", "", "context_switches_total", "Total number of context switches.") @forks_total = CMetrics::Counter.new @forks_total.create("node", "", "forks_total", "Total number of forks.") @boot_time_seconds = CMetrics::Gauge.new @boot_time_seconds.create("node", "", "boot_time_seconds", "Node boot time, in unixtime.") @procs_running = CMetrics::Gauge.new @procs_running.create("node", "", "procs_running", "Number of processes in runnable state.") @procs_blocked = CMetrics::Gauge.new @procs_blocked.create("node", "", "procs_blocked", "Number of processes blocked waiting for I/O to complete.") end
Public Instance Methods
cmetrics()
click to toggle source
# File lib/fluent/plugin/node_exporter/stat_collector.rb, line 71 def cmetrics { intr_total: @intr_total, context_switches_total: @context_switches_total, forks_total: @forks_total, boot_time_seconds: @boot_time_seconds, procs_running: @procs_running, procs_blocked: @procs_blocked } end
run()
click to toggle source
# File lib/fluent/plugin/node_exporter/stat_collector.rb, line 46 def run stat_update end
stat_update()
click to toggle source
# File lib/fluent/plugin/node_exporter/stat_collector.rb, line 50 def stat_update stat_path = File.join(@procfs_path, "stat") File.readlines(stat_path).each do |line| entry, value, _ = line.split case entry when "intr" @intr_total.set(value.to_f) when "ctxt" @context_switches_total.set(value.to_f) when "btime" @boot_time_seconds.set(value.to_f) when "processes" @forks_total.set(value.to_f) when "procs_running" @procs_running.set(value.to_f) when "procs_blocked" @procs_blocked.set(value.to_f) end end end