Class: Bipbip::Plugin::Network
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::Network
- Defined in:
- lib/bipbip/plugin/network.rb
Instance Attribute Summary
Attributes inherited from Bipbip::Plugin
#config, #frequency, #metric_group, #name, #tags
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
factory, factory_from_plugin, #initialize, #metrics_names, #run, #source_identifier
Methods included from InterruptibleSleep
#interrupt_sleep, #interruptible_sleep
Constructor Details
This class inherits a constructor from Bipbip::Plugin
Instance Method Details
#metrics_schema ⇒ Object
3 4 5 6 7 |
# File 'lib/bipbip/plugin/network.rb', line 3 def metrics_schema [ { name: 'connections_total', type: 'gauge', unit: 'Connections' } ] end |
#monitor ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/bipbip/plugin/network.rb', line 9 def monitor tcp_summary = `ss -s | grep '^TCP:'` tcp_counters = /^TCP:\s+(\d+) \(estab (\d+), closed (\d+), orphaned (\d+), synrecv (\d+), timewait (\d+)\/(\d+)\), ports (\d+)$/.match(tcp_summary) fail "Cannot match ss-output `#{tcp_summary}`" unless tcp_counters { connections_total: tcp_counters[1].to_i } end |