Skip to content

Commit ea8547c

Browse files
committed
Modifed diagram
2 parents 83fb3bc + ec2ce4c commit ea8547c

1 file changed

Lines changed: 48 additions & 65 deletions

File tree

doc/memory_statistics/memory_statistics_hld.md

Lines changed: 48 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
- [CLI Commands](#cli-commands)
3030
- [YANG Model Enhancements](#yang-model-enhancements)
3131
- [Config DB Enhancements](#config-db-enhancements)
32-
- [Configuration File for Memory Statistics Daemon](#configuration-file-for-memory-statistics-daemon)
3332
- [Warmboot and Fastboot Design Impact](#warmboot-and-fastboot-design-impact)
3433
- [Testing Requirements/Design](#testing-requirementsdesign)
3534
- [Unit Test Cases](#unit-test-cases)
@@ -40,7 +39,7 @@
4039

4140
| Version | Date | Description | Author |
4241
|---------|------------|---------------------------------------------------|-------------------------|
43-
| 1.0 | 2024-07-22 | Initial version | Arham Nasir |
42+
| 1.0 | 2024-07-22 | Initial version | Arham Nasir, Kanza Latif|
4443

4544
## Scope
4645

@@ -74,9 +73,9 @@ This section explains how Memory Statistics feature works, focusing on user cont
7473

7574
### Feature Overview
7675

77-
- **Feature Scope:** Memory Statistics feature offers a systematic approach to monitoring system-wide memory usage. It automatically records crucial metrics such as Total Memory, Used Memory, Free Memory, and Available Memory. For those requiring more in-depth analysis, additional metrics like Active Memory, Inactive Memory, and others are accessible via extended command options, providing a more detailed view.
78-
- **Configurability:** This feature offers customizable options for data collection frequency and the duration of data retention according to their specific operational needs. By default, the system is configured to collect memory data every 5 minutes and retains this information for 15 days, ensuring a balance between granularity and storage management.
79-
- **Enable/Disable Functionality:** This feature is enabled by default to ensure continuous monitoring but can be easily disabled to conserve system resources, suiting various administrative preferences.
76+
- **Feature Scope:** Memory Statistics feature offers a systematic approach to monitoring system-wide memory usage. It automatically records crucial metrics such as Total Memory, Used Memory, Free Memory, Available Memory, Cached Memory, Shared Memory and Buffers.
77+
- **Configurability:** This feature offers customizable options for data collection frequency and the duration of data retention according to their specific operational needs. By default, the system is configured to collect memory at all times and sample it every 5 minutes and retains this information for 15 days , ensuring a balance between granularity and storage management.
78+
- **Enable/Disable Functionality:** This feature is disabled by default to conserve system resources , suiting various administrative preferences but can be easily enabled to ensure continuous monitoring.
8079

8180

8281
### Feature Specification
@@ -90,9 +89,9 @@ Memory Statistics utilizes a dedicated systemd process for the periodic collecti
9089
User interaction with the Memory Statistics feature is designed to be straightforward and efficient, utilizing a set of powerful CLI commands that enable administrators to manage and analyze memory data effectively.The CLI interface includes commands for:
9190

9291
- **Viewing Memory Statistics:** Users can view memory data over custom time intervals with `--from` and `--to` options for defining the start and end times. This allows for flexible and targeted data analysis.
93-
- **Default Memory Overview:** For a quick general overview without specific parameters, the default command displays system memory statistics covering the last 15 days. This will provides a summary of crucial metrics such as Total Memory, Used Memory, Free Memory, and Available Memory, ideal for routine checks.
92+
- **Default Memory Overview:** For a quick general overview without specific parameters, the default command displays system memory statistics covering the last 15 days. This will provide a summary of crucial metrics such as Total Memory, Used Memory, Free Memory, Available Memory, Cached Memory, Shared Memory and Buffers, ideal for routine checks.
9493
- **Selecting Specific Memory Metrics:** This feature enables users to choose specific memory metrics to display, such as Total Memory or Free Memory, which helps in focusing on relevant data points and reducing output clutter.
95-
- **Configuring Data Collection and Retention:** Administrators can adjust the frequency of data collection and the duration of data retention through commands and can specify how long to retain the collected data.
94+
- **Configuring Data Collection and Retention:** Administrators can adjust the frequency of data collection and the duration of data retention through commands and can specify how long to retain the collected data for.
9695
- **Enabling/Disabling the Feature:** To adapt to different operational requirements, users can enable or disable the Memory Statistics feature as needed.
9796

9897
### Functional Requirements
@@ -104,19 +103,19 @@ User interaction with the Memory Statistics feature is designed to be straightfo
104103

105104
The overall SONiC architecture will remain the same. However, the following updates and additions will be implemented:
106105

107-
- **New Daemon Process:**
108-
- **memorystatsd:** A new systemd daemon process that will be implemented to gather and log memory statistics, utilizing configuration settings read from a designated configuration file.
109-
- **memstatsmgrd:** A new manager daemon that will monitor changes in the ConfigDB's `MEMORY_STATS_TABLE` and update the memorystats configuration file accordingly. `memstatsmgrd` will restart the `memorystatsd` service to apply the new settings.
106+
- **Daemon Process:**
107+
- **memorystatsd:** A new system daemon process that will be implemented to gather and log memory statistics.
108+
- **hostcfgd:** The existing host config daemon will monitor changes in the ConfigDB's `MEMORY_STATISTICS_TABLE` and will reload the `memorystatsd` service to apply the new settings.
110109

111110
- **Log File Directories:** Supporting log file directories will be established via SONiC Buildimage.
112-
- **SONiC Utilities Updates:** Changes will be made in the SONiC Utilities container to add new "show" commands for displaying memory statistics and "config" commands.
113-
- **New Configuration Table:** A new table, MEMORY_STATS_TABLE, will be added to ConfigDB to store memory-stats configuration parameters.
111+
- **SONiC Utilities Updates:** Changes will be made in the SONiC Utilities container to add new "show" and "config" commands.
112+
- **New Configuration Table:** A new table, MEMORY_STATISTICS_TABLE, will be added to ConfigDB to store memory-stats configuration parameters.
114113
The high-level feature design diagram is shown below.
115114

116115
<p align="center">
117116
<img src="./images/architecture_diagram.svg" alt="architecture diagram for memory data" width="80%"/>
118117
<br>
119-
Figure 1: Feature architecture diagram showing the unix socket, daemon, ConfigDB, and data file
118+
Figure 1: Feature architecture diagram showing the unix socket, daemon, ConfigDB and data file
120119
</p>
121120

122121
### Sequence Diagram
@@ -178,28 +177,30 @@ No SAI API change or addition is needed for this HLD.
178177
To configure the interval for memory data collection, use the following command:
179178

180179
admin@sonic:~$ config memory-stats sampling-interval <interval>
180+
Default sampling-interval is 5 minutes
181181

182182
**Adjust the Data Retention Period**
183183

184184
To set how long the memory data should be retained, use the following command:
185185

186186
admin@sonic:~$ config memory-stats retention-period <period>
187+
Default retention-period is 15 days
187188

188189
**Enable/Disable Memory Statistics Monitoring**
189190

190191
To enable or disable the memory statistics monitoring feature, use the following command:
191192

192193
admin@sonic:~$ config memory-stats enable/disable
194+
By default, it is disabled.
193195

194196
**View Memory Usage**
195197

196-
To display basic or detailed memory usage statistics, use the following command with optional parameters for time range and specific metrics:
198+
To display memory usage statistics, use the following command with optional parameters for time range and specific metrics:
197199

198-
admin@sonic:~$ show memory-stats [--detail] [--from <date-time>] [--to <date-time>] [--select <metric>]
200+
admin@sonic:~$ show memory-stats [--from <date-time>] [--to <date-time>] [--select <metric>]
199201

200202
**Command Definition**
201-
- **show memory-stats:** Display basic memory usage statistics.
202-
- **--detail:** Display detailed memory usage statistics.
203+
- **show memory-stats:** Display basic memory usage statistics
203204
- **--from <date-time>:** Display memory statistics from the specified start date-time.
204205
- **--to <date-time>:** Display memory statistics up to the specified end date-time.
205206
- **--select <metric>:** Display specific memory statistics, such as total memory.
@@ -208,13 +209,11 @@ To display basic or detailed memory usage statistics, use the following command
208209

209210
Below is an example of the Memory Statistics output as it appears in the CLI. This display provides a summary of system memory metrics over a default time period, ideal for routine monitoring and analysis:
210211

211-
sonic:~$ show memory-stats
212-
213212
Codes: M - minutes, H - hours, D - days
214213
--------------------------------------------------------------------------------
215214
Report Generated: 2024-06-15 09:00:00
216215
Analysis Period: From 2024-06-01 09:00:00 to 2024-06-15 09:00:00
217-
Interval: Bi-daily
216+
Interval: Bi-daily
218217
--------------------------------------------------------------------------------
219218
Metric Current High Low D1-D2 D3-D4 D5-D6 D7-D8 D9-D10 D11-D12 D13-D14 D15
220219
Value Value Value 01Jun24 03Jun24 05Jun24 07Jun24 09Jun24 11Jun24 13Jun24 15Jun24
@@ -223,10 +222,13 @@ Below is an example of the Memory Statistics output as it appears in the CLI. Th
223222
Used Memory 2.3G 2.5G 2.0G 2.1G 2.2G 2.2G 2.3G 2.4G 2.3G 2.2G 2.3G
224223
Free Memory 11.9G 12.4G 10.6G 11.0G 11.2G 11.4G 11.5G 11.7G 11.8G 11.9G 12.0G
225224
Available Memory 13.0G 14.3G 12.4G 12.6G 12.7G 12.8G 12.9G 13.0G 13.1G 13.2G 13.3G
225+
Cached Memory
226+
Buffer Memory
227+
Shared Memory
226228

227229
**View Memory Statistics Configuration**
228230

229-
To display the current configuration parameters data collection frequency, retention period, and enable/disable status in the MEMORY_STATS_TABLE, use the following command:
231+
To display the current configuration parameters such as data collection frequency, retention period, and enable/disable status in the MEMORY_STATISTICS_TABLE, use the following command:
230232

231233
admin@sonic:~$ show memory-stats config
232234

@@ -267,13 +269,13 @@ module memory-stats {
267269
268270
leaf enabled {
269271
type boolean;
270-
default true;
272+
default false;
271273
description "Enable or disable memory statistics";
272274
}
273275
274276
leaf sampling-interval {
275277
type uint16;
276-
units "minutes"";
278+
units "minutes";
277279
description "Interval for sampling memory statistics";
278280
}
279281
@@ -288,7 +290,7 @@ module memory-stats {
288290

289291
### Config DB Enhancements
290292

291-
A new table, `MEMORY_STATS_TABLE`, will be introduced in `ConfigDB` to store the configuration settings of the Memory Statistics feature. This table will allow for management of data collection frequency, retention period, and enable/disable status. The relevant configuration parameters and the schema for this table are detailed below.
293+
A new table, `MEMORY_STATISTICS_TABLE`, will be introduced in `ConfigDB` to store the configuration settings of the Memory Statistics feature. This table will allow for management of data collection frequency, retention period, and enable/disable status. The relevant configuration parameters and the schema for this table are detailed below.
292294

293295
**MEMORY_STATS Configuration Parameters**
294296

@@ -310,41 +312,23 @@ MEMORY_STATS_TABLE: {
310312
}
311313
```
312314

313-
### Configuration File for Memory Statistics Daemon
314-
315-
A configuration file will be created to store the settings for the `memorystatsd` daemon. This file will be read by the daemon to determine its operating parameters, such as the sampling interval and data retention period.
316-
317-
**Example Configuration File**
318-
319-
```
320-
# Memory Statistics Daemon Configuration
321-
322-
# Enable or disable memory statistics collection
323-
enabled=true
324-
325-
# Interval for memory data collection
326-
sampling_interval=5
327-
328-
# Duration for which memory data is retained
329-
retention_period=15
330-
```
331-
**Daemon Configuration Management**
315+
6. **Daemon Configuration Management**
332316

333-
The `memorystatsd` daemon will read its configuration from the configuration file. The daemon and its manager, `memstatsmgrd`, will be designed to:
317+
The `memorystatsd` will dynamically manage its configuration using the `hostcfgd`. The design will:
334318

335-
- **Read Configuration at Startup:** On startup, `memorystatsd` will read the configuration file to get the initial settings.
336-
- **Monitor ConfigDB for Changes:** `memstatsmgrd` will watch the `MEMORY_STATS_TABLE` in ConfigDB for any configuration changes.
337-
- **Update Configuration File:** When configurations are updated via CLI, `memstatsmgrd` will update the configuration file based on changes detected in ConfigDB.
338-
- **Restart to Apply Changes:** `memstatsmgrd` will restart the `memorystatsd` service to apply the new settings if necessary.
319+
1. **Read Configuration at Startup**: On startup, `memorystatsd` will read its configuration directly from the ConfigDB to initialize its settings.
320+
2. **Monitor ConfigDB for Changes**: `hostcfgd` will monitor the `MEMORY_STATISTICS_TABLE` in ConfigDB for any changes to the configurations.
321+
3. **Signal Daemon to Reload Configuration**: When configurations are updated via CLI and written to ConfigDB, hostcfgd will detect these changes and signal `memorystatsd` to reload its configuration.
322+
4. **Reload to Apply Changes**: `memorystatsd` will reload its configurations upon receiving the signal and apply the new settings.
339323

340324
**Workflow for Configuration Management**
341325

342-
1. **Initial Setup:** On deployment, default settings are written to both ConfigDB and the configuration file.
343-
2. **Daemon Startup:** `memorystatsd` reads the configuration file to initialize its parameters.
344-
3. **Runtime Configuration Changes:** Administrators update settings via CLI, which writes changes to ConfigDB.
345-
4. **Monitor ConfigDB for Changes:** `memstatsmgrd` detects these changes in ConfigDB.
346-
5. **Update Configuration File:** `memstatsmgrd` updates the configuration file to reflect the new settings.
347-
6. **Restart Daemon:** `memstatsmgrd` restarts the `memorystatsd` service to apply the new settings.
326+
1. **Initial Setup**: On deployment, default settings are written to the ConfigDB.
327+
2. **Daemon Startup**: `memorystatsd` reads configuration from ConfigDB and initializes its parameters.
328+
3. **Runtime Configuration Changes**: Administrators update settings via CLI, which writes changes to ConfigDB.
329+
4. **Monitor ConfigDB for Changes**: `hostcfgd` detects changes in ConfigDB.
330+
5. **Signal Daemon to Reload Configuration**: hostcfgd signals `memorystatsd` to reload its configuration.
331+
6. **Reload Daemon**: `memorystatsd` reloads the configuration to apply the new settings.
348332

349333
## Warmboot and Fastboot Design Impact
350334

@@ -356,17 +340,16 @@ There is no impact on warmboot/fastboot functionalities by this HLD.
356340

357341
| Test Case ID | Test Case Description |
358342
|--------------|----------------------------------------------------------------------------------------------|
359-
| UT1 | Verify CLI to show default memory statistics for the last 15 days |
360-
| UT2 | Verify CLI to show detailed memory statistics with the --detail option |
361-
| UT3 | Verify CLI to show memory data for a custom time range using --from and --to options |
362-
| UT4 | Verify CLI to show selective memory metrics using the --select option |
363-
| UT5 | Verify CLI for error handling with incorrect syntax or invalid parameters |
364-
| UT6 | Verify CLI to reject future dates in --from or --to options |
365-
| UT7 | Verify CLI to reject cases where --from date is later than --to date |
366-
| UT8 | Verify CLI to configure memory data collection frequency using config memory-stats sampling-interval <interval> |
367-
| UT9 | Verify CLI to configure memory data retention period using config memory-stats retention-period <period> |
368-
| UT10 | Verify CLI to enable memory statistics monitoring using config memory-stats enable |
369-
| UT11 | Verify CLI to disable memory statistics monitoring using config memory-stats disable |
343+
| UT1 | Verify CLI to show default memory statistics for the last 15 days |
344+
| UT2 | Verify CLI to show memory data for a custom time range using --from and --to options |
345+
| UT3 | Verify CLI to show selective memory metrics using the --select option |
346+
| UT4 | Verify CLI for error handling with incorrect syntax or invalid parameters |
347+
| UT5 | Verify CLI to reject future dates in --from or --to options |
348+
| UT6 | Verify CLI to reject cases where --from date is later than --to date |
349+
| UT7 | Verify CLI to configure memory data collection frequency using config memory-stats sampling-interval <interval> |
350+
| UT8 | Verify CLI to configure memory data retention period using config memory-stats retention-period <period> |
351+
| UT9 | Verify CLI to enable memory statistics monitoring using config memory-stats enable |
352+
| UT10 | Verify CLI to disable memory statistics monitoring using config memory-stats disable |
370353

371354
### System Test Cases
372355

0 commit comments

Comments
 (0)