MySQL 26.10.0
Source Code Documentation
health_monitor_disk_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2025, 2026, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#pragma once
25
26#include "fx_point_forecast.h"
28#include "health_monitor_metric_buffer.h" // and Stat_Buffer
29
30namespace hm {
31
32/**
33 Disk Info
34 Record structure for health_block_device.
35*/
36struct Disk_Info {
37 Disk_Info() = default;
38 std::string device_name;
39 time_t timestamp{};
40 uint64_t total_bytes{};
41 uint64_t avail_bytes{};
42 std::string mount_point;
43 std::string mount_source;
44 std::string filesystem_id;
45 std::string filesystem_type;
46 // True if block device, e.g. /dev/sdc vs /dev/shm
47 bool block_device{false};
48 bool partition{false};
49};
50
51using Disk_Stats_Buffer = std::shared_ptr<Stat_Buffer<Disk_Info>>;
52
53/**
54 Disk metric time series.
55*/
57 Disk_Metric() = default;
58 Disk_Metric(time_t ts, uint64_t total_bytes, uint64_t used_bytes)
59 : timestamp(ts),
60 total_mb(static_cast<double>(total_bytes / MiB)),
61 used_mb(static_cast<double>(used_bytes / MiB)) {}
62 Disk_Metric(const Disk_Info &disk_info)
63 : timestamp(disk_info.timestamp),
64 total_mb(static_cast<double>(disk_info.total_bytes / MiB)),
65 used_mb(static_cast<double>(
66 (disk_info.total_bytes - disk_info.avail_bytes) / MiB)) {}
67 time_t timestamp{};
68 double total_mb{};
69 double used_mb{};
70};
71
72using Disk_Metric_Buffer = std::shared_ptr<Metric_Buffer<Disk_Metric>>;
73
74/**
75 Aggregated disk metric.
76*/
78 time_t timestamp{}; // start time of aggregation window
79 int32_t interval{}; // aggregation window size (minutes)
80 double usage_pct_min{}; // minimum disk usage percent
81 double usage_pct_max{}; // maximum disk usage percent
82 double usage_pct_avg{}; // average disk usage percent
83 double usage_stddev{}; // standard deviation of usage percent
84 int32_t sample_count{}; // samples in aggregation window
85};
86
88 std::shared_ptr<Stat_Buffer<Disk_Metric_Aggregate>>;
89
90// Forecast depletion ETA classifications
92
93/**
94 Forecast record. Values are defined as double to preserve accuracy over
95 multiple iterations.
96*/
98 Disk_Forecast() = default;
99 Disk_Forecast(const Point_Forecast &pf, double vol_size_mb)
100 : timestamp(time(nullptr)),
101 prediction_time(static_cast<time_t>(pf.ts_pred)),
103 volume_size_mb(vol_size_mb),
104 forecast_mb(pf.yhat),
105 ci_lower_mb(pf.ci_low),
106 ci_upper_mb(pf.ci_high) {}
107 time_t timestamp{}; // time of forecast
108 time_t prediction_time{}; // predicted time of the forecasted values
109 int32_t horizon_minutes{}; // forecast horizon in minutes (60, 1440, 10080)
110 double volume_size_mb{}; // filesystem capacity (MiB)
111 double forecast_mb{}; // predicted available disk space (MiB)
112 double ci_lower_mb{}; // lower bound of confidence interval (MiB)
113 double ci_upper_mb{}; // upper bound of confidence interval (MiB)
114};
115
116using Disk_Forecast_Buffer = std::shared_ptr<Stat_Buffer<Disk_Forecast>>;
117
119 time_t timestamp{}; // time of forecast
120 // Inputs echoed
121 double volume_size_mb{0.0};
122 double current_usage_mb{0.0};
123 double current_usage_pct{0.0};
124 // Trend diagnostics
125 double trend_per_day_mb{0.0}; // signed MB/day
126 double usage_rate_pct_per_day{0.0}; // signed % of volume per day
127 // Depletion ETA
128 bool has_depletion_eta{false};
129 double days_to_full{0.0}; // valid iff has_depletion_eta
130 // Status
132};
133
135 std::shared_ptr<Stat_Buffer<Disk_Forecast_Summary>>;
136
137} // namespace hm
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
Definition: component_command.h:29
Dfx_Status
Definition: health_monitor_disk_bits.h:91
std::shared_ptr< Stat_Buffer< Disk_Metric_Aggregate > > Disk_Metric_Aggregate_Buffer
Definition: health_monitor_disk_bits.h:88
std::shared_ptr< Stat_Buffer< Disk_Info > > Disk_Stats_Buffer
Definition: health_monitor_disk_bits.h:51
std::shared_ptr< Stat_Buffer< Disk_Forecast_Summary > > Disk_Forecast_Summary_Buffer
Definition: health_monitor_disk_bits.h:135
static constexpr double MiB
Definition: health_monitor_constants.h:57
std::shared_ptr< Stat_Buffer< Disk_Forecast > > Disk_Forecast_Buffer
Definition: health_monitor_disk_bits.h:116
std::shared_ptr< Metric_Buffer< Disk_Metric > > Disk_Metric_Buffer
Definition: health_monitor_disk_bits.h:72
Raw forecast record.
Definition: fx_point_forecast.h:31
Definition: health_monitor_disk_bits.h:118
bool has_depletion_eta
Definition: health_monitor_disk_bits.h:128
double trend_per_day_mb
Definition: health_monitor_disk_bits.h:125
time_t timestamp
Definition: health_monitor_disk_bits.h:119
double current_usage_pct
Definition: health_monitor_disk_bits.h:123
double current_usage_mb
Definition: health_monitor_disk_bits.h:122
double volume_size_mb
Definition: health_monitor_disk_bits.h:121
Dfx_Status status
Definition: health_monitor_disk_bits.h:131
double usage_rate_pct_per_day
Definition: health_monitor_disk_bits.h:126
double days_to_full
Definition: health_monitor_disk_bits.h:129
Forecast record.
Definition: health_monitor_disk_bits.h:97
double ci_lower_mb
Definition: health_monitor_disk_bits.h:112
Disk_Forecast()=default
double volume_size_mb
Definition: health_monitor_disk_bits.h:110
Disk_Forecast(const Point_Forecast &pf, double vol_size_mb)
Definition: health_monitor_disk_bits.h:99
time_t timestamp
Definition: health_monitor_disk_bits.h:107
double forecast_mb
Definition: health_monitor_disk_bits.h:111
double ci_upper_mb
Definition: health_monitor_disk_bits.h:113
time_t prediction_time
Definition: health_monitor_disk_bits.h:108
int32_t horizon_minutes
Definition: health_monitor_disk_bits.h:109
Disk Info Record structure for health_block_device.
Definition: health_monitor_disk_bits.h:36
std::string mount_point
Definition: health_monitor_disk_bits.h:42
uint64_t avail_bytes
Definition: health_monitor_disk_bits.h:41
bool block_device
Definition: health_monitor_disk_bits.h:47
Disk_Info()=default
uint64_t total_bytes
Definition: health_monitor_disk_bits.h:40
std::string filesystem_type
Definition: health_monitor_disk_bits.h:45
time_t timestamp
Definition: health_monitor_disk_bits.h:39
std::string device_name
Definition: health_monitor_disk_bits.h:38
std::string mount_source
Definition: health_monitor_disk_bits.h:43
bool partition
Definition: health_monitor_disk_bits.h:48
std::string filesystem_id
Definition: health_monitor_disk_bits.h:44
Aggregated disk metric.
Definition: health_monitor_disk_bits.h:77
double usage_pct_min
Definition: health_monitor_disk_bits.h:80
double usage_stddev
Definition: health_monitor_disk_bits.h:83
int32_t sample_count
Definition: health_monitor_disk_bits.h:84
int32_t interval
Definition: health_monitor_disk_bits.h:79
double usage_pct_avg
Definition: health_monitor_disk_bits.h:82
time_t timestamp
Definition: health_monitor_disk_bits.h:78
double usage_pct_max
Definition: health_monitor_disk_bits.h:81
Disk metric time series.
Definition: health_monitor_disk_bits.h:56
time_t timestamp
Definition: health_monitor_disk_bits.h:67
Disk_Metric(const Disk_Info &disk_info)
Definition: health_monitor_disk_bits.h:62
double total_mb
Definition: health_monitor_disk_bits.h:68
Disk_Metric()=default
Disk_Metric(time_t ts, uint64_t total_bytes, uint64_t used_bytes)
Definition: health_monitor_disk_bits.h:58
double used_mb
Definition: health_monitor_disk_bits.h:69