Skip to content

Commit

Permalink
program.ipfix: include PCI stats from control app
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergall committed Jul 25, 2018
1 parent 95ff0ca commit 5151c96
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/program/ipfix/stats/stats.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Display statistics for IPFIX processes

-- XXX Re-write needed
module(..., package.seeall)

local shm = require("core.shm")
Expand All @@ -22,6 +25,16 @@ local function format(indent, format, ...)
print(string.format(format, ...))
end

local function ppid_from_group (pid)
local ppid
local group = shm.root.."/"..shm.resolve("/"..pid.."/group")
local stat = assert(S.lstat(group))
if stat.islnk then
ppid = S.readlink(group):match("/(%d+)/group")
end
return ppid
end

local function pci_stats(indent, path)
local indent = indent or 0
for _, pciaddr in ipairs(shm.children(path.."/pci")) do
Expand Down Expand Up @@ -140,17 +153,26 @@ function run (args)

local ipfix = {}
local rss = {}
local ctrls = {}

for _, pid in ipairs(pids) do
for _, dir in ipairs(shm.children('/'..pid)) do
if dir == 'ipfix_templates' then
table.insert(ipfix, ipfix_info(tonumber(pid)))
local ppid = ppid_from_group(pid)
if ppid then
ctrls[ppid] = true
end
break
end
end
for _, dir in ipairs(shm.children('/'..pid..'/apps')) do
if dir == 'rss' then
table.insert(rss, rss_info(tonumber(pid)))
local ppid = ppid_from_group(pid)
if ppid then
ctrls[ppid] = true
end
end
end
end
Expand Down Expand Up @@ -182,6 +204,13 @@ function run (args)
end
end

for ppid, _ in pairs(ctrls) do
print()
format(0, "Control process #%d", ppid)
pci_stats(2, '/'..ppid)
print()
end

for _, rss in ipairs(rss) do
print()
format(0, "RSS process #%d", rss.pid)
Expand Down

0 comments on commit 5151c96

Please sign in to comment.