MySQL 26.10.0
Source Code Documentation
system_info_platform.h
Go to the documentation of this file.
1/* Copyright (c) 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#pragma once
25
26#include <chrono>
27#include <cstdint>
28#include <string_view>
29#include <system_error>
30
32
34
35/** Collect filesystem information for the active platform. */
36[[nodiscard]] Filesystem_snapshot query_filesystem_platform(
37 std::string_view path);
38
39/** Collect storage device information for the active platform. */
40[[nodiscard]] Storage_snapshot query_storage_devices_platform();
41
42/** Collect host memory information for the active platform. */
43[[nodiscard]] Host_memory_snapshot query_host_memory_platform();
44
45/** Collect host CPU information for the active platform. */
46[[nodiscard]] Host_cpu_snapshot query_host_cpu_platform();
47
48/** Collect process memory information for the active platform. */
49[[nodiscard]] Process_memory_snapshot query_process_memory_platform();
50
51/** Collect process thread information for the active platform. */
52[[nodiscard]] Process_threads_snapshot query_process_threads_platform();
53
54/**
55 Convert cumulative CPU ticks to whole milliseconds.
56
57 @param[in] ticks Cumulative CPU ticks
58 @param[in] ticks_per_second Number of CPU ticks per second
59 @param[out] milliseconds Converted whole milliseconds, unchanged on error
60 @retval false Success
61 @retval true Error
62*/
63[[nodiscard]] bool cpu_ticks_to_milliseconds(
64 uint64_t ticks, uint64_t ticks_per_second,
66
67#ifdef __APPLE__
68/** Create an error code in the native Mach error domain. */
69[[nodiscard]] std::error_code mach_error_code(int error);
70#endif
71
72/**
73 Reject invalid available filesystem usage values.
74
75 The function transforms its snapshot argument and returns the transformed
76 value. Passing an lvalue preserves the original. Passing a moved value avoids
77 a copy.
78*/
79[[nodiscard]] Filesystem_snapshot validate_filesystem_snapshot(
80 Filesystem_snapshot snapshot);
81
82/**
83 Reject invalid available storage device values.
84*/
85[[nodiscard]] Storage_snapshot validate_storage_snapshot(
86 Storage_snapshot snapshot);
87
88/**
89 Reject invalid available host memory values.
90*/
91[[nodiscard]] Host_memory_snapshot validate_host_memory_snapshot(
92 Host_memory_snapshot snapshot);
93
94/**
95 Reject invalid available host CPU values.
96*/
97[[nodiscard]] Host_cpu_snapshot validate_host_cpu_snapshot(
98 Host_cpu_snapshot snapshot);
99
100/**
101 Reject invalid available process identity values.
102*/
103[[nodiscard]] Process_memory_snapshot validate_process_memory_snapshot(
104 Process_memory_snapshot snapshot);
105
106/**
107 Reject invalid available process thread values.
108*/
109[[nodiscard]] Process_threads_snapshot validate_process_threads_snapshot(
110 Process_threads_snapshot snapshot);
111
112} // namespace mysql::system_info::internal
static char * path
Definition: mysqldump.cc:153
std::chrono::milliseconds milliseconds
Definition: authorize_manager.cc:70
Definition: system_info_linux.cc:46
Storage_snapshot query_storage_devices_platform()
Collect Linux storage device metadata from procfs and sysfs.
Definition: system_info_linux.cc:187
Host_memory_snapshot validate_host_memory_snapshot(Host_memory_snapshot snapshot)
Reject invalid available host memory values.
Definition: system_info.cc:252
Host_memory_snapshot query_host_memory_platform()
Collect Linux host memory from procfs.
Definition: system_info_linux.cc:208
Filesystem_snapshot query_filesystem_platform(std::string_view)
Collect Linux filesystem identity and space metadata for one path.
Definition: system_info_unsupported.cc:28
Host_cpu_snapshot validate_host_cpu_snapshot(Host_cpu_snapshot snapshot)
Reject invalid available host CPU values.
Definition: system_info.cc:277
Storage_snapshot validate_storage_snapshot(Storage_snapshot snapshot)
Reject invalid available storage device values.
Definition: system_info.cc:146
Host_cpu_snapshot query_host_cpu_platform()
Collect cumulative Linux CPU times from /proc/stat.
Definition: system_info_linux.cc:267
Process_memory_snapshot query_process_memory_platform()
Collect Linux process memory metadata.
Definition: system_info_linux.cc:321
std::error_code mach_error_code(int error)
Convert a Mach return code to std::error_code.
Definition: system_info_macos.cc:160
Filesystem_snapshot validate_filesystem_snapshot(Filesystem_snapshot snapshot)
Reject invalid available filesystem usage values.
Definition: system_info.cc:128
bool cpu_ticks_to_milliseconds(uint64_t ticks, uint64_t ticks_per_second, std::chrono::milliseconds &milliseconds)
Convert cumulative CPU ticks to whole milliseconds.
Definition: system_info.cc:103
Process_memory_snapshot validate_process_memory_snapshot(Process_memory_snapshot snapshot)
Reject invalid available process identity values.
Definition: system_info.cc:311
Process_threads_snapshot validate_process_threads_snapshot(Process_threads_snapshot snapshot)
Reject invalid available process thread values.
Definition: system_info.cc:328
Process_threads_snapshot query_process_threads_platform()
Collect Linux thread metadata for the current process.
Definition: system_info_linux.cc:391