MySQL 26.10.0
Source Code Documentation
hm::Disk_Forecaster Class Reference

#include <health_monitor_disk_forecaster.h>

Inheritance diagram for hm::Disk_Forecaster:
[legend]

Classes

struct  Status_snapshot
 

Public Types

enum class  Dfx_Run_Mode { NONE , NORMAL , TEST , STANDBY }
 
enum class  Dfx_Test_State { NONE , IDLE , RUNNING }
 

Public Member Functions

 Disk_Forecaster ()
 
virtual ~Disk_Forecaster () override
 
 Disk_Forecaster (const Disk_Forecaster &)=delete
 
Disk_Forecaster & operator= (const Disk_Forecaster &)=delete
 
 Disk_Forecaster (Disk_Forecaster &&)=delete
 
Disk_Forecaster & operator= (Disk_Forecaster &&)=delete
 
void initialize ()
 Initialize the Disk Forecaster. More...
 
void initialize_timers ()
 Initialize the forecast and report timers. More...
 
void advance_cycle_timers ()
 Advance the timers driven by the base interval. More...
 
void pre_process () override
 Issue status before starting the collection cycle. More...
 
void process_normal_cycle ()
 Normal processing cycle. More...
 
void process () override
 Main processing loop, 10 second interval. More...
 
void post_process () override
 Issue a status message after stopping the collection cycle. More...
 
void set_disk_input_available (bool available)
 
Dfx_Run_Mode run_mode () const
 
bool is_new_run_mode () const
 
Dfx_Test_State test_state () const
 
void set_run_mode (Dfx_Run_Mode mode)
 
void set_is_new_run_mode (bool is_new)
 
void set_test_state (Dfx_Test_State state)
 
const std::string & run_mode_name ()
 
const std::string & test_state_name ()
 
const char * run_mode_name_ptr () const
 
const char * test_state_name_ptr () const
 
const std::string & forecast_status_name (Dfx_Status status)
 
bool running () const override
 Return health_monitor.disk_forecast_running. More...
 
int report_interval () const
 
std::string test_filename ()
 
std::string volume ()
 
bool dynamic_settings_changed () override
 Indicate if the dynamic Disk Forecast settings have changed. More...
 
bool static_settings_changed () override
 Indicate if the static Disk Forecast settings have changed. More...
 
void set_params () final
 Set collection parameters from the system variables. More...
 
bool update_settings () override
 Apply pending settings unless a Disk Forecaster processing cycle is active. More...
 
Disk_Metric_Buffer disk_metric_buffer ()
 
Disk_Metric_Aggregate_Buffer disk_metric_aggregate_buffer ()
 
Disk_Forecast_Buffer disk_forecast_buffer ()
 
Disk_Forecast_Summary_Buffer disk_forecast_summary_buffer ()
 
void reset_filesystem_series ()
 Reset disk metrics and forecasts before sampling a different filesystem. More...
 
Status_snapshot status_snapshot () const
 
- 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 void set_buffer_size ()
 
virtual bool 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)
 
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 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_collector_state ()
 
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 constexpr int default_sample_interval ()
 
static constexpr int default_report_interval ()
 
static void reset_filesystem_series (Disk_forecast_reset_context &context)
 
- 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)
 

Static Public Attributes

static const std::array< std::string, 4 > RUN_MODE_NAMES
 
static const std::array< std::string, 3 > TEST_STATE_NAMES
 
static const char * dfx_run_mode_names [5]
 
static const std::array< std::string, 4 > FORECAST_STATUS_NAMES
 
- 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 Member Functions

void log_info_message (const std::string &msg, bool levels)
 Informational message with collector state and optional forecast status. More...
 
void log_info_message (const std::string &msg)
 Informational message with collector state and forecast status. More...
 
void log_resource_status () override
 Collector or forecast status. More...
 
void log_resource_levels () override
 Forecast status, no message. More...
 
std::string format_settings () override
 
std::string format_status_info () override
 
Cycle_Timer & forecast_timer ()
 
Cycle_Timer & report_timer ()
 
Cycle_Timer & short_report_timer ()
 
std::string generate_report (std::vector< Disk_Forecast > &forecasts, Disk_Forecast_Summary &summary)
 Format the disk forecast report for the diagnostic log. More...
 
void log_forecast_status (std::vector< Disk_Forecast > &forecasts, Disk_Forecast_Summary &summary)
 Send disk usage forecast summary to the error log. More...
 
std::string format_disk_forecast (const Disk_Forecast &dfx)
 Generate a human-readable log message from a Disk_Forecast value. More...
 
std::string format_forecast_summary (const Disk_Forecast_Summary &dfxs)
 Generate a human-readable log message from a Disk_Forecast_Summary. More...
 
int initialize_test ()
 Initialize the unit test. More...
 
int process_test_cycle ()
 Runs the unit test driven by the test data file. More...
 
int load_unit_test_data ()
 Load the unit test data into the disk metrics buffer. More...
 
