diff --git a/scripts/callbacks/system/5min/influxdb.lua b/scripts/callbacks/system/5min/influxdb.lua
index 6535154301..8d8c9c6235 100644
--- a/scripts/callbacks/system/5min/influxdb.lua
+++ b/scripts/callbacks/system/5min/influxdb.lua
@@ -7,29 +7,29 @@ local ts_utils = require("ts_utils_core")
local MAX_INFLUX_EXPORT_QUEUE_LEN = 30
local probe = {
- name = "InfluxDB",
- description = "Monitors InfluxDB health and performance",
- page_script = "influxdb_stats.lua",
- page_order = 1600,
+ name = "InfluxDB",
+ description = "Monitors InfluxDB health and performance",
+ page_script = "influxdb_stats.lua",
+ page_order = 1600,
}
-- ##############################################
local function get_memory_size_query(influxdb, schema, tstart, tend, time_step)
- --[[
- See comments in function driver:getMemoryUsage() to understand
- why it is necessary to subtract the HeapReleased from Sys.
- --]]
- local q = 'SELECT MEAN(Sys) - MEAN(HeapReleased) as mem_bytes' ..
+ --[[
+ See comments in function driver:getMemoryUsage() to understand
+ why it is necessary to subtract the HeapReleased from Sys.
+ --]]
+ local q = 'SELECT MEAN(Sys) - MEAN(HeapReleased) as mem_bytes' ..
' FROM "_internal".."runtime"' ..
" WHERE time >= " .. tstart .. "000000000 AND time <= " .. tend .. "000000000" ..
" GROUP BY TIME(".. time_step .."s)"
- return(q)
+ return(q)
end
local function get_write_success_query(influxdb, schema, tstart, tend, time_step)
- local q = 'SELECT SUM(writePointsOk) as points' ..
+ local q = 'SELECT SUM(writePointsOk) as points' ..
' FROM (SELECT '..
' (DERIVATIVE(MEAN(writePointsOk)) / '.. time_step ..') as writePointsOk' ..
' FROM "monitor"."shard" WHERE "database"=\''.. influxdb.db ..'\'' ..
@@ -37,152 +37,154 @@ local function get_write_success_query(influxdb, schema, tstart, tend, time_step
" GROUP BY id)" ..
" GROUP BY TIME(".. time_step .."s)"
- return(q)
+ return(q)
end
-- ##############################################
function probe.isEnabled()
- return(ts_utils.getDriverName() == "influxdb")
+ return(ts_utils.getDriverName() == "influxdb")
end
-- ##############################################
function probe.loadSchemas(ts_utils)
- local schema
+ local schema
- schema = ts_utils.newSchema("influxdb:storage_size", {
- metrics_type = ts_utils.metrics.gauge,
- })
- schema:addTag("ifid")
- schema:addMetric("disk_bytes")
+ schema = ts_utils.newSchema("influxdb:storage_size", {
+ metrics_type = ts_utils.metrics.gauge,
+ })
+ schema:addTag("ifid")
+ schema:addMetric("disk_bytes")
- schema = ts_utils.newSchema("influxdb:exported_points",
- {metrics_type = ts_utils.metrics.counter})
- schema:addTag("ifid")
- schema:addMetric("points")
+ schema = ts_utils.newSchema("influxdb:exported_points",
+ {metrics_type = ts_utils.metrics.counter})
+ schema:addTag("ifid")
+ schema:addMetric("points")
- schema = ts_utils.newSchema("influxdb:dropped_points",{metrics_type = ts_utils.metrics.counter})
- schema:addTag("ifid")
- schema:addMetric("points")
+ schema = ts_utils.newSchema("influxdb:dropped_points",{metrics_type = ts_utils.metrics.counter})
+ schema:addTag("ifid")
+ schema:addMetric("points")
- schema = ts_utils.newSchema("influxdb:exports", {metrics_type = ts_utils.metrics.counter})
- schema:addTag("ifid")
- schema:addMetric("num_exports")
+ schema = ts_utils.newSchema("influxdb:exports", {metrics_type = ts_utils.metrics.counter})
+ schema:addTag("ifid")
+ schema:addMetric("num_exports")
- schema = ts_utils.newSchema("influxdb:rtt", {metrics_type = ts_utils.metrics.gauge})
- schema:addTag("ifid")
- schema:addMetric("millis_rtt")
+ schema = ts_utils.newSchema("influxdb:rtt", {metrics_type = ts_utils.metrics.gauge})
+ schema:addTag("ifid")
+ schema:addMetric("millis_rtt")
- -- The following metrics are built-in into influxdb
- schema = ts_utils.newSchema("influxdb:memory_size", {
- influx_internal_query = get_memory_size_query,
- metrics_type = ts_utils.metrics.gauge, step = 10
- })
- schema:addTag("ifid")
- schema:addMetric("mem_bytes")
+ -- The following metrics are built-in into influxdb
+ schema = ts_utils.newSchema("influxdb:memory_size", {
+ influx_internal_query = get_memory_size_query,
+ metrics_type = ts_utils.metrics.gauge, step = 10
+ })
+ schema:addTag("ifid")
+ schema:addMetric("mem_bytes")
- schema = ts_utils.newSchema("influxdb:write_successes", {
- influx_internal_query = get_write_success_query,
- metrics_type = ts_utils.metrics.counter, step = 10
- })
- schema:addTag("ifid")
- schema:addMetric("points")
+ schema = ts_utils.newSchema("influxdb:write_successes", {
+ influx_internal_query = get_write_success_query,
+ metrics_type = ts_utils.metrics.counter, step = 10
+ })
+ schema:addTag("ifid")
+ schema:addMetric("points")
end
-- ##############################################
function probe.getTimeseriesMenu(ts_utils)
- local influxdb = ts_utils.getQueryDriver()
+ local influxdb = ts_utils.getQueryDriver()
- return {
- {schema="influxdb:storage_size", label=i18n("traffic_recording.storage_utilization")},
- {schema="influxdb:memory_size", label=i18n("about.ram_memory")},
- {schema="influxdb:write_successes", label=i18n("system_stats.write_througput")},
- {schema="influxdb:exports", label=i18n("system_stats.exports_label"),
- value_formatter = {"export_rate", "exports_format"},
- metrics_labels = {i18n("system_stats.exports_label")}},
- {schema="influxdb:exported_points", label=i18n("system_stats.exported_points")},
- {schema="influxdb:dropped_points", label=i18n("system_stats.dropped_points")},
- {schema="custom:infludb_exported_vs_dropped_points", label=i18n("system_stats.exported_vs_dropped_points"),
- custom_schema = {
- bases = {"influxdb:exported_points", "influxdb:dropped_points"},
- types = {"area", "line"}, axis = {1,2},
+ return {
+ {schema="influxdb:storage_size", label=i18n("traffic_recording.storage_utilization")},
+ {schema="influxdb:memory_size", label=i18n("about.ram_memory")},
+ {schema="influxdb:write_successes", label=i18n("system_stats.write_througput")},
+ {schema="influxdb:exports", label=i18n("system_stats.exports_label"),
+ value_formatter = {"export_rate", "exports_format"},
+ metrics_labels = {i18n("system_stats.exports_label")}},
+ {schema="influxdb:exported_points", label=i18n("system_stats.exported_points")},
+ {schema="influxdb:dropped_points", label=i18n("system_stats.dropped_points")},
+ {schema="custom:infludb_exported_vs_dropped_points", label=i18n("system_stats.exported_vs_dropped_points"),
+ custom_schema = {
+ bases = {"influxdb:exported_points", "influxdb:dropped_points"},
+ types = {"area", "line"}, axis = {1,2},
+ },
+ metrics_labels = {i18n("system_stats.exported_points"), i18n("system_stats.dropped_points")},
},
- metrics_labels = {i18n("system_stats.exported_points"), i18n("system_stats.dropped_points")},
- },
- {schema="influxdb:rtt", label=i18n("graphs.num_ms_rtt")},
- }
+ {schema="influxdb:rtt", label=i18n("graphs.num_ms_rtt")},
+ }
end
-- ##############################################
function probe.getExportStats()
- local points_exported
- local points_dropped
- local exports
- local ifnames = interface.getIfNames()
+ local points_exported
+ local points_dropped
+ local exports
+ local ifnames = interface.getIfNames()
- local influxdb = ts_utils.getQueryDriver()
+ local influxdb = ts_utils.getQueryDriver()
- points_exported = influxdb:get_exported_points()
- points_dropped = influxdb:get_dropped_points()
- exports = influxdb:get_exports()
+ points_exported = influxdb:get_exported_points()
+ points_dropped = influxdb:get_dropped_points()
+ exports = influxdb:get_exports()
- local res = {
- health = influxdb:get_health(),
- points_exported = points_exported,
- points_dropped = points_dropped,
- exports = exports,
- }
+ local res = {
+ health = influxdb:get_health(),
+ points_exported = points_exported,
+ points_dropped = points_dropped,
+ exports = exports,
+ }
- return(res)
+ return(res)
end
-- ##############################################
function probe._measureRtt(when, ts_utils, influxdb)
- local start_ms = ntop.gettimemsec()
- local res = influxdb:getInfluxdbVersion()
- local ifid = getSystemInterfaceId()
+ local start_ms = ntop.gettimemsec()
+ local res = influxdb:getInfluxdbVersion()
+ local ifid = getSystemInterfaceId()
- if res ~= nil then
- local end_ms = ntop.gettimemsec()
+ if res ~= nil then
+ local end_ms = ntop.gettimemsec()
- ts_utils.append("influxdb:rtt", {ifid = ifid, millis_rtt = ((end_ms-start_ms)*1000)}, when)
- end
+ ts_utils.append("influxdb:rtt", {ifid = ifid, millis_rtt = ((end_ms-start_ms)*1000)}, when)
+ end
end
-- ##############################################
function probe._exportStats(when, ts_utils, influxdb)
- local stats = probe.getExportStats()
- local ifid = getSystemInterfaceId()
+ local stats = probe.getExportStats()
+ local ifid = getSystemInterfaceId()
- ts_utils.append("influxdb:exported_points", {ifid = ifid, points = stats.points_exported}, when)
- ts_utils.append("influxdb:dropped_points", {ifid = ifid, points = stats.points_dropped}, when)
- ts_utils.append("influxdb:exports", {ifid = ifid, num_exports = stats.exports}, when)
+ ts_utils.append("influxdb:exported_points", {ifid = ifid, points = stats.points_exported}, when)
+ ts_utils.append("influxdb:dropped_points", {ifid = ifid, points = stats.points_dropped}, when)
+ ts_utils.append("influxdb:exports", {ifid = ifid, num_exports = stats.exports}, when)
end
-- ##############################################
function probe._exportStorageSize(when, ts_utils, influxdb)
- local disk_bytes = influxdb:getDiskUsage()
- local ifid = getSystemInterfaceId()
+ local disk_bytes = influxdb:getDiskUsage()
+ local ifid = getSystemInterfaceId()
- if(disk_bytes ~= nil) then
- ts_utils.append("influxdb:storage_size", {ifid = ifid, disk_bytes = disk_bytes}, when)
- end
+ if(disk_bytes ~= nil) then
+ ts_utils.append("influxdb:storage_size", {ifid = ifid, disk_bytes = disk_bytes}, when)
+ end
end
-- ##############################################
-function probe.runTask(when, ts_utils)
- local influxdb = ts_utils.getQueryDriver()
+function probe.runTask(when, ts_utils, ts_creation)
+ if ts_creation then
+ local influxdb = ts_utils.getQueryDriver()
- probe._exportStats(when, ts_utils, influxdb)
- probe._measureRtt(when, ts_utils, influxdb)
- probe._exportStorageSize(when, ts_utils, influxdb)
+ probe._exportStats(when, ts_utils, influxdb)
+ probe._measureRtt(when, ts_utils, influxdb)
+ probe._exportStorageSize(when, ts_utils, influxdb)
+ end
end
-- ##############################################
diff --git a/scripts/callbacks/system/minute/redis.lua b/scripts/callbacks/system/minute/redis.lua
index 6daab73405..b65bd00404 100644
--- a/scripts/callbacks/system/minute/redis.lua
+++ b/scripts/callbacks/system/minute/redis.lua
@@ -134,33 +134,37 @@ end
-- ##############################################
-function probe.runTask(when, ts_utils)
- local ifid = getSystemInterfaceId()
- local stats = probe.getStats()
- local hits_key = "ntopng.cache.redis.stats"
- local json = require("dkjson")
- local old_hits_stats = ntop.getCache(hits_key)
- local hits_stats = ntop.getCacheStats()
+function probe.runTask(when, ts_utils, ts_creation)
+ if ts_creation then
+ local ifid = getSystemInterfaceId()
+ local stats = probe.getStats()
+ local hits_key = "ntopng.cache.redis.stats"
+ local json = require("dkjson")
+ local hits_stats = ntop.getCacheStats()
- if(not isEmptyString(old_hits_stats)) then
- old_hits_stats = json.decode(old_hits_stats) or {}
- else
- old_hits_stats = {}
- end
- ts_utils.append("redis:memory", {ifid = ifid, resident_bytes = stats["memory"]}, when)
- ts_utils.append("redis:keys", {ifid = ifid, num_keys = stats["dbsize"]}, when)
+ local old_hits_stats = ntop.getCache(hits_key)
- for key, val in pairs(hits_stats) do
- if(old_hits_stats[key] ~= nil) then
- local delta = math.max(val - old_hits_stats[key], 0)
-
- -- Dump the delta value as a gauge
- ts_utils.append("redis:hits", {ifid = ifid, command = key, num_calls = delta}, when)
+ if(not isEmptyString(old_hits_stats)) then
+ old_hits_stats = json.decode(old_hits_stats) or {}
+ else
+ old_hits_stats = {}
end
- end
- ntop.setCache(hits_key, json.encode(hits_stats))
+ ts_utils.append("redis:memory", {ifid = ifid, resident_bytes = stats["memory"]}, when)
+ ts_utils.append("redis:keys", {ifid = ifid, num_keys = stats["dbsize"]}, when)
+
+ for key, val in pairs(hits_stats) do
+ if(old_hits_stats[key] ~= nil) then
+ local delta = math.max(val - old_hits_stats[key], 0)
+
+ -- Dump the delta value as a gauge
+ ts_utils.append("redis:hits", {ifid = ifid, command = key, num_calls = delta}, when)
+ end
+ end
+
+ ntop.setCache(hits_key, json.encode(hits_stats))
+ end
end
-- ##############################################
diff --git a/scripts/callbacks/system/minute/rtt.lua b/scripts/callbacks/system/minute/rtt.lua
index 240daeeffd..746c7325c5 100644
--- a/scripts/callbacks/system/minute/rtt.lua
+++ b/scripts/callbacks/system/minute/rtt.lua
@@ -77,7 +77,7 @@ end
-- ##############################################
-function probe.runTask(when, ts_utils)
+function probe.runTask(when, ts_utils, ts_creation)
local hosts = rtt_utils.getHosts()
local pinged_hosts = {}
local max_latency = {}
@@ -145,7 +145,9 @@ function probe.runTask(when, ts_utils)
print("[RTT] Reading response for host ".. host .."\n")
end
- ts_utils.append("monitored_host:rtt", {ifid = getSystemInterfaceId(), host = key, millis_rtt = rtt}, when)
+ if ts_creation then
+ ts_utils.append("monitored_host:rtt", {ifid = getSystemInterfaceId(), host = key, millis_rtt = rtt}, when)
+ end
rtt = tonumber(rtt)
rtt_utils.setLastRttUpdate(key, when, rtt, host)
diff --git a/scripts/callbacks/system/second/cpu.lua b/scripts/callbacks/system/second/cpu.lua
index aa95ab80e3..9a62f3064e 100644
--- a/scripts/callbacks/system/second/cpu.lua
+++ b/scripts/callbacks/system/second/cpu.lua
@@ -3,18 +3,18 @@
--
local probe = {
- name = "CPU",
- descripton = "Monitors the CPU usage",
+ name = "CPU",
+ descripton = "Monitors the CPU usage",
}
-- ##############################################
-function probe.runTask(when, ts_utils)
- local cpu_load = ntop.refreshCpuLoad()
+function probe.runTask(when, ts_utils, ts_creation)
+ local cpu_load = ntop.refreshCpuLoad()
- if(cpu_load ~= nil) then
- ts_utils.append("system:cpu_load", {ifid = getSystemInterfaceId(), load_percentage = cpu_load}, when)
- end
+ if ts_creation and cpu_load then
+ ts_utils.append("system:cpu_load", {ifid = getSystemInterfaceId(), load_percentage = cpu_load}, when)
+ end
end
-- ##############################################
diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua
index 322aa8506d..2fa55aaf06 100644
--- a/scripts/locales/en.lua
+++ b/scripts/locales/en.lua
@@ -2854,6 +2854,7 @@ local lang = {
["none"] = "None",
["note_timeseries_resolution_disabled"] = "NOTE: this is disabled because \"%{pref}\" is not set to the default value.",
["note_update_frequency_disabled"] = "NOTE: this is disabled because of the \"%{pref}\" requirements.",
+ ["system_probes_timeseries"] = "Probes Timeseries",
["other_timeseries"] = "Other Timeseries",
["per_category"] = "Per Category",
["per_protocol"] = "Per Application",
@@ -2957,6 +2958,8 @@ local lang = {
["toggle_email_notification_title"] = "Toggle Email Notification",
["toggle_flow_db_dump_export_description"] = "Toggle the export of tiny flows, that are flows with few packets or bytes. Reduces flow cardinality in databases, speeds-up inserts and searches. Tuning tiny flows can help to limit flow cardinality while not reducing visibility on dumped information.",
["toggle_flow_db_dump_export_title"] = "Tiny Flows Export",
+ ["toggle_system_probes_timeseries_title"] = "Probes",
+ ["toggle_system_probes_timeseries_description"] = "Toggle the creation of timeseries for system probes such as the RTT and the Redis monitor.",
["toggle_flow_rrds_description"] = "Toggle the creation of bytes timeseries for each port of the remote device as received through ZMQ (e.g. sFlow/NetFlow/SNMP).
For non sFlow devices, %%INPUT_SNMP and %%OUTPUT_SNMP must appear into the nprobe template.",
["toggle_flow_rrds_title"] = "Flow Devices",
["toggle_host_mask_description"] = "For privacy reasons it might be necessary to mask hosts IP addresses. For instance if you are an ISP you are not supposed to know which local addresses are accessing remote hosts.",
diff --git a/scripts/lua/admin/prefs.lua b/scripts/lua/admin/prefs.lua
index af897659ad..e4891a474e 100644
--- a/scripts/lua/admin/prefs.lua
+++ b/scripts/lua/admin/prefs.lua
@@ -1432,6 +1432,13 @@ function printStatsTimeseries()
"ntopng.prefs.l2_device_ndpi_timeseries_creation", nil,
elementToSwitch, showElementArray, javascriptAfterSwitch, showElement)
+ print('