Simple System Monitoring for a Linux Desktop

The Problem

What exactly is eating into my HDD / processor / network right now??

Yeah! On the (Linux) desktop, we’d like to know why things crawl along sometimes. Which process(es) is the culprit behind that disk activity, or the memory hogger, or eating up network bandwidth?

Many tools exist that can help us pinpoint these facts. Sometimes, though, it’s just easier if someone shows us a quick easy way to get relevant facts; so here goes:

The Shell Script

Below is a very simple shell script wrapper that invokes various little utility programs (iotop, iftop, dstat, …) in separate gnome terminal windows.

# cat monitor.sh
#!/bin/bash
# monitors.sh
# Simple script to setup & run various 'monitor' programs in terminal   # windows
 if [ `id -u` -ne 0 ]; then
      echo "$0: need to be root!"
      exit 1
 fi
 gnome-terminal --working-directory=${HOME} -e iotop -t IOTOP &

 gnome-terminal --working-directory=${HOME} -e 'dstat --time --top-io-adv --top-cpu --top-mem 5' -t DTOP &

 gnome-terminal --working-directory=${HOME} -e dstat -t DSTAT &

 gnome-terminal --working-directory=${HOME} -e 'iftop -i wlan0' -t IFTOP &
#

At the heart of this simple script is the gnome-terminal command.
Set the working directory to whatever you wish (it is set to your HOME directory above).
The ‘-e’ option specifies the command to run in the new terminal window.
Small Note:
– For the iftop command, I’ve specified wlan0 as the network interface; update it for your box
dstat is like an advanced vmstat !

The ‘-t’ option specifies, you guessed it, the window title.

I find iotop particularly useful in pinpointing which process is banging on the disk!

Trying it out


# ./monitor.sh &
[1] 20722
#

Screenshot on my system: a 3GB laptop running Ubuntu 13.10:

Image

Try it out on your Linux box! YMMV of course..

Limitations

a) Under some intense workloads, what if your system gets _so_ bogged down and slow that one can’t even easily switch between windows to see what is going on? In these cases, the above tools have limited impact. Do try out the following:
i) sar
ii) munin
i
ii) nagios

These sophisticated tools collect data samples while the system runs, letting you interpret system behaviour at a later point in time. As an added benefit, munin provides a cool GUI interface for system monitoring and analysis.
(BTW, the GNOME system-monitor GUI app is pretty cool too).

b) All the simpler tools mentioned here:
– are CLI-based, not GUI
– applies for the local system.

Related

Try this Google search “monitoring linux system”
Linux Profiling with perf

Kaiwan N Billimoria

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s