/src/ntopng/include/ContainerStats.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * |
3 | | * (C) 2013-24 - 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 | | #ifndef _CONTAINER_STATS_H_ |
23 | | #define _CONTAINER_STATS_H_ |
24 | | |
25 | | #include "ntop_includes.h" |
26 | | |
27 | | class ContainerStats { |
28 | | private: |
29 | | std::set<std::string> containers; |
30 | | u_int32_t num_flows_as_client, num_flows_as_server; |
31 | | double tot_rtt_as_client, tot_rtt_variance_as_client; |
32 | | double tot_rtt_as_server, tot_rtt_variance_as_server; |
33 | | |
34 | | public: |
35 | | ContainerStats(); |
36 | | |
37 | 0 | inline void addContainer(std::string container_id) { |
38 | 0 | containers.insert(container_id); |
39 | 0 | } |
40 | 0 | inline u_int32_t getNumContainers() { return (containers.size()); } |
41 | 0 | inline void incNumFlowsAsClient() { num_flows_as_client++; } |
42 | 0 | inline void incNumFlowsAsServer() { num_flows_as_server++; } |
43 | 0 | inline u_int32_t getNumFlowsAsClient() { return (num_flows_as_client); } |
44 | 0 | inline u_int32_t getNumFlowsAsServer() { return (num_flows_as_server); } |
45 | 0 | inline double getRttAsClient() { |
46 | 0 | return (num_flows_as_client ? (tot_rtt_as_client / num_flows_as_client) |
47 | 0 | : 0); |
48 | 0 | } |
49 | 0 | inline double getRttAsServer() { |
50 | 0 | return (num_flows_as_server ? (tot_rtt_as_server / num_flows_as_server) |
51 | 0 | : 0); |
52 | 0 | } |
53 | 0 | inline double getRttVarianceAsClient() { |
54 | 0 | return (num_flows_as_client |
55 | 0 | ? (tot_rtt_variance_as_client / num_flows_as_client) |
56 | 0 | : 0); |
57 | 0 | } |
58 | 0 | inline double getRttVarianceAsServer() { |
59 | 0 | return (num_flows_as_server |
60 | 0 | ? (tot_rtt_variance_as_server / num_flows_as_server) |
61 | 0 | : 0); |
62 | 0 | } |
63 | | void accountLatency(double rtt, double rtt_variance, bool as_client); |
64 | | |
65 | | void lua(lua_State* vm); |
66 | | }; |
67 | | |
68 | | #endif |