Removed telemetry

This commit is contained in:
MatteoBiscosi 2022-07-05 15:17:08 +02:00
parent 2e005803e3
commit 8dad513a4e
12 changed files with 1 additions and 125 deletions

View file

@ -15,7 +15,6 @@ local recovery_utils = require "recovery_utils"
local alert_entities = require "alert_entities"
local alert_consts = require "alert_consts"
local format_utils = require "format_utils"
local telemetry_utils = require "telemetry_utils"
local alerts_api = require "alerts_api"
local icmp_utils = require "icmp_utils"
local flow_risk_utils = require "flow_risk_utils"
@ -909,18 +908,6 @@ local function notify_ntopng_status(started)
end
local entity_value = ntop.getInfo().product
obj = {
entity_id = alerts_api.systemEntity(entity_value), entity_val = entity_value,
type = alert_consts.alertType("alert_process_notification"),
score = score,
message = msg,
when = os.time() }
if anomalous then
telemetry_utils.notify(obj)
end
local entity_info = alerts_api.systemEntity(entity_value)
local type_info = alert_consts.alert_types.alert_process_notification.new(
event,

View file

@ -1950,10 +1950,8 @@ local known_parameters = {
["hosts_ts_creation"] = validateChoiceInline({"off", "light", "full"}),
["ts_high_resolution"] = validateNumber,
["lbd_hosts_as_macs"] = validateBool,
["toggle_send_telemetry_data"] = validateBool,
["toggle_emit_flow_alerts"] = validateBool,
["toggle_emit_host_alerts"] = validateBool,
["telemetry_email"] = validateSingleWord,
["toggle_date_type"] = validateSingleWord,

View file

@ -170,7 +170,6 @@ page_utils.menu_entries = {
-- Help
about = {key = "about", i18n_title = "about.about", section = "about", help_link = "https://www.ntop.org/guides/ntopng/web_gui/help_menu.html?#about"},
telemetry = {key = "telemetry", i18n_title = "telemetry", section = "about"},
blog = {key = "blog", i18n_title = "about.ntop_blog", section = "about"},
telegram = {key = "telegram", i18n_title = "about.telegram", section = "about"},
report_issue = {key = "report_issue", i18n_title = "about.report_issue", section = "about"},

View file

@ -365,15 +365,6 @@ local menu_subpages = {
title = i18n("prefs.network_discovery_interval_title"),
description = i18n("prefs.network_discovery_interval_description"),
},
}}, {id="telemetry", label=i18n("prefs.telemetry"), advanced=false, pro_only=false, hidden=info.oem, entries={
toggle_send_telemetry_data = {
title = i18n("prefs.toggle_send_telemetry_data_title"),
description = i18n("prefs.toggle_send_telemetry_data_description", {product = info.product, url = ntop.getHttpPrefix() .. "/lua/telemetry.lua", ntop_org="https://www.ntop.org"}),
},
telemetry_email = {
title = i18n("prefs.telemetry_email_title"),
description = i18n("prefs.telemetry_email_description", {product = info.product, url = ntop.getHttpPrefix() .. "/lua/telemetry.lua", ntop_org="https://www.ntop.org"}),
},
}}, {id="recording", label=i18n("prefs.recording"), advanced=false, pro_only=false, hidden=(not recording_utils.isAvailable()), entries={
n2disk_license = {
title = i18n("prefs.n2disk_license_title"),
@ -417,9 +408,6 @@ local menu_subpages = {
connectivity_check_url = {
title = i18n("prefs.connectivity_check_url_title"),
description = i18n("prefs.connectivity_check_url_description"),
}, toggle_send_telemetry_data = {
title = i18n("prefs.toggle_send_telemetry_data_title"),
description = i18n("prefs.toggle_send_telemetry_data_description", { product = info.product}),
}, toggle_thpt_content = {
title = i18n("prefs.toggle_thpt_content_title"),
description = i18n("prefs.toggle_thpt_content_description"),

View file

@ -1,103 +0,0 @@
--
-- (C) 2017-22 - ntop.org
--
local json = require "dkjson"
local telemetry_utils = {}
-- local TELEMETRY_URL = "http://192.168.2.131:8000/phptest.php"
-- local TELEMETRY_URL = "http://192.168.2.131:8000"
local TELEMETRY_URL = "https://telemetry.ntop.org/crash.php"
local TELEMETRY_TIMEOUT = 3
local TELEMETRY_ENABLED_KEY = "ntopng.prefs.send_telemetry_data"
local TELEMETRY_RECORDS_SENT = "ntopng.cache.telemetry_data_sent"
local TELEMETRY_MAX_NUM_RECORDS = 5
function telemetry_utils.telemetry_enabled()
if ntop.isOffline() then
return false
end
local tm = ntop.getPref(TELEMETRY_ENABLED_KEY)
return tm == "1"
end
function telemetry_utils.telemetry_disabled()
local tm = ntop.getPref(TELEMETRY_ENABLED_KEY)
return tm == "0"
end
function telemetry_utils.notify(obj)
if telemetry_utils.telemetry_enabled() then
local mail = ntop.getPref("ntopng.prefs.telemetry_email")
if isEmptyString(mail) then
mail = nil
end
local msg = {data = obj, mail = mail, timestamp = os.time()}
local encoded_msg = json.encode(msg)
local res = ntop.httpPost(TELEMETRY_URL, encoded_msg, nil, nil, TELEMETRY_TIMEOUT, true)
if res and res["RESPONSE_CODE"] == 200 then
ntop.rpushCache(TELEMETRY_RECORDS_SENT, encoded_msg, TELEMETRY_MAX_NUM_RECORDS)
end
end
end
function telemetry_utils.dismiss_notice()
local dism = ntop.getPref(TELEMETRY_ENABLED_KEY)
local disabled = ntop.getPref("ntopng.prefs.disable_telemetry_data_message") == "1"
return not isAdministrator() or dism ~= "" or disabled
end
function telemetry_utils.print_overview()
local info = ntop.getInfo()
print("<table class=\"table table-bordered table-striped\">\n")
print[[<tr><th>]] print(i18n("telemetry_page.send_telemetry_data")) print [[</th><td>
]]
if telemetry_utils.telemetry_enabled() then
print('<span class="badge bg-success">'..i18n('prefs.telemetry_contribute')..'</span>')
elseif telemetry_utils.telemetry_disabled() then
print('<span class="badge bg-secondary">'..i18n('prefs.telemetry_do_not_contribute')..'</span>')
else -- no preference expressed
print('<i>'..i18n('telemetry_page.telemetry_data_no_consent')..'</i>')
end
if isAdministrator() then
print[[ (]] print(i18n("telemetry_page.telemetry_data_change_preference", {url = ntop.getHttpPrefix().."/lua/admin/prefs.lua?tab=telemetry"})) print[[)]]
end
print[[ </td></tr>
]]
print[[<tr><th>]] print(i18n("telemetry_page.telemetry_data")) print [[</th><td>
<b>]] print(i18n("telemetry_page.crash_report")) print[[</b>. ]] print(i18n("telemetry_page.crash_report_descr", {product=ntop.getInfo()["product"]})) print [[<br><code>{"entity_type":1,"type":20,"when":1558634220,"entity_value":"ntopng","message":"Started after anomalous termination. ]] print(info.product) print[[ v.]] print(info.version) print[[ (]] print(info.OS) print[[[pid: 28775][options: --interface \"tcp://*:1234c\" --interface \"eno1\" --interface \"view:tcp://*:1234c,eno1\" --local-networks \"192.168.2.0/24\" --disable-login \"1\" ]","severity":2}</code>
</td></tr>
]]
local transmitted_data = ntop.lrangeCache(TELEMETRY_RECORDS_SENT, 0, -1) or {}
if table.len(transmitted_data) > 0 then
print[[<tr><th>]] print(i18n("telemetry_page.last_data_sent")) print[[</th><td><code>]]
for i, msg in ipairs(transmitted_data) do
if msg then
print(noHtml(msg).."<br>")
end
end
print[[</code></td><tr>]]
end
print("</table>")
end
return telemetry_utils

View file

@ -44,16 +44,6 @@ local pages = page_utils.menu_entries
--- It's a good convention to put the predicate functions inside the module: `predicates_defined_toasts`
local defined_toats = {
{
id = 0,
dismissable = false,
has_priority = false,
predicate = predicates.contribute,
pages = EMPTY_PAGES,
subpages = EMPTY_PAGES,
excluded_pages = {pages.preferences.key},
excluded_subpages = EMPTY_PAGES
},
{
id = 1,
dismissable = false,

View file

@ -9,7 +9,6 @@ local check_utils = require("checks")
local endpoint_configs = require("endpoints")
local recipients_manager = require("recipients")
local page_utils = require('page_utils')
local telemetry_utils = require("telemetry_utils")
local toast_ui = require("toast_ui")
local stats_utils = require("stats_utils")
local delete_data_utils = require("delete_data_utils")
@ -95,23 +94,6 @@ local function create_geo_ip_toast_ui(toast)
return toast_ui:new(toast.id, title, description, ToastLevel.WARNING, nil, toast.dismissable)
end
-- ###############################################################
local function create_contribute_toast_ui(toast)
local title = i18n("about.contribute_to_project")
local description = i18n("about.telemetry_data_opt_out_msg", {
tel_url = ntop.getHttpPrefix() .. "/lua/telemetry.lua",
ntop_org = "https://www.ntop.org/"
})
local action = {
url = ntop.getHttpPrefix() .. '/lua/admin/prefs.lua?tab=telemetry',
title = i18n("configure")
}
return toast_ui:new(toast.id, title, description, ToastLevel.INFO, action, toast.dismissable)
end
-- ###############################################################
@ -330,17 +312,6 @@ function predicates.temp_working_dir(toast, container)
end
end
--- Create an instance for contribute alert toast
--- @param toast table The toast is the logic model defined in defined_toasts
--- @param container table Is the table where to put the new toast ui
function predicates.contribute(toast, container)
if not IS_ADMIN then return end
if (not info.oem) and (not telemetry_utils.dismiss_notice()) then
table.insert(container, create_contribute_toast_ui(toast))
end
end
--- @param toast table The toast is the logic model defined in defined_toasts
--- @param container table Is the table where to put the new toast ui
function predicates.update_ntopng(toast, container)