Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YANG Model and Configuration Support for Memory Statistics #20354

Merged
Merged
20 changes: 20 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Table of Contents
* [L2 Neighbors](#l2-neighbors)
* [Loopback Interface](#loopback-interface)
* [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN)
* [Memory Statistics](#memory-statistics)
* [Management Interface](#management-interface)
* [Management port](#management-port)
* [Management VRF](#management-vrf)
Expand Down Expand Up @@ -1478,6 +1479,25 @@ lossless traffic for dynamic buffer calculation
}
```

### Memory Statistics
The memory statistics configuration is stored in the **MEMORY_STATISTICS** table. This table is used by the memory statistics daemon to manage memory monitoring settings. The configuration allows enabling or disabling memory collection, specifying how frequently memory statistics are sampled, and defining how long the memory data is retained.

```
{
"MEMORY_STATISTICS": {
"memory_statistics": {
"enabled": "false",
"sampling_interval": "5",
"retention_period": "15"
}
}
}

```
- **enabled**: Defines whether the memory statistics collection is active (true or false).
- **sampling_interval**: Interval between data collection.
- **retention_period**: Time to retain collected data.

### Management Interface

Management interfaces are defined in **MGMT_INTERFACE** table. Object
Expand Down
2 changes: 2 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def run(self):
'./yang-models/sonic-kubernetes_master.yang',
'./yang-models/sonic-loopback-interface.yang',
'./yang-models/sonic-lossless-traffic-pattern.yang',
'./yang-models/sonic-memory-statistics.yang',
'./yang-models/sonic-mgmt_interface.yang',
'./yang-models/sonic-mgmt_port.yang',
'./yang-models/sonic-mgmt_vrf.yang',
Expand Down Expand Up @@ -240,6 +241,7 @@ def run(self):
'./cvlyang-models/sonic-kubernetes_master.yang',
'./cvlyang-models/sonic-loopback-interface.yang',
'./cvlyang-models/sonic-mgmt_interface.yang',
'./cvlyang-models/sonic-memory-statistics.yang',
'./cvlyang-models/sonic-mgmt_port.yang',
'./cvlyang-models/sonic-mgmt_vrf.yang',
'./cvlyang-models/sonic-ntp.yang',
Expand Down
7 changes: 7 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,13 @@
"motd": "Some message of the day",
"logout": "Some logout message"
}
},
"MEMORY_STATISTICS": {
"memory_statistics": {
"enabled": "false",
"sampling_interval": "5",
"retention_period": "15"
}
}
},
"SAMPLE_CONFIG_DB_UNKNOWN": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"MEMORY_STATISTICS_VALID_CONFIG": {
"desc": "Configuring memory statistics with valid values."
},
"MEMORY_STATISTICS_WITH_INVALID_SAMPLING_INTERVAL": {
"desc": "Configuring memory statistics with an invalid sampling_interval ( out of acceptable range).",
"eStrKey": "Range",
"eStr": "3..15"
},
"MEMORY_STATISTICS_WITH_INVALID_RETENTION_PERIOD": {
"desc": "Configuring memory statistics with an invalid retention_period (out of acceptable range).",
"eStrKey": "Range",
"eStr": "1..30"
},
"MEMORY_STATISTICS_WITH_ENABLE_FEATURE": {
"desc": "Enabling memory statistics feature with valid values."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"MEMORY_STATISTICS_VALID_CONFIG": {
"sonic-memory-statistics:sonic-memory-statistics": {
"sonic-memory-statistics:MEMORY_STATISTICS": {
"memory_statistics":{
"enabled": "false",
"sampling_interval": "5",
"retention_period": "15"
}
}
}
},
"MEMORY_STATISTICS_WITH_INVALID_SAMPLING_INTERVAL": {
"sonic-memory-statistics:sonic-memory-statistics": {
"sonic-memory-statistics:MEMORY_STATISTICS": {
"memory_statistics":{
"enabled": "true",
"sampling_interval": "45",
"retention_period": "20"
}
}
}
},
"MEMORY_STATISTICS_WITH_INVALID_RETENTION_PERIOD": {
"sonic-memory-statistics:sonic-memory-statistics": {
"sonic-memory-statistics:MEMORY_STATISTICS": {
"memory_statistics":{
"enabled": "true",
"sampling_interval": "5",
"retention_period": "45"
}
}
}
},
"MEMORY_STATISTICS_WITH_ENABLE_FEATURE": {
"sonic-memory-statistics:sonic-memory-statistics": {
"sonic-memory-statistics:MEMORY_STATISTICS": {
"memory_statistics":{
"enabled": "true",
"sampling_interval": "5",
"retention_period": "30"
}
}
}
}

}
47 changes: 47 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-memory-statistics.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module sonic-memory-statistics {
yang-version 1.1;

namespace "http://github.com/sonic-net/sonic-memory-statistics";
prefix memstats;

import sonic-types {
prefix stypes;
}

description "YANG module for configuring memory statistics in SONiC-based OS.";

revision 2024-07-22 {
description "First Revision";
}

container sonic-memory-statistics {
container MEMORY_STATISTICS {
description "Memory statistics configuration parameters.";
container memory_statistics{
leaf enabled {
type boolean;
default false;
description "Flag to enable or disable memory statistics collection. If set to false, the memory statistics collection will stop.";
}

leaf sampling_interval {
type uint8 {
range "3..15";
}
units "minutes";
default 5;
description "Time interval in minutes for sampling memory statistics. Valid range, is between 3 minutes to 30 minutes.";
}

leaf retention_period {
type uint8 {
range "1..30";
}
units "days";
default 15;
description "Retention period for memory statistics data, defined in days. Valid range is from 1 day to 30 days.";
}
}
}
}
}
Loading