npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@junjokar/docker-stats-monitor

v0.0.3

Published

Monitor that outputs Docker Stats numbers in CSV format, tested with Docker v4.30

Downloads

11

Readme

You can use this package with npx:

npx @junjokar/docker-stats-monitor

If used with no arguments, the monitor will use the regular docker command, save the data to the process' current working directory and will run indefinitely. You can either define the environment variable DOCKER_MONITOR_OUTPUT with the path to a directory or pass the argument DOCKER_MONITOR_OUTPUT=path/to/directory in the npx command to alter where the output should be saved. You may also determine for how many seconds the monitoring should run using the environment variable DOCKER_MONITOR_DURATION or passing the argument DOCKER_MONITOR_DURATION=300 to the npx command. You can use the variable DOCKER_MONITOR_WSL to pass the name of a WSL distribution you're running to run the docker command in the container from the outside if running this code from within the container is impossible. Finally, you can use the variable DOCKER_MONITOR_ADMIN to pass access privileges strategies and data.

npx @junjokar/docker-stats-monitor DOCKER_MONITOR_OUTPUT=path/to/directory 
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_DURATION=300
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_WSL=openSUSE-Leap-15.5
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_ADMIN=sudo
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_OUTPUT=path/to/another/directory DOCKER_MONITOR_DURATION=120
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_DURATION=450 DOCKER_MONITOR_OUTPUT=path/to/yet/another/directory 
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_DURATION=9000 DOCKER_MONITOR_OUTPUT=path/to/new/directory DOCKER_MONITOR_WSL=kali-linux
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_DURATION=571 DOCKER_MONITOR_OUTPUT=path/to/directory DOCKER_MONITOR_ADMIN=ssh,root@remote_server
npx @junjokar/docker-stats-monitor DOCKER_MONITOR_OUTPUT=path/to/another/directory DOCKER_MONITOR_DURATION=360 DOCKER_MONITOR_WSL=Ubuntu-22.04 DOCKER_MONITOR_ADMIN=sudo

As mentioned in passing, DOCKER_MONITOR_OUTPUT should hold a string with the path to a directory where the file 'docker_stats_(timestamp).csv' will be saved and DOCKER_MONITOR_DURATION should hold the string of a parseable integer representing the amount of seconds the monitoring should run for. DOCKER_MONITOR_WSL must contain the name of a valid WSL distribution installed on the local system. DOCKER_MONITOR_ADMIN must contain the access or elevation strategy desired. It can be one of the following: 'sudo', 'gsudo', 'doas', 'pkexec', 'pfexec', 'dzdo', 'ssh' or 'runuser'; in the case of 'ssh' or 'runuser' you may add the data necessary after a comma, as shown above. If both the CLI argument and the environment variable are specified, the CLI argument has priority.

You can also use this package in your own code importing the function 'monitor', which is exposed by the package:

const { monitor } = require('@junjokar/docker-stats-monitor');
monitor()

When using the function in code, the environment variables and arguments don't work. You can call the function with no arguments to use the same defaults from the npx command or you may pass whatever custom values you wish. If you want the process to run indefinitely, pass any negative value for the duration.

const { monitor } = require('@junjokar/docker-stats-monitor');
monitor("path/to/results/directory", 600, "Ubuntu-24.04", "sudo")

The results are saved in a CSV file with the following structure:

