File tree Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class IPXP_API InputPlugin
96
96
};
97
97
98
98
// / Statistics related to packet parsing.
99
- ParserStats m_parser_stats = { };
99
+ ParserStats m_parser_stats { 10 };
100
100
101
101
private:
102
102
void create_parser_stats_telemetry (
Original file line number Diff line number Diff line change 25
25
26
26
#pragma once
27
27
28
+ #include " ../../src/plugins/input/parser/topPorts.hpp"
29
+
28
30
#include < array>
29
31
#include < cstdint>
30
32
#include < string>
@@ -162,6 +164,23 @@ struct VlanStats {
162
164
* \brief Structure for storing parser statistics.
163
165
*/
164
166
struct ParserStats {
167
+ ParserStats (size_t top_ports_count)
168
+ : top_ports(top_ports_count)
169
+ , mpls_packets(0 )
170
+ , vlan_packets(0 )
171
+ , pppoe_packets(0 )
172
+ , trill_packets(0 )
173
+ , ipv4_packets(0 )
174
+ , ipv6_packets(0 )
175
+ , tcp_packets(0 )
176
+ , udp_packets(0 )
177
+ , seen_packets(0 )
178
+ , unknown_packets(0 )
179
+ {
180
+ }
181
+
182
+ TopPorts top_ports;
183
+
165
184
uint64_t mpls_packets;
166
185
uint64_t vlan_packets;
167
186
uint64_t pppoe_packets;
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ target_link_libraries(ipfixprobe-core
32
32
atomic::atomic
33
33
unwind::unwind
34
34
${CMAKE_DL_LIBS}
35
+ top-ports
35
36
)
36
37
37
38
add_executable (ipfixprobe main.cpp )
Original file line number Diff line number Diff line change 13
13
* SPDX-License-Identifier: BSD-3-Clause
14
14
*/
15
15
16
+ #include < numeric>
17
+
16
18
#include < ipfixprobe/inputPlugin.hpp>
17
19
18
20
namespace ipxp {
@@ -35,6 +37,19 @@ static telemetry::Content get_parser_stats_content(const ParserStats& parserStat
35
37
36
38
dict[" seen_packets" ] = parserStats.seen_packets ;
37
39
dict[" unknown_packets" ] = parserStats.unknown_packets ;
40
+ const std::vector<TopPorts::PortStats>& ports = parserStats.top_ports .get_top_ports ();
41
+ if (ports.empty ()) {
42
+ dict[" top_10_ports" ] = " " ;
43
+ } else {
44
+ std::string top_ports = ports[0 ].to_string ();
45
+ dict[" top_10_ports" ] = std::accumulate (
46
+ ports.begin () + 1 ,
47
+ ports.end (),
48
+ top_ports,
49
+ [](std::string acc, const TopPorts::PortStats& port_frequency) {
50
+ return acc + " , " + port_frequency.to_string ();
51
+ });
52
+ }
38
53
return dict;
39
54
}
40
55
You can’t perform that action at this time.
0 commit comments