Skip to content

Commit

Permalink
Adapt to new versions of logger and token bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandergall committed Mar 4, 2020
1 parent e54bb30 commit 233c894
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 7 additions & 5 deletions src/apps/ipfix/ipfix.lua
Expand Up @@ -21,6 +21,8 @@ local ipv4 = require("lib.protocol.ipv4")
local ipv6 = require("lib.protocol.ipv6")
local udp = require("lib.protocol.udp")
local ctable = require("lib.ctable")
local logger = require("lib.logger")
local token_bucket = require("lib.token_bucket")
local C = ffi.C
local S = require("syscall")

Expand Down Expand Up @@ -192,13 +194,13 @@ function FlowSet:new (spec, args)
" -> "..table.size)
end
require('jit').flush()
o.table_tb:rate(math.ceil(table.size / o.scan_time))
o.table_tb:set(math.ceil(table.size / o.scan_time))
end
}
if args.cache_size then
params.initial_size = math.ceil(args.cache_size / 0.4)
end
o.table_tb = lib.token_bucket_new()
o.table_tb = token_bucket.new({ rate = 1 }) -- Will be set by resize_callback
o.table = ctable.new(params)
o.table_tstamp = C.get_unix_time()
o.table_scan_time = 0
Expand Down Expand Up @@ -323,7 +325,7 @@ function FlowSet:expire_records(out, now)
now_ms = to_milliseconds(now)
local active = to_milliseconds(self.active_timeout)
local idle = to_milliseconds(self.idle_timeout)
for i = 1, self.table_tb:take_all() do
for i = 1, self.table_tb:take_burst() do
local entry
cursor, entry = self.table:next_entry(cursor, cursor + 1)
if entry then
Expand Down Expand Up @@ -439,8 +441,8 @@ function IPFIX:new(config)
observation_domain = config.observation_domain,
instance = config.instance,
add_packet_metadata = config.add_packet_metadata,
logger = lib.logger_new({ module = ("[%5d]"):format(S.getpid())
.." IPFIX exporter"} ) }
logger = logger.new({ module = ("[%5d]"):format(S.getpid())
.." IPFIX exporter"} ) }
o.shm = {
-- Total number of packets received
received_packets = { counter },
Expand Down
7 changes: 4 additions & 3 deletions src/apps/ipfix/maps.lua
Expand Up @@ -5,6 +5,7 @@ local lib = require("core.lib")
local ctable = require("lib.ctable")
local ethernet = require("lib.protocol.ethernet")
local lpm = require("lib.lpm.lpm4_248").LPM4_248
local logger = require("lib.logger")

-- Map MAC addresses to peer AS number
--
Expand Down Expand Up @@ -111,9 +112,9 @@ function mk_map(name, file, log_rate, log_fh)
end
local map = { map = map }
if log_fh then
map.logger = lib.logger_new({ rate = log_rate or 0.05,
fh = log_fh,
module = info.logger_module })
map.logger = logger.new({ rate = log_rate or 0.05,
fh = log_fh,
module = info.logger_module })
end
return map
end
5 changes: 3 additions & 2 deletions src/apps/ipfix/template.lua
Expand Up @@ -11,6 +11,7 @@ local lib = require("core.lib")
local counter = require("core.counter")
local ethernet = require("lib.protocol.ethernet")
local ipv4 = require("lib.protocol.ipv4")
local logger = require("lib.logger")
local metadata = require("apps.rss.metadata")
local strings = require("apps.ipfix.strings")
local dns = require("apps.ipfix.dns")
Expand Down Expand Up @@ -213,8 +214,8 @@ function make_template_info(spec)
record_ptr_t = ptr_to(record_t),
swap_fn = gen_swap_fn(),
match = pf.compile_filter(spec.filter),
logger = lib.logger_new({module = ("[%5d]"):format(S.getpid())
.." IPFIX template #"..spec.id }),
logger = logger.new({module = ("[%5d]"):format(S.getpid())
.." IPFIX template #"..spec.id }),
counters = spec.counters,
counters_names = counters_names,
extract = spec.extract,
Expand Down
8 changes: 2 additions & 6 deletions src/program/ipfix/probe_rss/probe_rss.lua
Expand Up @@ -6,6 +6,7 @@ local app_graph = require("core.config")
local worker = require("core.worker")
local shm = require("core.shm")
local pci = require("lib.hardware.pci")
local logger = require("lib.logger")
local probe = require("program.ipfix.lib")

local main_config = {
Expand Down Expand Up @@ -233,7 +234,6 @@ end

local long_opts = {
duration = "D",
logfile = "l",
debug = "d",
jit = "j",
help = "h",
Expand All @@ -246,7 +246,7 @@ function run (parameters)
local profiling, traceprofiling
local jit = { opts = {} }
local log_pid = string.format("[%5d]", S.getpid())
local logger = lib.logger_new({ module = log_pid.." RSS master" })
local logger = logger.new({ module = log_pid.." RSS master" })
local opt = {
D = function (arg)
if arg:match("^[0-9]+$") then
Expand All @@ -255,10 +255,6 @@ function run (parameters)
usage()
end
end,
l = function (arg)
local logfh = assert(io.open(arg, "a"))
lib.logger_default.fh = logfh
end,
h = function (arg) usage() end,
d = function (arg) _G.developer_debug = true end,
b = function (arg)
Expand Down

0 comments on commit 233c894

Please sign in to comment.