DEV Community

Rudolf Olah
Rudolf Olah

Posted on

proc-watch: find out what is using the most CPU and memory

When you are running multiple EC2 instances or running a shared environment, it is useful to monitor the amount of CPU being used and how much memory is being used over time.

For example, if there's a lot of processing happening and CPU usage

  • there could be something strange going on
  • ...or it could be an expected amount of CPU usage depending on the workloads of the compute nodes

If there's a lot of memory usage that is unexpected

  • it could be a memory leak
  • ...or a new process launched that is consuming more resources

If there are more users logging in and starting various programs, there could be more processes running or more CPU or memory usage around particular times of the days.

It can be hard to tell what's actually happening unless you SSH into the instance and check the CPU/memory usage with top or htop.

proc-watch is meant to help in this respect. It is a Python program that will parse the output of ps on Linux and MacOS systems to tell you:

  • the number of processes that are currently running
  • the process that is using the most memory
  • the process that is using the most CPU
  • the most memory being used by one process
  • the most CPU being used by one process

It exports these metrics to Prometheus so that you can monitor the changes over time.

Here's how it would be useful:

  • you will be able to see that the system has no load when the most CPU or memory usage is barely hovering above 0.1%
  • when a resource-intensive process is started, you will be able to see that, a-ha! It's headless Chrome starting an automated test run!

Check out the code here: https://github.com/rudolfolah/proc-watch

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Imagine monitoring that's actually built for developers

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay