-- -- (C) 2013-17 - ntop.org -- dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path if(ntop.isPro()) then package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path require "snmp_utils" shaper_utils = require("shaper_utils") host_pools_utils = require "host_pools_utils" end require "lua_utils" require "graph_utils" require "alert_utils" require "historical_utils" local json = require ("dkjson") local host_pools_utils = require "host_pools_utils" debug_hosts = false page = _GET["page"] protocol_id = _GET["protocol"] application = _GET["application"] host_info = url2hostinfo(_GET) host_ip = host_info["host"] host_name = hostinfo2hostkey(host_info) host_vlan = host_info["vlan"] or 0 always_show_hist = _GET["always_show_hist"] ntopinfo = ntop.getInfo() active_page = "hosts" interface.select(ifname) ifstats = interface.getStats() ifId = ifstats.id is_packetdump_enabled = isLocalPacketdumpEnabled() host = nil family = nil prefs = ntop.getPrefs() local hostkey = hostinfo2hostkey(host_info, nil, true --[[ force show vlan --]]) local labelKey = host_info["host"].."@"..host_info["vlan"] if((host_name == nil) or (host_ip == nil)) then sendHTTPContentTypeHeader('text/html') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") print("
" .. i18n("host_details.host_parameter_missing_message") .. "
") return end if(protocol_id == nil) then protocol_id = "" end -- print(">>>") print(host_info["host"]) print("<<<") if(debug_hosts) then traceError(TRACE_DEBUG,TRACE_CONSOLE, i18n("host_details.trace_debug_host_info",{hostinfo=host_info["host"],vlan=host_vlan}).."\n") end host = interface.getHostInfo(host_info["host"], host_vlan) restoreFailed = false if((host == nil) and ((_POST["mode"] == "restore") or (page == "historical"))) then if(debug_hosts) then traceError(TRACE_DEBUG,TRACE_CONSOLE, i18n("host_details.trace_debug_restored_host_info").."\n") end interface.restoreHost(host_info["host"], host_vlan) host = interface.getHostInfo(host_info["host"], host_vlan) restoreFailed = true end only_historical = false local host_pool_id = nil if (host ~= nil) then if (isAdministrator() and (_POST["pool"] ~= nil)) then host_pool_id = _POST["pool"] local prev_pool = tostring(host["host_pool_id"]) if host_pool_id ~= prev_pool then local key = host2member(host["ip"], host["vlan"]) if not host_pools_utils.changeMemberPool(ifId, key, host_pool_id, host) then host_pool_id = nil else interface.reloadHostPools() end end end if (host_pool_id == nil) then host_pool_id = tostring(host["host_pool_id"]) end end if(host == nil) then if (rrd_exists(host_ip, "bytes.rrd") and always_show_hist == "true") then page = "historical" only_historical = true sendHTTPContentTypeHeader('text/html') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") print [[
]] else -- We need to check if this is an aggregated host if(not(restoreFailed) and (host_info ~= nil) and (host_info["host"] ~= nil)) then json = ntop.getCache(host_info["host"].. "." .. ifId .. ".json") end sendHTTPContentTypeHeader('text/html') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") if page == "alerts" then print('') else dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") print('
'.. i18n("host_details.host_cannot_be_found_message",{host=hostinfo2hostkey(host_info)}) .. " ") if((json ~= nil) and (json ~= "")) then print[[
]] print[[]] print[[]] print[[
]] print[[ ]] print(i18n("host_details.restore_from_cache_message",{js_code="\"javascript:void(0);\" onclick=\"$(\'#host_restore_form\').submit();\""})) else print(purgedErrorString()) end print("
") dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua") end return end else sendHTTPContentTypeHeader('text/html') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") print("\n") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") -- Added global javascript variable, in order to disable the refresh of pie chart in case -- of historical interface print('\n\n') if(host["ip"] ~= nil) then host_name = hostinfo2hostkey(host) host_info["host"] = host["ip"] end if(_POST["custom_name"] ~=nil) then setHostAltName(hostinfo2hostkey(host_info), _POST["custom_name"]) end host["label"] = getHostAltName(hostinfo2hostkey(host_info), host["mac"]) if((host["label"] == nil) or (host["label"] == "")) then host["label"] = getHostAltName(host["ip"]) end hostbase = dirs.workingdir .. "/" .. ifId .. "/rrd/" .. getPathFromKey(hostinfo2hostkey(host_info)) rrdname = hostbase .. "/bytes.rrd" -- print(rrdname) print [[
]] --tprint(host) if((page == "overview") or (page == nil)) then print("\n") if(host["ip"] ~= nil) then if(host["mac"] ~= "00:00:00:00:00:00") then print("') end if(host['localhost'] and (host["mac"] ~= "") and (info["version.enterprise_edition"])) then local ports = find_mac_snmp_ports(host["mac"], _GET["snmp_recache"] == "true") if(ports ~= nil) then local rsps = 1 for snmp_device_ip,port in pairs(ports) do rsps = rsps + 1 end if(rsps > 1) then print('') print("\n") for snmp_device_ip,port in pairs(ports) do local community = get_snmp_community(snmp_device_ip) local trunk print("") if(port.trunk) then trunk = ' trunk' else trunk = "" end print("\n") end end end end print("") print("") else if(host["mac"] ~= nil) then print("\n") end end if(ifstats.vlan and (host["vlan"] ~= nil)) then print("\n") end if(host["os"] ~= "") then print("") if(host["os"] ~= "") then print("\n") else print("\n") end print("") end if((host["asn"] ~= nil) and (host["asn"] > 0)) then print("") print('') print("\n") end if(host["ip"] ~= nil) then if(host["name"] == nil) then host["name"] = getResolvedAddress(hostkey2hostinfo(host["ip"])) end print("") if(isAdministrator()) then print("\n") end if(host["num_alerts"] > 0) then print("\n") end if ntop.isPro() and ifstats.inline and (host["has_blocking_quota"] or host["has_blocking_shaper"]) then print("") end print("\n") print("\n") if((host["bytes.sent"]+host["bytes.rcvd"]) > 0) then print("\n") end print("\n") local flows_th = i18n("details.flows_non_packet_iface") if interface.isPacketInterface() then if interface.isPcapDumpInterface() == false then flows_th = i18n("details.flows_packet_iface") else flows_th = i18n("details.flows_packet_pcap_dump_iface") end end print("\n") print("") print("") if host["tcp.packets.seq_problems"] == true then print("\n") print("\n") print("\n") end if((host["info"] ~= nil) or (host["label"] ~= nil))then print("\n") end if(host["json"] ~= nil) then print("\n") end print("
"..i18n("details.router_access_point_mac_address").."" ..get_symbolic_mac(host["mac"]).. " "..getHostIcon(host["mac"])) print(' 
'.. i18n("details.host_snmp_localization") ..'

'..i18n("details.note")..': '..i18n("details.note_hosts_located_snmp_device",{url="https://tools.ietf.org/html/rfc4188"})..'

"..i18n("snmp.snmp_device")..""..i18n("details.device_port").."
"..getResolvedAddress(hostkey2hostinfo(snmp_device_ip))..""..port.id.." "..get_snmp_port_label(snmp_device_ip, community, port.id)..""..trunk.."
"..i18n("ip_address").."" .. host["ip"]) if(host.childSafe == true) then print(getSafeChildIcon()) end historicalProtoHostHref(getInterfaceId(ifname), host["ip"], nil, nil, nil) if(host["local_network_name"] ~= nil) then print(" [ ".. host["local_network_name"].." ]") end if((host["city"] ~= nil) and (host["city"] ~= "")) then print(" [ " .. host["city"] .." "..getFlag(host["country"]).." ]") end print[[]] print(i18n("details.host_pool")..": ") if not ifstats.isView then print[[]] print(host_pools_utils.getPoolName(ifId, host_pool_id)) print[[]] print[[  ]] print[[]] else -- no link for view interfaces print(host_pools_utils.getPoolName(ifId, host_pool_id)) end print("
"..i18n("mac_address").."" .. host["mac"].. "
") if(ifstats.sprobe) then print(i18n("details.source_id")) else print(i18n("details.vlan_id")) end print(""..host["vlan"].."
"..i18n("os").." "..mapOS2Icon(host["os"]) .. "
"..i18n("asn").."") print(""..host.asname.." [ "..i18n("asn").." ".. host.asn.." ]'..i18n("details.whois_lookup")..'
"..i18n("name").." ") else print("") end if(host["ip"] == host["name"]) then print(" ") end --tprint(host) io.write("\n") print(host["name"] .. " ") print[[ ]] print[[ ]] if(host["localhost"] == true) then print(''..i18n("details.label_local_host")..'') else print(''..i18n("details.label_remote")..'') end if(host["privatehost"] == true) then print(' '..i18n("details.label_private_ip")..'') end if(host["systemhost"] == true) then print(' '..i18n("details.label_system_ip")..' '..'') end if(host["is_blacklisted"] == true) then print(' '..i18n("details.label_blacklisted_host")..'') end print(getHostIcon(labelKey)) print("
"..i18n("details.alerts").." "..host["num_alerts"] .. "
"..i18n("host_details.blocked_traffic").."") if host["has_blocking_quota"] then if host["has_blocking_shaper"] then print(i18n("host_details.host_traffic_blocked_quota_and_shaper")) else print(i18n("host_details.host_traffic_blocked_quota")) end else print(i18n("host_details.host_traffic_blocked_shaper")) end print(".") print("
"..i18n("details.first_last_seen").."" .. formatEpoch(host["seen.first"]) .. " [" .. secondsToTime(os.time()-host["seen.first"]) .. " "..i18n("details.ago").."]" .. "" .. formatEpoch(host["seen.last"]) .. " [" .. secondsToTime(os.time()-host["seen.last"]) .. " "..i18n("details.ago") .. "]" .. "
"..i18n("details.sent_vs_received_traffic_breakdown").."") breakdownBar(host["bytes.sent"], i18n("sent"), host["bytes.rcvd"], i18n("details.rcvd"), 0, 100) print("
"..i18n("details.traffic_sent_received").."" .. formatPackets(host["packets.sent"]) .. " / ".. bytesToSize(host["bytes.sent"]) .. " " .. formatPackets(host["packets.rcvd"]) .. " / ".. bytesToSize(host["bytes.rcvd"]) .. "
"..flows_th.."'"..i18n("details.as_client").."''"..i18n("details.as_server").."'
" .. formatValue(host["active_flows.as_client"]) .. " \n") print("/ " .. formatValue(host["flows.as_client"]) .. " \n") if interface.isPacketInterface() then print("/ " .. formatValue(host["low_goodput_flows.as_client"]) .. " \n") end print("" .. formatValue(host["active_flows.as_server"]) .. " \n") print("/ "..formatValue(host["flows.as_server"]) .. " \n") if interface.isPacketInterface() then print("/ " .. formatValue(host["low_goodput_flows.as_server"]) .. " \n") end print("
"..i18n("details.tcp_packets_sent_analysis")..""..i18n("details.retransmissions").."".. formatPackets(host["tcp.packets.retransmissions"]) .."
"..i18n("details.out_of_order").."".. formatPackets(host["tcp.packets.out_of_order"]) .."
"..i18n("details.lost").."".. formatPackets(host["tcp.packets.lost"]) .."
"..i18n("details.further_host_names_information").."") if(host["info"] ~= nil) then print(host["info"]) end if((host["label"] ~= nil) and (host["info"] ~= host["label"])) then print(host["label"]) end print("
JSON "..i18n("download").."
\n") elseif((page == "packets")) then print [[ ]] if(host["bytes.sent"] > 0) then print('') end if(host["bytes.rcvd"] > 0) then print('') end if (host["tcp.packets.rcvd"] + host["tcp.packets.sent"] > 0) then print('') end if (not isEmptyString(host["mac"])) and (host["mac"] ~= "00:00:00:00:00:00") then local macinfo = interface.getMacInfo(host["mac"], host_info["vlan"]) if (macinfo ~= nil) and (macinfo["arp_requests.sent"] + macinfo["arp_requests.rcvd"] + macinfo["arp_replies.sent"] + macinfo["arp_replies.rcvd"] > 0) then print('') end end hostinfo2json(host_info) print [[
'..i18n("packets_page.sent_distribution")..'
'..i18n("packets_page.received_distribution")..'
'..i18n("packets_page.tcp_flags_distribution")..'
'..i18n("packets_page.arp_distribution")..'

]] elseif((page == "ports")) then print [[ ]] if(host["bytes.sent"] > 0) then print('') end if(host["bytes.rcvd"] > 0) then print('') end hostinfo2json(host_info) print [[
'..i18n("ports_page.client_ports")..'
'..i18n("ports_page.server_ports")..'

]] elseif((page == "peers")) then host_info = url2hostinfo(_GET) peers = getTopFlowPeers(hostinfo2hostkey(host_info), 1 --[[exists query]]) found = 0 for key, value in pairs(peers) do found = 1 break end if(found) then print [[
]] print(i18n("peers_page.top_peers_for_host",{hostkey=hostinfo2hostkey(host_info)})) print [[
]] print(i18n("peers_page.top_peer_protocol")) print[[

]] print(i18n("peers_page.host")) print[[ ]] print(i18n("l7_protocol")) print[[ ]] print(i18n("peers_page.traffic_volume")) print[[
]] else print(" "..i18n("peers_page.no_active_flows_message").."
") end elseif((page == "traffic")) then total = 0 for id, _ in ipairs(l4_keys) do k = l4_keys[id][2] if(host[k..".bytes.sent"] ~= nil) then total = total + host[k..".bytes.sent"] end if(host[k..".bytes.rcvd"] ~= nil) then total = total + host[k..".bytes.rcvd"] end end if(total == 0) then print("
"..i18n("traffic_page.no_traffic_observed_message").."
") else print [[

]] print("

\n") for id, _ in ipairs(l4_keys) do label = l4_keys[id][1] k = l4_keys[id][2] sent = host[k..".bytes.sent"] if(sent == nil) then sent = 0 end rcvd = host[k..".bytes.rcvd"] if(rcvd == nil) then rcvd = 0 end if((sent > 0) or (rcvd > 0)) then print("\n") end end print("
]] print(i18n("traffic_page.l4_proto_overview")) print[[
"..i18n("protocol")..""..i18n("sent")..""..i18n("received")..""..i18n("breakdown")..""..i18n("total").."
") fname = getRRDName(ifId, hostinfo2hostkey(host_info), k) if(not ntop.exists(fname)) then print("".. label .."") else print(label) end t = sent+rcvd historicalProtoHostHref(ifId, host, l4_keys[id][3], nil, nil) print("" .. bytesToSize(sent) .. "" .. bytesToSize(rcvd) .. "") breakdownBar(sent, i18n("sent"), rcvd, i18n("traffic_page.rcvd"), 0, 100) print("" .. bytesToSize(t).. "" .. round((t * 100)/total, 2).. " %
\n") print("\n") end elseif((page == "ICMP")) then print [[
]] print(i18n("icmp_page.icmp_message")) print[[]] print(i18n("icmp_page.last_sent_peer")) print[[]] print(i18n("icmp_page.last_rcvd_peer")) print[[]] print(i18n("breakdown")) print[[]] print(i18n("icmp_page.packets_sent")) print[[]] print(i18n("icmp_page.packets_received")) print[[]] print(i18n("total")) print[[
]] elseif((page == "ndpi")) then if(host["ndpi"] ~= nil) then print [[

]] print("

]] print(i18n("ndpi_page.protocol_overview")) print[[
\n") local direction_filter = "" local base_url = ntop.getHttpPrefix().."/lua/host_details.lua?ifid="..ifId.."&"..hostinfo2url(host_info).."&page=ndpi"; if(direction ~= nil) then direction_filter = '' end print('
') print('
') print [[ ]] print("\n") print ('\n') print ("") print("
"..i18n("ndpi_page.application_protocol")..""..i18n("duration")..""..i18n("sent")..""..i18n("received")..""..i18n("breakdown")..""..i18n("total").."
\n") print [[ ]] end elseif(page == "activities") then print("\n") print [[ ]] print("
]] print(i18n("activities_page.host_activity")) print[[

\n") elseif(page == "dns") then if(host["dns"] ~= nil) then print("\n") print("") print("") print("") print("") if(host["dns"]["sent"]["num_queries"] > 0) then print [[ ]] end print("") print("") print("") if(host["dns"]["rcvd"]["num_queries"] > 0) then print [[ ]] end print('') local dns_ratio = tonumber(host["dns"]["sent"]["num_queries"]) / tonumber(host["dns"]["rcvd"]["num_replies_ok"]+host["dns"]["rcvd"]["num_replies_error"]) local dns_ratio_str = string.format("%.2f", dns_ratio) if(dns_ratio < 0.9) then dns_ratio_str = "".. dns_ratio_str .."" end print('
"..i18n("dns_page.dns_breakdown")..""..i18n("dns_page.queries")..""..i18n("dns_page.positive_replies")..""..i18n("dns_page.error_replies")..""..i18n("dns_page.reply_breakdown").."
"..i18n("sent").."".. formatValue(host["dns"]["sent"]["num_queries"]) .." ".. formatValue(host["dns"]["sent"]["num_replies_ok"]) .." ".. formatValue(host["dns"]["sent"]["num_replies_error"]) .." ") breakdownBar(host["dns"]["sent"]["num_replies_ok"], "OK", host["dns"]["sent"]["num_replies_error"], "Error", 0, 100) print("
]] print(i18n("dns_page.dns_query_sent_distribution")) print[[
"..i18n("dns_page.rcvd").."".. formatValue(host["dns"]["rcvd"]["num_queries"]) .." ".. formatValue(host["dns"]["rcvd"]["num_replies_ok"]) .." ".. formatValue(host["dns"]["rcvd"]["num_replies_error"]) .." ") breakdownBar(host["dns"]["rcvd"]["num_replies_ok"], "OK", host["dns"]["rcvd"]["num_replies_error"], "Error", 50, 100) print("
DNS Rcvd Query Distribution
'..i18n("dns_page.request_vs_reply")..''..i18n("dns_page.ratio")..''..i18n("breakdown")..'
'.. dns_ratio_str ..'') breakdownBar(host["dns"]["sent"]["num_queries"], i18n("dns_page.queries"), host["dns"]["rcvd"]["num_replies_ok"]+host["dns"]["rcvd"]["num_replies_error"], i18n("dns_page.replies"), 30, 70) print [[
]] print(i18n("dns_page.note")) print[[:
]] print(i18n("dns_page.note_dns_ratio")) print[[
]] end elseif(page == "http") then if(http ~= nil) then print("\n") if(host["sites"] ~= nil) then local top_sites = json.decode(host["sites"], 1, nil) local top_sites_old = json.decode(host["sites.old"], 1, nil) old_top_len = table.len(top_sites_old) if(old_top_len > 10) then old_top_len = 10 end top_len = table.len(top_sites) if(top_len > 10) then top_len = 10 end if(old_top_len > top_len) then num = old_top_len else num = top_len end print("\n") sites = {} for k,v in pairsByValues(top_sites, rev) do table.insert(sites, { k, v }) end sites_old = {} for k,v in pairsByValues(top_sites_old, rev) do table.insert(sites_old, { k, v }) end for i=1,num do if(sites[i] == nil) then sites[i] = { "", 0 } end if(sites_old[i] == nil) then sites_old[i] = { "", 0 } end print("\n") else print(" \n") end if(sites_old[i][1] ~= "") then print("\n") else print(" \n") end end end print("") print("") print("") print("") print("") print("") print("") print("") print("") print("") print("") print("") print("") vh = http["virtual_hosts"] if(vh ~= nil) then local now = os.time() local ago1h = now - 3600 num = table.len(vh) if(num > 0) then local ifId = getInterfaceId(ifname) print("\n") for k,v in pairsByKeys(vh, asc) do local j = string.gsub(k, "%.", "___") print("") print("") print("") print("\n") end end end print("
"..i18n("http_page.top_visited_sites")..""..i18n("http_page.current_sites")..""..i18n("http_page.contacts")..""..i18n("http_page.last_5_minutes_sites")..""..i18n("http_page.contacts").."
") if(sites[i][1] ~= "") then print(formatWebSite(sites[i][1])..""..sites[i][2].." "..formatWebSite(sites_old[i][1])..""..sites_old[i][2].."
 
"..i18n("http_page.http_queries")..""..i18n("http_page.method")..""..i18n("http_page.requests")..""..i18n("http_page.distribution").."
GET".. formatValue(http["sender"]["query"]["num_get"]) .." ") print [[
]] print("
POST".. formatValue(http["sender"]["query"]["num_post"]) .."
HEAD".. formatValue(http["sender"]["query"]["num_head"]) .."
PUT".. formatValue(http["sender"]["query"]["num_put"]) .."
"..i18n("http_page.other_method").."".. formatValue(http["sender"]["query"]["num_other"]) .."
 
"..i18n("http_page.http_responses")..""..i18n("http_page.response_code")..""..i18n("http_page.responses")..""..i18n("http_page.distribution").."
"..i18n("http_page.response_code_1xx").."".. formatValue(http["receiver"]["response"]["num_1xx"]) .." ") print [[
]] print("
"..i18n("http_page.response_code_2xx").."".. formatValue(http["receiver"]["response"]["num_2xx"]) .."
"..i18n("http_page.response_code_3xx").."".. formatValue(http["receiver"]["response"]["num_3xx"]) .."
"..i18n("http_page.response_code_4xx").."".. formatValue(http["receiver"]["response"]["num_4xx"]) .."
"..i18n("http_page.response_code_5xx").."".. formatValue(http["receiver"]["response"]["num_5xx"]) .."
"..i18n("http_page.virtual_hosts").."Name"..i18n("http_page.traffic_sent")..""..i18n("http_page.traffic_received")..""..i18n("http_page.requests_served").."
"..k.." ") historicalProtoHostHref(ifId, host, nil, nil, k) print(""..bytesToSize(vh[k]["bytes.sent"])..""..bytesToSize(vh[k]["bytes.rcvd"])..""..formatValue(vh[k]["http.requests"]).."
\n") end elseif(page == "flows") then print [[
]] end elseif(page == "categories") then print [[
]] print(i18n("categories_page.traffic_categories")) print[[
]] print(i18n("categories_page.note")) print[[:
  • ]] print(i18n("categories_page.note_percentages")) if ntop.getCache("ntopng.prefs.host_categories_rrd_creation") ~= "1" then print("
  • "..i18n("categories_page.note_historical_per_category_traffic",{url=ntop.getHttpPrefix().."/lua/admin/prefs.lua"})) print(" "..i18n("categories_page.note_rrd_samples").."
  • ") else print("
  • ".. i18n("categories_page.note_category_label").."
  • ") end print [[
]] elseif(page == "snmp" and ntop.isPro()) then local sys_object_id = true local community = get_snmp_community(host_ip) local snmp_devices = get_snmp_devices() if snmp_devices[host_ip] == nil then -- host has not been configured local msg = i18n("snmp_page.not_configured_as_snmp_device_message",{host_ip=host_ip}) msg = msg.." "..i18n("snmp_page.guide_snmp_page_message",{url=ntop.getHttpPrefix().."/lua/pro/enterprise/snmpdevices_stats.lua"}) local trying = " "..i18n("snmp_page.trying_to_retrive_message",{community=community}) trying = trying.. " " if ntop.isEnterprise() then print("
"..msg.."
") end print(trying) sys_object_id = get_snmp_value(host_ip, community, "1.3.6.1.2.1.1.2.0", false) end if(sys_object_id ~= nil) then print("") print_snmp_report(host_ip, true) else print("") end elseif(page == "talkers") then print("
") print('
') dofile(dirs.installdir .. "/scripts/lua/inc/sankey.lua") print("

") elseif(page == "geomap") then print("
") print [[
]] addGoogleMapsScript() print[[
]] ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/geolocation_disclaimer.inc") print [[
]] elseif(page == "jaccard") then -- NOTE: code temporarily disabled print [[
]] jaccard = interface.similarHostActivity(host_info["host"],host_info["vlan"]) if(jaccard ~= nil) then print [[ ]] vals = {} for k,v in pairs(jaccard) do vals[v] = k end max_hosts = 10 n = 0 if(host["name"] == nil) then host["name"] = getResolvedAddress(hostkey2hostinfo(host["ip"])) end for v,k in pairsByKeys(vals, rev) do if(v > 0) then if(n == 0) then print("\n") print("\n") end correlated_host = interface.getHostInfo(k) if(correlated_host ~= nil) then if(correlated_host["name"] == nil) then correlated_host["name"] = getResolvedAddress(hostkey2hostinfo(correlated_host["ip"])) end -- print the host row together with the Jaccard coefficient print("") -- print("") print("") print(""); -- print the activity map row print(" ]] print("") n = n +1 if(n >= max_hosts) then break end end end end if(n > 0) then print("
Local Hosts Similar to ".. hostinfo2hostkey(host) .."Jaccard CoefficientActivity Map
"..correlated_host["name"]..""..hostinfo2hostkey(correlated_host)..""..round(v,2)..""); print(""); print [[
\n") else print("There is no host correlated to ".. hostinfo2hostkey(host).."

\n") end print [[ Note:

]] end elseif(page == "contacts") then if(num > 0) then mode = "embed" if(host["name"] == nil) then host["name"] = getResolvedAddress(hostkey2hostinfo(host["ip"])) end name = host["name"] dofile(dirs.installdir .. "/scripts/lua/hosts_interaction.lua") print("\n") print("\n") print("") if(cnum == 0) then print("") else print("\n") end if(snum == 0) then print("") else print("\n") end print("\n") print("
"..i18n("contacts_page.client_contacts_initiator")..""..i18n("contacts_page.server_contacts_receiver").."
"..i18n("contacts_page.no_client_contacts_so_far").."\n") print("\n") -- TOFIX VLAN (We need to remove the host vlan and add the client vlan) -- Client sortTable = {} for k,v in pairs(host["contacts"]["client"]) do sortTable[v]=k end num = 0 max_num = 64 -- Do not create huge maps for _v,k in pairsByKeys(sortTable, rev) do if(num >= max_num) then break end num = num + 1 name = interface.getHostInfo(k) -- TOFIX VLAN (We need to remove the host vlan and add the client vlan) v = host["contacts"]["client"][k] info = interface.getHostInfo(k) if(info ~= nil) then if(info["name"] ~= nil) then n = info["name"] else n = getResolvedAddress(hostkey2hostinfo(info["ip"])) end url = ""..n.."" else url = k end if(info ~= nil) then url = url .. getFlag(info["country"]).." " end -- print(v.."
") print("\n") end print("
"..i18n("contacts_page.server_address")..""..i18n("contacts_page.contacts").."
"..url.."" .. formatValue(v) .. "
"..i18n("contacts_page.no_server_contacts_so_far").."\n") print("\n") -- Server sortTable = {} for k,v in pairs(host["contacts"]["server"]) do sortTable[v]=k end for _v,k in pairsByKeys(sortTable, rev) do v = host["contacts"]["server"][k] info = interface.getHostInfo(k) if(info ~= nil) then if(info["name"] ~= nil) then n = info["name"] else n = getResolvedAddress(hostkey2hostinfo(info["ip"])) end url = ""..n.."" else url = k end if(info ~= nil) then url = url ..getFlag(info["country"]).." " end print("\n") end print("
"..i18n("contacts_page.client_address")..""..i18n("contacts_page.contacts").."
"..url.."" .. formatValue(v) .. "
\n") else print(i18n("contacts_page.no_contacts_message")) end elseif(page == "alerts") then drawAlertSourceSettings(hostkey, i18n("show_alerts.host_delete_config_btn", {host=host_name}), "show_alerts.host_delete_config_confirm", "host_details.lua", {ifid=ifId, host=host_ip}, host_name, "host") elseif (page == "quotas" and ntop.isEnterprise() and host_pool_id ~= host_pools_utils.DEFAULT_POOL_ID and ifstats.inline) then local page_params = {ifid=ifId, pool=host_pool_id, host=hostkey, page=page} host_pools_utils.printQuotas(host_pool_id, host, page_params) elseif (page == "config") then if(not isAdministrator()) then return end if(host["localhost"] == true and is_packetdump_enabled) then local dump_status = host["dump_host_traffic"] if(_POST["dump_traffic"] ~= nil) then if(_POST["dump_traffic"] == "true") then dump_status = true else dump_status = false end interface.select(ifname) -- if we submitted a form, nothing is select()ed interface.setHostDumpPolicy(dump_status, host_info["host"], host_vlan) end if(dump_status) then dump_traffic_checked = 'checked="checked"' dump_traffic_value = "false" -- Opposite else dump_traffic_checked = "" dump_traffic_value = "true" -- Opposite end end local trigger_alerts = true local trigger_alerts_checked = "checked" if host["localhost"] == true then if (_POST["trigger_alerts"] ~= nil) then if _POST["trigger_alerts"] ~= "true" then trigger_alerts = false trigger_alerts_checked = "" end ntop.setHashCache(get_alerts_suppressed_hash_name(getInterfaceId(ifname)), hostkey, tostring(trigger_alerts)) interface.select(ifname) interface.refreshHostsAlertsConfiguration(host_ip, host_vlan) else trigger_alerts = ntop.getHashCache(get_alerts_suppressed_hash_name(getInterfaceId(ifname)), hostkey) if trigger_alerts == "false" then trigger_alerts = false trigger_alerts_checked = "" end end end if(_POST["custom_icon"] ~= nil) then setHostIcon(labelKey, _POST["custom_icon"]) end print[[ ]] if not ifstats.isView then printPoolChangeDropdown(host_pool_id) end if host["localhost"] then print [[]] end print [[]] if(ifstats.inline and (host.localhost or host.systemhost)) then -- Traffic policy drop_host_traffic = _POST["drop_host_traffic"] host_key = hostinfo2hostkey(host_info) if(drop_host_traffic ~= nil) then if(drop_host_traffic == "false") then ntop.delHashCache("ntopng.prefs.drop_host_traffic", host_key) else ntop.setHashCache("ntopng.prefs.drop_host_traffic", host_key, drop_host_traffic) end interface.updateHostTrafficPolicy(host_info["host"], host_vlan) else drop_host_traffic = ntop.getHashCache("ntopng.prefs.drop_host_traffic", host_key) if(drop_host_traffic == nil) then drop_host_traffic = "false" end end print("') print('') print('') end print[[
]] print(i18n("host_config.host_alias")) print[[
]] pickIcon(labelKey, host["mac"]) print [[  
]] print(i18n("host_config.trigger_host_alerts")) print[[
]] print(i18n("host_config.trigger_alerts_for_host",{host=host["name"]})) print[[
]] print(i18n("host_config.dump_host_traffic")) print[[
]] print(i18n("host_config.dump_traffic")) print[[
" .. i18n("host_config.host_traffic_policy") .. "") if(host["localhost"] == true) then drop_traffic = ntop.getHashCache("ntopng.prefs.drop_host_traffic", host_key) if(drop_traffic == "true") then drop_traffic_checked = 'checked="checked"' drop_traffic_value = "false" -- Opposite else drop_traffic_checked = "" drop_traffic_value = "true" -- Opposite end print[[
]] print(' '..i18n("host_config.drop_all_host_traffic")..'') print('\n') print('
') end print[[]] print(i18n("host_config.modify_host_pool_policy_btn")) print[[]] print('
]] elseif(page == "historical") then if(_GET["rrd_file"] == nil) then rrdfile = "bytes.rrd" else rrdfile=_GET["rrd_file"] end host_url = "host="..host_ip host_key = host_ip if(host_vlan and (host_vlan > 0)) then host_url = host_url.."&vlan="..host_vlan host_key = host_key.."@"..host_vlan end drawRRD(ifId, host_key, rrdfile, _GET["zoom"], ntop.getHttpPrefix()..'/lua/host_details.lua?ifid='..ifId..'&'..host_url..'&page=historical', 1, _GET["epoch"], nil, makeTopStatsScriptsArray()) elseif(page == "traffic_report") then dofile(dirs.installdir .. "/pro/scripts/lua/enterprise/traffic_report.lua") elseif(page == "sprobe") then print [[
]] print [[
Show :
Aggregated by :

]] print(i18n("sprobe_page.top_users")) print[[
]] print [[
Show :
Aggregated by :

]] print(i18n("sprobe_page.top_processes")) print[[
]] print [[
Show :
Aggregated by :

]] print(i18n("sprobe_page.processes_traffic_tree")) print[[
]] print(i18n("sprobe_page.show_more_info")) print[[
]] print [[
]] print [[ ]] -- End Sprobe Page end end if (host ~= nil) then print[[]] print [[ ]] end dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")