int read_unit_test_file (std::vector< Disk_Metric > &disk_metrics)
 Read the unit test file and populate the disk metrics buffer. More...
 
void run_unit_test ()
 Run the unit test: Generate forecasts from the uploaded disk metric data, update the forecast tables with results, write the forecast report to the diagnostics log. 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...
 

Protected Attributes

PSI_rwlock_key m_metric_rwlock_key {}
 
PSI_rwlock_key m_aggregate_rwlock_key {}
 
PSI_rwlock_key m_forecast_rwlock_key {}
 
PSI_rwlock_key m_forecast_summary_rwlock_key {}
 
PSI_rwlock_key m_forecast_model_rwlock_key {}
 
PSI_rwlock_info m_rwlock_info [5]
 
PSI_memory_key m_metric_memory_key {}
 
PSI_memory_key m_aggregate_memory_key {}
 
PSI_memory_key m_forecast_memory_key {}
 
PSI_memory_key m_forecast_summary_memory_key {}
 
PSI_memory_info m_memory_info [4]
 
- 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
 

Private Member Functions

void set_disk_metric_buffer_size ()
 Resize the disk metric time series buffer if sample interval changes. More...
 
void set_disk_metric_aggregate_buffer_size ()
 Set the disk metric aggregated buffer size to include rows for all 3 aggregation tiers. More...
 
void set_disk_forecast_buffer_size ()
 Set the sizes for the disk forecast and disk forecast summary buffers. More...
 
bool volume_size_changed () const
 
void set_volume_size_changed (bool change)
 
Holt_Winters_Forecaster & forecaster ()
 
Dfx_Status compute_status (double current_usage_pct, bool has_depletion_eta, double days_to_full, double usage_rate_pct_per_day)
 Determine disk status based on usage and forecast metrics. More...
 
Disk_Forecast_Summary compute_summary (const Holt_Winters_State &model, double volume_size_mb, double current_usage_mb)
 Compute a summary of the forecast model and current usage. More...
 
int generate_forecast (std::vector< Disk_Forecast > &disk_forecasts, Disk_Forecast_Summary &summary)
 Terminology level - Baseline ('real') value with trend and seasonal components removed. More...
 
bool ready_to_forecast (bool log_warning=true)
 Check if the forecaster is ready to produce forecasts. More...
 
void update_forecast_tables (std::vector< Disk_Forecast > &forecasts, Disk_Forecast_Summary &summary)
 Update disk forecast buffers with the lastest forecast and summary. More...
 
void update_storage_totals (const Disk_Metric &disk_metric)
 Update storage totals, convert to MiB. More...
 
void set_total_metric_count (size_t metric_count)
 
void save_forecast_status (const std::vector< Disk_Forecast > &forecasts, const Disk_Forecast_Summary &summary)
 

Static Private Member Functions

static mysql_rwlock_t * model_lock ()
 

Private Attributes

Dfx_Run_Mode m_run_mode {Dfx_Run_Mode::NORMAL}
 
bool m_is_new_run_mode {false}
 
Dfx_Test_State m_test_state {Dfx_Test_State::NONE}
 
std::string m_test_filename
 
std::mutex m_processing_mutex
 
std::mutex m_settings_mutex
 
bool m_static_settings_changed {false}
 
bool m_dynamic_settings_changed {false}
 
Disk_Metric_Buffer m_disk_metric_buffer
 
Disk_Metric_Aggregate_Buffer m_disk_metric_aggregate_buffer
 
Disk_Forecast_Buffer m_disk_forecast_buffer
 
Disk_Forecast_Summary_Buffer m_disk_forecast_summary_buffer
 
Cycle_Timer m_forecast_timer
 
Cycle_Timer m_report_timer
 
Cycle_Timer m_short_report_timer
 
bool m_first_normal_cycle {true}
 
int m_forecast_interval_seconds {k_forecast_interval_seconds}
 
int m_report_interval_seconds {k_report_interval_seconds}
 
int m_short_report_interval_seconds {seconds_per_hour}
 
std::atomic< bool > m_disk_input_available {false}
 
uint64_t m_total_mb {}
 
uint64_t m_last_total_mb {}
 
uint64_t m_used_mb {}
 
double m_used_pct {}
 
std::string m_configured_volume
 
std::string m_volume
 
uint64_t m_volume_generation {0}
 
bool m_volume_size_changed {}
 
Holt_Winters_Forecaster m_forecaster
 
std::mutex m_series_mutex
 
size_t m_total_metric_count {}
 
time_t m_last_forecast_time {}
 
std::vector< Disk_Forecast > m_last_forecasts
 
Disk_Forecast_Summary m_last_forecast_summary
 

Static Private Attributes

static char m_dfx_run_mode_name [32] {}
 
static char m_dfx_test_state_name [32] {}
 
static constexpr int k_disk_forecast_base_interval_seconds {10}
 
static constexpr int k_time_series_interval_seconds {60}
 
static constexpr size_t k_metric_retention_seconds {seconds_per_day * 14}
 
static constexpr int k_forecast_interval_seconds {seconds_per_hour}
 
static constexpr int k_report_interval_seconds {seconds_per_hour * 4}
 
static constexpr int k_forecast_retention_seconds {seconds_per_day * 14}
 
static constexpr int k_tier_1_days {23}
 
static constexpr int k_tier_2_days {60}
 
static constexpr int k_tier_3_days {275}
 
static constexpr int k_tier_1_rows {minutes_per_day / k_tier_1_days}
 
static constexpr int k_tier_2_rows {minutes_per_day / k_tier_2_days}
 
static constexpr int k_tier_3_rows {minutes_per_day / k_tier_3_days}
 
static mysql_rwlock_t m_model_lock {}
 

Additional Inherited Members

- Public Attributes inherited from hm::Collector
const std::string k_started {"Started"}
 
const std::string k_stopped {"Stopped"}
 
const std::string k_offline_mode {"OFFLINE_MODE"}
 
const std::string k_super_read_only {"SUPER_READ_ONLY"}
 
const std::string k_invalid_path {"Invalid Path"}
 
const std::string k_error {"ERROR"}
 
const std::string k_system_error {"SYSTEM ERROR"}
 
const std::string k_failed {"failed"}
 
const std::string k_remaining {"attempts remaining"}
 
int m_retention {0}
 
std::atomic< bool > m_settings_pending {false}
 
int m_status_interval {0}
 
int m_status_counter {0}
 
bool m_verbose_log {false}
 
bool m_force_status {false}
 
Cycle_Timer m_sample_timer
 
Cycle_Timer m_status_timer
 

Member Enumeration Documentation

◆ Dfx_Run_Mode

Enumerator
NONE 
NORMAL 
TEST 
STANDBY 

◆ Dfx_Test_State

Enumerator
NONE 
IDLE 
RUNNING 

Constructor & Destructor Documentation

◆ Disk_Forecaster() [1/3]

hm::Disk_Forecaster::Disk_Forecaster ( )

◆ ~Disk_Forecaster()

virtual hm::Disk_Forecaster::~Disk_Forecaster ( )
inlineoverridevirtual

◆ Disk_Forecaster() [2/3]

hm::Disk_Forecaster::Disk_Forecaster ( const Disk_Forecaster &  )
delete

◆ Disk_Forecaster() [3/3]

hm::Disk_Forecaster::Disk_Forecaster ( Disk_Forecaster &&  )
delete

Member Function Documentation

◆ advance_cycle_timers()

void hm::Disk_Forecaster::advance_cycle_timers ( )

Advance the timers driven by the base interval.

◆ compute_status()

Dfx_Status hm::Disk_Forecaster::compute_status ( double  current_usage_pct,
bool  has_depletion_eta,
double  days_to_full,
double  usage_rate_pct_per_day 
)
private

Determine disk status based on usage and forecast metrics.

Status levels:

  • Critical if:
    • current usage >= 95%, or
    • depletion ETA <= 1 day, or
    • usage rate >= 15% per day, or
    • current usage >= 90% and depletion ETA <= 2 days
  • Warning if:
    • usage rate >= 8% per day, or
    • current usage >= 80% and depletion ETA <= 7 days
  • Normal otherwise
    Parameters
    current_usage_pctCurrent disk usage as a percentage of total.
    has_depletion_etaWhether a depletion ETA is available.
    days_to_fullEstimated days until full (if slope positive).
    usage_rate_pct_per_dayProjected daily usage rate as percent of volume.
    Returns
    Dfx_Status The computed status level.

◆ compute_summary()

Disk_Forecast_Summary hm::Disk_Forecaster::compute_summary ( const Holt_Winters_State &  model,
double  volume_size_mb,
double  current_usage_mb 
)
private

Compute a summary of the forecast model and current usage.

Computes:

  • Trend_per_day_mb: projected daily change in used MiB
  • Usage_rate_pct_per_day: projected daily change as percent of volume
  • Days_to_full: estimated days until full (if slope positive)
  • Status: Normal, Warning, or Critical based on thresholds
    Parameters
    modelCurrent Holt-Winters state
    volume_size_mbTotal volume size in MiB
    current_usage_mbMost recent disk usage in MiB
    Returns
    Disk_Forecast_Summary Summary of trend, ETA, and status
    Note
    The caller must hold the forecast-model read or write lock.

◆ default_report_interval()

static constexpr int hm::Disk_Forecaster::default_report_interval ( )
inlinestaticconstexpr

◆ default_sample_interval()

static constexpr int hm::Disk_Forecaster::default_sample_interval ( )
inlinestaticconstexpr

◆ disk_forecast_buffer()

Disk_Forecast_Buffer hm::Disk_Forecaster::disk_forecast_buffer ( )
inline

◆ disk_forecast_summary_buffer()

Disk_Forecast_Summary_Buffer hm::Disk_Forecaster::disk_forecast_summary_buffer ( )
inline

◆ disk_metric_aggregate_buffer()

Disk_Metric_Aggregate_Buffer hm::Disk_Forecaster::disk_metric_aggregate_buffer ( )
inline

◆ disk_metric_buffer()

Disk_Metric_Buffer hm::Disk_Forecaster::disk_metric_buffer ( )
inline

◆ dynamic_settings_changed()

bool hm::Disk_Forecaster::dynamic_settings_changed ( )
overridevirtual

Indicate if the dynamic Disk Forecast settings have changed.

Dynamic settings can be applied without restarting the collector thread.

Returns
true if settings have changed

Reimplemented from hm::Collector.

◆ forecast_status_name()

const std::string & hm::Disk_Forecaster::forecast_status_name ( Dfx_Status  status)

◆ forecast_timer()

Cycle_Timer & hm::Disk_Forecaster::forecast_timer ( )
inlineprotected

◆ forecaster()

Holt_Winters_Forecaster & hm::Disk_Forecaster::forecaster ( )
inlineprivate

◆ format_disk_forecast()

std::string hm::Disk_Forecaster::format_disk_forecast ( const Disk_Forecast &  dfx)
protected

Generate a human-readable log message from a Disk_Forecast value.

Parameters
dfxThe forecast to log
Returns
Formatted log message string

◆ format_forecast_summary()

std::string hm::Disk_Forecaster::format_forecast_summary ( const Disk_Forecast_Summary &  dfxs)
protected

Generate a human-readable log message from a Disk_Forecast_Summary.

Parameters
dfxsThe summary to log
Returns
Formatted log message string

◆ format_settings()

std::string hm::Disk_Forecaster::format_settings ( )
overrideprotectedvirtual

Reimplemented from hm::Collector.

◆ format_status_info()

std::string hm::Disk_Forecaster::format_status_info ( )
overrideprotectedvirtual

Reimplemented from hm::Collector.

◆ generate_forecast()

int hm::Disk_Forecaster::generate_forecast ( std::vector< Disk_Forecast > &  forecasts,
Disk_Forecast_Summary &  summary 
)
private

Terminology level - Baseline ('real') value with trend and seasonal components removed.

season - Fixed periodic cycle, in this case a season = 1 day = 1440 minutes. trend - Slope of the level. fitted - A prediction inside the data set, i.e. what we would have predicted one step ahead: last level + last trend + seasonal value from one day ago at this time. Actual value - fitted value gives us an idea of the forecast accuracy. residual - Difference between the actual value and the one-step-ahead fitted value. We track residuals to estimate σ for prediction intervals. Ideally, residuals are like “white noise” and approximately normal. If residuals show some kind of structure, then the model should be refined (adjust α/β/γ, season length, additive vs. multiplicative, account for events, etc.) phase - The index inside the daily (seasonal) cycle: 0..m-1. Example: At minute index t, the phase is t % m. Phases let us reuse "the same minute tomorrow" information.

Notation and inputs n - Number of disk space usage values in the time series. T = Last data point. y_t - Used disk space at time index t, where t = 0..T (T = n - 1). m - Seasonal (daily) period in samples (1440 for 24h @ 1-min).

Exponential smoothing parameters, all in [0,1]: alpha(α) for level, beta(β) for trend, gamma(γ) for season

State at time t: Level ℓ_t — Baseline (the 'de‑seasonalized' center of the series). Trend b_t — Slope per sample, how fast baseline is changing at that point. Seasonal s_t — Repeating adjustment based on phase t % m.

Fitted ŷ_{t|t-1} — The one‑step‑ahead forecast made just before seeing y_t. Residual e_t = y_t − ŷ_{t|t-1} — the forecast error at step t.

Initialize if needed, advance state over this batch, emit 3 forecasts, and compute trend/ETA/status summary.

The 'batch' time series contains only the unprocessed tail of a much larger metric stream from the Disk_Metric buffer. This function:

  1. Generates a temporary time series batch from the unprocessed Disk_Metrics.
  2. Initializes the model from if not yet initialized (requires >= 2*m points).
  3. Advances the model over all samples in the batch
  4. Returns forecasts for +1h, +1d, +7d.
  5. Computes trend-per-day, usage-rate %/day, days-to-full, and status.
Parameters
[out]forecastsForecasts produced for 1h, 1d, 7d
[out]summaryOutput summary with trend/ETA/status
Returns
0 on success, non-zero on error or if not enough data is available
Note
IMPORTANT: Assumes a read lock is held on the disk metric buffer.

◆ generate_report()

std::string hm::Disk_Forecaster::generate_report ( std::vector< Disk_Forecast > &  forecasts,
Disk_Forecast_Summary &  summary 
)
protected

Format the disk forecast report for the diagnostic log.

Sort forecasts by horizon. Return "No forecasts available" if the vector is empty. Trend, accuracy and usage breakdown sections currently contain placeholders.

Parameters
[in,out]forecastsVector of horizon forecasts (1h/1d/7d), sorted in place.
[in]summaryLatest forecast summary (trend, rate, ETA, status).
Returns
Formatted report, or "No forecasts available".

