-- -- (C) 2013-17 - ntop.org -- local dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "lua_utils" local discover = require "discover_utils" local ifId = getInterfaceId(ifname) local refresh_button = '' if _GET["request_discovery"] == "true" then refresh_button = "" discover.requestNetworkDiscovery(ifId) end local discovery_requested = discover.networkDiscoveryRequested(ifId) if discovery_requested then refresh_button = "" end sendHTTPContentTypeHeader('text/html') ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua") -- print('

'..i18n("discover.network_discovery")..' 


') print('

'..i18n("discover.network_discovery")..' '..refresh_button..'


') local discovered = discover.discover2table(ifname) if discovery_requested then print("") print('
 '..i18n('discover.network_discovery_not_enabled', {url=ntop.getHttpPrefix().."/lua/admin/prefs.lua?tab=discovery", flask_icon=""})..'
') elseif discovered["status"]["code"] == "NOCACHE" then -- nothing to show and nothing has been requested print('
 '..discovered["status"]["message"]..'
') end if discovered["status"]["code"] == "ERROR" then print('
 '..discovered["status"]["message"]..'
') elseif discovered["status"]["code"] == "OK" then -- everything is ok print("") print("") print("") print("") for _, el in ipairs(discovered["devices"] or {}) do print("") -- IP print("\n") -- Name print("\n") -- Manufacturer print("\n") -- Mac print("\n") -- OS print("\n") -- Information print("\n") -- Device print("\n") print("") end end print("
"..i18n("discover.network_discovery_datetime")..""..formatEpoch(discovered["discovery_timestamp"]).."
"..i18n("ip_address")..""..i18n("name")..""..i18n("mac_stats.manufacturer")..""..i18n("mac_address")..""..i18n("os")..""..i18n("info")..""..i18n("discover.device").."
") print(""..tostring(el["ip"]).."") if el["icon"] then print(el["icon"] .. " ") end if el["ghost"] then print(' '..discover.ghost_icon..'') end print("") if el["sym"] then print(el["sym"]) end if el["symIP"] then if el["sym"] then print(" ["..el["symIP"].."]") else print(el["symIP"]) end end print("") if el["manufacturer"] then print(el["manufacturer"]) else print(get_manufacturer_mac(el["mac"])) end if el["modelName"] then print(" ["..el["modelName"].."]") end print("") print(""..el["mac"].." ") print("") local mac_info = interface.getMacInfo(el.mac, 0) -- 0 = vlanId if(mac_info ~= nil) then print(getOperatingSystemIcon(mac_info.operatingSystem)) else print(" ") end print("") if el["information"] then print(table.concat(el["information"], "
")) end if el["url"] then if el["information"] then print("
"..el["url"]) else print(el["url"]) end end print("
") if el["device_label"] then print(el["device_label"]) end print("
\n") if(discovered["ghost_found"]) then print('NOTE: The '..discover.ghost_icon..' icon highlights ghost hosts (i.e. they do not belong to the interface IP address network).') end dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")