-
Notifications
You must be signed in to change notification settings - Fork 862
Expand file tree
/
Copy pathILinuxUtilizationParser.cs
More file actions
92 lines (80 loc) · 4.42 KB
/
ILinuxUtilizationParser.cs
File metadata and controls
92 lines (80 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux;
/// <summary>
/// An interface to be implemented by a parser that reads files and extracts resource utilization data from them.
/// For both versions of cgroup controllers, the parser reads files from the /sys/fs/cgroup directory.
/// </summary>
internal interface ILinuxUtilizationParser
{
/// <summary>
/// Reads file /sys/fs/cgroup/memory.max, which is used to check the maximum amount of memory that can be used by a cgroup.
/// It is part of the cgroup v2 memory controller.
/// </summary>
/// <returns>maybeMemory.</returns>
ulong GetAvailableMemoryInBytes();
/// <summary>
/// Reads the file /sys/fs/cgroup/cpu.stat, which is part of the cgroup v2 CPU controller.
/// It provides statistics about the CPU usage of a cgroup.
/// </summary>
/// <returns>nanoseconds.</returns>
long GetCgroupCpuUsageInNanoseconds();
/// <summary>
/// For CgroupV2 only and experimental. Reads the file cpu.stat based on /proc/self/cgroup, which is part of the cgroup v2 CPU controller.
/// It provides statistics about the CPU usage of a cgroup from its actual slice.
/// </summary>
/// <returns>nanoseconds.</returns>
long GetCgroupCpuUsageInNanosecondsV2();
/// <summary>
/// Reads the file /sys/fs/cgroup/cpu.max, which is part of the cgroup v2 CPU controller.
/// It is used to set the maximum amount of CPU time that can be used by a cgroup.
/// The file contains two fields, separated by a space.
/// The first field is the quota, which specifies the maximum amount of CPU time (in microseconds) that can be used by the cgroup during one period.
/// The second value is the period, which specifies the length of a period in microseconds.
/// </summary>
/// <returns>cpuUnits.</returns>
float GetCgroupLimitedCpus();
/// <summary>
/// For CgroupV2 only and experimental. Reads the file cpu.max based on /proc/self/cgroup, which is part of the cgroup v2 CPU controller.
/// It is used to set the maximum amount of CPU time that can be used by a cgroup from actual slice.
/// The file contains two fields, separated by a space.
/// The first field is the quota, which specifies the maximum amount of CPU time (in microseconds) that can be used by the cgroup during one period.
/// The second value is the period, which specifies the length of a period in microseconds.
/// </summary>
/// <returns>cpuUnits.</returns>
float GetCgroupLimitV2();
/// <summary>
/// Reads the file /proc/stat, which provides information about the system’s memory usage.
/// It contains information about the total amount of installed memory, the amount of free and used memory, and the amount of memory used by the kernel and buffers/cache.
/// </summary>
/// <returns>memory.</returns>
ulong GetHostAvailableMemory();
/// <summary>
/// Reads the file /sys/fs/cgroup/cpuset.cpus.effective, which is part of the cgroup v2 cpuset controller.
/// It shows the effective cpus that the cgroup can use.
/// </summary>
/// <returns>cpuCount.</returns>
float GetHostCpuCount();
/// <summary>
/// Reads the file /sys/fs/cgroup/cpu.stat, which is part of the cgroup v2 CPU controller.
/// It provides statistics about the CPU usage of a cgroup.
/// The file contains several fields, including usage_usec, which shows the total CPU time (in microseconds).
/// </summary>
/// <returns>total / (double)_userHz * NanosecondsInSecond.</returns>
long GetHostCpuUsageInNanoseconds();
/// <summary>
/// Reads the file /sys/fs/cgroup/memory.current, which is a file that contains the current memory usage of a cgroup in bytes.
/// </summary>
/// <returns>memoryUsage.</returns>
ulong GetMemoryUsageInBytes();
/// <summary>
/// Reads the file /sys/fs/cgroup/cpu.weight. And calculates the Pod CPU Request in millicores.
/// </summary>
/// <returns>cpuPodRequest.</returns>
float GetCgroupRequestCpu();
/// <summary>
/// For CgroupV2 only and experimental. Reads the file cpu.weight based on /proc/self/cgroup. And calculates the Pod CPU Request in millicores based on actual slice.
/// </summary>
/// <returns>cpuPodRequest.</returns>
float GetCgroupRequestCpuV2();
}