Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::network_metrics_collector Class Reference

Unified network metrics collector implementing collector_plugin interface. More...

#include <network_metrics_collector.h>

Inheritance diagram for kcenon::monitoring::network_metrics_collector:
Inheritance graph
Collaboration diagram for kcenon::monitoring::network_metrics_collector:
Collaboration graph

Public Member Functions

 network_metrics_collector ()
 
 ~network_metrics_collector () override=default
 
 network_metrics_collector (const network_metrics_collector &)=delete
 
network_metrics_collectoroperator= (const network_metrics_collector &)=delete
 
 network_metrics_collector (network_metrics_collector &&)=delete
 
network_metrics_collectoroperator= (network_metrics_collector &&)=delete
 
auto name () const -> std::string_view override
 Get the unique name of this plugin.
 
auto collect () -> std::vector< metric > override
 Collect current metrics from this plugin.
 
auto interval () const -> std::chrono::milliseconds override
 Get the collection interval for this plugin.
 
auto is_available () const -> bool override
 Check if this plugin is available on the current system.
 
auto get_metric_types () const -> std::vector< std::string > override
 Get supported metric types.
 
auto get_metadata () const -> plugin_metadata override
 Get plugin metadata.
 
auto initialize (const config_map &config) -> bool override
 
auto get_statistics () const -> stats_map override
 
network_metrics get_last_metrics () const
 
bool is_socket_buffer_monitoring_available () const
 
bool is_tcp_state_monitoring_available () const
 
- Public Member Functions inherited from kcenon::monitoring::collector_plugin
virtual ~collector_plugin ()=default
 
virtual void shutdown ()
 Shutdown plugin and release resources.
 

Private Member Functions

void add_socket_buffer_metrics (std::vector< metric > &metrics, const network_metrics &data)
 
void add_tcp_state_metrics (std::vector< metric > &metrics, const network_metrics &data)
 

Private Attributes

std::unique_ptr< network_info_collectorcollector_
 
bool enabled_ {true}
 
network_metrics_config config_
 
network_metrics last_metrics_
 
std::atomic< size_t > collection_count_ {0}
 
std::atomic< size_t > collection_errors_ {0}
 

Detailed Description

Unified network metrics collector implementing collector_plugin interface.

Combines socket buffer and TCP state monitoring into a single collector. Provides configurable collection of different metric types.

Examples
system_collectors_example.cpp.

Definition at line 240 of file network_metrics_collector.h.

Constructor & Destructor Documentation

◆ network_metrics_collector() [1/3]

kcenon::monitoring::network_metrics_collector::network_metrics_collector ( )

◆ ~network_metrics_collector()

kcenon::monitoring::network_metrics_collector::~network_metrics_collector ( )
overridedefault

◆ network_metrics_collector() [2/3]

kcenon::monitoring::network_metrics_collector::network_metrics_collector ( const network_metrics_collector & )
delete

◆ network_metrics_collector() [3/3]

kcenon::monitoring::network_metrics_collector::network_metrics_collector ( network_metrics_collector && )
delete

Member Function Documentation

◆ add_socket_buffer_metrics()

void kcenon::monitoring::network_metrics_collector::add_socket_buffer_metrics ( std::vector< metric > & metrics,
const network_metrics & data )
private

◆ add_tcp_state_metrics()

void kcenon::monitoring::network_metrics_collector::add_tcp_state_metrics ( std::vector< metric > & metrics,
const network_metrics & data )
private

◆ collect()

auto kcenon::monitoring::network_metrics_collector::collect ( ) -> std::vector< metric >
overridevirtual

Collect current metrics from this plugin.

Returns
Vector of collected metrics

This method is called periodically based on interval(). Implementations should:

  • Return quickly (< 100ms recommended)
  • Handle errors gracefully (return empty vector on failure)
  • Be thread-safe if concurrent collection is enabled
  • Avoid blocking I/O when possible

Implements kcenon::monitoring::collector_plugin.

Examples
system_collectors_example.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ get_last_metrics()

network_metrics kcenon::monitoring::network_metrics_collector::get_last_metrics ( ) const

Get last collected network metrics

Returns
Most recent network_metrics reading

◆ get_metadata()

auto kcenon::monitoring::network_metrics_collector::get_metadata ( ) const -> plugin_metadata
inlineoverridevirtual

Get plugin metadata.

Returns
Metadata describing this plugin

Default implementation returns minimal metadata. Override to provide rich plugin information.

Reimplemented from kcenon::monitoring::collector_plugin.

Definition at line 258 of file network_metrics_collector.h.

258 {
259 return plugin_metadata{
260 .name = name(),
261 .description = "Network metrics (socket buffers, TCP states)",
262 .category = plugin_category::network,
263 .version = "1.0.0",
264 .dependencies = {},
265 .requires_platform_support = true
266 };
267 }
auto name() const -> std::string_view override
Get the unique name of this plugin.
@ network
Network metrics (connectivity, bandwidth)

References name(), and kcenon::monitoring::network.

Here is the call graph for this function:

◆ get_metric_types()

auto kcenon::monitoring::network_metrics_collector::get_metric_types ( ) const -> std::vector< std::string >
overridevirtual

Get supported metric types.

Returns
Vector of metric type names this plugin produces

Used for filtering and documentation.

Implements kcenon::monitoring::collector_plugin.

◆ get_statistics()

auto kcenon::monitoring::network_metrics_collector::get_statistics ( ) const -> stats_map
overridevirtual

Get collector statistics

Returns
Map of statistic name to value

Reimplemented from kcenon::monitoring::collector_plugin.

Examples
system_collectors_example.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ initialize()

auto kcenon::monitoring::network_metrics_collector::initialize ( const config_map & config) -> bool
overridevirtual

Initialize the collector with configuration

Parameters
configConfiguration options:
  • "collect_socket_buffers": "true"/"false" (default: true)
  • "collect_tcp_states": "true"/"false" (default: true)
  • "time_wait_warning_threshold": count (default: 10000)
  • "close_wait_warning_threshold": count (default: 100)
  • "queue_full_threshold_bytes": bytes (default: 65536)
  • "memory_warning_threshold_bytes": bytes (default: 104857600)
Returns
true if initialization successful

Reimplemented from kcenon::monitoring::collector_plugin.

Examples
system_collectors_example.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ interval()

auto kcenon::monitoring::network_metrics_collector::interval ( ) const -> std::chrono::milliseconds
inlineoverridevirtual

Get the collection interval for this plugin.

Returns
Collection interval in milliseconds

The registry uses this value to schedule collection tasks. Typical values:

  • Fast metrics (CPU, memory): 1-5 seconds
  • Slow metrics (disk, network): 10-60 seconds
  • Very slow metrics (SMART data): 5-15 minutes

Implements kcenon::monitoring::collector_plugin.

Definition at line 254 of file network_metrics_collector.h.

254{ return std::chrono::seconds(10); }

◆ is_available()

auto kcenon::monitoring::network_metrics_collector::is_available ( ) const -> bool
overridevirtual

Check if this plugin is available on the current system.

Returns
True if plugin can collect metrics, false otherwise

Availability checks may include:

  • Platform compatibility (Linux-only, Windows-only)
  • Hardware presence (GPU, sensors)
  • Permission checks (root required)
  • Resource availability (proc filesystem, WMI)

The registry may skip unavailable plugins during registration.

Implements kcenon::monitoring::collector_plugin.

Examples
system_collectors_example.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ is_socket_buffer_monitoring_available()

bool kcenon::monitoring::network_metrics_collector::is_socket_buffer_monitoring_available ( ) const

Check if socket buffer monitoring is available

Returns
True if socket buffer metrics are accessible

◆ is_tcp_state_monitoring_available()

bool kcenon::monitoring::network_metrics_collector::is_tcp_state_monitoring_available ( ) const

Check if TCP state monitoring is available

Returns
True if TCP state metrics are accessible

◆ name()

auto kcenon::monitoring::network_metrics_collector::name ( ) const -> std::string_view
inlineoverridevirtual

Get the unique name of this plugin.

Returns
Plugin name (must be unique within registry)

The name is used for:

  • Plugin lookup and discovery
  • Configuration mapping
  • Metric tagging (added as "collector" tag)

Implements kcenon::monitoring::collector_plugin.

Examples
system_collectors_example.cpp.

Definition at line 252 of file network_metrics_collector.h.

252{ return "network_metrics_collector"; }

Referenced by get_metadata(), and main().

Here is the caller graph for this function:

◆ operator=() [1/2]

network_metrics_collector & kcenon::monitoring::network_metrics_collector::operator= ( const network_metrics_collector & )
delete

◆ operator=() [2/2]

network_metrics_collector & kcenon::monitoring::network_metrics_collector::operator= ( network_metrics_collector && )
delete

Member Data Documentation

◆ collection_count_

std::atomic<size_t> kcenon::monitoring::network_metrics_collector::collection_count_ {0}
private

Definition at line 317 of file network_metrics_collector.h.

317{0};

◆ collection_errors_

std::atomic<size_t> kcenon::monitoring::network_metrics_collector::collection_errors_ {0}
private

Definition at line 318 of file network_metrics_collector.h.

318{0};

◆ collector_

std::unique_ptr<network_info_collector> kcenon::monitoring::network_metrics_collector::collector_
private

Definition at line 307 of file network_metrics_collector.h.

◆ config_

network_metrics_config kcenon::monitoring::network_metrics_collector::config_
private

Definition at line 311 of file network_metrics_collector.h.

◆ enabled_

bool kcenon::monitoring::network_metrics_collector::enabled_ {true}
private

Definition at line 310 of file network_metrics_collector.h.

310{true};

◆ last_metrics_

network_metrics kcenon::monitoring::network_metrics_collector::last_metrics_
private

Definition at line 314 of file network_metrics_collector.h.


The documentation for this class was generated from the following file: