ntopng/scripts/lua/reset_stats.lua
Simone Mainardi 482c2ca834 Implements counter resets
This commits adds two reset buttons to the interface page.

One button allows the reset of all interface counters, namely,
packets and bytes received, packets dropped, and the number of
flows exported and dropped (when mysql or elasticsearch is enabled).

The other button allows the reset of only the drops.
2016-12-21 12:48:04 +01:00

28 lines
646 B
Lua

--
-- (C) 2013-16 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
local json = require("dkjson")
sendHTTPHeader('application/json; charset=iso-8859-1')
local action = _GET["action"]
interface.select(ifname)
local res = { ["status"] = "ok" }
if haveAdminPrivileges() then
if action == "reset_drops" then
interface.resetCounters(true --[[ reset only drops --]])
elseif action == "reset_all" then
interface.resetCounters(false --[[ reset all counters --]])
end
else
res["status"] = "unauthorized"
end
print(json.encode(res, nil))