mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Simple REST call for reading redis hash values
This commit is contained in:
parent
a4a57e8775
commit
52331d4dfa
1 changed files with 32 additions and 0 deletions
32
scripts/lua/rest/v2/get/redis/read_hash_values.lua
Normal file
32
scripts/lua/rest/v2/get/redis/read_hash_values.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
--
|
||||
-- (C) 2013-23 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local rest_utils = require("rest_utils")
|
||||
|
||||
local rc = rest_utils.consts.success.ok
|
||||
local res = {}
|
||||
|
||||
local hashname = _GET["hashname"] or "ntop.host.blackhole"
|
||||
|
||||
if isEmptyString(hashname) then
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
rest_utils.answer(rc)
|
||||
return
|
||||
end
|
||||
|
||||
local h_values = ntop.getHashKeysCache(hashname)
|
||||
|
||||
for key, val in pairs(h_values) do
|
||||
res[#res + 1] = {
|
||||
ip = key,
|
||||
time = ntop.getHashCache(hashname, key)
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
rest_utils.answer(rc, res)
|
||||
Loading…
Add table
Add a link
Reference in a new issue