mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
Fixes HTTPS monitoring not working
This commit is contained in:
parent
71fbbdbf58
commit
371b0f2a90
6 changed files with 26 additions and 31 deletions
|
|
@ -9,6 +9,7 @@ require "lua_utils"
|
|||
local json = require("dkjson")
|
||||
local script_manager = require("script_manager")
|
||||
local am_utils = require "am_utils"
|
||||
local format_utils = require "format_utils"
|
||||
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
|
|
@ -45,14 +46,16 @@ for key, am_host in pairs(am_hosts) do
|
|||
column_ifname = am_host.ifname or ""
|
||||
end
|
||||
|
||||
if (last_update) and (am_host.measurement == 'throughput') then
|
||||
last_update.value = format_utils.bitsToSize(last_update.value * 8 --[[ Stored in bytes ]])
|
||||
end
|
||||
|
||||
if(last_update ~= nil) then
|
||||
column_last_update = last_update.when
|
||||
column_last_value = last_update.value
|
||||
column_last_ip = last_update.ip
|
||||
end
|
||||
|
||||
column_last_value = tonumber(column_last_value)
|
||||
|
||||
if(column_last_value == nil) then
|
||||
chart = ""
|
||||
end
|
||||
|
|
|
|||
|
|
@ -935,7 +935,11 @@ function am_utils.run_am_check(when, all_hosts, granularity)
|
|||
local operator = info.measurement.operator
|
||||
local jitter = tonumber(info.jitter)
|
||||
local mean = tonumber(info.mean)
|
||||
local calculate_scaling = true
|
||||
|
||||
if info.calculate_scaling then
|
||||
calculate_scaling = info.calculate_scaling
|
||||
end
|
||||
if(do_trace) then
|
||||
print("[AM result] "..key.."\n")
|
||||
-- tprint(info)
|
||||
|
|
@ -947,7 +951,7 @@ function am_utils.run_am_check(when, all_hosts, granularity)
|
|||
if areSystemTimeseriesEnabled() then
|
||||
local value = host_value
|
||||
|
||||
if info.measurement.chart_scaling_value then
|
||||
if (calculate_scaling) and (info.measurement.chart_scaling_value) and (info.measurement.chart_scaling_value == 1) then
|
||||
value = value * info.measurement.chart_scaling_value
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -176,15 +176,15 @@ function format_utils.bitsToSizeMultiplier(bits, multiplier)
|
|||
local terabit = gigabit * multiplier;
|
||||
|
||||
if((bits >= kilobit) and (bits < megabit)) then
|
||||
return round(bits / kilobit, precision) .. ' kbit/s';
|
||||
return round(bits / kilobit, precision) .. ' kbps';
|
||||
elseif((bits >= megabit) and (bits < gigabit)) then
|
||||
return round(bits / megabit, precision) .. ' Mbit/s';
|
||||
return round(bits / megabit, precision) .. ' Mbps';
|
||||
elseif((bits >= gigabit) and (bits < terabit)) then
|
||||
return round(bits / gigabit, precision) .. ' Gbit/s';
|
||||
return round(bits / gigabit, precision) .. ' Gbps';
|
||||
elseif(bits >= terabit) then
|
||||
return round(bits / terabit, precision) .. ' Tbit/s';
|
||||
return round(bits / terabit, precision) .. ' Tbps';
|
||||
else
|
||||
return round(bits, precision) .. ' bit/s';
|
||||
return round(bits, precision) .. ' bps';
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,21 +20,9 @@ local result = {}
|
|||
-- the hosts identifiers, whereas the table values contain host information
|
||||
-- see (am_utils.key2host for the details on such format).
|
||||
local function check(measurement, hosts, granularity)
|
||||
package.path = dirs.installdir .. "/pro/scripts/lua/enterprise/modules/?.lua;" .. package.path
|
||||
local infrastructure_utils = require "infrastructure_utils"
|
||||
result[measurement] = {}
|
||||
|
||||
for key, host in pairs(hosts) do
|
||||
if host.is_infrastructure then
|
||||
local infrastructure_instance = infrastructure_utils.get_instance_by_host(host.host)
|
||||
|
||||
if infrastructure_instance then
|
||||
local _, protocol = infrastructure_utils.getHostAndHTTPMeasurement(infrastructure_instance.url)
|
||||
host.host = protocol .. '://' .. host.host
|
||||
measurement = protocol
|
||||
end
|
||||
end
|
||||
|
||||
for key, host in pairs(hosts) do
|
||||
local domain_name = host.host
|
||||
|
||||
if do_trace then
|
||||
|
|
@ -61,17 +49,15 @@ local function check(measurement, hosts, granularity)
|
|||
end
|
||||
|
||||
if(rv and rv.HTTP_STATS and (rv.HTTP_STATS.TOTAL_TIME > 0)) then
|
||||
local download_bit = rv.BYTES_DOWNLOAD * 8
|
||||
local download_bytes = rv.BYTES_DOWNLOAD
|
||||
local total_time = rv.HTTP_STATS.TOTAL_TIME
|
||||
local lookup_time = (rv.HTTP_STATS.NAMELOOKUP_TIME or 0)
|
||||
|
||||
local bandwidth = (download_bit / total_time) / 1000000
|
||||
|
||||
if not result[measurement] then
|
||||
result[measurement] = {}
|
||||
end
|
||||
-- the total_time is in seconds, being Bps, bandwidth is bit / seconds,
|
||||
-- however all the timeseries are saved as Bps
|
||||
local bandwidth = download_bytes / total_time
|
||||
|
||||
result[measurement][key] = {
|
||||
calculate_scaling = false,
|
||||
value = bandwidth,
|
||||
resolved_addr = rv.RESOLVED_IP,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue