-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathes.lua
46 lines (41 loc) · 984 Bytes
/
es.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
description = "total connections to es"
short_description = "total connections to es"
category = "misc"
args =
{
{
name = "refresh",
description = "",
argtype = "int"
},
}
function on_set_arg(name, val)
refresh = tonumber(val)
return true
end
function on_init()
_accepts = {}
_total = 0
etime = chisel.request_field("evt.latency")
ctime = chisel.request_field("evt.time")
src_ip = chisel.request_field("fd.cip")
sysdig.set_filter("fd.sport=9200 and evt.type=accept")
chisel.set_interval_s(refresh)
return true
end
function on_interval(ts_s, ts_ns, delta)
table.sort(_accepts)
for k,v in pairs(_accepts) do
print(k.."\t".._accepts[k])
end
print("Total connections: ".._total.."/"..refresh.."s\n")
_accepts = {}
_total = 0
return true
end
function on_event()
local src_ip = evt.field(src_ip)
_accepts[src_ip] = (_accepts[src_ip] or 0) + 1
_total = _total + 1
return true
end