MySQL 26.10.0
Source Code Documentation
health_monitor_storage_mapping.h
Go to the documentation of this file.
1/* Copyright (c) 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
27
28#include <ctime>
29#include <string>
30#include <vector>
31
33
34namespace hm {
35
37 time_t m_timestamp{0};
38 std::string m_device_name;
39 uint64_t m_reads{0};
40 uint64_t m_read_bytes{0};
41 uint64_t m_read_time_ms{0};
42 uint64_t m_writes{0};
43 uint64_t m_write_bytes{0};
44 uint64_t m_write_time_ms{0};
45 uint64_t m_flushes{0};
46 uint64_t m_flush_time_ms{0};
48 bool m_flush_available{false};
49};
50
51/**
52 Convert a storage snapshot into Health Monitor disk records.
53
54 This function merges five storage capabilities:
55 - Device inventory and disk/partition classification
56 - Capacity and sector size
57 - Read/write counters
58 - Flush counters
59 - Partition-to-disk hierarchy
60
61 Each capability contains rows keyed by a device name such as `sda` or `sda1`.
62 These rows are then joined into one System_Disk_Stats record per device.
63
64 For example:
65 inventory: sda = disk
66 capacity: sda = 1 TB
67 read_write: sda = 100 reads, 50 writes
68 flush: unavailable
69 produces an sda record with inventory, capacity and read/write counts, but
70 flush availability is false because it's not available on the platform.
71
72 @param[in] snapshot Storage snapshot to convert
73 @param[in] timestamp Timestamp to apply to every converted record
74 @param[in,out] output Destination records, unchanged unless data is available
75 @return Storage conversion result state
76*/
78 const mysql::system_info::Storage_snapshot &snapshot, time_t timestamp,
79 std::vector<System_Disk_Stats> &output);
80
81/**
82 Convert a disk record into a Performance Schema table row.
83
84 @param[in] record Disk record to convert
85 @return Converted table row
86*/
87System_Disk_Table_Row make_system_disk_table_row(
88 const System_Disk_Stats &record);
89
90/**
91 Determine whether disk table column is NULL.
92
93 @param[in] row Table row
94 @param[in] index Performance Schema column index
95 @return true when the column is NULL
96*/
97bool system_disk_table_column_is_null(const System_Disk_Table_Row &row,
98 unsigned int index);
99
100/**
101 Determine whether a read/write metric can use a disk record.
102
103 @param[in] record Disk record
104 @param[in] partition Device classification
105 @return true when the record is eligible
106*/
107bool system_disk_read_write_metric_eligible(const System_Disk_Stats &record,
108 bool partition);
109
110/**
111 Determine whether a flush metric can use a disk record.
112
113 @param[in] record Disk record
114 @param[in] partition Device classification
115 @return true when the record is eligible
116*/
117bool system_disk_flush_metric_eligible(const System_Disk_Stats &record,
118 bool partition);
119
120} // namespace hm
static int record
Definition: mysqltest.cc:195
constexpr value_type timestamp
Definition: classic_protocol_constants.h:278
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
Definition: component_command.h:29
bool system_disk_table_column_is_null(const System_Disk_Table_Row &row, const unsigned int index)
Determine whether disk table column is NULL.
Definition: health_monitor_storage_mapping.cc:227
Result_state convert_storage_snapshot(const mysql::system_info::Storage_snapshot &snapshot, const time_t timestamp, std::vector< System_Disk_Stats > &output)
Convert a storage snapshot into Health Monitor disk records.
Definition: health_monitor_storage_mapping.cc:75
bool system_disk_read_write_metric_eligible(const System_Disk_Stats &record, const bool partition)
Determine whether a read/write metric can use a disk record.
Definition: health_monitor_storage_mapping.cc:246
bool system_disk_flush_metric_eligible(const System_Disk_Stats &record, const bool partition)
Determine whether a flush metric can use a disk record.
Definition: health_monitor_storage_mapping.cc:252
System_Disk_Table_Row make_system_disk_table_row(const System_Disk_Stats &record)
Convert a disk record into a Performance Schema table row.
Definition: health_monitor_storage_mapping.cc:209
Result_state
State of one system information capability.
Definition: system_info.h:39
Definition: health_monitor_storage_mapping.h:36
uint64_t m_flushes
Definition: health_monitor_storage_mapping.h:45
bool m_flush_available
Definition: health_monitor_storage_mapping.h:48
std::string m_device_name
Definition: health_monitor_storage_mapping.h:38
time_t m_timestamp
Definition: health_monitor_storage_mapping.h:37
uint64_t m_read_time_ms
Definition: health_monitor_storage_mapping.h:41
uint64_t m_write_time_ms
Definition: health_monitor_storage_mapping.h:44
uint64_t m_flush_time_ms
Definition: health_monitor_storage_mapping.h:46
uint64_t m_reads
Definition: health_monitor_storage_mapping.h:39
uint64_t m_writes
Definition: health_monitor_storage_mapping.h:42
uint64_t m_read_bytes
Definition: health_monitor_storage_mapping.h:40
bool m_read_write_available
Definition: health_monitor_storage_mapping.h:47
uint64_t m_write_bytes
Definition: health_monitor_storage_mapping.h:43
Storage capabilities collected at one collection point.
Definition: system_info.h:261