Commit 2826255
authored
procdockerstatsd-rs: use ASCII hyphen for invalid container name (#346)
Replace Unicode dash with ASCII hyphen-minus in INVALID_CONTAINER_NAME constant and related comment, so the invalid container name matches what docker stats actually returns.
Why I did this
We found some error in syslog:
ERR memory_threshold_check: Failed to parse memory usage for "{'CPU%': '--', 'MEM%': '--', 'MEM_BYTES': '0', 'MEM_LIMIT_BYTES': '0', 'NAME': '--', 'PIDS': '--'}": could not convert string to float: '--'
2026 Feb 6 22:43:04.172360 air-2700-1 ERR memory_threshold_check: Failed to parse memory usage for "{'CPU%': '--', 'MEM%': '--', 'MEM_BYTES': '0', 'MEM_LIMIT_BYTES': '0', 'NAME': '--', 'PIDS': '--'}": could not convert string to float: '--'
2026 Feb 6 22:43:04.172422 air-2700-1 ERR memory_threshold_check: Failure occurred could not convert string to float: '--'
The error is statistical. The flow is as below:
procdockerstatsd calls "docker stats" command periodically, parse the output and store to STATE DB
memory_threshold_check which is called by monit service, handles the data in STATE DB and check the memory usage
For detailed docker code, please check:
https://github.com/docker/cli/blob/93fa57bbcd08f2f5be7f6cf22f4273a2b5a49e71/cli/command/container/formatter_stats.go#L25
https://github.com/docker/cli/blob/93fa57bbcd08f2f5be7f6cf22f4273a2b5a49e71/cli/command/container/formatter_stats.go#L169
How I did this
procdockerstatsd should check the command output and ignore invalid value:
If the name is empty of "--", ignore the output, log a warning message to syslog.
How I test this
Manual test.1 parent 84b2892 commit 2826255
1 file changed
+28
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
0 commit comments