|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
#include <system_resource_collector.h>


Public Member Functions | |
| system_resource_collector () | |
| system_resource_collector (const system_metrics_config &config) | |
| ~system_resource_collector () override=default | |
| bool | initialize (const std::unordered_map< std::string, std::string > &config) override |
| std::vector< metric > | collect () override |
| std::string | get_name () const override |
| std::vector< std::string > | get_metric_types () const override |
| bool | is_healthy () const override |
| std::unordered_map< std::string, double > | get_statistics () const override |
| system_metrics_config | get_config () const |
| void | set_config (const system_metrics_config &config) |
| system_resources | get_last_resources () const |
| template<typename Duration > | |
| std::vector< load_average_sample > | get_load_history (Duration duration) const |
| template<typename Duration > | |
| load_average_statistics | get_load_statistics (Duration duration) const |
| std::vector< load_average_sample > | get_all_load_history () const |
| load_average_statistics | get_all_load_statistics () const |
| void | configure_load_history (size_t max_samples) |
| bool | is_load_history_enabled () const |
Public Member Functions inherited from kcenon::monitoring::metric_collector_plugin | |
| virtual | ~metric_collector_plugin ()=default |
Private Member Functions | |
| metric | create_metric (const std::string &name, double value, const std::string &unit="", const std::unordered_map< std::string, std::string > &labels={}) const |
| void | add_cpu_metrics (std::vector< metric > &metrics, const system_resources &resources) |
| void | add_memory_metrics (std::vector< metric > &metrics, const system_resources &resources) |
| void | add_disk_metrics (std::vector< metric > &metrics, const system_resources &resources) |
| void | add_network_metrics (std::vector< metric > &metrics, const system_resources &resources) |
| void | add_process_metrics (std::vector< metric > &metrics, const system_resources &resources) |
Private Attributes | |
| std::unique_ptr< system_info_collector > | collector_ |
| bool | collect_cpu_metrics_ {true} |
| bool | collect_memory_metrics_ {true} |
| bool | collect_disk_metrics_ {true} |
| bool | collect_network_metrics_ {true} |
| bool | collect_process_metrics_ {true} |
| std::mutex | stats_mutex_ |
| std::atomic< size_t > | collection_count_ {0} |
| std::atomic< size_t > | collection_errors_ {0} |
| std::atomic< int64_t > | init_time_ns_ {0} |
| std::shared_ptr< system_resources > | last_resources_ |
| std::unique_ptr< load_average_history > | load_history_ |
| bool | enable_load_history_ {true} |
System resource collector plugin implementation
Collects system-level metrics with consistent naming convention:
Definition at line 287 of file system_resource_collector.h.
| kcenon::monitoring::system_resource_collector::system_resource_collector | ( | ) |
|
explicit |
Construct with configuration
| config | Collection configuration |
|
overridedefault |
|
private |
|
private |
|
private |
|
private |
|
private |
|
overridevirtual |
Collect metrics from the data source
Implements kcenon::monitoring::metric_collector_plugin.
Referenced by main().

| void kcenon::monitoring::system_resource_collector::configure_load_history | ( | size_t | max_samples | ) |
Configure load history buffer size
| max_samples | Maximum number of samples to keep (default: 1000) |
|
private |
| std::vector< load_average_sample > kcenon::monitoring::system_resource_collector::get_all_load_history | ( | ) | const |
Get all load average history
Referenced by main().

| load_average_statistics kcenon::monitoring::system_resource_collector::get_all_load_statistics | ( | ) | const |
Get load average statistics for all history
Referenced by main().

| system_metrics_config kcenon::monitoring::system_resource_collector::get_config | ( | ) | const |
Get current configuration
| system_resources kcenon::monitoring::system_resource_collector::get_last_resources | ( | ) | const |
Get last collected resources
Referenced by main().

|
inline |
Get load average history for trend analysis
| duration | How far back to look |
Definition at line 331 of file system_resource_collector.h.
References load_history_.
|
inline |
Get load average statistics for a duration
| duration | How far back to look |
Definition at line 344 of file system_resource_collector.h.
References load_history_.
|
overridevirtual |
Get supported metric types
Implements kcenon::monitoring::metric_collector_plugin.
|
inlineoverridevirtual |
Get the name of this plugin
Implements kcenon::monitoring::metric_collector_plugin.
Definition at line 302 of file system_resource_collector.h.
Referenced by main().

|
overridevirtual |
Get plugin-specific statistics
Implements kcenon::monitoring::metric_collector_plugin.
Referenced by main().

|
overridevirtual |
Initialize the plugin with configuration
| config | Plugin-specific configuration |
Implements kcenon::monitoring::metric_collector_plugin.
Referenced by main().

|
overridevirtual |
Check if the plugin is healthy
Implements kcenon::monitoring::metric_collector_plugin.
Referenced by main().

| bool kcenon::monitoring::system_resource_collector::is_load_history_enabled | ( | ) | const |
Check if load history tracking is enabled
| void kcenon::monitoring::system_resource_collector::set_config | ( | const system_metrics_config & | config | ) |
Update configuration
| config | New configuration to apply |
|
private |
Definition at line 380 of file system_resource_collector.h.
|
private |
Definition at line 382 of file system_resource_collector.h.
|
private |
Definition at line 381 of file system_resource_collector.h.
|
private |
Definition at line 383 of file system_resource_collector.h.
|
private |
Definition at line 384 of file system_resource_collector.h.
|
private |
Definition at line 388 of file system_resource_collector.h.
|
private |
Definition at line 389 of file system_resource_collector.h.
|
private |
Definition at line 377 of file system_resource_collector.h.
|
private |
Definition at line 395 of file system_resource_collector.h.
|
private |
Definition at line 390 of file system_resource_collector.h.
|
private |
Definition at line 391 of file system_resource_collector.h.
|
private |
Definition at line 394 of file system_resource_collector.h.
Referenced by get_load_history(), and get_load_statistics().
|
mutableprivate |
Definition at line 387 of file system_resource_collector.h.