Andries filmer

Feel free with Open Source Software

Andries Filmer - Internet professional sinds 1996.
Ik ben groot voorstander van Free- en Opensource Software (FOSS) en laat deze site jouw overtuigen waarom dit goed is.
Home Over deze website Kennisbank Ezelsoren Freelancer Online gereedschap

Commandline system monitoring

Index
  1. Introduction
  2. Part 1 (default system tools)
    1. ps
    2. free
    3. top
    4. vmstat
    5. uptime
    6. watch
  3. Part II (installed system tools)
    1. dstat
    2. ngrep
    3. atop
    4. nethogs
    5. iostat
    6. bmon
    7. inotify, incron and authctl
    8. Stress
  4. Others
  5. Resources
  6. Comments

Introduction

There are many commandline monitoring tools. On this page you can find a list of commands who I commonly use. The first part are commands you can use without installing a package. This page gives only some shorthand examples. The man pages can tell you much more ;)

Part 1 (default system tools)

ps

Displays The Processes

Print All Process On The Server

 ps aux

Print All Process On The Server (wrapping commands)

 ps auxww

Print A Process Tree

 ps -ejH
 ps axjf
 pstree

Display Only The Process IDs of apache

 pgrep apache

Find Out The Top 10 Memory Consuming Process

 ps -auxf | sort -nr -k 4 | head -10

free

Displays Memory Usage

 free -o

top

display Linux tasks

By default, it displays the most CPU-intensive tasks running on the server and updates the list every five seconds.

 top

vmstat

System Activity, Hardware and System Information

The command vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity

 vmstat 3

Display Memory Utilization Slabinfo

 vmstat -m

Get Information About Active / Inactive Memory Pages

 vmstat -a

uptime

Tell How Long The System Has Been Running

The uptime command can be used to see how long the server has been running. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

 uptime

watch

Watch changeable data continuously

Default it repeatedly reruns a command every 2 seconds by default. The next command shows the output of the free command updated every 2 seconds.

 watch free

To see the interrupts occurring on your system, run the command:

 watch -n.1 'cat /proc/interrupts'	

Part II (installed system tools)

dstat

versatile tool for generating system resource statistics

 apt-get install dstat

More info

ngrep

Ngrep is a pcap-aware tool that will allow you to specify extended regular expressions to match against data part of packets on the network.

No arguments. Shows all traffic going through the default network card.

 ngrep -qd eth1 'HTTP' tcp port 80

Be quiet, look only at tcp packets with either source or dest port 80 on interface eth1, look for anything matching 'HTTP'.

 ngrep -qd le0 port 53

Watch all tcp and udp port 53 (nameserver) traffic on interface le0. Be quiet.

 ngrep 'USER|PASS' tcp port 21

Look only at tcp packets with either source or dest port 21, look for anything resembling an FTP login.

 ngrep -wiA 2 'user|pass' tcp port 21

atop

AT Computing's System & Process Monitor

 apt-get install atop

The program atop is an interactive monitor to view the load on a Linux system. It shows the occupation of the most critical hardware resources (from a performance point of view) on system level, i.e. cpu, memory, disk and network.

When running atop interactively (no output redirection), keys can be pressed to control the output. In general, lower case keys can be used to show other information for the active processes and upper case keys can be used to influence the sort order of the active process list.

g # Show generic output (default). m # Show memory related output. d # Show disk-related output. n # Show network related output (when kernel patch 'cnt' is installed). s # Show scheduling characteristics. v # Show various process characteristics. c # Show the command line of the process. u # Show the process activity accumulated per user. p # Show the process activity accumulated per program (i.e. process name).

Useful website: http://www.atoptool.nl for patch and more info. The man page is very useful too ;)

nethogs

Net top tool grouping bandwidth per process

Instead of breaking the traffic down per protocol or per subnet, like most tools do, it groups bandwidth by process. If there's suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this.

 apt-get install nethogs

More info: http://nethogs.sourceforge.net

iostat

Average CPU Load, Disk Activity

 apt-get install iostat

 iostat

bmon

Graphs/tracks network activity/bandwidth real time.

 apt-get install bmon

Just type bmon to see your network activity/bandwith in real time ;)

 bmon

inotify, incron and authctl

There is a separate page about Monitoring file system events with inotify, incron and authctl. Very usefull if you want to know what files are created or modified.

Stress

Check the system onder (heavy) load.

 apt-get install stress

 stress -c 20 -i 4 --verbose --timeout 1h

Others

I don't use the next tools, but maybe you like them.

  • sar - Collect and Report System Activity
  • multitail – tail multiple files in a single terminal window
  • swatch – track your log files and fire off alerts
  • iftop - display bandwidth usage on an interface by host

Resources

This page is created on 2010-08-03 and updated on 2011-04-07

I appreciate if you give some comment about this page. Please go ahead.
Your e-mailaddress will not be published it is only to contact you (if needed).

 
Your name
Your e-mailaddress
To prefent robots to use this form I ask you kindly to type the next characters in the input field.
 

 


Mijn Curriculum vitae | De content op deze website heeft de Creativecommons 3.0 licentie | © 2011
Andries Filmer | http://andries.filmer.nl | andries@filmer.nl | © 2011
Deze website wordt gerealiseerd met Free- en Open Source Software: | | | | | |