◆ initialize()

void hm::Disk_Forecaster::initialize ( )

Initialize the Disk Forecaster.

Performs initialization after construction. Call this immediately after creating the collector.

◆ initialize_test()

int hm::Disk_Forecaster::initialize_test ( )
protected

Initialize the unit test.

Assumes run_mode = TEST

Returns
0 if test initialized, 1 otherwise

◆ initialize_timers()

void hm::Disk_Forecaster::initialize_timers ( )

Initialize the forecast and report timers.

◆ is_new_run_mode()

bool hm::Disk_Forecaster::is_new_run_mode ( ) const
inline

◆ load_unit_test_data()

int hm::Disk_Forecaster::load_unit_test_data ( )
protected

Load the unit test data into the disk metrics buffer.

Returns
0 if successful, non-zero otherwise

◆ log_forecast_status()

void hm::Disk_Forecaster::log_forecast_status ( std::vector< Disk_Forecast > &  forecasts,
Disk_Forecast_Summary &  summary 
)
protected

Send disk usage forecast summary to the error log.

Parameters
forecastsThe most recent forecast record
summaryThe last forecast summary

◆ log_info_message() [1/2]

void hm::Disk_Forecaster::log_info_message ( const std::string &  msg)
protected

Informational message with collector state and forecast status.

◆ log_info_message() [2/2]

void hm::Disk_Forecaster::log_info_message ( const std::string &  msg,
bool  levels 
)
protected

Informational message with collector state and optional forecast status.

◆ log_resource_levels()

void hm::Disk_Forecaster::log_resource_levels ( )
overrideprotectedvirtual

Forecast status, no message.

Reimplemented from hm::Collector.

◆ log_resource_status()

void hm::Disk_Forecaster::log_resource_status ( )
overrideprotectedvirtual

Collector or forecast status.

Implements hm::Collector.

◆ model_lock()

mysql_rwlock_t * hm::Disk_Forecaster::model_lock ( )
staticprivate

◆ operator=() [1/2]

Disk_Forecaster & hm::Disk_Forecaster::operator= ( const Disk_Forecaster &  )
delete

◆ operator=() [2/2]

Disk_Forecaster & hm::Disk_Forecaster::operator= ( Disk_Forecaster &&  )
delete

◆ post_process()

void hm::Disk_Forecaster::post_process ( )
overridevirtual

Issue a status message after stopping the collection cycle.

Reimplemented from hm::Thread.

◆ pre_process()

void hm::Disk_Forecaster::pre_process ( )
overridevirtual

Issue status before starting the collection cycle.

Reimplemented from hm::Thread.

◆ process()

void hm::Disk_Forecaster::process ( )
overridevirtual

Main processing loop, 10 second interval.

Get disk metrics every minute, generate forecasts, issue forecast reports.

Reimplemented from hm::Collector.

◆ process_normal_cycle()

void hm::Disk_Forecaster::process_normal_cycle ( )

Normal processing cycle.

Get disk metrics every minute, generate forecasts, issue forecast reports.

◆ process_test_cycle()

int hm::Disk_Forecaster::process_test_cycle ( )
protected

Runs the unit test driven by the test data file.

Returns
0 if successful, non-zero otherwise

◆ read_unit_test_file()

int hm::Disk_Forecaster::read_unit_test_file ( std::vector< Disk_Metric > &  disk_metrics)
protected

Read the unit test file and populate the disk metrics buffer.

Parameters
disk_metricsVector to hold the parsed disk metrics
Returns
0 if successful, non-zero otherwise

◆ ready_to_forecast()

bool hm::Disk_Forecaster::ready_to_forecast ( bool  log_warning = true)
private

Check if the forecaster is ready to produce forecasts.

Parameters
log_warningWhether to log a warning if not ready.
Returns
True if ready, false otherwise.

◆ report_interval()

int hm::Disk_Forecaster::report_interval ( ) const
inline

◆ report_timer()

Cycle_Timer & hm::Disk_Forecaster::report_timer ( )
inlineprotected

◆ reset_filesystem_series() [1/2]

void hm::Disk_Forecaster::reset_filesystem_series ( )

Reset disk metrics and forecasts before sampling a different filesystem.

◆ reset_filesystem_series() [2/2]

void hm::Disk_Forecaster::reset_filesystem_series ( Disk_forecast_reset_context &  context)
static

◆ run_mode()

Dfx_Run_Mode hm::Disk_Forecaster::run_mode ( ) const
inline

◆ run_mode_name()

const std::string & hm::Disk_Forecaster::run_mode_name ( )

◆ run_mode_name_ptr()

const char * hm::Disk_Forecaster::run_mode_name_ptr ( ) const
inline

◆ run_unit_test()

void hm::Disk_Forecaster::run_unit_test ( )
protected

Run the unit test: Generate forecasts from the uploaded disk metric data, update the forecast tables with results, write the forecast report to the diagnostics log.

◆ running()

bool hm::Disk_Forecaster::running ( ) const
overridevirtual

Return health_monitor.disk_forecast_running.

Reimplemented from hm::Thread.

◆ save_forecast_status()

void hm::Disk_Forecaster::save_forecast_status ( const std::vector< Disk_Forecast > &  forecasts,
const Disk_Forecast_Summary &  summary 
)
inlineprivate

◆ set_disk_forecast_buffer_size()

void hm::Disk_Forecaster::set_disk_forecast_buffer_size ( )
private

Set the sizes for the disk forecast and disk forecast summary buffers.

Must be inside collector lock.

◆ set_disk_input_available()

void hm::Disk_Forecaster::set_disk_input_available ( bool  available)
inline

◆ set_disk_metric_aggregate_buffer_size()

void hm::Disk_Forecaster::set_disk_metric_aggregate_buffer_size ( )
private

Set the disk metric aggregated buffer size to include rows for all 3 aggregation tiers.

Must be inside collector lock.

◆ set_disk_metric_buffer_size()

void hm::Disk_Forecaster::set_disk_metric_buffer_size ( )
private

Resize the disk metric time series buffer if sample interval changes.

Must be inside collector lock.

◆ set_is_new_run_mode()

void hm::Disk_Forecaster::set_is_new_run_mode ( bool  is_new)
inline

◆ set_params()

void hm::Disk_Forecaster::set_params ( )
finalvirtual

Set collection parameters from the system variables.

Reimplemented from hm::Collector.

◆ set_run_mode()

void hm::Disk_Forecaster::set_run_mode ( Dfx_Run_Mode  mode)

◆ set_test_state()

void hm::Disk_Forecaster::set_test_state ( Dfx_Test_State  state)

◆ set_total_metric_count()

void hm::Disk_Forecaster::set_total_metric_count ( size_t  metric_count)
inlineprivate

◆ set_volume_size_changed()

void hm::Disk_Forecaster::set_volume_size_changed ( bool  change)
inlineprivate

◆ short_report_timer()

Cycle_Timer & hm::Disk_Forecaster::short_report_timer ( )
inlineprotected

◆ static_settings_changed()

bool hm::Disk_Forecaster::static_settings_changed ( )
overridevirtual

Indicate if the static Disk Forecast settings have changed.

Changes to static settings require that the collector thread be restarted.

Returns
true if settings have changed

Reimplemented from hm::Collector.

◆ status_snapshot()

Disk_Forecaster::Status_snapshot hm::Disk_Forecaster::status_snapshot ( ) const

◆ test_filename()

std::string hm::Disk_Forecaster::test_filename ( )
inline

◆ test_state()

Dfx_Test_State hm::Disk_Forecaster::test_state ( ) const
inline

◆ test_state_name()

const std::string & hm::Disk_Forecaster::test_state_name ( )

◆ test_state_name_ptr()

const char * hm::Disk_Forecaster::test_state_name_ptr ( ) const
inline

◆ update_forecast_tables()

void hm::Disk_Forecaster::update_forecast_tables ( std::vector< Disk_Forecast > &  forecasts,
Disk_Forecast_Summary &  summary 
)
private

Update disk forecast buffers with the lastest forecast and summary.

Parameters
[in]forecastsVector of forecasts for 1h, 1d, 1w
[in]summaryForecast summary record

◆ update_settings()

bool hm::Disk_Forecaster::update_settings ( )
overridevirtual

Apply pending settings unless a Disk Forecaster processing cycle is active.

This method is called from the Supervisor thread.

If a cycle is active, leave the settings pending and return so the Supervisor can update other collectors. The Disk Forecaster thread signals the Supervisor after the cycle completes.

Returns
true if settings were applied, false if processing is active

Reimplemented from hm::Collector.

◆ update_storage_totals()

void hm::Disk_Forecaster::update_storage_totals ( const Disk_Metric &  disk_metric)
private

Update storage totals, convert to MiB.

Note
The caller must hold the forecast-model write lock.

◆ volume()

std::string hm::Disk_Forecaster::volume ( )
inline

◆ volume_size_changed()

bool hm::Disk_Forecaster::volume_size_changed ( ) const
inlineprivate

Member Data Documentation

◆ dfx_run_mode_names

const char * hm::Disk_Forecaster::dfx_run_mode_names
static
Initial value:
= {
RUN_MODE_NAMES[0].c_str(), RUN_MODE_NAMES[1].c_str(),
RUN_MODE_NAMES[2].c_str(), RUN_MODE_NAMES[3].c_str(), nullptr}
static const std::array< std::string, 4 > RUN_MODE_NAMES
Definition: health_monitor_disk_forecaster.h:79

◆ FORECAST_STATUS_NAMES

const std::array< std::string, 4 > hm::Disk_Forecaster::FORECAST_STATUS_NAMES
static
Initial value:
= {
"NONE", "NORMAL", "WARNING", "CRITICAL"}

◆ k_disk_forecast_base_interval_seconds

constexpr int hm::Disk_Forecaster::k_disk_forecast_base_interval_seconds {10}
staticconstexprprivate