Timestamp,Container ID,Name,PIDs,CPU %,MEMORY USAGE,MEMORY LIMIT,MEMORY %,NETWORK INPUT,NETWORK OUTPUT,BLOCK INPUT,BLOCK OUTPUT
2024-06-24T19:26:20.009Z,c3f68fd744d3,docker-container-1,57,1.04%,717.1MiB,750MiB,95.61%,4.67kB,1.37kB,0B,0B
2024-06-24T19:26:20.009Z,011d5effd1b7,docker-container-2,60,0.59%,161.8MiB,500MiB,32.36%,48.2kB,49.4kB,0B,0B
2024-06-24T19:26:20.009Z,c02898741057,docker-container-3,13,375.75%,377.5MiB,750MiB,50.33%,15kB,3.69kB,0B,0B
2024-06-24T19:26:20.009Z,753d77db7c33,docker-container-4,33,1.01%,175.3MiB,500MiB,35.06%,18.8kB,23.8kB,0B,0B
2024-06-24T19:26:20.009Z,10ca793eec3c,docker-container-5,5,0.20%,11.3MiB,500MiB,2.26%,1.48kB,0B,0B,0B
2024-06-24T19:26:20.010Z,fd97e56c87a1,docker-container-6,24,0.12%,205.4MiB,750MiB,27.39%,21.3kB,4.43kB,0B,0B
2024-06-24T19:26:20.010Z,132f36583df3,docker-container-7,46,52.80%,214MiB,1GiB,20.90%,312kB,1.66MB,0B,0B
2024-06-24T19:26:20.010Z,074384db398c,docker-container-8,42,2.66%,191.9MiB,1GiB,18.74%,34.8kB,29.4kB,0B,0B
2024-06-24T19:26:20.510Z,011d5effd1b7,docker-container-2,60,0.17%,161.8MiB,500MiB,32.36%,48.2kB,49.4kB,0B,0B
2024-06-24T19:26:20.510Z,c02898741057,docker-container-3,13,449.88%,389.1MiB,750MiB,51.89%,15kB,3.69kB,0B,0B
2024-06-24T19:26:20.510Z,753d77db7c33,docker-container-4,33,0.55%,175.3MiB,500MiB,35.06%,19.1kB,24.6kB,0B,0B
2024-06-24T19:26:20.510Z,10ca793eec3c,docker-container-5,5,0.17%,11.17MiB,500MiB,2.23%,1.48kB,0B,0B,0B
2024-06-24T19:26:20.510Z,172e4a6364f5,docker-container-9,81,14.39%,744MiB,750MiB,99.20%,105kB,105kB,0B,0B
2024-06-24T19:26:20.510Z,fd97e56c87a1,docker-container-6,24,0.10%,205.4MiB,750MiB,27.39%,21.3kB,4.43kB,0B,0B
2024-06-24T19:26:20.510Z,132f36583df3,docker-container-7,47,16.41%,216.2MiB,1GiB,21.12%,320kB,1.69MB,0B,0B
2024-06-24T19:26:20.510Z,074384db398c,docker-container-8,42,3.73%,191.9MiB,1GiB,18.74%,35.6kB,29.6kB,0B,0B
2024-06-24T19:26:21.010Z,c3f68fd744d3,docker-container-1,57,3.14%,717.1MiB,750MiB,95.61%,4.67kB,1.37kB,0B,0B
2024-06-24T19:26:21.010Z,011d5effd1b7,docker-container-2,60,0.17%,161.8MiB,500MiB,32.36%,48.2kB,49.4kB,0B,0B
2024-06-24T19:26:21.010Z,c02898741057,docker-container-3,13,449.88%,389.1MiB,750MiB,51.89%,15kB,3.69kB,0B,0B
2024-06-24T19:26:21.010Z,753d77db7c33,docker-container-4,33,0.55%,175.3MiB,500MiB,35.06%,19.1kB,24.6kB,0B,0B
2024-06-24T19:26:21.010Z,10ca793eec3c,docker-container-5,5,0.17%,11.17MiB,500MiB,2.23%,1.48kB,0B,0B,0B
2024-06-24T19:26:21.010Z,172e4a6364f5,docker-container-9,81,14.39%,744MiB,750MiB,99.20%,105kB,105kB,0B,0B
2024-06-24T19:26:21.010Z,fd97e56c87a1,docker-container-6,24,0.10%,205.4MiB,750MiB,27.39%,21.3kB,4.43kB,0B,0B
2024-06-24T19:26:21.010Z,132f36583df3,docker-container-7,47,16.41%,216.2MiB,1GiB,21.12%,320kB,1.69MB,0B,0B
2024-06-24T19:26:21.010Z,074384db398c,docker-container-8,42,3.73%,191.9MiB,1GiB,18.74%,35.6kB,29.6kB,0B,0B
2024-06-24T19:26:21.510Z,c3f68fd744d3,docker-container-1,57,0.95%,717.1MiB,750MiB,95.61%,4.67kB,1.37kB,0B,0B
2024-06-24T19:26:21.510Z,011d5effd1b7,docker-container-2,60,0.15%,161.8MiB,500MiB,32.36%,48.2kB,49.4kB,0B,0B
2024-06-24T19:26:21.510Z,c02898741057,docker-container-3,13,371.59%,443.9MiB,750MiB,59.18%,36kB,667kB,0B,0B
2024-06-24T19:26:21.510Z,753d77db7c33,docker-container-4,33,0.77%,175.3MiB,500MiB,35.06%,19.1kB,24.6kB,0B,0B
2024-06-24T19:26:21.510Z,10ca793eec3c,docker-container-5,5,0.17%,11.29MiB,500MiB,2.26%,1.48kB,0B,0B,0B
2024-06-24T19:26:21.510Z,172e4a6364f5,docker-container-9,81,131.75%,743.8MiB,750MiB,99.17%,764kB,123kB,0B,0B
2024-06-24T19:26:21.510Z,fd97e56c87a1,docker-container-6,24,0.08%,205.4MiB,750MiB,27.39%,21.3kB,4.43kB,0B,0B
2024-06-24T19:26:21.510Z,132f36583df3,docker-container-7,47,7.30%,216.2MiB,1GiB,21.12%,324kB,1.71MB,0B,0B
2024-06-24T19:26:21.510Z,074384db398c,docker-container-8,42,6.25%,191.9MiB,1GiB,18.74%,35.6kB,29.6kB,0B,0B