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, #metric_group, #name, #pid
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
factory, #frequency, #initialize, #interrupt, #interrupted?, #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
5 6 7 8 9 |
# File 'lib/bipbip/plugin/network.rb', line 5 def metrics_schema [ {:name => 'connections_total', :type => 'gauge', :unit => 'Connections'}, ] end |
#monitor ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/bipbip/plugin/network.rb', line 11 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) raise "Cannot match ss-output `#{tcp_summary}`" unless tcp_counters {:connections_total => tcp_counters[1].to_i} end |