![]() |
MySQL 26.10.0
Source Code Documentation
|
System Collector. More...
#include <health_monitor_system.h>
Public Member Functions | |
| System_Collector () | |
| void | set_buffer_size () final |
| Resize the stat buffers if necessary. More... | |
| void | set_cpu_buffer_size () |
| void | set_disk_buffer_size () |
| void | set_memory_buffer_size () |
| void | set_process_buffer_size () |
| bool | set_rows_per_sample () |
| Set the number of rows per sample for each statistic type. More... | |
| bool | settings_changed () override |
| Return true if the collector settings have changed. More... | |
| void | set_params () final |
| Set collection parameters from the system variables. More... | |
| bool | running () const override |
| Return health_monitor.system_running. More... | |
| std::shared_ptr< Stat_Buffer< System_CPU_Stats > > | sys_cpu_buffer () |
| std::shared_ptr< Stat_Buffer< System_CPU_Stats > > | get_cpu_stats_buffer () |
| Get the system CPU statistics and return them in a local stat buffer. More... | |
| std::shared_ptr< Stat_Buffer< System_Disk_Stats > > | sys_disk_buffer () |
| std::shared_ptr< Stat_Buffer< System_Disk_Stats > > | get_disk_stats_buffer () |
| Get the system disk statistics and return them in a local stat buffer. More... | |
| std::shared_ptr< Stat_Buffer< System_Memory_Stats > > | sys_memory_buffer () |
| std::shared_ptr< Stat_Buffer< System_Memory_Stats > > | get_memory_stats_buffer () |
| Get the system memory statistics and return them in a local stat buffer. More... | |
| std::shared_ptr< Stat_Buffer< System_Process_Stats > > | sys_process_buffer () |
| int | get_process_stats (std::vector< System_Process_Stats > &sys_process_stats) |
| Get the mysqld process stats. More... | |
| int | get_process_stats (std::vector< System_Process_Stats > &sys_process_stats, const time_t ×tamp) |
| Get the mysqld process stats. More... | |
| std::shared_ptr< Stat_Buffer< System_Process_Stats > > | get_process_stats_buffer () |
| Get the mysqld process statistics and return them in a local stat buffer. More... | |
| void | set_state (ss::System_State &new_state) |
| Set the next state. More... | |
| void | set_start_state () |
| void | set_stop_state () |
| void | set_normal_state () |
| void | set_warning_state () |
| void | set_error_state () |
| void | log_resource_status () override |
| System status, depending on state. More... | |
| void | log_warning_error_condition () |
| Error condition warning. More... | |
| std::string | format_settings () override |
| System Collector settings formatted string. More... | |
| std::string | format_status_info () override |
| System Collector status formatted string. More... | |
| std::string | tag_collector_state () override |
| Collector state tag. More... | |
Public Member Functions inherited from hm::Collector | |
| Collector ()=default | |
| Collector (const char *name, const char *resource_name, const char *instr_name, const char *os_name, const char *description) | |
| ~Collector () override=default | |
| Collector (const Collector &)=delete | |
| Collector & | operator= (const Collector &)=delete |
| Collector (Collector &&)=delete | |
| Collector & | operator= (Collector &&)=delete |
| const char * | resource_name () const |
| void | run_process () override |
| Sample collection loop. More... | |
| virtual bool | dynamic_settings_changed () |
| virtual bool | static_settings_changed () |
| void | mark_settings_pending () |
| Mark a settings update for evaluation by the Supervisor. More... | |
| bool | settings_pending () const |
| void | set_settings_pending (bool pending) |
| virtual bool | update_settings () |
| Update system variable settings for the Collector. More... | |
| int | base_interval () const |
| int | sample_interval () const |
| void | set_sample_interval (int sample_interval) |
| Set the sample interval, adjust to the nearest multiple of the base interval. More... | |
| void | set_collector_intervals (int base_interval, int sample_interval) |
| Set the base and sample intervals together to ensure that the sample interval is a multiple of the base interval. More... | |
| virtual void | log_collector_status (bool settings) |
| Collector status with optional settings. More... | |
| virtual void | log_collector_status (const std::string &state_msg, bool settings) |
| Collector status with optional message and optional settings. More... | |
| virtual void | log_status () |
| Issue a log status message for the collector. More... | |
| virtual void | log_resource_levels () |
| Log general resource status with state, mode (Fallback, Recovery, ...) and levels. More... | |
| virtual std::string | build_collector_message (const std::string &status, const std::string &mode, const std::string &message, bool settings) |
| Formatted collector message with optional settings. More... | |
| virtual std::string | build_resource_message (const std::string &status, const std::string &mode, const std::string &message, bool levels) |
| Formatted resource message, no levels or settings. More... | |
| virtual std::string | tag_resource_state () |
| virtual std::string | tag_mode () |
Public Member Functions inherited from hm::Thread | |
| Thread ()=default | |
| Thread (const char *name, const char *instr_name, const char *os_name, const char *desc) | |
| virtual | ~Thread ()=0 |
| const char * | name () const |
| virtual int | start () |
| virtual void | stop () |
| void | signal () |
| Signal the processing loop to end the current cycle. More... | |
Static Public Member Functions | |
| static int | get_cpu_stats (std::vector< System_CPU_Stats > &sys_cpu_stats) |
| Get the system CPU stats. More... | |
| static int | get_cpu_stats (std::vector< System_CPU_Stats > &sys_cpu_stats, const time_t ×tamp) |
| Get the system CPU stats. More... | |
| static int | get_disk_stats (std::vector< System_Disk_Stats > &sys_disk_stats) |
| Get storage device stats. More... | |
| static int | get_disk_stats (std::vector< System_Disk_Stats > &sys_disk_stats, const time_t ×tamp) |
| Get storage statistics for all available devices. More... | |
| static int | get_memory_stats (System_Memory_Stats &mem_stats) |
| Get the system memory stats. More... | |
| static int | get_memory_stats (System_Memory_Stats &mem_stats, const time_t ×tamp) |
| Get the system memory stats. More... | |
Static Public Member Functions inherited from hm::Collector | |
| static std::string | format_level (uint64_t mbytes) |
| Format storage amount in MiB, no units. More... | |
| static std::string | format_mb (uint64_t mbytes, int prec, bool show_units) |
| Format storage amount. More... | |
Static Public Member Functions inherited from hm::Thread | |
| static void | cleanup () |
| Cleanup thread instrumentation. More... | |
| static int | join (my_thread_handle *thread, void **value_ptr) |
| static bool | joinable (const my_thread_handle &thread) |
Protected Member Functions | |
| void | pre_process () override |
| Tasks before starting the collection loop. More... | |
| void | process () override |
| Collect the current system stats and write to the stat buffer. More... | |
| void | post_process () override |
| Final tasks before exiting the thread. More... | |
Protected Member Functions inherited from hm::Collector | |
| void | consume_settings_pending () |
| Consume one pending notification without clearing a concurrent update. More... | |
| void | apply_pending_settings () |
| Apply settings while the collector command lock is held. More... | |
| Cycle_Timer & | sample_timer () |
| Cycle_Timer & | status_message_timer () |
| void | initialize_sample_timers () |
| Initialize collection timers. More... | |
| void | advance_sample_timers () |
| Process collector sample and status timers. More... | |
Protected Member Functions inherited from hm::Thread | |
| int | start_thread () |
| void | stop_thread () |
| void | request_thread_stop () |
| Request that the worker stop without waiting for it to exit. More... | |
| void | join_thread () |
| Wait for a stopped worker to exit. More... | |
| bool | stop_requested () |
| Return true when worker shutdown has been requested. More... | |
Private Attributes | |
| std::shared_ptr< Stat_Buffer< System_CPU_Stats > > | m_sys_cpu_buffer {nullptr} |
| std::shared_ptr< Stat_Buffer< System_Disk_Stats > > | m_sys_disk_buffer {nullptr} |
| std::shared_ptr< Stat_Buffer< System_Memory_Stats > > | m_sys_memory_buffer |
| std::shared_ptr< Stat_Buffer< System_Process_Stats > > | m_sys_process_buffer |
| PSI_rwlock_key | m_rwlock_key {0} |
| PSI_rwlock_info | m_rwlock_info |
| PSI_memory_key | m_memory_key_cpu_stats {0} |
| PSI_memory_key | m_memory_key_cpu_stats_history {0} |
| PSI_memory_key | m_memory_key_disk_stats {0} |
| PSI_memory_key | m_memory_key_disk_stats_history {0} |
| PSI_memory_key | m_memory_key_memory_stats {0} |
| PSI_memory_key | m_memory_key_memory_stats_history {0} |
| PSI_memory_key | m_memory_key_process_stats {0} |
| PSI_memory_key | m_memory_key_process_stats_history {0} |
Additional Inherited Members | |
Static Public Attributes inherited from hm::Collector | |
| static constexpr uint64_t | no_warn_level {std::numeric_limits<uint64_t>::max()} |
| static constexpr int | k_min_interval {1} |
| static constexpr int | k_max_interval {86400} |
| static constexpr int | k_default_base_interval {10} |
| static constexpr int | k_default_sample_interval {k_default_base_interval * 6} |
Protected Attributes inherited from hm::Collector | |
| const std::string | m_resource_name |
| bool | m_running {false} |
Protected Attributes inherited from hm::Thread | |
| std::mutex | m_command_lock |
| const std::string | m_name |
| const std::string | m_instr_name |
| const std::string | m_os_name |
| const std::string | m_description |
| std::atomic< bool > | m_thread_running {false} |
| bool | m_stop {false} |
| my_thread_handle | m_thread |
| PSI_thread_key | m_thread_key {0} |
| PSI_thread_info | m_thread_info |
| mysql_mutex_t | m_wait_lock |
| PSI_mutex_key | m_mutex_key {0} |
| PSI_mutex_info | m_mutex_info |
| mysql_cond_t | m_wait |
| PSI_cond_key | m_cond_key {0} |
| PSI_cond_info | m_cond_info |
System Collector.
The System Collector collects and publishes CPU, disk I/O, memory, and process statistics. It does not issue resource warnings or take corrective action based on these values.
| hm::System_Collector::System_Collector | ( | ) |
|
overridevirtual |
System Collector settings formatted string.
Reimplemented from hm::Collector.
|
overridevirtual |
System Collector status formatted string.
Reimplemented from hm::Collector.
|
static |
Get the system CPU stats.
| [in,out] | sys_cpu_stats | Stats for each CPU |
|
static |
Get the system CPU stats.
| [out] | sys_cpu_stats | Stats for each CPU |
| [in] | timestamp | Timestamp to use for the record |
| std::shared_ptr< Stat_Buffer< System_CPU_Stats > > hm::System_Collector::get_cpu_stats_buffer | ( | ) |
Get the system CPU statistics and return them in a local stat buffer.
|
static |
Get storage device stats.
| [in,out] | sys_disk_stats | Stats for each available storage device |
|
static |
Get storage statistics for all available devices.
| [out] | sys_disk_stats | Stats for each available storage device |
| [in] | timestamp | Timestamp to use for the record |
| std::shared_ptr< Stat_Buffer< System_Disk_Stats > > hm::System_Collector::get_disk_stats_buffer | ( | ) |
Get the system disk statistics and return them in a local stat buffer.
|
static |
Get the system memory stats.
| [in,out] | mem_stats | System memory info |
|
static |
Get the system memory stats.
| [out] | mem_stats | System memory stats |
| [in] | timestamp | Timestamp to use for the record |
| std::shared_ptr< Stat_Buffer< System_Memory_Stats > > hm::System_Collector::get_memory_stats_buffer | ( | ) |
Get the system memory statistics and return them in a local stat buffer.
| int hm::System_Collector::get_process_stats | ( | std::vector< System_Process_Stats > & | sys_process_stats | ) |
Get the mysqld process stats.
| [out] | sys_process_stats | Array of stats for each thread |
| int hm::System_Collector::get_process_stats | ( | std::vector< System_Process_Stats > & | sys_process_stats, |
| const time_t & | timestamp | ||
| ) |
Get the mysqld process stats.
| [out] | sys_process_stats | Array of stats for each thread |
| [in] | timestamp | Timestamp to use for the record |
| std::shared_ptr< Stat_Buffer< System_Process_Stats > > hm::System_Collector::get_process_stats_buffer | ( | ) |
Get the mysqld process statistics and return them in a local stat buffer.
|
overridevirtual |
System status, depending on state.
Implements hm::Collector.
| void hm::System_Collector::log_warning_error_condition | ( | ) |
Error condition warning.
|
overrideprotectedvirtual |
Final tasks before exiting the thread.
Reimplemented from hm::Thread.
|
overrideprotectedvirtual |
Tasks before starting the collection loop.
Reimplemented from hm::Thread.
|
overrideprotectedvirtual |
Collect the current system stats and write to the stat buffer.
Reimplemented from hm::Collector.
|
overridevirtual |
Return health_monitor.system_running.
Reimplemented from hm::Thread.
|
finalvirtual |
Resize the stat buffers if necessary.
Account for the expected number of rows per sample. Must be inside collector lock.
Reimplemented from hm::Collector.
| void hm::System_Collector::set_cpu_buffer_size | ( | ) |
| void hm::System_Collector::set_disk_buffer_size | ( | ) |
|
inline |
| void hm::System_Collector::set_memory_buffer_size | ( | ) |
|
inline |
|
finalvirtual |
Set collection parameters from the system variables.
Reimplemented from hm::Collector.
| void hm::System_Collector::set_process_buffer_size | ( | ) |
| bool hm::System_Collector::set_rows_per_sample | ( | ) |
Set the number of rows per sample for each statistic type.
The number of rows for cpu and disk stats should remain effectively constant.
|
inline |
| void hm::System_Collector::set_state | ( | ss::System_State & | new_state | ) |
Set the next state.
|
inline |
|
inline |
|
overridevirtual |
Return true if the collector settings have changed.
Reimplemented from hm::Collector.
|
inline |
|
inline |
|
inline |
|
inline |
|
overridevirtual |
Collector state tag.
Reimplemented from hm::Collector.
| uint32_t hm::System_Collector::m_cpu_rows_per_sample {1} |
| bool hm::System_Collector::m_cpu_stats_error {false} |
| bool hm::System_Collector::m_cpu_stats_history {true} |
| ss::System_State* hm::System_Collector::m_current_state {nullptr} |
| uint32_t hm::System_Collector::m_disk_rows_per_sample {1} |
| bool hm::System_Collector::m_disk_stats_error {false} |
| bool hm::System_Collector::m_disk_stats_history {true} |
| ss::Error_State hm::System_Collector::m_error_state |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
| uint32_t hm::System_Collector::m_memory_rows_per_sample {1} |
| bool hm::System_Collector::m_memory_stats_error {false} |
| bool hm::System_Collector::m_memory_stats_history {true} |
| ss::Normal_State hm::System_Collector::m_normal_state |
| uint32_t hm::System_Collector::m_process_rows_per_sample {1} |
| bool hm::System_Collector::m_process_stats_error {false} |
| bool hm::System_Collector::m_process_stats_history {true} |
| bool hm::System_Collector::m_rows_per_sample_set {false} |
|
private |
|
private |
| std::atomic<bool> hm::System_Collector::m_settings_changed {false} |
| ss::Start_State hm::System_Collector::m_start_state |
| ss::Stop_State hm::System_Collector::m_stop_state |
|
private |
|
private |
|
private |
|
private |
| bool hm::System_Collector::m_sysinfo_error {false} |
| bool hm::System_Collector::m_sysinfo_warning {false} |
| ss::Warning_State hm::System_Collector::m_warning_state |