mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Implemented local hosts looking glass (more criteria to be added)
This commit is contained in:
parent
8263c1c65a
commit
091378fd7b
13 changed files with 412 additions and 55 deletions
|
|
@ -17,6 +17,12 @@ sortOrder = _GET["sortOrder"]
|
|||
protocol = _GET["protocol"]
|
||||
net = _GET["net"]
|
||||
long_names = _GET["long_names"]
|
||||
criteria = _GET["criteria"]
|
||||
|
||||
criteria_key = nil
|
||||
if(criteria ~= nil) then
|
||||
criteria_key, criteria_format = label2criteriakey(criteria)
|
||||
end
|
||||
|
||||
-- Host comparison parameters
|
||||
mode = _GET["mode"]
|
||||
|
|
@ -58,7 +64,11 @@ else
|
|||
end
|
||||
|
||||
if((sortColumn == nil) or (sortColumn == "column_"))then
|
||||
sortColumn = getDefaultTableSort("hosts")
|
||||
if(criteria == nil) then
|
||||
sortColumn = getDefaultTableSort("hosts")
|
||||
else
|
||||
sortColumn = getDefaultTableSort("localhosts")
|
||||
end
|
||||
else
|
||||
if((sortColumn ~= "column_")
|
||||
and (sortColumn ~= "")) then
|
||||
|
|
@ -67,7 +77,11 @@ else
|
|||
end
|
||||
|
||||
if(sortOrder == nil) then
|
||||
sortOrder = getDefaultTableSortOrder("hosts")
|
||||
if(criteria == nil) then
|
||||
sortOrder = getDefaultTableSortOrder("hosts")
|
||||
else
|
||||
sortOrder = getDefaultTableSortOrder("localhosts")
|
||||
end
|
||||
else
|
||||
if((sortColumn ~= "column_")
|
||||
and (sortColumn ~= "")) then
|
||||
|
|
@ -105,7 +119,7 @@ elseif mode == "remote" then
|
|||
hosts_retrv_function = interface.getRemoteHostsInfo
|
||||
end
|
||||
|
||||
hosts_stats = hosts_retrv_function(false, sortColumn, perPage, to_skip, sOrder,
|
||||
hosts_stats = hosts_retrv_function(false, sortColumn, perPage, to_skip, sOrder,
|
||||
country, os_, tonumber(vlan), tonumber(asn),
|
||||
tonumber(network), mac) -- false = little details
|
||||
|
||||
|
|
@ -214,48 +228,55 @@ for key, value in pairs(hosts_stats) do
|
|||
end
|
||||
|
||||
if(ok == true) then
|
||||
-- io.write("==>"..key.."\n")
|
||||
-- tprint(hosts_stats[key])
|
||||
--io.write("==>"..key.."\n")
|
||||
-- tprint(hosts_stats[key])
|
||||
--io.write("==>"..hosts_stats[key]["bytes.sent"].."[" .. sortColumn .. "]["..key.."]\n")
|
||||
|
||||
if(sortColumn == "column_") then
|
||||
vals[key] = key -- hosts_stats[key]["ipkey"]
|
||||
elseif(sortColumn == "column_name") then
|
||||
elseif(sortColumn == "column_name") then
|
||||
hosts_stats[key]["name"] = update_host_name(hosts_stats[key])
|
||||
vals[hosts_stats[key]["name"]..postfix] = key
|
||||
elseif(sortColumn == "column_since") then
|
||||
elseif(sortColumn == "column_since") then
|
||||
vals[(now-hosts_stats[key]["seen.first"])+postfix] = key
|
||||
elseif(sortColumn == "column_alerts") then
|
||||
elseif(sortColumn == "column_alerts") then
|
||||
vals[(now-hosts_stats[key]["num_alerts"])+postfix] = key
|
||||
elseif(sortColumn == "column_family") then
|
||||
elseif(sortColumn == "column_family") then
|
||||
vals[(now-hosts_stats[key]["family"])+postfix] = key
|
||||
elseif(sortColumn == "column_last") then
|
||||
elseif(sortColumn == "column_last") then
|
||||
vals[(now-hosts_stats[key]["seen.last"]+1)+postfix] = key
|
||||
elseif(sortColumn == "column_category") then
|
||||
elseif(sortColumn == "column_category") then
|
||||
if(hosts_stats[key]["category"] == nil) then hosts_stats[key]["category"] = "" end
|
||||
vals[hosts_stats[key]["category"]..postfix] = key
|
||||
elseif(sortColumn == "column_httpbl") then
|
||||
elseif(sortColumn == "column_httpbl") then
|
||||
if(hosts_stats[key]["httpbl"] == nil) then hosts_stats[key]["httpbl"] = "" end
|
||||
vals[hosts_stats[key]["httpbl"]..postfix] = key
|
||||
elseif(sortColumn == "column_asn") then
|
||||
elseif(sortColumn == "column_asn") then
|
||||
vals[hosts_stats[key]["asn"]..postfix] = key
|
||||
elseif(sortColumn == "column_country") then
|
||||
elseif(sortColumn == "column_country") then
|
||||
vals[hosts_stats[key]["country"]..postfix] = key
|
||||
elseif(sortColumn == "column_vlan") then
|
||||
elseif(sortColumn == "column_vlan") then
|
||||
vals[hosts_stats[key]["vlan"]..postfix] = key
|
||||
elseif(sortColumn == "column_thpt") then
|
||||
elseif(sortColumn == "column_thpt") then
|
||||
vals[hosts_stats[key]["throughput_"..throughput_type]+postfix] = key
|
||||
elseif(sortColumn == "column_queries") then
|
||||
elseif(sortColumn == "column_queries") then
|
||||
vals[hosts_stats[key]["queries.rcvd"]+postfix] = key
|
||||
elseif(sortColumn == "column_ip") then
|
||||
elseif(sortColumn == "column_ip") then
|
||||
vals[hosts_stats[key]["ipkey"]+postfix] = key
|
||||
else
|
||||
-- io.write(key.."\n")
|
||||
-- io.write(hosts_stats[key].."\n")
|
||||
-- for k,v in pairs(hosts_stats[key]) do io.write(k.."\n") end
|
||||
|
||||
vals[(hosts_stats[key]["bytes.sent"]+hosts_stats[key]["bytes.rcvd"])+postfix] = key
|
||||
-- looking_glass_criteria
|
||||
elseif(criteria ~= nil) then
|
||||
-- io.write("==> "..criteria.."\n")
|
||||
if(sortColumn == "column_"..criteria) then
|
||||
vals[hosts_stats[key]["criteria"][criteria_key]+postfix] = key
|
||||
--io.write(key.."="..hosts_stats[key]["criteria"][criteria_key].."\n")
|
||||
end
|
||||
end
|
||||
else
|
||||
-- io.write(key.."\n")
|
||||
-- io.write(hosts_stats[key].."\n")
|
||||
-- for k,v in pairs(hosts_stats[key]) do io.write(k.."\n") end
|
||||
|
||||
vals[(hosts_stats[key]["bytes.sent"]+hosts_stats[key]["bytes.rcvd"])+postfix] = key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -375,10 +396,14 @@ for _key, _value in pairsByKeys(vals, funct) do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
print(", \"column_since\" : \"" .. secondsToTime(now-value["seen.first"]+1) .. "\", ")
|
||||
print("\"column_last\" : \"" .. secondsToTime(now-value["seen.last"]+1) .. "\", ")
|
||||
|
||||
if(criteria ~= nil) then
|
||||
-- io.write(criteria_key.."\n")
|
||||
print("\"column_"..criteria.."\" : \"" .. criteria_format(value["criteria"][criteria_key]) .. "\", ")
|
||||
end
|
||||
|
||||
if((value["throughput_trend_"..throughput_type] ~= nil) and
|
||||
(value["throughput_trend_"..throughput_type] > 0)) then
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue