Basic Unix System Monitoring Commands

This post is a cheat to remember which are the main commands to find usage of your consumed resources on a Unix machine.

  • ps
    Try -ef or aux with –sort rss , or –sort -rss
  • pmap
  • pstack
  • pstree
  • pgrep
    Use -f to match against full command line instead of only process name.
    Use -a for display the full command line used + pid.
    [lipi@i5-moll ~]$ pgrep -af virtualbox
    4584 /usr/lib/virtualbox/VBoxXPCOMIPCD
    4589 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
    4672 /usr/lib/virtualbox/VirtualBox --comment Windows XP --startvm f82f...

Be careful, -a is not implemented in some pgreps, use -l instead: list the process name as well as the process ID.

  • pkill
    With -f it will match the full command line instead of only the process name, just like with pgrep.
  • lstopo
  • free
    lipi@gall:~$ free -m
                 total       used       free     shared    buffers     cached
    Mem:          7941       3195       4745          0        157       2076
    -/+ buffers/cache:        962       6979
    Swap:         1906          0       1906

    Here, we see a system with 7941MiB of physical RAM, with 3194 MiB currently in use.

    The “shared” column lists the amount of physical memory shared between multiple processes. Here, we see that about 0 MiB of pages are being shared.

    The “buffers” column shows the amount of memory being used by the kernel buffer cache. The buffer cache is used for example to speed up disk operations (see slabtop) This memory is reclaimed if it is needed by applications.

    The “cached” column indicates how many memory pages the kernel has cached for faster access later.

    The memory used for buffers and cache can be reclaimed for use by applications, so the line “-/+ buffers/cache” provides an indication of the memory actually used by applications (“used” column) or available to applications (“free” column). The sum of the memory used by buffers and cache reported in the first line is subtracted from the total used memory and added to the total free memory to give the two figures on the second line.

    In the “swap” line, we see the total amount and used swap space. Note that the amount of swap reported by free is somewhat less than the total size of your swap partitions and files. This is because several blocks of each swap area must be used to store a map of how each page in the swap area is being utilized. This overhead should be rather small; only a few kilobytes per swap area.

  • vmstat
  • iostat
  • sar
  • mpstat
  • /proc/meminfo
  • /proc/cpuinfo
  • cpuid
  • netstat
    -a : Show all sockets, both listening and non-listening ones.
    -n : Show numbers instead of trying to resolve hostnames
    -p : Show program id (PID) of connection owners.
  • ipcs
    Provides information on the ipc facilities for which the calling process has read access, shared memory, semaphores, queues, etc.
  • blkid
  • lsblk
  • slabtop
  • *top
    http://blog.asashi.net/2013/01/every-top-for-nix/
  • iftop, iptraf, jnettop: To measure network bandwidth and traffic

References:
http://nilesh-joshi.blogspot.co.uk/2010/04/interpreting-output-of-free-command.html
http://blog.asashi.net/2013/01/every-top-for-nix/