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,
|
6
|
-
plugin.set_default(:
|
7
|
-
plugin.states.set_default(:warning,
|
8
|
-
plugin.states.set_default(:critical,
|
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 =
|
13
|
-
{
|
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
|