-- -- (C) 2013-20 - ntop.org -- local dirs = ntop.getDirs() require "lua_utils" local recording_utils = require "recording_utils" if((not isAdministrator()) or (not recording_utils.isAvailable())) then return end local ifstats = interface.getStats() local enabled = false local running = false local restart_req = false local custom_provider = (recording_utils.getCurrentTrafficRecordingProvider(ifstats.id) ~= "ntopng") local extraction_checks_ok, extraction_checks_msg if _POST["action"] ~= nil and _POST["action"] == "restart" then restart_req = true end if custom_provider then enabled = true running = recording_utils.isActive(ifstats.id) extraction_checks_ok, extraction_checks_msg = recording_utils.checkExtraction(ifstats.id) elseif recording_utils.isEnabled(ifstats.id) then enabled = true if recording_utils.isActive(ifstats.id) then running = true else -- failure if restart_req then recording_utils.restart(ifstats.id) end end end print("

"..i18n("traffic_recording.traffic_recording_status")) print(" ") print("


") print("\n") print("\n") print("\n") local stats = recording_utils.stats(ifstats.id) if stats ~= nil then local first_epoch = nil local last_epoch = nil local start_time = nil if stats['FirstDumpedEpoch'] ~= nil and stats['LastDumpedEpoch'] ~= nil then first_epoch = tonumber(stats['FirstDumpedEpoch']) last_epoch = tonumber(stats['LastDumpedEpoch']) end if stats['Duration'] ~= nil then local u = split(stats['Duration'], ':'); local uptime = tonumber(u[1])*24*60*60+tonumber(u[2])*60*60+tonumber(u[3])*60+u[4] start_time = os.time()-uptime end if stats['FirstDumpedEpoch'] ~= nil then print("\n") end if start_time ~= nil then print("\n") end if stats['Bytes'] ~= nil and stats['Packets'] ~= nil then print("\n") end if stats['Dropped'] ~= nil then print("\n") end end if custom_provider and running then local warn = '' if not extraction_checks_ok then warn = ' ' end print("\n") end print("\n") print("
"..i18n("interface")..""..ifstats.name.."
"..i18n("status").."") if running then print(i18n("traffic_recording.recording")) elseif enabled then print(""..i18n("traffic_recording.failure")..". "..i18n("traffic_recording.failure_note").."") if not custom_provider then print[[
]] print("  ") end else print(i18n("traffic_recording.disabled")) end print("
"..i18n("traffic_recording.dump_window").."") if first_epoch ~= nil and last_epoch ~= nil and first_epoch > 0 and last_epoch > 0 then print(formatEpoch(first_epoch).." - "..formatEpoch(last_epoch)) else print(i18n("traffic_recording.no_file")) end print("
"..i18n("traffic_recording.active_since")..""..formatEpoch(start_time)) if (start_time ~= nil) and (first_epoch ~= nil) and (first_epoch > 0) and (start_time > first_epoch) then print(' - ') print(i18n("traffic_recording.missing_data_msg")) end print("
"..i18n("if_stats_overview.received_traffic")..""..bytesToSize(stats['Bytes']).." ["..formatValue(stats['Packets']).." "..i18n("pkts").."]
"..i18n("if_stats_overview.dropped_packets")..""..stats['Dropped'].." "..i18n("pkts").."
"..i18n("traffic_recording.traffic_extractions")..""..warn..extraction_checks_msg.."
"..i18n("about.last_log").."\n") local log = recording_utils.log(ifstats.id, 32) local logs = split(log, "\n") for i = 1, #logs do local row = split(logs[i], "]: ") if row[2] ~= nil then print(row[2].."
\n") else print(row[1].."
\n") end end print("
\n")