riemann-babbler 1.0.8.3 → 1.0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,14 +2,32 @@ class Riemann::Babbler::NetStat < Riemann::Babbler
2
2
 
3
3
  def init
4
4
  plugin.set_default(:service, 'netstat')
5
- plugin.set_default(:interval, 60)
6
- plugin.set_default(:port, 80)
7
- plugin.states.set_default(:warning, 300)
8
- plugin.states.set_default(:critical, 400)
5
+ plugin.set_default(:interval, 5)
6
+ plugin.set_default(:ports, [80, 3994])
7
+ plugin.states.set_default(:warning, nil)
8
+ plugin.states.set_default(:critical, nil)
9
+ end
10
+
11
+ def get_conn_count
12
+ filter = nil
13
+ plugin.ports.each do |port|
14
+ if filter == nil
15
+ filter = "\\( src *:#{port}"
16
+ else
17
+ filter += " or src *:#{port}"
18
+ end
19
+ end
20
+ filter += " \\) and not dst 127.0.0.1:*"
21
+ cmd = "ss -t -4 -n state established " + filter + " | wc -l"
22
+ shell(cmd).to_i - 1
9
23
  end
10
24
 
11
25
  def collect
12
- count = shell("netstat -nat4 | egrep -e ':#{plugin.port}\s' | grep ESTA | wc -l").to_i
13
- {:service => "#{plugin.service} tcp #{plugin.port}", :metric => count, :description => "count established connects: #{count} to port #{plugin.port}"}
26
+ count = get_conn_count()
27
+ {
28
+ :service => "#{plugin.service} tcp #{plugin.ports.join(', ')}",
29
+ :metric => count,
30
+ :description => "count established connects: #{count} to ports #{plugin.ports.join(', ')}"
31
+ }
14
32
  end
15
33
  end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.0.8.3'
3
+ VERSION = '1.0.8.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8.3
4
+ version: 1.0.8.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: