mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Reworks mac address lists
This commit is contained in:
parent
d3f0945449
commit
5e4488a448
17 changed files with 215 additions and 185 deletions
41
scripts/lua/modules/mac_utils.lua
Normal file
41
scripts/lua/modules/mac_utils.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
require "lua_utils"
|
||||
|
||||
local json = require ("dkjson")
|
||||
|
||||
local now = os.time()
|
||||
|
||||
function mac2record(mac)
|
||||
local record = {}
|
||||
record["key"] = hostinfo2jqueryid(mac)
|
||||
|
||||
local link = "<A HREF='"..ntop.getHttpPrefix()..'/lua/mac_details.lua?'..hostinfo2url(mac).."' title='"..mac["mac"].."'>"..mac["mac"]..'</A>'
|
||||
if not isSpecialMac(mac["mac"]) then
|
||||
local icon = getHostIcon(mac["mac"])
|
||||
if(icon ~= "") then
|
||||
link = link.." "..icon
|
||||
end
|
||||
end
|
||||
record["column_link"] = link
|
||||
|
||||
local manufacturer = get_manufacturer_mac(mac["mac"])
|
||||
if(manufacturer == nil) then manufacturer = "" end
|
||||
record["column_manufacturer"] = manufacturer
|
||||
|
||||
record["column_hosts"] = mac["num_hosts"]..""
|
||||
record["column_since"] = secondsToTime(now - mac["seen.first"]+1)
|
||||
|
||||
local sent2rcvd = round((mac["bytes.sent"] * 100) / (mac["bytes.sent"] + mac["bytes.rcvd"]), 0)
|
||||
record["column_breakdown"] = "<div class='progress'><div class='progress-bar progress-bar-warning' style='width: "
|
||||
.. sent2rcvd .."%;'>Sent</div><div class='progress-bar progress-bar-info' style='width: " .. (100-sent2rcvd) .. "%;'>Rcvd</div></div>"
|
||||
|
||||
if(throughput_type == "pps") then
|
||||
record["column_thpt"] = pktsToSize(mac["throughput_pps"])
|
||||
else
|
||||
record["column_thpt"] = bitsToSize(8*mac["throughput_bps"])
|
||||
end
|
||||
|
||||
record["column_traffic"] = bytesToSize(mac["bytes.sent"] + mac["bytes.rcvd"])
|
||||
|
||||
return record
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue