-
Notifications
You must be signed in to change notification settings - Fork 5
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
Just use http module #4
Comments
@caub thank you for your comment! Will think how this can improve the library. Generally I want to keep dependencies very low ... and as sockets work fine so far, I will think of how I can/should use http module ... closing it for now. |
@sebhildebrandt Thanks, fair enough One quick question, could you comment on how const dockerStats = async containerId => {
const { name, cpu_stats, precpu_stats, memory_stats } = await fetch(`http://v1.39/containers/${containerId}/stats?stream=false`, { socketPath: '/var/run/docker.sock' });
const cpuPercent = (cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage) / (cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage) * cpu_stats.cpu_usage.percpu_usage.length * 100;
return {id, name, cpuPercent, memPercent: memory_stats.usage * 100 / memory_stats.limit};
} Is this the percentage of increase of CPU? (if |
So this is a longer story. First: yes, the calculation is based on previous stats. I actually did this wrong but then I based my calculation on the way how docker does it in his own code for calculating stats (actually to get in sync with |
Thanks, it looks weird, but yea, good idea I'll look at docker CLI source |
I saw you kinda reimplemented http in dockerSocket.js
you could just use http module, example in this lib I made
fetchu({ path: '/v1.39/services', socketPath: '/var/run/docker.sock' })
from discussion in node-fetch/node-fetch#336 (comment)
The text was updated successfully, but these errors were encountered: