Comments (3)
Yes I can confirm, docker stats
shows this:
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
ca51d2673640 deluge 0.47% 307.7MiB / 15.51GiB 1.94% 0B / 0B 82.6MB / 7.8GB 14
Ctop shows this:
▶ deluge ca51d267364 0% 5G / 16G 0B / 0B 0B / 0B 14 11 hours
from ctop.
I believe its a ctop issue.
For one container ctop says it uses 3GB of ram, but docker stats -a reports less than 900mb.
Since the overall memory usage checked using htop on my host machine says 2.2gb, I do believe docker stats is correct.
from ctop.
I noticed the same: ctop
and docker stats
were opened in two SSH sessions on a split screen to make sure that
It seems that the memory usage is fetched from the Docker API here:
c.MemUsage = int64(stats.MemoryStats.Usage - stats.MemoryStats.Stats.Cache)
First I thought that this calculation would explain the difference, but the docker stats API seems to do the same:
On Linux, the Docker CLI reports memory usage by subtracting cache usage from the total memory usage. The API does not perform such a calculation but rather provides the total memory usage and the amount from the cache so that clients can use the data as needed. The cache usage is defined as the value of total_inactive_file field in the memory.stat file on cgroup v1 hosts.
I tried to query the Docker API directly for the example container:
$ curl --silent -XGET --unix-socket /run/docker.sock http://localhost/containers/5448a42fa234/stats?stream=false | jq .memory_stats
{
"usage": 531767296,
"stats": {
"active_anon": 11137024,
"active_file": 229097472,
"anon": 34324480,
"anon_thp": 0,
"file": 458465280,
"file_dirty": 0,
"file_mapped": 13746176,
"file_writeback": 0,
"inactive_anon": 24154112,
"inactive_file": 229367808,
"kernel_stack": 311296,
"pgactivate": 85402,
"pgdeactivate": 125321,
"pgfault": 9911151,
"pglazyfree": 9997,
"pglazyfreed": 0,
"pgmajfault": 34183,
"pgrefill": 129975,
"pgscan": 381701,
"pgsteal": 239245,
"shmem": 0,
"slab": 37055848,
"slab_reclaimable": 36716704,
"slab_unreclaimable": 339144,
"sock": 0,
"thp_collapse_alloc": 0,
"thp_fault_alloc": 13,
"unevictable": 0,
"workingset_activate": 0,
"workingset_nodereclaim": 0,
"workingset_refault": 0
},
"limit": 536870912
}
^C
This shows that .memory_stats.usage
equals to the value displayed in ctop. We have 507,1 MiB from the API, but just because the value has changed during my research. In ctop
, it now shows me 507 M too, instead of 509 M from the previous screenshot. If we calculate usage - inactive_file
, this equals to 288,4 MiB and matches the docker stats
value:
The Docker Documentation notes that the inactive_file
field was defines as cache
up to Docker 19.03. My machine runs Docker 24.0.6. Since the latest release of ctop is ~1.5 years old, it may be tested on an older Docker version and the used library could return 0 for the attribute, which doesn't exist any more. Further debugging would be required to find out what's exactly happening here and to be sure if this is a problem of ctop or the used library for fetching Dockers data.
Since it seems to be unmaintained, it probably won't get fixed in this project.
Update: Calling /stats
with ?stream=false
query parameter makes more sense here to get just a single snapshot instead of automated frequent updates.
from ctop.
Related Issues (20)
- When compiled on arm memory shows zero HOT 2
- Scrollability of Log View.
- CTOP crash when accessing gitlab container widget HOT 3
- Cpu usage allways at 0 HOT 3
- Is it possible to use ctop with Colima on macOS? HOT 2
- Add Support for ANSI Escape Sequences in Container Logs
- Instructions to install on Ubuntu using APT repository doesn't work HOT 1
- Is this project still maintained? HOT 4
- Get "http://unix.sock/info": dial unix /var/run/docker.sock: connect: no such file or directory HOT 1
- Vulnerability of dependency "golang.org/x/net" HOT 2
- Can't connect to docker-desktop
- Support Lunar Ubuntu's release HOT 1
- Support for Alacritty HOT 4
- Feature request: GPU/vRAM utilisation collumn
- ctop eats more and more memory
- ctop Manual copy/paste command changed
- 3rd party debian/ubuntu repo not up to date? HOT 2
- Is there a way to make this work for Podman
- [Feature] Add Docker context-aware support
- ctop for debian bookworm not present in repository HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ctop.