-- -- (C) 2013-17 - ntop.org -- dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path local shaper_utils if(ntop.isPro()) then package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path require "snmp_utils" shaper_utils = require("shaper_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 sendHTTPHeader('text/html; charset=iso-8859-1') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") print("
| (Router/AccessPoint) MAC Address | " ..get_symbolic_mac(host["mac"]).. " "..getHostIcon(host["mac"]).." | ") else if(host["localhost"] == true and is_packetdump_enabled) then print(" | ||
|---|---|---|---|---|
| Traffic Dump | ") end end print(' | |||
| Host SNMP Location | SNMP Device | Device Port | ||
| "..ntop.getResolvedAddress(host).." | ") print(""..port.id.." "..port.name..""..trunk.." | |||
| Device IP / Port Index | ".. host.deviceIP .."@"..host.deviceIfIdx.." | |||
| IP Address | " .. host["ip"]) 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 ]] print(host_pools_utils.getPoolName(ifId, host_pool_id)) print[[]] print(" | |||
| MAC Address | " .. host["mac"].. " | |||
| ") if(ifstats.sprobe) then print('Source Id') else print('VLAN ID') end print(" | "..host["vlan"].." | |||
| OS | "..mapOS2Icon(host["os"]) .. " | \n") else print(" | \n") end print(" | |
| ASN | ") print(""..host.asname.." [ ASN ".. host.asn.." ] | ") print('Whois Lookup | ') print("||
| Name | ") if(isAdministrator()) then print("") else print(" | ")
end
if(host["ip"] == host["name"]) then
print(" | \n") end if(host["num_alerts"] > 0) then print(" | |
| Alerts | "..host["num_alerts"] .. " | |||
| First / Last Seen | " .. formatEpoch(host["seen.first"]) .. " [" .. secondsToTime(os.time()-host["seen.first"]) .. " ago]" .. " | \n") print("" .. 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(" | ") 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 Analysis | Retransmissions | ".. formatPackets(host["tcp.packets.retransmissions"]) .." | ||
| Out of Order | ".. formatPackets(host["tcp.packets.out_of_order"]) .." | |||
| Lost | ".. formatPackets(host["tcp.packets.lost"]) .." | |||
| Info | "..host["info"].." | |||
| JSON | Download | |||
| Sent Distribution | |||||
|---|---|---|---|---|---|
| Received Distribution | |||||
]] elseif((page == "ports")) then 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 |
|---|
| L4 Protocol Overview | |||||
|---|---|---|---|---|---|
| Protocol | Sent | Received | Breakdown | 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, "Sent", rcvd, "Rcvd", 0, 100) print(" | " .. bytesToSize(t).. " | " .. round((t * 100)/total, 2).. " % |
| Protocol Overview | |||||
|---|---|---|---|---|---|
| Application Protocol | Sent | Received | Breakdown | Total | |
|---|---|---|---|---|---|
| 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: | |
| DNS Breakdown | Queries | Positive Replies | Error Replies | Reply Breakdown | |
|---|---|---|---|---|---|
| Sent | ".. formatValue(host["dns"]["sent"]["num_queries"]) .." | ") print("".. formatValue(host["dns"]["sent"]["num_replies_ok"]) .." | ") print("".. 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"]) .." | ") print("".. formatValue(host["dns"]["rcvd"]["num_replies_ok"]) .." | ") print("".. 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 Reply | ') breakdownBar(host["dns"]["sent"]["num_queries"], "Queries", host["dns"]["rcvd"]["num_replies_ok"]+host["dns"]["rcvd"]["num_replies_error"], "Replies", 30, 70) print(' | ||||
| Top Visited Sites | Current Sites | Contacts | Last 5 Minute Sites | Contacts |
|---|---|---|---|---|
| ") if(sites[i][1] ~= "") then print(formatWebSite(sites[i][1]).." | "..sites[i][2].." | \n") else print("\n") end if(sites_old[i][1] ~= "") then print(" | "..formatWebSite(sites_old[i][1]).." | "..sites_old[i][2].." | \n") end end end print(" |
| HTTP Queries | Method | Requests | 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"]) .." | |||
| Other Method | ".. formatValue(http["sender"]["query"]["num_other"]) .." | |||
| HTTP Responses | Response code | Responses | Distribution | |
| 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 Hosts | Name | Traffic Sent | Traffic Received | Requests Served |
| "..k.." ") historicalProtoHostHref(ifId, host, nil, nil, k) print(" | ") print(""..bytesToSize(vh[k]["bytes.sent"]).." | ") print(""..bytesToSize(vh[k]["bytes.rcvd"]).." | ") print(""..formatValue(vh[k]["http.requests"]).." | |
| Traffic Categories | |
|---|---|
|
NOTE:
| |
| Local Hosts Similar to ".. hostinfo2hostkey(host) .." | Jaccard Coefficient | Activity Map | \n") end correlated_host = interface.getHostInfo(k) if(correlated_host ~= nil) then if(correlated_host["name"] == nil) then correlated_host["name"] = ntop.getResolvedAddress(correlated_host["ip"]) end -- print the host row together with the Jaccard coefficient print("|
|---|---|---|---|
| "..correlated_host["name"].." | ") print(""..hostinfo2hostkey(correlated_host).." | ") print(""..round(v,2).." | "); -- print the activity map row print(""); print(""); print [[ | ]] print("
\n") end print [[ Note:
| Client Contacts (Initiator) | Server Contacts (Receiver) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| No client contacts so far | ") else print("
| \n")
end
if(snum == 0) then
print("No server contacts so far | ") else print("
| \n")
end
print("
| Host Alias | |
|---|---|
| Host Pool | |
| 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[[') end print[[Modify Host Pool Policy]] print(' | Host Quota | ') print(' | ') end print[[
| Top Users |
|---|
| Top Processes |
|---|
| Processes Traffic Tree |
Mouse over to show the process information or double click to show more information.
|
|---|