Measuring Heavy CPU Usage Over Time On Linux And Unix | Linux Today

Measuring Heavy CPU Usage Over Time On Linux And Unix

Written By
Web Webster
Web Webster
Mar 31, 2009

[ Thanks to Mike
Golvach
for this link. ]

“In the first screenshot, we’ve isolated process id 499
(which happens to be the X server), since it’s the only process on
the box that meets the “CPU percentage” criteria. Once it finds
that process, it adds it to the default temporary file (the simple
way to maintain state ;). We then populate the /tmp/munchiestats
file with a whole bunch of other PID’s (some real, some
non-existent) and multiple instances of PID 499 (but, less than 9,
so we don’t trigger the kill on the next execution) and cat that so
you can see the contents:

“In the second screenshot, we run munchies again and see it
clear all the PID’s in the temp file that are legitimate, but
aren’t using over 10% of the CPU anymore. We also free any PID’s in
the temp file that don’t exist any more (possibly, from a process
exiting, but – in this case – because we just made them up ;). The
final run executes the kill of PID 499 and removes it from the temp
file:”


Complete Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.