-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add YANG Model and Configuration Support for Memory Statistics (#20354)
This PR introduces a new YANG model for configuring memory statistics in SONiC, along with necessary updates to the configuration database and test cases. The following changes have been made: YANG Model: Created a new YANG module sonic-memory-statistics.yang for managing memory statistics configuration parameters, including: enabled: Boolean flag to enable or disable memory statistics collection. sampling_interval: Configurable time interval for sampling memory statistics. retention_period: Configurable retention period for memory statistics data. Configuration Database: Updated sample_config_db.json to include default values for the memory statistics configuration, ensuring seamless integration with the existing configuration management. Test Cases: Added comprehensive test cases in memory_statistics.json to validate the configuration parameters, including valid configurations and error scenarios for invalid sampling intervals and retention periods. These changes aim to enhance the monitoring capabilities of SONiC by providing a structured way to configure memory statistics, thereby improving overall system performance and resource management.
- Loading branch information
1 parent
9e64ebe
commit e108423
Showing
6 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/sonic-yang-models/tests/yang_model_tests/tests/memory_statistics.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/sonic-yang-models/tests/yang_model_tests/tests_config/memory_statistics.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
47
src/sonic-yang-models/yang-models/sonic-memory-statistics.yang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."; | ||
} | ||
} | ||
} | ||
} | ||
} |