◆ k_forecast_interval_seconds

constexpr int hm::Disk_Forecaster::k_forecast_interval_seconds {seconds_per_hour}
staticconstexprprivate

◆ k_forecast_retention_seconds

constexpr int hm::Disk_Forecaster::k_forecast_retention_seconds {seconds_per_day * 14}
staticconstexprprivate

◆ k_metric_retention_seconds

constexpr size_t hm::Disk_Forecaster::k_metric_retention_seconds {seconds_per_day * 14}
staticconstexprprivate

◆ k_report_interval_seconds

constexpr int hm::Disk_Forecaster::k_report_interval_seconds {seconds_per_hour * 4}
staticconstexprprivate

◆ k_tier_1_days

constexpr int hm::Disk_Forecaster::k_tier_1_days {23}
staticconstexprprivate

◆ k_tier_1_rows

constexpr int hm::Disk_Forecaster::k_tier_1_rows {minutes_per_day / k_tier_1_days}
staticconstexprprivate

◆ k_tier_2_days

constexpr int hm::Disk_Forecaster::k_tier_2_days {60}
staticconstexprprivate

◆ k_tier_2_rows

constexpr int hm::Disk_Forecaster::k_tier_2_rows {minutes_per_day / k_tier_2_days}
staticconstexprprivate

◆ k_tier_3_days

constexpr int hm::Disk_Forecaster::k_tier_3_days {275}
staticconstexprprivate

◆ k_tier_3_rows

constexpr int hm::Disk_Forecaster::k_tier_3_rows {minutes_per_day / k_tier_3_days}
staticconstexprprivate

◆ k_time_series_interval_seconds

constexpr int hm::Disk_Forecaster::k_time_series_interval_seconds {60}
staticconstexprprivate

◆ m_aggregate_memory_key

PSI_memory_key hm::Disk_Forecaster::m_aggregate_memory_key {}
protected

◆ m_aggregate_rwlock_key

PSI_rwlock_key hm::Disk_Forecaster::m_aggregate_rwlock_key {}
protected

◆ m_configured_volume

std::string hm::Disk_Forecaster::m_configured_volume
private

◆ m_dfx_run_mode_name

char hm::Disk_Forecaster::m_dfx_run_mode_name {}
staticprivate

◆ m_dfx_test_state_name

char hm::Disk_Forecaster::m_dfx_test_state_name {}
staticprivate

◆ m_disk_forecast_buffer

Disk_Forecast_Buffer hm::Disk_Forecaster::m_disk_forecast_buffer
private

◆ m_disk_forecast_summary_buffer

Disk_Forecast_Summary_Buffer hm::Disk_Forecaster::m_disk_forecast_summary_buffer
private

◆ m_disk_input_available

std::atomic<bool> hm::Disk_Forecaster::m_disk_input_available {false}
private

◆ m_disk_metric_aggregate_buffer

Disk_Metric_Aggregate_Buffer hm::Disk_Forecaster::m_disk_metric_aggregate_buffer
private

◆ m_disk_metric_buffer

Disk_Metric_Buffer hm::Disk_Forecaster::m_disk_metric_buffer
private

◆ m_dynamic_settings_changed

bool hm::Disk_Forecaster::m_dynamic_settings_changed {false}
private

◆ m_first_normal_cycle

bool hm::Disk_Forecaster::m_first_normal_cycle {true}
private

◆ m_forecast_interval_seconds

int hm::Disk_Forecaster::m_forecast_interval_seconds {k_forecast_interval_seconds}
private

◆ m_forecast_memory_key

PSI_memory_key hm::Disk_Forecaster::m_forecast_memory_key {}
protected

◆ m_forecast_model_rwlock_key

PSI_rwlock_key hm::Disk_Forecaster::m_forecast_model_rwlock_key {}
protected

◆ m_forecast_rwlock_key

PSI_rwlock_key hm::Disk_Forecaster::m_forecast_rwlock_key {}
protected

◆ m_forecast_summary_memory_key

PSI_memory_key hm::Disk_Forecaster::m_forecast_summary_memory_key {}
protected

◆ m_forecast_summary_rwlock_key

PSI_rwlock_key hm::Disk_Forecaster::m_forecast_summary_rwlock_key {}
protected

◆ m_forecast_timer

Cycle_Timer hm::Disk_Forecaster::m_forecast_timer
private

◆ m_forecaster

Holt_Winters_Forecaster hm::Disk_Forecaster::m_forecaster
private

◆ m_is_new_run_mode

bool hm::Disk_Forecaster::m_is_new_run_mode {false}
private

◆ m_last_forecast_summary

Disk_Forecast_Summary hm::Disk_Forecaster::m_last_forecast_summary
private

◆ m_last_forecast_time

time_t hm::Disk_Forecaster::m_last_forecast_time {}
private

◆ m_last_forecasts

std::vector<Disk_Forecast> hm::Disk_Forecaster::m_last_forecasts
private

◆ m_last_total_mb

