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
9696 };
9797
9898 // / Statistics related to packet parsing.
99- ParserStats m_parser_stats = { };
99+ ParserStats m_parser_stats { 10 };
100100
101101private:
102102 void create_parser_stats_telemetry (
Original file line number Diff line number Diff line change 2525
2626#pragma once
2727
28+ #include " ../../src/plugins/input/parser/topPorts.hpp"
29+
2830#include < array>
2931#include < cstdint>
3032#include < string>
@@ -162,6 +164,23 @@ struct VlanStats {
162164 * \brief Structure for storing parser statistics.
163165 */
164166struct 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+
165184 uint64_t mpls_packets;
166185 uint64_t vlan_packets;
167186 uint64_t pppoe_packets;
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ target_link_libraries(ipfixprobe-core
3232 atomic::atomic
3333 unwind::unwind
3434 ${CMAKE_DL_LIBS}
35+ top-ports
3536)
3637
3738add_executable (ipfixprobe main.cpp)
Original file line number Diff line number Diff line change 1313 * SPDX-License-Identifier: BSD-3-Clause
1414 */
1515
16+ #include < numeric>
17+
1618#include < ipfixprobe/inputPlugin.hpp>
1719
1820namespace ipxp {
@@ -35,6 +37,19 @@ static telemetry::Content get_parser_stats_content(const ParserStats& parserStat
3537
3638 dict[" seen_packets" ] = parserStats.seen_packets ;
3739 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+ }
3853 return dict;
3954}
4055
You can’t perform that action at this time.
0 commit comments