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.
This commit is contained in:
Simone Mainardi 2016-12-21 12:48:04 +01:00
parent 5b041093e3
commit 482c2ca834
12 changed files with 206 additions and 58 deletions

View file

@ -392,6 +392,7 @@ MySQLDB::MySQLDB(NetworkInterface *_iface) : DB(_iface) {
mysqlDroppedFlowsQueueTooLong = 0;
mysqlExportedFlows = 0, mysqlLastExportedFlows = 0;
mysqlExportRate = 0;
checkpointDroppedFlows = checkpointExportedFlows = 0;
lastUpdateTime.tv_sec = 0, lastUpdateTime.tv_usec = 0;
connectToDB(&mysql, false);
}
@ -430,10 +431,13 @@ void MySQLDB::updateStats(const struct timeval *tv) {
/* ******************************************* */
void MySQLDB::lua(lua_State *vm) const {
lua_push_int_table_entry(vm, "flow_export_count", mysqlExportedFlows);
lua_push_int32_table_entry(vm, "flow_export_drops", mysqlDroppedFlowsQueueTooLong);
lua_push_float_table_entry(vm, "flow_export_rate", mysqlExportRate);
void MySQLDB::lua(lua_State *vm, bool since_last_checkpoint) const {
lua_push_int_table_entry(vm, "flow_export_count",
mysqlExportedFlows - (since_last_checkpoint ? checkpointExportedFlows : 0));
lua_push_int32_table_entry(vm, "flow_export_drops",
mysqlDroppedFlowsQueueTooLong - (since_last_checkpoint ? checkpointDroppedFlows : 0));
lua_push_float_table_entry(vm, "flow_export_rate",
mysqlExportRate >= 0 ? mysqlExportRate : 0);
}
/* ******************************************* */