class Riemann::Tools::Sockstat

Constants

TCP_METRICS
UDP_METRICS

Public Class Methods

new() click to toggle source
# File bin/riemann-sockstat, line 13
def initialize
  @collect_tcp = true
end

Public Instance Methods

collect_tcp(raw_stats) click to toggle source
# File bin/riemann-sockstat, line 23
def collect_tcp(raw_stats)
  stats = raw_stats.match(/TCP:\sinuse\s(\d+)\sorphan\s(\d+)\stw\s(\d+)\salloc\s(\d+)\smem\s(\d+)/).captures
  report_stats('tcp', Hash[*TCP_METRICS.zip(stats).flatten])
end
report_stats(sock_kind, stats) click to toggle source
# File bin/riemann-sockstat, line 28
def report_stats(sock_kind, stats)
  stats.each_pair do |k, v|
    report({
      service:      "#{sock_kind}_#{k}",
      metric:       v.to_i,
      state:        'ok',
      tags:         ['sockstat'],
      description:  ''
    })
  end
end
tick() click to toggle source
# File bin/riemann-sockstat, line 17
def tick
  raw_stats = `cat /proc/net/sockstat`

  collect_tcp(raw_stats) if @collect_tcp
end