Skip to content

Commit

Permalink
Add SNMP Interface MIB for PCI devices
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergall committed Mar 19, 2018
1 parent 8178577 commit 7a9e3c8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/program/ipfix/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ local basic = require("apps.basic.basic_apps")
local arp = require("apps.ipv4.arp")
local ipfix = require("apps.ipfix.ipfix")
local template = require("apps.ipfix.template")
local ifmib = require("lib.ipc.shmem.iftable_mib")

local ifmib_dir = '/ifmib'

-- apps that can be used as an input or output for the exporter
local in_apps, out_apps = {}, {}
Expand Down Expand Up @@ -81,6 +84,20 @@ function in_apps.pci (spec)
end
out_apps.pci = in_apps.pci

function create_ifmib(stats, ifname, ifalias)
-- stats can be nil in case this process is not the master
-- of the device
if not stats then return end
if not shm.exists(ifmib_dir) then
shm.mkdir(ifmib_dir)
end
ifmib.init_snmp( { ifDescr = ifname,
ifName = ifname,
ifAlias = ifalias or "NetFlow input", },
ifname:gsub('/', '-'), stats,
shm.root..ifmib_dir, 5)
end

probe_config = {
-- Probe-specific
output_type = {required = true},
Expand Down Expand Up @@ -198,6 +215,11 @@ function configure_graph (arg, in_graph)

engine.configure(graph)

if config.input_type and config.input_type == "pci" then
local pciaddr = unpack(parse_spec(config.input, '/'))
create_ifmib(engine.app_table['in'].stats, (pciaddr:gsub("[:%.]", "_")))
end

if config.output_type == "tap_routed" then
local tap_config = out_app[2]
local name = tap_config.name
Expand Down
23 changes: 20 additions & 3 deletions src/program/ipfix/probe_rss/probe_rss.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ function run (parameters)
if duration ~= 0 then engine_opts.duration = duration end

local probe_config = assert(loadfile(file))()
engine.configure(create_app_graph(probe_config, busywait))
local graph, in_app_specs = create_app_graph(probe_config, busywait)
engine.configure(graph)

for _, spec in ipairs(in_app_specs) do
probe.create_ifmib(engine.app_table[spec.name].stats,
spec.ifname, spec.ifalias)
end

jit.flush()
engine.busywait = busywait
engine.main(engine_opts)
Expand All @@ -99,6 +106,8 @@ local main_config = {
}
local interface_config = {
device = { required = true },
name = { default = nil},
description = { default = nil },
tag = { default = nil },
config = { default = {} }
}
Expand Down Expand Up @@ -183,12 +192,19 @@ function create_app_graph (probe_config, busywait)
main.rss)

local tags = {}
local in_app_specs = {}
for i, interface in ipairs(main.interfaces) do
local interface = lib.parse(interface, interface_config)
local suffix = #main.interfaces > 1 and i or ''
local input_name = "input"..suffix
local device_info = pci.device_info(interface.device)
interface.config.pciaddr = interface.device
table.insert(in_app_specs,
{ pciaddr = interface.device,
name = input_name,
ifname = interface.name or
(interface.device:gsub("[:%.]", "_")),
ifalias = interface.description })
app_graph.app(graph, input_name,
require(device_info.driver).driver,
interface.config)
Expand Down Expand Up @@ -245,7 +261,7 @@ function create_app_graph (probe_config, busywait)
config.observation_domain = od
config.output = "ipfixexport"..od
if exporter.maps_log_dir then
config.maps_log_file =
config.maps_logfile =
exporter.maps_log_dir.."/"..od..".log"
end
if instance.embed then
Expand Down Expand Up @@ -276,5 +292,6 @@ function create_app_graph (probe_config, busywait)
end
end
end
return graph

return graph, in_app_specs
end

0 comments on commit 7a9e3c8

Please sign in to comment.