mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Add system stats REST endpoint. Load disk space utilzation via AJAX (fix #3421)
This commit is contained in:
parent
5351320114
commit
da6f1c354d
4 changed files with 171 additions and 84 deletions
28
scripts/lua/rest/get/system/stats.lua
Normal file
28
scripts/lua/rest/get/system/stats.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
--
|
||||
-- (C) 2013-20 - ntop.org
|
||||
--
|
||||
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local json = require ("dkjson")
|
||||
local page_utils = require("page_utils")
|
||||
local tracker = require("tracker")
|
||||
local storage_utils = require("storage_utils")
|
||||
|
||||
if not isAllowedSystemInterface() then
|
||||
sendHTTPContentTypeHeader('text/html')
|
||||
page_utils.print_header()
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
|
||||
print("<div class=\"alert alert-danger\"><img src=".. ntop.getHttpPrefix() .. "/img/warning.png>"..i18n("error_not_granted").."</div>")
|
||||
return
|
||||
end
|
||||
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
local stats = ntop.systemHostStat()
|
||||
stats.epoch = os.time()
|
||||
stats.storage = storage_utils.storageInfo()
|
||||
|
||||
print(json.encode(stats, nil))
|
||||
Loading…
Add table
Add a link
Reference in a new issue