uint64_t hm::Disk_Forecaster::m_last_total_mb {}
private

◆ m_memory_info

PSI_memory_info hm::Disk_Forecaster::m_memory_info[4]
protected
Initial value:
= {
{&m_metric_memory_key, "disk_forecaster_metric", PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_PROVISIONING, "Health Monitor disk metrics buffer"},
{&m_aggregate_memory_key, "disk_forecaster_aggregate", PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_PROVISIONING, "Health Monitor aggregated metrics buffer"},
{&m_forecast_memory_key, "disk_forecaster_forecast", PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_PROVISIONING, "Health Monitor forecast buffer"},
{&m_forecast_summary_memory_key, "disk_forecaster_forecast_summary", PSI_FLAG_ONLY_GLOBAL_STAT, PSI_VOLATILITY_PROVISIONING, "Health Monitor forecast summary buffer"}
}
PSI_memory_key m_forecast_summary_memory_key
Definition: health_monitor_disk_forecaster.h:419
PSI_memory_key m_aggregate_memory_key
Definition: health_monitor_disk_forecaster.h:417
PSI_memory_key m_metric_memory_key
Definition: health_monitor_disk_forecaster.h:416
PSI_memory_key m_forecast_memory_key
Definition: health_monitor_disk_forecaster.h:418
#define PSI_VOLATILITY_PROVISIONING
Definition: psi_bits.h:155
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_bits.h:112

◆ m_metric_memory_key

PSI_memory_key hm::Disk_Forecaster::m_metric_memory_key {}
protected

◆ m_metric_rwlock_key

PSI_rwlock_key hm::Disk_Forecaster::m_metric_rwlock_key {}
protected

◆ m_model_lock

mysql_rwlock_t hm::Disk_Forecaster::m_model_lock {}
staticprivate

◆ m_processing_mutex

std::mutex hm::Disk_Forecaster::m_processing_mutex
private

◆ m_report_interval_seconds

int hm::Disk_Forecaster::m_report_interval_seconds {k_report_interval_seconds}
private

◆ m_report_timer

Cycle_Timer hm::Disk_Forecaster::m_report_timer
private

◆ m_run_mode

Dfx_Run_Mode hm::Disk_Forecaster::m_run_mode {Dfx_Run_Mode::NORMAL}
private

◆ m_rwlock_info

PSI_rwlock_info hm::Disk_Forecaster::m_rwlock_info[5]
protected
Initial value:
= {
}
PSI_rwlock_key m_metric_rwlock_key
Definition: health_monitor_disk_forecaster.h:403
PSI_rwlock_key m_forecast_rwlock_key
Definition: health_monitor_disk_forecaster.h:405
PSI_rwlock_key m_forecast_model_rwlock_key
Definition: health_monitor_disk_forecaster.h:407
PSI_rwlock_key m_aggregate_rwlock_key
Definition: health_monitor_disk_forecaster.h:404
PSI_rwlock_key m_forecast_summary_rwlock_key
Definition: health_monitor_disk_forecaster.h:406
#define PSI_DOCUMENT_ME
Definition: component_common.h:29
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:35

◆ m_series_mutex

std::mutex hm::Disk_Forecaster::m_series_mutex
private

◆ m_settings_mutex

std::mutex hm::Disk_Forecaster::m_settings_mutex
private

◆ m_short_report_interval_seconds

int hm::Disk_Forecaster::m_short_report_interval_seconds {seconds_per_hour}
private

◆ m_short_report_timer

Cycle_Timer hm::Disk_Forecaster::m_short_report_timer
private

◆ m_static_settings_changed

bool hm::Disk_Forecaster::m_static_settings_changed {false}
private

◆ m_test_filename

std::string hm::Disk_Forecaster::m_test_filename
private

◆ m_test_state

Dfx_Test_State hm::Disk_Forecaster::m_test_state {Dfx_Test_State::NONE}
private

◆ m_total_mb

uint64_t hm::Disk_Forecaster::m_total_mb {}
private

◆ m_total_metric_count

size_t hm::Disk_Forecaster::m_total_metric_count {}
private

◆ m_used_mb

uint64_t hm::Disk_Forecaster::m_used_mb {}
private

◆ m_used_pct

double hm::Disk_Forecaster::m_used_pct {}
private

◆ m_volume

std::string hm::Disk_Forecaster::m_volume
private

◆ m_volume_generation

uint64_t hm::Disk_Forecaster::m_volume_generation {0}
private

◆ m_volume_size_changed

bool hm::Disk_Forecaster::m_volume_size_changed {}
private

◆ RUN_MODE_NAMES

const std::array< std::string, 4 > hm::Disk_Forecaster::RUN_MODE_NAMES
static
Initial value:
= {
"NONE", "NORMAL", "TEST", "STANDBY"}

◆ TEST_STATE_NAMES

const std::array< std::string, 3 > hm::Disk_Forecaster::TEST_STATE_NAMES
static
Initial value:
= {
"NONE", "IDLE", "RUNNING"}

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