Class: Opstat::Parsers::HaproxyTables

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/parsers/haproxy_tables.rb

Constant Summary collapse

REGEX =
/# table:\s+(?<OPSTAT_TAG_table>[^,]+), type:\s+[^,]+, size:(?<table_size>\d+), used:(?<table_used>\d+)/

Instance Method Summary collapse

Methods included from Logging

#log_level, #oplogger, #preconfig_logger

Instance Method Details

#parse_data(data:, time:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/parsers/haproxy_tables.rb', line 9

def parse_data(data:, time:)
  report = []  
  data.each do |line|
    haproxy_table = REGEX.match(line)
    if haproxy_table
      captured_data = haproxy_table.named_captures
    captured_data['table_size'] = captured_data['table_size'].to_i
    captured_data['table_used'] = captured_data['table_used'].to_i
      report << captured_data
    end
  end
  return report
end