mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
Uses httpGetAuthToken to retrieve data from ntopng REST API
This commit is contained in:
parent
6e4f5c3a8b
commit
7e8d61b064
2 changed files with 13 additions and 2 deletions
|
|
@ -35,8 +35,14 @@ local function check(measurement, hosts, granularity)
|
|||
end
|
||||
|
||||
-- HTTP results are retrieved immediately
|
||||
local rv = ntop.httpGet(full_url, nil, nil, 10 --[[ timeout ]], host.save_result == true --[[ whether to return the content --]],
|
||||
nil, false --[[ don't follow redirects ]])
|
||||
local rv
|
||||
if host.token then
|
||||
rv = ntop.httpGetAuthToken(full_url, host.token, 10 --[[ timeout ]], host.save_result == true --[[ whether to return the content --]],
|
||||
nil, true --[[ follow redirects ]])
|
||||
else
|
||||
rv = ntop.httpGet(full_url, nil, nil, 10 --[[ timeout ]], host.save_result == true --[[ whether to return the content --]],
|
||||
nil, false --[[ don't follow redirects ]])
|
||||
end
|
||||
|
||||
if(rv and rv.HTTP_STATS and (rv.HTTP_STATS.TOTAL_TIME > 0)) then
|
||||
local total_time = rv.HTTP_STATS.TOTAL_TIME * 1000
|
||||
|
|
|
|||
|
|
@ -414,6 +414,11 @@ end
|
|||
-- @param save_result Whether the result fetched with the measure should be saved (e.g., the HTTP response) [optional]
|
||||
-- @param readonly Bool used by the GUI to know if, when true, an entry is considered read only hence it cannot be modified/deleted [optional]
|
||||
function am_utils.addHost(host, measurement, am_value, granularity, pool, token, save_result, readonly)
|
||||
host = "localhost:3000/lua/rest/v1/get/interface/data.lua?ifid=0"
|
||||
token = "e08f7b422c962dd761dd517ff9491c5b"
|
||||
save_result = true
|
||||
readonly = true
|
||||
|
||||
local active_monitoring_pools = require("active_monitoring_pools")
|
||||
local am_pool = active_monitoring_pools:create()
|
||||
local host_key = am_utils.getAmHostKey(host, measurement)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue