|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Adaptive collector wrapper. More...
#include <adaptive_monitor.h>

Public Member Functions | |
| adaptive_collector (std::shared_ptr< kcenon::monitoring::metrics_collector > collector, const adaptive_config &config={}) | |
| common::Result< kcenon::monitoring::metrics_snapshot > | collect () |
| Collect metrics with adaptive sampling. | |
| void | adapt (const kcenon::monitoring::system_metrics &sys_metrics) |
| Adapt collection behavior based on load. | |
| adaptation_stats | get_stats () const |
| Get current adaptation statistics. | |
| std::chrono::milliseconds | get_current_interval () const |
| Get current collection interval. | |
| void | set_config (const adaptive_config &config) |
| Set adaptive configuration. | |
| adaptive_config | get_config () const |
| Get adaptive configuration. | |
| void | set_enabled (bool enabled) |
| Enable or disable adaptive behavior. | |
| bool | is_enabled () const |
| Check if adaptive behavior is enabled. | |
Private Member Functions | |
| bool | should_sample () const |
| Determine if current sample should be collected. | |
Static Private Member Functions | |
| static load_level | calculate_load_level_with_config (double cpu_usage, double memory_usage, const adaptive_config &cfg) |
| Calculate load level from metrics with provided config. | |
| static load_level | calculate_load_level_with_hysteresis (double cpu_usage, double memory_usage, load_level current_level, const adaptive_config &cfg) |
| Calculate load level with hysteresis support (ARC-005) | |
| static double | get_threshold_for_level (load_level level, const adaptive_config &cfg) |
| Get the threshold value for a given load level. | |
Private Attributes | |
| std::shared_ptr< kcenon::monitoring::metrics_collector > | collector_ |
| adaptive_config | config_ |
| std::mutex | config_mutex_ |
| adaptation_stats | stats_ |
| std::atomic< bool > | enabled_ {true} |
| std::atomic< double > | current_sampling_rate_ {1.0} |
| std::mutex | stats_mutex_ |
Adaptive collector wrapper.
Definition at line 156 of file adaptive_monitor.h.
|
inline |
Definition at line 167 of file adaptive_monitor.h.
|
inline |
Adapt collection behavior based on load.
Definition at line 192 of file adaptive_monitor.h.
References kcenon::monitoring::adaptation_stats::average_cpu_usage, kcenon::monitoring::adaptation_stats::average_memory_usage, calculate_load_level_with_hysteresis(), config_, config_mutex_, kcenon::monitoring::adaptive_config::cooldown_period, kcenon::monitoring::adaptation_stats::cooldown_prevented_changes, kcenon::monitoring::system_metrics::cpu_usage_percent, kcenon::monitoring::adaptation_stats::current_interval, kcenon::monitoring::adaptation_stats::current_load_level, kcenon::monitoring::adaptation_stats::current_sampling_rate, current_sampling_rate_, kcenon::monitoring::adaptation_stats::downscale_count, kcenon::monitoring::adaptive_config::enable_cooldown, kcenon::monitoring::adaptive_config::get_interval_for_load(), kcenon::monitoring::adaptive_config::get_sampling_rate_for_load(), kcenon::monitoring::adaptation_stats::last_adaptation, kcenon::monitoring::adaptation_stats::last_level_change, kcenon::monitoring::system_metrics::memory_usage_percent, kcenon::monitoring::adaptive_config::smoothing_factor, stats_, stats_mutex_, kcenon::monitoring::adaptation_stats::total_adaptations, and kcenon::monitoring::adaptation_stats::upscale_count.
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().


|
inlinestaticprivate |
Calculate load level from metrics with provided config.
Definition at line 324 of file adaptive_monitor.h.
References kcenon::monitoring::aggressive, kcenon::monitoring::balanced, kcenon::monitoring::conservative, kcenon::monitoring::critical, kcenon::monitoring::high, kcenon::monitoring::adaptive_config::high_threshold, kcenon::monitoring::idle, kcenon::monitoring::adaptive_config::idle_threshold, kcenon::monitoring::low, kcenon::monitoring::adaptive_config::low_threshold, kcenon::monitoring::adaptive_config::memory_critical_threshold, kcenon::monitoring::adaptive_config::memory_warning_threshold, kcenon::monitoring::moderate, kcenon::monitoring::adaptive_config::moderate_threshold, and kcenon::monitoring::adaptive_config::strategy.
Referenced by calculate_load_level_with_hysteresis().

|
inlinestaticprivate |
Calculate load level with hysteresis support (ARC-005)
Hysteresis prevents oscillation at threshold boundaries by requiring the metric to cross a margin before changing levels.
| cpu_usage | Current CPU usage percentage |
| memory_usage | Current memory usage percentage |
| current_level | Current load level |
| cfg | Adaptive configuration |
Definition at line 380 of file adaptive_monitor.h.
References kcenon::monitoring::aggressive, kcenon::monitoring::balanced, calculate_load_level_with_config(), kcenon::monitoring::conservative, kcenon::monitoring::adaptive_config::enable_hysteresis, get_threshold_for_level(), kcenon::monitoring::adaptive_config::high_threshold, kcenon::monitoring::adaptive_config::hysteresis_margin, kcenon::monitoring::adaptive_config::memory_critical_threshold, kcenon::monitoring::adaptive_config::memory_warning_threshold, kcenon::monitoring::adaptive_config::moderate_threshold, and kcenon::monitoring::adaptive_config::strategy.
Referenced by adapt().


|
inline |
Collect metrics with adaptive sampling.
Definition at line 178 of file adaptive_monitor.h.
References kcenon::monitoring::metrics_collector::collect(), collector_, kcenon::monitoring::operation_cancelled, kcenon::monitoring::adaptation_stats::samples_collected, kcenon::monitoring::adaptation_stats::samples_dropped, should_sample(), and stats_.
Referenced by TEST_F(), and TEST_F().


|
inline |
Get adaptive configuration.
Definition at line 288 of file adaptive_monitor.h.
References config_, and config_mutex_.
|
inline |
Get current collection interval.
Definition at line 270 of file adaptive_monitor.h.
References kcenon::monitoring::adaptation_stats::current_interval, stats_, and stats_mutex_.
|
inline |
Get current adaptation statistics.
Definition at line 262 of file adaptive_monitor.h.
References stats_, and stats_mutex_.
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

|
inlinestaticprivate |
Get the threshold value for a given load level.
Definition at line 445 of file adaptive_monitor.h.
References kcenon::monitoring::critical, kcenon::monitoring::high, kcenon::monitoring::adaptive_config::high_threshold, kcenon::monitoring::idle, kcenon::monitoring::adaptive_config::idle_threshold, kcenon::monitoring::low, kcenon::monitoring::adaptive_config::low_threshold, kcenon::monitoring::moderate, and kcenon::monitoring::adaptive_config::moderate_threshold.
Referenced by calculate_load_level_with_hysteresis().

|
inline |
Check if adaptive behavior is enabled.
Definition at line 303 of file adaptive_monitor.h.
References enabled_.
Referenced by TEST_F().

|
inline |
Set adaptive configuration.
Definition at line 279 of file adaptive_monitor.h.
References config_, and config_mutex_.
Referenced by TEST_F().

|
inline |
Enable or disable adaptive behavior.
Definition at line 296 of file adaptive_monitor.h.
References enabled_.
Referenced by TEST_F().

|
inlineprivate |
Determine if current sample should be collected.
Definition at line 311 of file adaptive_monitor.h.
References current_sampling_rate_, and enabled_.
Referenced by collect().

|
private |
Definition at line 158 of file adaptive_monitor.h.
Referenced by collect().
|
private |
Definition at line 159 of file adaptive_monitor.h.
Referenced by adapt(), get_config(), and set_config().
|
mutableprivate |
Definition at line 160 of file adaptive_monitor.h.
Referenced by adapt(), get_config(), and set_config().
|
private |
Definition at line 163 of file adaptive_monitor.h.
Referenced by adapt(), and should_sample().
|
private |
Definition at line 162 of file adaptive_monitor.h.
Referenced by is_enabled(), set_enabled(), and should_sample().
|
private |
Definition at line 161 of file adaptive_monitor.h.
Referenced by adapt(), collect(), get_current_interval(), and get_stats().
|
mutableprivate |
Definition at line 164 of file adaptive_monitor.h.
Referenced by adapt(), get_current_interval(), and get_stats().