-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbacklog_sysdig.lua
More file actions
47 lines (42 loc) · 896 Bytes
/
backlog_sysdig.lua
File metadata and controls
47 lines (42 loc) · 896 Bytes
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
47
description = "queue (backlog) utilization"
short_description = "queue utilization"
category = "misc"
args =
{
{
name = "port",
description = "port to monitor",
argtype = "int"
},
}
function on_set_arg(name, val)
port = tonumber(val)
return true
end
function on_init()
util = nil
sport = chisel.request_field("fd.sport")
queue = chisel.request_field("evt.arg[2]")
sysdig.set_filter("fd.sport="..port.." and evt.type=accept")
chisel.set_interval_s(5)
return true
end
function on_interval(ts_s, ts_ns, delta)
local list = util
local sum = 0
local num = 0
while list do
sum = sum + list.queue
num = num + 1
list = list.next
end
if num ~= 0 then
print("Utilization for port "..port.." is "..(sum / num).."%")
end
util = nil
return true
end
function on_event()
util = { next = util, queue = evt.field(queue) }
return true
end