FOSSPicks

ProcMon

If you've ever had the pleasure of using Microsoft Windows, you might have run a Microsoft tool called Process Manager (ProcMon) to find out why your system is running slowly. Unlike other monitoring tools that might show you which processes were consuming the most resources, ProcMon focuses on which system calls (syscalls) a process is currently working on, enabling you to perform some analysis on what is going on behind a simple process name. Syscalls represent the functions that an application or process has requested to be run by the operating system or kernel, such as reading or writing data, allocating memory, waiting (polling) for an interrupt or a message, or opening a device. Monitoring which syscalls a process is running is a great way to troubleshoot your own projects or to determine whether a random process might be failing, stalling, or performing badly. It's more granular than the process-wide analysis offered by tools like top or a desktop system monitor.

Microsoft has ported its famous ProcMon to Linux and placed the source code on GitHub from where it can be easily built and executed. There's even a command-line option to build a deb package. ProcMon Linux runs within a terminal using curses and presents much of the same information as its desktop Windows counterpart. Most importantly, this means showing the resource-hungry syscalls, the process IDs they're sharing, the operations they're performing, and how much of your system time they're consuming. It's a fascinating insight into what various applications might be doing, such as Chrome, X11, or your Windows compositor, and it shows a different side to resource usage than the normal top kind of view. With specific command-line arguments, you can choose specific process IDs to trace, track only specific syscalls, and output a log of traces to an external file, which can be later reread and run through for analysis. ProcMon is definitely a refreshing change from normal Linux resource monitors and a useful addition to your $PATH.

Project Website

https://github.com/Sysinternals/ProcMon-for-Linux

On Windows, ProcMon might be ideal for identifying malware. On Linux, it's perfect for feeling smugly free of malware.

Storage monitor

diskgraph

These days, there are too few purely C-coded utilities that are useful, modern, self-contained, compiled in seconds, and relatively easy to understand. However, diskgraph is an instantly compiled command-line tool that draws a chart in your terminal showing storage throughput for both input and output operations. Each measurement is represented by a character-sized square that represents a 500ms interval, with the y-axis showing an automatically scaled bandwidth (amount transferred over time) and the x-axis showing the time frame. The blocks will scroll from the right to the left as time progresses so you can more easily see fluctuating load conditions as you read and write files, allowing you to easily see periods of peak and low transfer and how your hardware is performing. It's very simple, but it presents information that isn't easily visualized any other way.

The executable takes only a single argument, the storage device, with no further options to configure how the utility looks or behaves. But this is an ideal opportunity rather than a limitation, because the entire project's code is contained within a single .c file of just less than 500 lines of code. This makes it ideal for study and also for user-developed modification such as extra arguments. It would be trivial to change the character I/O blocks into bars, for instance, or to add some other visualization method or to change the way the bandwidth is calculated. It's exactly the kind of project to start with if you want to investigate more serious system-level Linux programming, maybe ultimately leading even to kernel development. The code is relatively easy to understand, operates at a low level, and should be safe to modify – diskgraph only reads from devices rather than writing to them without requiring special privileges.

Project Website

https://github.com/stolk/diskgraph

Diskgraph is a super simple tool for monitoring storage I/O, but it's also eminently hackable and easy to understand.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus