Skip to content

fix(chisels): process non-empty captures without events #2159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions userspace/sysdig/chisels/lsof.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.
description = "This chisel prints the open file descriptors for every process in the system, with an output that is similar to the one of lsof. Output is at a point in time; adjust this in the filter. It defaults to time of evt.num=0";
short_description = "List (and optionally filter) the open file descriptors.";
category = "System State";

-- Argument list
args =
{
Expand Down Expand Up @@ -66,7 +66,7 @@ function on_init()
end

-- Final chisel initialization
function on_capture_start()
function on_capture_start()
capturing = true
return true
end
Expand All @@ -83,16 +83,16 @@ function on_capture_end()
if not capturing then
return
end

if match == false then

local ttable = sysdig.get_thread_table(filter)

if match == false and next(ttable) == nil then
print("empty capture or no event matching the filter")
return
end

local ttable = sysdig.get_thread_table(filter)

local sorted_ttable = pairs_top_by_val(ttable, 0, function(t,a,b) return a < b end)

print(extend_string("COMMAND", 20) ..
extend_string("PID", 8) ..
extend_string("TID", 8) ..
Expand Down
14 changes: 7 additions & 7 deletions userspace/sysdig/chisels/netstat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.
description = "Print the system network connections, with an output that is similar to the one of netstat. Output is at a point in time; adjust this in the filter. It defaults to time of evt.num=0";
short_description = "List (and optionally filter) network connections.";
category = "System State";

-- Argument list
args =
{
Expand Down Expand Up @@ -66,7 +66,7 @@ function on_init()
end

-- Final chisel initialization
function on_capture_start()
function on_capture_start()
capturing = true
return true
end
Expand All @@ -83,14 +83,14 @@ function on_capture_end()
if not capturing then
return
end

if match == false then

local ttable = sysdig.get_thread_table(filter)

if match == false and next(ttable) == nil then
print("empty capture or no event matching the filter")
return
end

local ttable = sysdig.get_thread_table(filter)

print(extend_string("Proto", 6) ..
extend_string("Server Address", 25) ..
extend_string("Client Address", 25) ..
Expand All @@ -99,7 +99,7 @@ function on_capture_end()

for tid, proc in pairs(ttable) do
local fdtable = proc.fdtable

for fd, fdinfo in pairs(fdtable) do
local cip = fdinfo.cip
local cport = fdinfo.cport
Expand Down
14 changes: 7 additions & 7 deletions userspace/sysdig/chisels/ps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.
description = "List the running processes, with an output that is similar to the one of ps. Output is at a point in time; adjust this in the filter. It defaults to time of evt.num=0";
short_description = "List (and optionally filter) the machine processes.";
category = "System State";

-- Argument list
args =
{
Expand Down Expand Up @@ -65,7 +65,7 @@ function on_init()
return true
end

function on_capture_start()
function on_capture_start()
capturing = true
return true
end
Expand All @@ -82,16 +82,16 @@ function on_capture_end(ts_s, ts_ns, delta)
if not capturing then
return
end

if match == false then

local ttable = sysdig.get_thread_table(filter)

if match == false and next(ttable) == nil then
print("empty capture or no event matching the filter")
return
end

local ttable = sysdig.get_thread_table(filter)

local sorted_ttable = pairs_top_by_val(ttable, 0, function(t,a,b) return a < b end)

print(extend_string("TID", 8) ..
extend_string("PID", 8) ..
extend_string("USER", 12) ..
Expand Down
Loading