MySQL 26.10.0
Source Code Documentation
health_monitor_memory_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
32
33namespace hm {
34
35/**
36 Convert a host memory snapshot into a System Memory Stats record.
37
38 The snapshot must have a valid System_result to be converted.
39 - 'Unavailable' for a value means there is no equivalent on this platform.
40 - 'Failed' means that the collection attempt failed.
41
42 For example, swap_activity is available on Linux but not macOS, and would be
43 represented as NULL in the memory tables.
44
45 @param[in] snapshot Memory snapshot to convert
46 @param[in] timestamp Timestamp for the converted record
47 @param[in,out] output Destination record, no change on failure
48 @return true on success, false on failure
49*/
52 System_Memory_Stats &output);
53
54/**
55 Convert a host memory snapshot into a Memory Collector record.
56
57 The snapshot must have a valid System_result to be converted.
58 - 'Unavailable' for a value means there is no equivalent on this platform.
59 - 'Failed' means that the collection attempt failed.
60
61 If the record is complete but a value is unavailable, then that value is
62 represented as NULL in the table.
63
64 @param[in] snapshot Host memory snapshot to convert
65 @param[in,out] output Destination record, no change on failure
66 @return true on success, false on failure
67*/
70 System_Memory_Info &output);
71
73 time_t m_timestamp{0};
74 uint64_t m_total_bytes{0};
75 uint64_t m_free_bytes{0};
76 uint64_t m_avail_bytes{0};
77 uint64_t m_cached_bytes{0};
78 uint64_t m_swap_total_bytes{0};
79 uint64_t m_swap_free_bytes{0};
80 float m_use_percent{0};
81 bool m_cache_available{false};
83};
84
85/**
86 Convert a system memory record into a Performance Schema table row.
87
88 @param[in] record System-memory record to convert
89 @return Converted table row
90*/
91Health_system_memory_row make_health_system_memory_row(
92 const System_Memory_Info &record);
93
94/**
95 Determine whether a nullable memory column is NULL.
96
97 @param[in] row Table row
98 @param[in] index Performance Schema column index
99 @return true when the column is NULL
100*/
101bool health_system_memory_column_is_null(const Health_system_memory_row &row,
102 unsigned int index);
103
104} // 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 health_system_memory_column_is_null(const Health_system_memory_row &row, const unsigned int index)
Determine whether a nullable memory column is NULL.
Definition: health_monitor_memory_mapping.cc:146
Health_system_memory_row make_health_system_memory_row(const System_Memory_Info &record)
Convert a system memory record into a Performance Schema table row.
Definition: health_monitor_memory_mapping.cc:126
bool convert_host_memory_snapshot(const mysql::system_info::Host_memory_snapshot &snapshot, const time_t timestamp, System_Memory_Stats &output)
Convert a host memory snapshot into a System Memory Stats record.
Definition: health_monitor_memory_mapping.cc:37
Definition: health_monitor_memory_mapping.h:72
uint64_t m_cached_bytes
Definition: health_monitor_memory_mapping.h:77
uint64_t m_total_bytes
Definition: health_monitor_memory_mapping.h:74
bool m_swap_capacity_available
Definition: health_monitor_memory_mapping.h:82
uint64_t m_free_bytes
Definition: health_monitor_memory_mapping.h:75
time_t m_timestamp
Definition: health_monitor_memory_mapping.h:73
uint64_t m_swap_free_bytes
Definition: health_monitor_memory_mapping.h:79
float m_use_percent
Definition: health_monitor_memory_mapping.h:80
bool m_cache_available
Definition: health_monitor_memory_mapping.h:81
uint64_t m_swap_total_bytes
Definition: health_monitor_memory_mapping.h:78
uint64_t m_avail_bytes
Definition: health_monitor_memory_mapping.h:76
Host memory capabilities collected at one collection point.
Definition: system_info.h:296