MySQL 26.10.0
Source Code Documentation
health_monitor_filesystem_sample.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 <functional>
30#include <string>
31
33
34namespace hm {
35
37 initial,
41};
42
44 std::string filesystem_id;
45 uint64_t capacity_bytes{0};
46 bool initialized{false};
47};
48
49using Disk_series_reset_action = std::function<void()>;
50using Disk_record_writer = std::function<void(const Disk_Info &)>;
51
52/**
53 Convert a filesystem snapshot into a Disk Collector record.
54
55 The snapshot must be complete to be converted into a Disk Collector record.
56 - Filesystem_identity and Filesystem_usage must have a valid System_result.
57 - 'Unavailable' means there is no equivalent on this platform.
58 - 'Failed' means that the collection attempt failed.
59
60 @param[in] snapshot Filesystem snapshot to convert
61 @param[in,out] output Destination record, unchanged on failure
62 @return true on success, false on failure
63*/
65 const mysql::system_info::Filesystem_snapshot &snapshot, Disk_Info &output);
66
67/**
68 Classify a complete sample against the last successful sample.
69
70 @param[in] state Last successful filesystem identity and capacity
71 @param[in] sample Complete current filesystem sample
72 @return Classification of the current sample
73*/
75 const Filesystem_sample_state &state, const Disk_Info &sample);
76
77/**
78 Accept a complete snapshot and update the last successful sample state.
79
80 @param[in] snapshot Filesystem snapshot to convert
81 @param[in,out] state Last successful filesystem identity and capacity
82 @param[in,out] output Destination record, unchanged on failure
83 @param[in,out] change Sample classification, unchanged on failure
84 @return true on success, false on failure
85*/
88 Filesystem_sample_state &state, Disk_Info &output,
89 Filesystem_change &change);
90
91/**
92 Publish the records for one complete filesystem sample.
93
94 A sample is one-time filesystem observation. 'Publishing' the sample means:
95 - Set the timestamp.
96 - Write to the disk stats buffer (health_block_device).
97 - Write to the disk metrics buffer (disk_metrics).
98
99 @param[in,out] sample Complete sample to timestamp and publish
100 @param[in] timestamp Timestamp used for every published record
101 @param[in] write_stat Whether to publish the Performance Schema record
102 @param[in] write_metric Whether to publish the disk metric
103 @param[in] change Current sample classification
104 @param[in] reset_series If true, then reset the time series
105 @param[in] stat_writer health_block_device record writer
106 @param[in] metric_writer disk_metric record writer
107*/
109 bool write_stat, bool write_metric,
110 Filesystem_change change,
111 const Disk_series_reset_action &reset_series,
112 const Disk_record_writer &stat_writer,
113 const Disk_record_writer &metric_writer);
114
115} // namespace hm
constexpr value_type timestamp
Definition: classic_protocol_constants.h:278
Definition: component_command.h:29
void publish_filesystem_records(Disk_Info &sample, time_t timestamp, bool write_stat, bool write_metric, Filesystem_change change, const Disk_series_reset_action &reset_series, const Disk_record_writer &stat_writer, const Disk_record_writer &metric_writer)
Publish the records for one complete filesystem sample.
Definition: health_monitor_filesystem_sample.cc:96
bool accept_filesystem_snapshot(const mysql::system_info::Filesystem_snapshot &snapshot, Filesystem_sample_state &state, Disk_Info &output, Filesystem_change &change)
Accept a complete snapshot and update the last successful sample state.
Definition: health_monitor_filesystem_sample.cc:76
Filesystem_change classify_filesystem_change(const Filesystem_sample_state &state, const Disk_Info &sample)
Classify a complete sample against the last successful sample.
Definition: health_monitor_filesystem_sample.cc:64
bool convert_filesystem_snapshot(const mysql::system_info::Filesystem_snapshot &snapshot, Disk_Info &output)
Convert a filesystem snapshot into a Disk Collector record.
Definition: health_monitor_filesystem_sample.cc:35
std::function< void()> Disk_series_reset_action
Definition: health_monitor_disk_forecast_reset.h:72
Filesystem_change
Definition: health_monitor_filesystem_sample.h:36
std::function< void(const Disk_Info &)> Disk_record_writer
Definition: health_monitor_filesystem_sample.h:50
Disk Info Record structure for health_block_device.
Definition: health_monitor_disk_bits.h:36
Definition: health_monitor_filesystem_sample.h:43
bool initialized
Definition: health_monitor_filesystem_sample.h:46
uint64_t capacity_bytes
Definition: health_monitor_filesystem_sample.h:45
std::string filesystem_id
Definition: health_monitor_filesystem_sample.h:44
Filesystem identity and usage collected for one monitored path.
Definition: system_info.h:184