Skip to content

Commit d434689

Browse files
dhanasekar-aristagshemesh2
authored andcommitted
Use monit validate to get live data (sonic-net#19759)
What is the motivation for this PR? disk/test_disk_exhaustion.py creates a 1.7G file in the test and deletes it at the end of the test. But "monit status" is configured to check only once every 60 secs in /etc/monit/monitrc. This provides a stale data resulting in memory high threshold getting breached. How did you do it? We should use "monit validate" instead of "monit status" How did you verify/test it? verified by running the test Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
1 parent a46dcb2 commit d434689

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

tests/common/plugins/memory_utilization/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- [Enabling and Disabling](#enabling-and-disabling)
1313
- [Configuration Examples](#configuration-examples)
1414
- [Supported Memory Monitors](#supported-memory-monitors)
15-
- [Monit Status Monitor](#monit-status-monitor)
15+
- [Monit Validate Monitor](#monit-validate-monitor)
1616
- [Free Memory Monitor](#free-memory-monitor)
1717
- [Docker Stats Monitor](#docker-stats-monitor)
1818
- [Top Monitor](#top-monitor)
@@ -225,12 +225,12 @@ Memory utilization checking is enabled by default for all tests. To disable it:
225225

226226
## Supported Memory Monitors and Configuration Examples
227227

228-
### Monit Status Monitor
228+
### Monit Validate Monitor
229229

230230
Monitors system memory usage via Monit.
231231

232-
- **Command**: `sudo monit status`
233-
- **Parser Function**: `parse_monit_status_output`
232+
- **Command**: `sudo monit validate`
233+
- **Parser Function**: `parse_monit_validate_output`
234234
- **Monitored Parameters**:
235235
- `memory_usage`: System memory utilization percentage
236236
- **Threshold Type**: Use `percentage_points` for percentage-based thresholds
@@ -239,7 +239,7 @@ Example configuration:
239239
```json
240240
{
241241
"name": "monit",
242-
"cmd": "sudo monit status",
242+
"cmd": "sudo monit validate",
243243
"memory_params": {
244244
"memory_usage": {
245245
"memory_increase_threshold": {
@@ -252,7 +252,7 @@ Example configuration:
252252
}
253253
}
254254
},
255-
"memory_check": "parse_monit_status_output"
255+
"memory_check": "parse_monit_validate_output"
256256
}
257257
```
258258

@@ -414,7 +414,7 @@ Example:
414414
"Arista-7050QX": [
415415
{
416416
"name": "monit",
417-
"cmd": "sudo monit status",
417+
"cmd": "sudo monit validate",
418418
"memory_params": {
419419
"memory_usage": {
420420
"memory_increase_threshold": {
@@ -427,7 +427,7 @@ Example:
427427
}
428428
}
429429
},
430-
"memory_check": "parse_monit_status_output"
430+
"memory_check": "parse_monit_validate_output"
431431
}
432432
]
433433
}

tests/common/plugins/memory_utilization/memory_utilization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,12 @@ def parse_free_output(output, memory_params):
495495
return memory_values
496496

497497

498-
def parse_monit_status_output(output, memory_params):
499-
"""Parse the 'monit status' command output to extract memory usage information."""
498+
def parse_monit_validate_output(output, memory_params):
499+
"""Parse the 'monit validate' command output to extract memory usage information."""
500500
memory_values = {}
501501

502502
if not output:
503-
logger.warning("Empty output for monit status command, returning empty values")
503+
logger.warning("Empty output for monit validate command, returning empty values")
504504
return memory_values
505505

506506
memory_pattern = r"memory usage\s+([\d\.]+ \w+)\s+\[(\d+\.\d+)%\]"

tests/common/plugins/memory_utilization/memory_utilization_common.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"COMMON": [
33
{
44
"name": "monit",
5-
"cmd": "sudo monit status",
5+
"cmd": "sudo monit validate",
66
"memory_params": {
77
"memory_usage": {
88
"memory_increase_threshold": {
@@ -15,7 +15,7 @@
1515
}
1616
}
1717
},
18-
"memory_check": "parse_monit_status_output"
18+
"memory_check": "parse_monit_validate_output"
1919
}
2020
]
2121
}

tests/common/plugins/memory_utilization/memory_utilization_dependence.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
{
4343
"name": "monit",
44-
"cmd": "sudo monit status",
44+
"cmd": "sudo monit validate",
4545
"memory_params": {
4646
"memory_usage": {
4747
"memory_increase_threshold": {
@@ -54,7 +54,7 @@
5454
}
5555
}
5656
},
57-
"memory_check": "parse_monit_status_output"
57+
"memory_check": "parse_monit_validate_output"
5858
},
5959
{
6060
"name": "docker",
@@ -203,7 +203,7 @@
203203
"Arista-7050QX": [
204204
{
205205
"name": "monit",
206-
"cmd": "sudo monit status",
206+
"cmd": "sudo monit validate",
207207
"memory_params": {
208208
"memory_usage": {
209209
"memory_increase_threshold": {
@@ -216,13 +216,13 @@
216216
}
217217
}
218218
},
219-
"memory_check": "parse_monit_status_output"
219+
"memory_check": "parse_monit_validate_output"
220220
}
221221
],
222222
"Mellanox-SN4600C": [
223223
{
224224
"name": "monit",
225-
"cmd": "sudo monit status",
225+
"cmd": "sudo monit validate",
226226
"memory_params": {
227227
"memory_usage": {
228228
"memory_increase_threshold": {
@@ -235,7 +235,7 @@
235235
}
236236
}
237237
},
238-
"memory_check": "parse_monit_status_output"
238+
"memory_check": "parse_monit_validate_output"
239239
},
240240
{
241241
"name": "docker",

0 commit comments

Comments
 (0)