rkyser
rkyser

Reputation: 3357

Linux CPU Usage Tools

Background I've written a tool to capture CPU usage on a per/thread basis. The output of the tools is a binary file, that I can pump into my parsing utility that I wrote. And the output of the parsing utility is a CSV file that I can import into Excel to chart pretty graphs of process/thread CPU usage.

This CPU usage capture tool is running on an embedded ARM platform running a Linux kernel based on 2.6.35.3. That being said, I was concerned about making the tool light weight. I didn't want it to store directly to a CSV file, in order to minimize the processing time and the file size of the captured data.

Question The tool works, but I'm wondering if I took the long way around the problem? Is there already a tool out there that does this (or something like it)?

You're probably wondering why I care if I already made a tool that works. Well, it's not as light weight as I'd like. It's taking up about 10% of CPU usage. As a benchmark, top only takes up about 1% (max).

Update I've decided to continue using my tool for now. At least until a better solution becomes available. I was able to shave off a couple percentage points by using open() instead of fopen() on /proc/stat. I'm also using read() instead of fgets().

Upvotes: 2

Views: 3021

Answers (2)

Wil Cooley
Wil Cooley

Reputation: 940

This might be a bit of a steep learning curve, but you might want look into SystemTap: http://sourceware.org/systemtap/

Upvotes: 0

P.P
P.P

Reputation: 121427

IBM has a tool called nmon which does the same(for AIX & Linux): According to IBM's documentation, it takes ~2% CPU. You may want to look at that.

Comparing nmon with your tool could give you a fair idea about your program's performance and how you may improve your csv capture.

Upvotes: 1

Related Questions