/src/ntopng/src/ContainerStats.cpp
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * (C) 2013-26 - ntop.org |
4 | | * |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | | * |
20 | | */ |
21 | | |
22 | | #include "ntop_includes.h" |
23 | | |
24 | | /* *************************************** */ |
25 | | |
26 | 0 | ContainerStats::ContainerStats() { |
27 | 0 | if (trace_new_delete) |
28 | 0 | ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__); |
29 | 0 | num_flows_as_client = num_flows_as_server = 0; |
30 | 0 | tot_rtt_as_client = tot_rtt_variance_as_client = 0; |
31 | 0 | tot_rtt_as_server = tot_rtt_variance_as_server = 0; |
32 | 0 | } |
33 | | |
34 | | /* *************************************** */ |
35 | | |
36 | | void ContainerStats::accountLatency(double rtt, double rtt_variance, |
37 | 0 | bool as_client) { |
38 | 0 | if (as_client) { |
39 | 0 | tot_rtt_as_client += rtt; |
40 | 0 | tot_rtt_variance_as_client += rtt_variance; |
41 | 0 | } else { |
42 | 0 | tot_rtt_as_server += rtt; |
43 | 0 | tot_rtt_variance_as_server += rtt_variance; |
44 | 0 | } |
45 | 0 | } |
46 | | |
47 | | /* *************************************** */ |
48 | | |
49 | 0 | void ContainerStats::lua(lua_State* vm) { |
50 | 0 | lua_newtable(vm); |
51 | |
|
52 | 0 | lua_push_int32_table_entry(vm, "num_containers", getNumContainers()); |
53 | 0 | lua_push_int32_table_entry(vm, "num_flows.as_client", getNumFlowsAsClient()); |
54 | 0 | lua_push_int32_table_entry(vm, "num_flows.as_server", getNumFlowsAsServer()); |
55 | | |
56 | | /* Latency stats */ |
57 | 0 | lua_push_float_table_entry(vm, "rtt_as_client", getRttAsClient()); |
58 | 0 | lua_push_float_table_entry(vm, "rtt_as_server", getRttAsServer()); |
59 | 0 | lua_push_float_table_entry(vm, "rtt_variance_as_client", |
60 | 0 | getRttVarianceAsClient()); |
61 | 0 | lua_push_float_table_entry(vm, "rtt_variance_as_server", |
62 | 0 | getRttVarianceAsServer()); |
63 | 0 | } |