31#include <unordered_map>
77 default:
return "UNKNOWN";
189class metrics_provider;
252 auto name() const -> std::string_view
override {
return "network_metrics_collector"; }
253 auto collect() -> std::vector<metric>
override;
254 auto interval() const -> std::chrono::milliseconds
override {
return std::chrono::seconds(10); }
261 .description =
"Network metrics (socket buffers, TCP states)",
265 .requires_platform_support =
true
Pure virtual interface for metric collector plugins.
Internal network data collector using platform abstraction layer.
network_metrics collect_metrics(const network_metrics_config &config)
bool is_tcp_state_monitoring_available() const
network_info_collector(network_info_collector &&)=delete
network_info_collector & operator=(network_info_collector &&)=delete
network_info_collector(const network_info_collector &)=delete
std::unique_ptr< platform::metrics_provider > provider_
~network_info_collector()
bool is_socket_buffer_monitoring_available() const
network_info_collector & operator=(const network_info_collector &)=delete
Unified network metrics collector implementing collector_plugin interface.
auto collect() -> std::vector< metric > override
Collect current metrics from this plugin.
auto get_metadata() const -> plugin_metadata override
Get plugin metadata.
auto is_available() const -> bool override
Check if this plugin is available on the current system.
void add_tcp_state_metrics(std::vector< metric > &metrics, const network_metrics &data)
network_metrics get_last_metrics() const
auto initialize(const config_map &config) -> bool override
auto get_statistics() const -> stats_map override
void add_socket_buffer_metrics(std::vector< metric > &metrics, const network_metrics &data)
std::atomic< size_t > collection_count_
auto name() const -> std::string_view override
Get the unique name of this plugin.
network_metrics_collector()
network_metrics_collector(network_metrics_collector &&)=delete
bool is_socket_buffer_monitoring_available() const
bool is_tcp_state_monitoring_available() const
std::unique_ptr< network_info_collector > collector_
auto interval() const -> std::chrono::milliseconds override
Get the collection interval for this plugin.
network_metrics_collector & operator=(network_metrics_collector &&)=delete
network_metrics_collector & operator=(const network_metrics_collector &)=delete
network_metrics_config config_
std::atomic< size_t > collection_errors_
network_metrics_collector(const network_metrics_collector &)=delete
network_metrics last_metrics_
~network_metrics_collector() override=default
auto get_metric_types() const -> std::vector< std::string > override
Get supported metric types.
Plugin interface for metric collectors.
Adapter for metric types to support interface definitions.
std::unordered_map< std::string, double > stats_map
Type alias for statistics map.
std::string tcp_state_to_string(tcp_state state)
Convert tcp_state to string representation.
tcp_state
TCP connection states as defined in RFC 793.
@ FIN_WAIT1
FIN sent, waiting for ACK or FIN.
@ SYN_SENT
SYN sent, waiting for SYN-ACK.
@ TIME_WAIT
Waiting for enough time to pass (2MSL)
@ FIN_WAIT2
FIN-ACK received, waiting for FIN.
@ UNKNOWN
Unknown or invalid state.
@ SYN_RECV
SYN received, SYN-ACK sent.
@ CLOSE
Connection closed.
@ ESTABLISHED
Connection established.
@ CLOSE_WAIT
Remote side has closed, waiting for local close.
@ LAST_ACK
FIN sent after CLOSE_WAIT, waiting for ACK.
@ CLOSING
Both sides sent FIN simultaneously.
@ LISTEN
Listening for incoming connections.
@ network
Network metrics (connectivity, bandwidth)
std::unordered_map< std::string, std::string > config_map
Type alias for configuration map.
@ platform
Platform/system power domain.
Configuration for network metrics collector.
bool collect_socket_buffers
Enable socket buffer collection.
uint64_t close_wait_warning_threshold
CLOSE_WAIT warning threshold.
uint64_t time_wait_warning_threshold
TIME_WAIT warning threshold.
uint64_t queue_full_threshold_bytes
Socket queue full threshold.
uint64_t memory_warning_threshold_bytes
Socket memory warning (100MB)
bool collect_tcp_states
Enable TCP state collection.
Aggregated network metrics from all sources.
uint64_t send_buffer_bytes
Total bytes in send buffers.
tcp_state_counts tcp_counts
TCP state counts.
std::chrono::system_clock::time_point timestamp
Reading timestamp.
bool socket_buffer_available
Socket buffer metrics availability.
bool tcp_state_available
TCP state metrics availability.
uint64_t socket_count
Total number of sockets.
uint64_t recv_buffer_bytes
Total bytes in receive buffers.
uint64_t udp_socket_count
Number of UDP sockets.
uint64_t tcp_socket_count
Number of TCP sockets.
uint64_t socket_memory_bytes
Total socket buffer memory used.
uint64_t total_connections
Total TCP connections.
Counts of connections in each TCP state.
uint64_t time_wait
TIME_WAIT connections.
uint64_t fin_wait2
FIN_WAIT2 connections.
uint64_t close
CLOSE connections.
uint64_t close_wait
CLOSE_WAIT connections (leak indicator)
uint64_t fin_wait1
FIN_WAIT1 connections.
void increment(tcp_state state)
uint64_t established
ESTABLISHED connections.
uint64_t syn_recv
SYN_RECV connections.
uint64_t closing
CLOSING connections.
uint64_t get_count(tcp_state state) const
uint64_t unknown
Unknown state connections.
uint64_t last_ack
LAST_ACK connections.
uint64_t listen
LISTEN sockets.
uint64_t syn_sent
SYN_SENT connections.