-- -- (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 local snmp_utils = require "snmp_utils" shaper_utils = require("shaper_utils") host_pools_utils = require "host_pools_utils" end require "lua_utils" require "graph_utils" local alert_utils = require "alert_utils" require "historical_utils" local json = require ("dkjson") local host_pools_utils = require "host_pools_utils" local host_pools = require "host_pools" local page_utils = require("page_utils") local host_pool = host_pools:create() 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("
Host parameter is missing (internal error ?)
") 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, "Host:" .. 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, "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(key, prev_pool, host_pool_id) then host_pool_id = nil else ntop.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('
Host '.. hostinfo2hostkey(host_info) .. ' cannot be found. ') if((json ~= nil) and (json ~= "")) then print[[
]] print[[]] print[[]] print[[
]] print[[ Click here to restore it from cache.]] 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 = snmp_utils.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 = snmp_utils.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 = "Recently Active Flows / Total" if interface.isPacketInterface() then if interface.isPcapDumpInterface() == false then flows_th = "Active Flows / Total Active / Low Goodput" else flows_th = "Flows / Total Active / Low Goodput" 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("
(Router/AccessPoint) MAC Address" ..get_symbolic_mac(host["mac"]).. " "..getHostIcon(host["mac"])) print(' 
Host SNMP Localization

NOTE: Hosts are located in SNMP devices using the Bridge MIB.

SNMP DeviceDevice Port
"..getResolvedAddress(hostkey2hostinfo(snmp_device_ip))..""..port.id.." "..get_snmp_port_label(snmp_device_ip, community, port.id)..""..trunk.."
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[[Host Pool: ]] if not ifstats.isView then print[[]] print(host_pools_utils.getPoolName(host_pool_id)) print[[]] print[[  ]] print[[]] else -- no link for view interfaces print(host_pools_utils.getPoolName(host_pool_id)) end print("
MAC Address" .. host["mac"].. "
") if(ifstats.sprobe) then print('Source Id') else print('VLAN ID') end print(""..host["vlan"].."
OS "..mapOS2Icon(host["os"]) .. "
ASN") print(""..host.asname.." [ ASN ".. host.asn.." ]Whois Lookup
Name ") else print("") end if(host["ip"] == host["name"]) then print('
Loading...
') end --tprint(host) io.write("\n") print(host["name"] .. " ") if(host["localhost"] == true) then print('Local Host') else print('Remote') end if(host["privatehost"] == true) then print(' Private IP') end if(host["systemhost"] == true) then print(' System IP ') end if(host["is_blacklisted"] == true) then print(' Blacklisted Host') end print(getHostIcon(labelKey)) print("
Alerts "..host["num_alerts"] .. "
Blocked Traffic") print("Some host traffic has been blocked by ") if host["has_blocking_quota"] then print(" an exceeded quota") if host["has_blocking_shaper"] then print(" and ") end end if host["has_blocking_shaper"] then print(" a blocking shaper") end print(".") print("
First / Last Seen" .. formatEpoch(host["seen.first"]) .. " [" .. secondsToTime(os.time()-host["seen.first"]) .. " ago]" .. "" .. formatEpoch(host["seen.last"]) .. " [" .. secondsToTime(os.time()-host["seen.last"]) .. " ago]" .. "
Sent vs Received Traffic Breakdown") breakdownBar(host["bytes.sent"], "Sent", host["bytes.rcvd"], "Rcvd", 0, 100) print("
Traffic Sent / Received" .. formatPackets(host["packets.sent"]) .. " / ".. bytesToSize(host["bytes.sent"]) .. " " .. formatPackets(host["packets.rcvd"]) .. " / ".. bytesToSize(host["bytes.rcvd"]) .. "
"..flows_th.."'As Client''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("
TCP Packets Sent AnalysisRetransmissions".. formatPackets(host["tcp.packets.retransmissions"]) .."
Out of Order".. formatPackets(host["tcp.packets.out_of_order"]) .."
Lost".. formatPackets(host["tcp.packets.lost"]) .."
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 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 [[
Sent Distribution
Received Distribution
TCP Flags Distribution
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 [[
Client Ports
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 [[
Top ]] print(hostinfo2hostkey(host_info) ) print [[ Peers
Top Peer Protocols

Host L7 Protocol Traffic Volume
]] else print(" No active flows have been observed for the specified host
") 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("
No traffic has been observed for the specified host
") 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("
L4 Protocol Overview
ProtocolSentReceivedBreakdownTotal
") 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, "Sent", rcvd, "Rcvd", 0, 100) print("" .. bytesToSize(t).. "" .. round((t * 100)/total, 2).. " %
\n") print("\n") end elseif((page == "ICMP")) then print [[
ICMP MessageLast Sent PeerLast Rcvd PeerBreakdownPackets SentPackets ReceivedTotal
]] elseif((page == "ndpi")) then if(host["ndpi"] ~= nil) then print [[

]] print("

Protocol Overview
\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("
Application ProtocolDurationSentReceivedBreakdownTotal
\n") print [[ ]] end elseif(page == "activities") then print("\n") print [[ ]] -- Host activity stats if host["localhost"] == true then print [[ ]] -- showHostActivityStats(hostbase, "", "1h") end print("
Host Activity

Protocol Activity
User Traffic
Background Traffic
Resolution: 
]] if(ntop.getCache("ntopng.prefs.host_activity_rrd_creation") == "0") then print('Please enable Activities Timeseries preferences to save historical host activities.

') end print [[

NOTE:
The above map filters host application traffic by splitting it in real user traffic (e.g. web page access)
and background traffic (e.g. your email client periodically checks for email presence). Host traffic sent (upload)
is marked as negative value in blue, traffic received (download) is marked as positive in green.

\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('
DNS BreakdownQueriesPositive RepliesError RepliesReply Breakdown
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("
DNS Query Sent Distribution
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
Request vs ReplyRatioBreakdown
'.. dns_ratio_str ..'') breakdownBar(host["dns"]["sent"]["num_queries"], "Queries", host["dns"]["rcvd"]["num_replies_ok"]+host["dns"]["rcvd"]["num_replies_error"], "Replies", 30, 70) print [[
NOTE:
Ideally the request vs reply DNS ratio should be 1 (one reply per request). When much lower than that then there are issues worth to be investigated as it means that the number of replies received is much lower than expected and this can indicate that we are using unresponsive DNS resolvers or that they are misconfigured (e.g. they have been move to another IP).
]] 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("
Top Visited SitesCurrent SitesContactsLast 5 Minute SitesContacts
") if(sites[i][1] ~= "") then print(formatWebSite(sites[i][1])..""..sites[i][2].." "..formatWebSite(sites_old[i][1])..""..sites_old[i][2].."
 
HTTP QueriesMethodRequestsDistribution
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"]) .."
Other Method".. formatValue(http["sender"]["query"]["num_other"]) .."
 
HTTP ResponsesResponse codeResponsesDistribution
1xx (Informational)".. formatValue(http["receiver"]["response"]["num_1xx"]) .." ") print [[
]] print("
2xx (Success)".. formatValue(http["receiver"]["response"]["num_2xx"]) .."
3xx (Redirection)".. formatValue(http["receiver"]["response"]["num_3xx"]) .."
4xx (Client Error)".. formatValue(http["receiver"]["response"]["num_4xx"]) .."
5xx (Server Error)".. formatValue(http["receiver"]["response"]["num_5xx"]) .."
Virtual HostsNameTraffic SentTraffic ReceivedRequests 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 [[
Traffic Categories
NOTE:
  • Percentages are related only to classified traffic. ]] if ntop.getCache("ntopng.prefs.host_categories_rrd_creation") ~= "1" then print("
  • Historical per-category traffic data can be enabled via ntopng Preferences.") print(" When enabled, RRDs with 5-minute samples will be created for each category detected and historical data will become accessible by clicking on each category.
  • ") else print("
  • Category labels can be clicked to browse historical data.
  • ") end print [[
]] elseif(page == "snmp" and ntop.isPro()) then local sys_object_id = true local community = snmp_utils.get_snmp_community(host_ip) local snmp_devices = snmp_utils.get_snmp_devices() if snmp_devices[host_ip] == nil then -- host has not been configured local msg = "Host "..host_ip.. " has not been configured as an SNMP device." msg = msg.." Visit page SNMP to add this host to the list of configured SNMP devices." local trying = " Trying to retrieve host SNMP MIB using the default community '"..community.."'" trying = trying.. " Loading..." 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("
Client Contacts (Initiator)Server Contacts (Receiver)
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("
Server AddressContacts
"..url.."" .. formatValue(v) .. "
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("
Client AddressContacts
"..url.."" .. formatValue(v) .. "
\n") else print("No contacts for this host") 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 print[[]] 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[[
Host Alias
]] pickIcon(labelKey, host["mac"]) print [[  
Host Pool
Trigger Host Alerts
Dump Host Traffic
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('') print('
') print(' Drop All Host Traffic') print('') print('
') print('\n') print('
') end print[[Modify Host Pool Policy]] 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 :

Top Users
]] print [[
Show :
Aggregated by :

Top Processes
]] print [[
Show :
Aggregated by :

Processes Traffic Tree
Mouse over to show the process information or double click to show more information.
]] print [[
]] print [[ ]] -- End Sprobe Page end end if (host ~= nil) then print[[]] print [[ ]] end dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")