ACC SHELL

Path : /usr/share/gnome/help/opensuse-manuals/C/
File Upload :
Current File : //usr/share/gnome/help/opensuse-manuals/C/cha.util.html

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 13. System Monitoring Utilities</title><link rel="stylesheet" href="susebooks.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="Documentation"><link rel="up" href="part.reference.administration.html" title="Part III. Administration"><link rel="prev" href="cha.fontconfig.html" title="Chapter 12. Installing and Configuring Fonts for the Graphical User Interface"><link rel="next" href="cha.update.html" title="Chapter 14. Upgrading the System and System Changes"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header" border="0" class="bctable"><tr><td width="80%"><div class="breadcrumbs"><p><a href="index.html"> Documentation</a><span class="breadcrumbs-sep"> &gt; </span><a href="book.opensuse.reference.html">Reference</a><span class="breadcrumbs-sep"> &gt; </span><a href="part.reference.administration.html">Administration</a><span class="breadcrumbs-sep"> &gt; </span><strong><a accesskey="p" title="Chapter 12. Installing and Configuring Fonts for the Graphical User Interface" href="cha.fontconfig.html"><span>&#9664;</span></a>  <a accesskey="n" title="Chapter 14. Upgrading the System and System Changes" href="cha.update.html"><span>&#9654;</span></a></strong></p></div></td></tr></table></div><div class="chapter" title="Chapter 13. System Monitoring Utilities"><div class="titlepage"><div><div><h2 class="title"><a name="cha.util"></a>Chapter 13. System Monitoring Utilities<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#cha.util">¶</a></span></h2></div></div></div><div class="toc"><p><b>Contents</b></p><dl><dt><span class="sect1"><a href="cha.util.html#sec.util.multi">13.1. Multi-Purpose Tools</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.system">13.2. System Information</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.processes">13.3. Processes</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.memory">13.4. Memory</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.networking">13.5. Networking</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.proc">13.6. The <code class="filename">/proc</code> File System</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.hardware">13.7. Hardware Information</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.file">13.8. Files and File Systems</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.user">13.9. User Information</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.time">13.10. Time and Date</a></span></dt><dt><span class="sect1"><a href="cha.util.html#sec.util.rrdtool">13.11. Graph Your Data: RRDtool</a></span></dt></dl></div><div class="abstract" title="Abstract"><p class="title"><b>Abstract</b></p><p>
   There are number of programs, tools, and utilities which you can use to
   examine the status of your system. This chapter introduces some of them
   and describes their most important and frequently used parameters.
  </p></div><p>
  For each of the described commands, examples of the relevant outputs are
  presented. In the examples, the first line is the command itself (after
  the &gt; or # sign prompt). Omissions are indicated with square brackets
  (<code class="literal">[...]</code>) and long lines are wrapped where necessary.
  Line breaks for long lines are indicated by a backslash
  (<code class="literal">\</code>).
 </p><pre class="screen"># command -x -y
output line 1
output line 2
output line 3 is annoyingly long, so long that \
    we have to break it
output line 3
[...]
output line 98
output line 99</pre><p>
  The descriptions have been kept short so that we can include as many
  utilities as possible. Further information for all the commands can be
  found in the manual pages. Most of the commands also understand the
  parameter <code class="option">--help</code>, which produces a brief list of possible
  parameters.
 </p><div class="sect1" title="13.1. Multi-Purpose Tools"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.multi"></a>13.1. Multi-Purpose Tools<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi">¶</a></span></h2></div></div></div><p>
   While most of the Linux system monitoring tools are specific to monitor a
   certain aspect of the system, there are a few <span class="quote">&#8220;<span class="quote">swiss army
   knife</span>&#8221;</span> tools showing various aspects of the system at a glance.
   Use these tools first in order to get an overview and find out which part
   of the system to examine further.
  </p><div class="sect2" title="13.1.1. vmstat"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.multi.vmstat"></a>13.1.1. <span class="command"><strong>vmstat</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.vmstat">¶</a></span></h3></div></div></div><p>
    vmstat collects information about processes, memory, I/O, interrupts and
    CPU. If called without a sampling rate, it displays average values since
    the last reboot. When called with a sampling rate, it displays actual
    samples:
   </p><div class="example"><a name="id454005"></a><p class="title"><b>Example 13.1. <span class="command">vmstat</span> Output on a Lightly Used Machine</b></p><div class="example-contents"><pre class="screen">
tux@mercury:~&gt; vmstat -a 2
procs -----------memory---------- ---swap-- -----io---- -system-- -----cpu-------
 r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy  id wa st
 0  0      0 750992 570648 548848    0    0     0     1    8    9  0  0 100  0  0
 0  0      0 750984 570648 548912    0    0     0     0   63   48  1  0 99   0  0
 0  0      0 751000 570648 548912    0    0     0     0   55   47  0  0 100  0  0
 0  0      0 751000 570648 548912    0    0     0     0   56   50  0  0 100  0  0
 0  0      0 751016 570648 548944    0    0     0     0   57   50  0  0 100  0  0</pre></div></div><br class="example-break"><div class="example"><a name="id454025"></a><p class="title"><b>Example 13.2. <span class="command">vmstat</span> Output on a Heavily Used Machine (CPU bound)</b></p><div class="example-contents"><pre class="screen">
tux@mercury:~&gt; vmstat 2
procs -----------memory----------- ---swap-- -----io---- -system-- -----cpu------
 r  b   swpd   free   buff   cache   si   so    bi    bo   in   cs us sy id wa st
32  1  26236 459640 110240 6312648    0    0  9944     2 4552 6597 95  5  0  0  0
23  1  26236 396728 110336 6136224    0    0  9588     0 4468 6273 94  6  0  0  0
35  0  26236 554920 110508 6166508    0    0  7684 27992 4474 4700 95  5  0  0  0
28  0  26236 518184 110516 6039996    0    0 10830     4 4446 4670 94  6  0  0  0
21  5  26236 716468 110684 6074872    0    0  8734 20534 4512 4061 96  4  0  0  0</pre></div></div><br class="example-break"><div class="tip"><table border="0" cellpadding="3" cellspacing="0" width="100%" summary="Tip"><tr class="head"><td width="32"><img alt="[Tip]" src="admon/tip.png"></td><th align="left"></th></tr><tr><td colspan="2" align="left" valign="top"><p>
     The first line of the vmstat output always displays average values
     since the last reboot.
    </p></td></tr></table></div><p>
    The columns show the following:
   </p><div class="variablelist"><dl><dt><span class="term"><span class="guimenu">r</span>
     </span></dt><dd><p>
       Shows the amount of processes in the run queue. These processes are
       waiting for a free CPU slot to be executed. If the number of
       processes in this column is constantly higher than the number of CPUs
       available, this is an indication for insufficient CPU power.
      </p></dd><dt><span class="term"><span class="guimenu">b</span>
     </span></dt><dd><p>
       Shows the amount of processes waiting for a resource other than a
       CPU. A high number in this column may indicate an I/O problem
       (network or disk).
      </p></dd><dt><span class="term"><span class="guimenu">swpd</span>
     </span></dt><dd><p>
       The amount of swap space currently used.
      </p></dd><dt><span class="term"><span class="guimenu">free</span>
     </span></dt><dd><p>
       The amount of unused memory.
      </p></dd><dt><span class="term"><span class="guimenu">inact</span>
     </span></dt><dd><p>
       Recently unused memory that can be reclaimed. This column is only
       visible when calling <span class="command"><strong>vmstat</strong></span> with the parameter
       <code class="option">-a</code> (recommended).
      </p></dd><dt><span class="term"><span class="guimenu">active</span>
     </span></dt><dd><p>
       Recently used memory that normally does not get reclaimed. This
       column is only visible when calling <span class="command"><strong>vmstat</strong></span> with
       the parameter <code class="option">-a</code> (recommended).
      </p></dd><dt><span class="term"><span class="guimenu">buff</span>
     </span></dt><dd><p>
       File buffer cache in RAM. This column is not visible when calling
       <span class="command"><strong>vmstat</strong></span> with the parameter <code class="option">-a</code>
       (recommended).
      </p></dd><dt><span class="term"><span class="guimenu">cache</span>
     </span></dt><dd><p>
       Page cache in RAM. This column is not visible when calling
       <span class="command"><strong>vmstat</strong></span> with the parameter <code class="option">-a</code>
       (recommended).
      </p></dd><dt><span class="term"><span class="guimenu">si</span>
     </span></dt><dd><p>
       Amount of data that is moved from RAM to swap per second. High values
       over a longer period of time in this column are an indication that
       the machine would benefit from more RAM.
      </p></dd><dt><span class="term"><span class="guimenu">so</span>
     </span></dt><dd><p>
       Amount of data that is moved from swap to RAM per second. High values
       over a longer period of time in this column are an indication that
       the machine would benefit from more RAM.
      </p></dd><dt><span class="term"><span class="guimenu">bi</span>
     </span></dt><dd><p>
       Number of blocks per second received from a block device (e.g. a disk
       read). Note that swapping also impacts the values shown here.
      </p></dd><dt><span class="term"><span class="guimenu">bo</span>
     </span></dt><dd><p>
       Number of blocks per second sent to a block device (e.g. a disk
       write). Note that swapping also impacts the values shown here.
      </p></dd><dt><span class="term"><span class="guimenu">in</span>
     </span></dt><dd><p>
       Interrupts per second. A high value indicates a high I/O level
       (network and/or disk).
      </p></dd><dt><span class="term"><span class="guimenu">cs</span>
     </span></dt><dd><p>
       Number of context switches per second. Simplified this means that the
       kernel has to replace executable code of one program in memory with
       that of another program.
      </p></dd><dt><span class="term"><span class="guimenu">us</span>
     </span></dt><dd><p>
       Percentage of CPU usage from user processes.
      </p></dd><dt><span class="term"><span class="guimenu">sy</span>
     </span></dt><dd><p>
       Percentage of CPU usage from system processes.
      </p></dd><dt><span class="term"><span class="guimenu">id</span>
     </span></dt><dd><p>
       Percentage of CPU time spent idling. If this value is zero over a
       longer period of time, your CPU(s) are working to full capacity. This
       is not necessarily a bad sign&#8212;rather refer to the values in
       columns <span class="guimenu">r</span> and <span class="guimenu">b</span> to determine if
       your machine is equipped with sufficient CPU power.
      </p></dd><dt><span class="term"><span class="guimenu">wa</span>
     </span></dt><dd><p>
       Time spent waiting for IO. If this value is significantly higher than
       zero over a longer period of time, there is a bottleneck in the I/O
       system (network or hard disk).
      </p></dd><dt><span class="term"><span class="guimenu">st</span>
     </span></dt><dd><p>
       Percentage of CPU time used by virtual machines.
      </p></dd></dl></div><p>
    See <span class="command"><strong>vmstat <code class="option">--help</code></strong></span> for more options.
   </p></div><div class="sect2" title="13.1.2. System Activity Information: sar and sadc"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.multi.sar"></a>13.1.2. System Activity Information: <span class="command"><strong>sar</strong></span> and <span class="command"><strong>sadc</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar">¶</a></span></h3></div></div></div><p>
    <span class="command"><strong>sar</strong></span> can generate extensive reports on almost all
    important system activities, among them CPU, memory, IRQ usage, IO, or
    networking. It can either generate reports on the fly or query existing
    reports gathered by the system activity data collector
    (<span class="command"><strong>sadc</strong></span>). <span class="command"><strong>sar</strong></span> and
    <span class="command"><strong>sadc</strong></span> both gather all their data from the
    <code class="filename">/proc</code> file system.
   </p><div class="note"><table border="0" cellpadding="3" cellspacing="0" width="100%" summary="Note: sysstat package"><tr class="head"><td width="32"><img alt="[Note]" src="admon/note.png"></td><th align="left">sysstat package</th></tr><tr><td colspan="2" align="left" valign="top"><p>
     <span class="command"><strong>sar</strong></span> and <span class="command"><strong>sadc</strong></span> are part of
     <code class="systemitem">sysstat</code> package. you need to install the
     package either with YaST, or with <span class="command"><strong>zypper in
     sysstat</strong></span>.
    </p></td></tr></table></div><div class="sect3" title="13.1.2.1. Automatically Collecting Daily Statistics With sadc"><div class="titlepage"><div><div><h4 class="title"><a name="sec.util.multi.sar.sadc"></a>13.1.2.1. Automatically Collecting Daily Statistics With <span class="command"><strong>sadc</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.sadc">¶</a></span></h4></div></div></div><p>
     If you want to monitor your system about a longer period of time, use
     <span class="command"><strong>sadc</strong></span> to automatically collect the data. You can read
     this data at any time using <span class="command"><strong>sar</strong></span>. To start
     <span class="command"><strong>sadc</strong></span>, simply run <span class="command"><strong>/etc/init.d/boot.sysstat
     start</strong></span>. This will add a link to
     <code class="filename">/etc/cron.d/</code> that calls <span class="command"><strong>sadc</strong></span>
     with the following default configuration:
    </p><div class="itemizedlist"><ul class="itemizedlist" type="bullet"><li class="listitem" style="list-style-type: disc"><p>
       All available data will be collected.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       Data is written to
       <code class="filename">/var/log/sa/sa<em class="replaceable"><code>DD</code></em></code>,
       where <em class="replaceable"><code>DD</code></em> stands for the current day. If a
       file already exists, it will be archived.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The summary report is written to
       <code class="filename">/var/log/sa/sar<em class="replaceable"><code>DD</code></em></code>,
       where <em class="replaceable"><code>DD</code></em> stands for the current day.
       Already existing files will be archived.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       Data is collected every ten minutes, a summary report is generated
       every 6 hours (see /etc/sysstat/sysstat.cron).
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The data is collected by the <code class="filename">/usr/lib64/sa/sa1</code>
       script (or <code class="filename">/usr/lib/sa/sa1</code> on 32bit systems)
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The summaries are generated by the script
       <code class="filename">/usr/lib64/sa/sa2</code> (or
       <code class="filename">/usr/lib/sa/sa2</code> on 32bit systems)
      </p></li></ul></div><p>
     If you need to customize the configuration, copy the
     <code class="filename">sa1</code> and <code class="filename">sa2</code> scripts and
     adjust them according to your needs. Replace the link
     <code class="filename">/etc/cron.d/sysstat</code> with a customized copy of
     <code class="filename">/etc/sysstat/sysstat.cron</code> calling your scripts.
    </p></div><div class="sect3" title="13.1.2.2. Generating reports with sar"><div class="titlepage"><div><div><h4 class="title"><a name="sec.util.multi.sar.report"></a>13.1.2.2. Generating reports with <span class="command"><strong>sar</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.report">¶</a></span></h4></div></div></div><p>
     To generate reports on the fly, call <span class="command"><strong>sar</strong></span> with an
     interval (seconds) and a count. To generate reports from files specify
     a filename with the option <code class="option">-f</code> instead of interval and
     count. If filename, interval and count are not specified,
     <span class="command"><strong>sar</strong></span> attempts to generate a report from
     <code class="filename">/var/log/sa/sa<em class="replaceable"><code>DD</code></em></code>, where
     <em class="replaceable"><code>DD</code></em> stands for the current day. This is the
     default location to where <span class="command"><strong>sadc</strong></span> writes its data.
     Query multiple files with multiple -f options.
    </p><pre class="screen">sar 2 10                         # on-the-fly report, 10 times every 2 seconds
sar -f ~/reports/sar_2010_05_03  # queries file sar_2010_05_03
sar                              # queries file from today in /var/log/sa/
cd /var/log/sa &amp;&amp;\
sar -f sa01 -f sa02              # queries files /var/log/sa/0[12]</pre><p>
     Find examples for useful <span class="command"><strong>sar</strong></span> calls and their
     interpretation below. For detailed information on the meaning of each
     column, please refer to the <code class="systemitem">man (1)</code> of
     <span class="command"><strong>sar</strong></span>. Also refer to the man page for more options and
     reports&#8212;<span class="command"><strong>sar</strong></span> offers plenty of them.
    </p><div class="sect4" title="13.1.2.2.1. CPU Utilization Report: sar"><div class="titlepage"><div><div><h5 class="title"><a name="sec.util.multi.sar.report.cpu"></a>13.1.2.2.1. CPU Utilization Report: <span class="command"><strong>sar</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.report.cpu">¶</a></span></h5></div></div></div><p>
      When called with no options, <span class="command"><strong>sar</strong></span> shows a basic
      report about CPU usage. On multi-processor machines, results for all
      CPUs are summarized. Use the option <code class="option">-P ALL</code> to also
      see statistics for individual CPUs.
     </p><pre class="screen">mercury:~ # sar 10 5
Linux 2.6.31.12-0.2-default (mercury) 03/05/10   _x86_64_   (2 CPU)

14:15:43   CPU    %user   %nice   %system   %iowait    %steal     %idle
14:15:53   all    38.55    0.00      6.10      0.10      0.00     55.25
14:16:03   all    12.59    0.00      4.90      0.33      0.00     82.18
14:16:13   all    56.59    0.00      8.16      0.44      0.00     34.81
14:16:23   all    58.45    0.00      3.00      0.00      0.00     38.55
14:16:33   all    86.46    0.00      4.70      0.00      0.00      8.85
Average:   all    49.94    0.00      5.38      0.18      0.00     44.50
</pre><p>
      If the value for <span class="guimenu">%iowait</span> (percentage of the CPU
      being idle while waiting for I/O) is significantly higher than zero
      over a longer period of time, there is a bottleneck in the I/O system
      (network or hard disk). If the <span class="guimenu">%idle</span> value is zero
      over a longer period of time, your CPU(s) are working to full
      capacity.
     </p></div><div class="sect4" title="13.1.2.2.2. Memory Usage Report: sar -r"><div class="titlepage"><div><div><h5 class="title"><a name="sec.util.multi.sar.report.memory"></a>13.1.2.2.2. Memory Usage Report: <span class="command"><strong>sar <code class="option">-r</code></strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.report.memory">¶</a></span></h5></div></div></div><p>
      Generate an overall picture of the system memory (RAM) by using the
      option <code class="option">-r</code>:
     </p><pre class="screen">
mercury:~ # sar -r 10 5
Linux 2.6.31.12-0.2-default (mercury) 03/05/10   _x86_64_   (2 CPU)

16:12:12 kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
16:12:22    548188   1507488    73.33     20524    64204  2338284   65.10
16:12:32    259320   1796356    87.39     20808    72660  2229080   62.06
16:12:42    381096   1674580    81.46     21084    75460  2328192   64.82
16:12:52    642668   1413008    68.74     21392    81212  1938820   53.98
16:13:02    311984   1743692    84.82     21712    84040  2212024   61.58
Average:    428651   1627025    79.15     21104    75515  2209280   61.51</pre><p>
      The last two columns (<span class="guimenu">kbcommit</span> and
      <span class="guimenu">%commit</span>) show an approximation of the total amount
      of memory (RAM plus swap) the current workload would need in the worst
      case (in kilobyte or percent respectively).
     </p></div><div class="sect4" title="13.1.2.2.3. Paging Statistics Report: sar -B"><div class="titlepage"><div><div><h5 class="title"><a name="sec.util.multi.sar.report.paging"></a>13.1.2.2.3. Paging Statistics Report: <span class="command"><strong>sar <code class="option">-B</code></strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.report.paging">¶</a></span></h5></div></div></div><p>
      Use the option <code class="option">-B</code> to display the kernel paging
      statistics.
     </p><pre class="screen">
mercury:~ # sar -B 10 5 
Linux 2.6.31.12-0.2-default (mercury) 03/05/10   _x86_64_   (2 CPU)

16:11:43 pgpgin/s pgpgout/s   fault/s majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s  %vmeff
16:11:53   225.20    104.00  91993.90     0.00  87572.60      0.00      0.00      0.00    0.00
16:12:03   718.32    601.00  82612.01     2.20  99785.69    560.56    839.24   1132.23   80.89
16:12:13  1222.00   1672.40 103126.00     1.70 106529.00   1136.00    982.40   1172.20   55.33
16:12:23   112.18     77.84 113406.59     0.10  97581.24     35.13    127.74    159.38   97.86
16:12:33   817.22     81.28 121312.91     9.41 111442.44      0.00      0.00      0.00    0.00
Average:   618.72    507.20 102494.86     2.68 100578.98    346.24    389.76    492.60   66.93</pre><p>
      The <span class="guimenu">majflt/s</span> (major faults per second) column shows
      how many pages are loaded from disk (swap) into memory. A large number
      of major faults slows down the system and is an indication of
      insufficient main memory. The <span class="guimenu">%vmeff</span> column shows
      the number of pages scanned (<span class="guimenu">pgscand/s</span>) in relation
      to the ones being reused from the main memory cache or the swap cache
      (<span class="guimenu">pgsteal/s</span>). It is a measurement of the efficiency
      of page reclaim. Healthy values are either near 100 (every inactive
      page swapped out is being reused) or 0 (no pages have been scanned).
      The value should not drop below 30.
     </p></div><div class="sect4" title="13.1.2.2.4. Block Device Statistics Report: sar -d"><div class="titlepage"><div><div><h5 class="title"><a name="sec.util.multi.sar.report.disk"></a>13.1.2.2.4. Block Device Statistics Report: <span class="command"><strong>sar <code class="option">-d</code></strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.report.disk">¶</a></span></h5></div></div></div><p>
      Use the option <code class="option">-d</code> to display the block device (hdd,
      optical drive, USB storage device, ...). Make sure to use the
      additional option <code class="option">-p</code> (pretty-print) to make the
      <span class="guimenu">DEV</span> column readable.
     </p><pre class="screen">
mercury:~ # sar -d -p 10 5
Linux 2.6.31.12-0.2-default (neo) 	03/05/10 	_x86_64_	(2 CPU)

16:28:31  DEV    tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
16:28:41  sdc  11.51     98.50    653.45     65.32      0.10   8.83   4.87   5.61
16:28:41 scd0   0.00      0.00      0.00      0.00      0.00   0.00   0.00   0.00

16:28:41  DEV    tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
16:28:51  sdc  15.38    329.27    465.93     51.69      0.10   6.39   4.70   7.23
16:28:51 scd0   0.00      0.00      0.00      0.00      0.00   0.00   0.00   0.00

16:28:51  DEV    tps rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
16:29:01  sdc  32.47   876.72    647.35     46.94      0.33  10.20   3.67  11.91
16:29:01 scd0   0.00     0.00      0.00      0.00      0.00   0.00   0.00   0.00

16:29:01  DEV    tps rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
16:29:11  sdc  48.75  2852.45    366.77     66.04      0.82  16.93   4.91  23.94
16:29:11 scd0   0.00     0.00      0.00      0.00      0.00   0.00   0.00   0.00

16:29:11  DEV    tps rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
16:29:21  sdc  13.20   362.40    412.00     58.67      0.16  12.03   6.09   8.04
16:29:21 scd0   0.00     0.00      0.00      0.00      0.00   0.00   0.00   0.00

Average:  DEV    tps rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
Average:  sdc  24.26   903.52    509.12     58.23      0.30  12.49   4.68  11.34
Average: scd0   0.00     0.00      0.00      0.00      0.00   0.00   0.00   0.00</pre><p>
      If your machine uses multiple disks, you will receive the best
      performance, if I/O requests are evenly spread over all disks. Compare
      the <span class="guimenu">Average</span> values for <span class="guimenu">tps</span>,
      <span class="guimenu">rd_sec/s</span>, and <span class="guimenu">wr_sec/s</span> of all
      disks. Constantly high values in the <span class="guimenu">svctm</span> and
      <span class="guimenu">%util</span> columns could be an indication that the
      amount of free space on the disk is insufficient.
     </p></div><div class="sect4" title="13.1.2.2.5. Network Statistics Reports: sar -n KEYWORD"><div class="titlepage"><div><div><h5 class="title"><a name="sec.util.multi.sar.report.net"></a>13.1.2.2.5. Network Statistics Reports: <span class="command"><strong>sar <code class="option">-n <em class="replaceable"><code>KEYWORD</code></em></code></strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.report.net">¶</a></span></h5></div></div></div><p>
      The option <code class="option">-n</code> lets you generate multiple network
      related reports. Specify one of the following keywords along with the
      <code class="option">-n</code>:
     </p><div class="itemizedlist"><ul class="itemizedlist" type="bullet"><li class="listitem" style="list-style-type: disc"><p>
        <span class="emphasis"><em>DEV</em></span>: Generates a statistic report for all
        network devices
       </p></li><li class="listitem" style="list-style-type: disc"><p>
        <span class="emphasis"><em>EDEV</em></span>: Generates an error statistics report for
        all network devices
       </p></li><li class="listitem" style="list-style-type: disc"><p>
        <span class="emphasis"><em>NFS</em></span>: Generates a statistic report for an NFS
        client
       </p></li><li class="listitem" style="list-style-type: disc"><p>
        <span class="emphasis"><em>NFSD</em></span>: Generates a statistic report for an NFS
        server
       </p></li><li class="listitem" style="list-style-type: disc"><p>
        <span class="emphasis"><em>SOCK</em></span>: Generates a statistic report on sockets
       </p></li><li class="listitem" style="list-style-type: disc"><p>
        <span class="emphasis"><em>ALL</em></span>: Generates all network statistic reports
       </p></li></ul></div></div></div><div class="sect3" title="13.1.2.3. Visualizing sar Data"><div class="titlepage"><div><div><h4 class="title"><a name="sec.util.multi.sar.visual"></a>13.1.2.3. Visualizing <span class="command"><strong>sar</strong></span> Data<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.multi.sar.visual">¶</a></span></h4></div></div></div><p>
     <span class="command"><strong>sar</strong></span> reports are not always easy to parse for humans.
     kSar, a Java application visualizing your <span class="command"><strong>sar</strong></span> data,
     creates easy-to-read graphs. It can even generate PDF reports. kSar
     takes data generated on the fly as well as past data from a file. kSar
     is licensed under the BSD license and is available from
     <a class="ulink" href="http://ksar.atomique.net/" target="_top">http://ksar.atomique.net/</a>.
    </p></div></div></div><div class="sect1" title="13.2. System Information"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.system"></a>13.2. System Information<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.2.1. Device Load Information: iostat"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.iostat"></a>13.2.1. Device Load Information: <span class="command"><strong>iostat</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.iostat">¶</a></span></h3></div></div></div><p>
    <span class="command"><strong>iostat</strong></span> monitors the system device loading. It
    generates reports that can be useful for better balancing the load
    between physical disks attached to your system.
   </p><p>
    The first <span class="command"><strong>iostat</strong></span> report shows statistics collected
    since the system was booted. Subsequent reports cover the time since the
    previous report.
   </p><pre class="screen">tux@mercury:~&gt; iostat
Linux 2.6.32.7-0.2-default (geeko@buildhost) 	02/24/10 	_x86_64_

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0,49    0,01    0,10    0,31    0,00   99,09

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               1,34         5,59        25,37    1459766    6629160
sda1              0,00         0,01         0,00       1519          0
sda2              0,87         5,11        17,83    1335365    4658152
sda3              0,47         0,47         7,54     122578    1971008</pre><p>
    When invoked with the <code class="option">-n</code> option,
    <span class="command"><strong>iostat</strong></span> adds statistics of network file systems (NFS)
    load. The option <code class="option">-x</code> shows extended statistics
    information.
   </p><p>
    You can also specify which device should be monitored at what time
    intervals. For example, <span class="command"><strong>iostat <code class="option">-p</code> sda 3
    5</strong></span> will display five reports at three second intervals for
    device sda.
   </p><div class="note"><table border="0" cellpadding="3" cellspacing="0" width="100%" summary="Note: sysstat package"><tr class="head"><td width="32"><img alt="[Note]" src="admon/note.png"></td><th align="left">sysstat package</th></tr><tr><td colspan="2" align="left" valign="top"><p>
     <span class="command"><strong>iostat</strong></span> is part of <code class="systemitem">sysstat</code>
     package. you need to install the package either with YaST, or with
     <span class="command"><strong>zypper in sysstat</strong></span>.
    </p></td></tr></table></div></div><div class="sect2" title="13.2.2. Processor Activity Monitoring: mpstat"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.mpstat"></a>13.2.2. Processor Activity Monitoring: <span class="command"><strong>mpstat</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.mpstat">¶</a></span></h3></div></div></div><p>
    The utility <span class="command"><strong>mpstat</strong></span> examines activities of each
    available processor. If your system has one processor only, the global
    average statistics will be reported.
   </p><p>
    With the <code class="option">-P</code> option, you can specify the number of
    processors to be reported (note that 0 is the first processor). The
    timing arguments work the same way as with the <span class="command"><strong>iostat</strong></span>
    command. Entering <span class="command"><strong>mpstat <code class="option">-P</code> 1 2 5</strong></span>
    prints five reports for the second processor (number 1) at 2 second
    intervals.
   </p><pre class="screen">tux@mercury:~&gt; mpstat -P 1 2 5
Linux 2.6.32.7-0.2-default (geeko@buildhost) 	02/24/10 	_x86_64_

08:57:10  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  \
 %guest   %idle
08:57:12    1    4.46    0.00    5.94    0.50    0.00    0.00    0.00  \
 0.00   89.11
08:57:14    1    1.98    0.00    2.97    0.99    0.00    0.99    0.00  \
 0.00   93.07
08:57:16    1    2.50    0.00    3.00    0.00    0.00    1.00    0.00  \
 0.00   93.50
08:57:18    1   14.36    0.00    1.98    0.00    0.00    0.50    0.00  \
 0.00   83.17
08:57:20    1    2.51    0.00    4.02    0.00    0.00    2.01    0.00  \
 0.00   91.46
Average:    1    5.17    0.00    3.58    0.30    0.00    0.90    0.00  \
 0.00   90.05</pre></div><div class="sect2" title="13.2.3. Task Monitoring: pidstat"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.pidstat"></a>13.2.3. Task Monitoring: <span class="command"><strong>pidstat</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.pidstat">¶</a></span></h3></div></div></div><p>
    If you need to see what load a particular task applies to your system,
    use <span class="command"><strong>pidstat</strong></span> command. It prints activity of every
    selected task or all tasks managed by Linux kernel if no task is
    specified. You can also set the number of reports to be displayed and
    the time interval between them.
   </p><p>
    For example, <span class="command"><strong>pidstat <code class="option">-C</code> top 2 3</strong></span>
    prints the load statistic for tasks whose command name includes the
    string <span class="quote">&#8220;<span class="quote">top</span>&#8221;</span>. There will be three reports printed at two
    second intervals.
   </p><pre class="screen">tux@mercury:~&gt; pidstat -C top 2 3
Linux 2.6.27.19-5-default (geeko@buildhost) 	03/23/2009 	_x86_64_

09:25:42 AM       PID    %usr %system  %guest    %CPU   CPU  Command
09:25:44 AM     23576   37.62   61.39    0.00   99.01     1  top

09:25:44 AM       PID    %usr %system  %guest    %CPU   CPU  Command
09:25:46 AM     23576   37.00   62.00    0.00   99.00     1  top

09:25:46 AM       PID    %usr %system  %guest    %CPU   CPU  Command
09:25:48 AM     23576   38.00   61.00    0.00   99.00     1  top

Average:          PID    %usr %system  %guest    %CPU   CPU  Command
Average:        23576   37.54   61.46    0.00   99.00     -  top</pre></div><div class="sect2" title="13.2.4. Kernel Ring Buffer: dmesg"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.dmesg"></a>13.2.4. Kernel Ring Buffer: <span class="command"><strong>dmesg</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.dmesg">¶</a></span></h3></div></div></div><p>
    The Linux kernel keeps certain messages in a ring buffer. To view these
    messages, enter the command <span class="command"><strong>dmesg</strong></span>:
   </p><pre class="screen">tux@mercury:~&gt; dmesg
[...]
end_request: I/O error, dev fd0, sector 0
subfs: unsuccessful attempt to mount media (256)
e100: eth0: e100_watchdog: link up, 100Mbps, half-duplex
NET: Registered protocol family 17
IA-32 Microcode Update Driver: v1.14 &lt;tigran@veritas.com&gt;
microcode: CPU0 updated from revision 0xe to 0x2e, date = 08112004
IA-32 Microcode Update Driver v1.14 unregistered
bootsplash: status on console 0 changed to on
NET: Registered protocol family 10
Disabled Privacy Extensions on device c0326ea0(lo)
IPv6 over IPv4 tunneling driver
powernow: This module only works with AMD K7 CPUs
bootsplash: status on console 0 changed to on</pre><p>
    Older events are logged in the files
    <code class="filename">/var/log/messages</code> and
    <code class="filename">/var/log/warn</code>.
   </p></div><div class="sect2" title="13.2.5. List of Open Files: lsof"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.lsof"></a>13.2.5. List of Open Files: <span class="command"><strong>lsof</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.lsof">¶</a></span></h3></div></div></div><p>
    To view a list of all the files open for the process with process ID
    <em class="replaceable"><code>PID</code></em>, use <code class="option">-p</code>. For example, to
    view all the files used by the current shell, enter:
   </p><pre class="screen">tux@mercury:~&gt; lsof -p $$
COMMAND  PID   USER   FD   TYPE DEVICE  SIZE/OFF NODE NAME
bash    5552 tux  cwd    DIR    3,3    1512 117619 /home/tux
bash    5552 tux  rtd    DIR    3,3     584      2 /
bash    5552 tux  txt    REG    3,3  498816  13047 /bin/bash
bash    5552 tux  mem    REG    0,0              0 [heap] (stat: No such
bash    5552 tux  mem    REG    3,3  217016 115687 /var/run/nscd/passwd
bash    5552 tux  mem    REG    3,3  208464  11867 /usr/lib/locale/en_GB.
[...]
bash    5552 tux  mem    REG    3,3     366   9720 /usr/lib/locale/en_GB.
bash    5552 tux  mem    REG    3,3   97165   8828 /lib/ld-2.3.6.so
bash    5552 tux    0u   CHR  136,5              7 /dev/pts/5
bash    5552 tux    1u   CHR  136,5              7 /dev/pts/5
bash    5552 tux    2u   CHR  136,5              7 /dev/pts/5
bash    5552 tux  255u   CHR  136,5              7 /dev/pts/5</pre><p>
    The special shell variable <code class="literal">$$</code>, whose value is the
    process ID of the shell, has been used.
   </p><p>
    The command <span class="command"><strong>lsof</strong></span> lists all the files currently open
    when used without any parameters. There are often thousands of open
    files, therefore, listing all of them is rarely useful. However, the
    list of all files can be combined with search functions to generate
    useful lists. For example, list all used character devices:
   </p><pre class="screen">tux@mercury:~&gt; lsof | grep CHR
bash      3838     tux    0u      CHR  136,0                 2 /dev/pts/0
bash      3838     tux    1u      CHR  136,0                 2 /dev/pts/0
bash      3838     tux    2u      CHR  136,0                 2 /dev/pts/0
bash      3838     tux  255u      CHR  136,0                 2 /dev/pts/0
bash      5552     tux    0u      CHR  136,5                 7 /dev/pts/5
bash      5552     tux    1u      CHR  136,5                 7 /dev/pts/5
bash      5552     tux    2u      CHR  136,5                 7 /dev/pts/5
bash      5552     tux  255u      CHR  136,5                 7 /dev/pts/5
X         5646       root  mem       CHR    1,1              1006 /dev/mem
lsof      5673     tux    0u      CHR  136,5                 7 /dev/pts/5
lsof      5673     tux    2u      CHR  136,5                 7 /dev/pts/5
grep      5674     tux    1u      CHR  136,5                 7 /dev/pts/5
grep      5674     tux    2u      CHR  136,5                 7 /dev/pts/5</pre><p>
    When used with <code class="option">-i</code>, <span class="command"><strong>lsof</strong></span> lists
    currently open Internet files as well:
   </p><pre class="screen">tux@mercury:~&gt; lsof -i
[...]
pidgin     4349 tux   17r  IPv4  15194      0t0  TCP \
 jupiter.example.com:58542-&gt;www.example.net:https (ESTABLISHED)
pidgin     4349 tux   21u  IPv4  15583      0t0  TCP \
 jupiter.example.com:37051-&gt;aol.example.org:aol (ESTABLISHED)
evolution  4578 tux   38u  IPv4  16102      0t0  TCP \
 jupiter.example.com:57419-&gt;imap.example.com:imaps (ESTABLISHED)
npviewer.  9425 tux   40u  IPv4  24769      0t0  TCP \
 jupiter.example.com:51416-&gt;www.example.com:http (CLOSE_WAIT)
npviewer.  9425 tux   49u  IPv4  24814      0t0  TCP \
 jupiter.example.com:43964-&gt;www.example.org:http (CLOSE_WAIT)
ssh       17394 tux    3u  IPv4  40654      0t0  TCP \
 jupiter.example.com:35454-&gt;saturn.example.com:ssh (ESTABLISHED)</pre></div><div class="sect2" title="13.2.6. Kernel and udev Event Sequence Viewer: udevadm monitor"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.udevmonitor"></a>13.2.6. Kernel and udev Event Sequence Viewer: <span class="command"><strong>udevadm monitor</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.udevmonitor">¶</a></span></h3></div></div></div><p>
    <span class="command"><strong>udevadm monitor</strong></span> listens to the kernel uevents and
    events sent out by a udev rule and prints the device path (DEVPATH) of
    the event to the console. This is a sequence of events while connecting
    a USB memory stick:
   </p><div class="note"><table border="0" cellpadding="3" cellspacing="0" width="100%" summary="Note: Monitoring udev Events"><tr class="head"><td width="32"><img alt="[Note]" src="admon/note.png"></td><th align="left">Monitoring udev Events</th></tr><tr><td colspan="2" align="left" valign="top"><p>
     Only root user is allowed to monitor udev events by running the
     <span class="command"><strong>udevadm</strong></span> command.
    </p></td></tr></table></div><pre class="screen">UEVENT[1138806687] add@/devices/pci0000:00/0000:00:1d.7/usb4/4-2/4-2.2
UEVENT[1138806687] add@/devices/pci0000:00/0000:00:1d.7/usb4/4-2/4-2.2/4-2.2
UEVENT[1138806687] add@/class/scsi_host/host4
UEVENT[1138806687] add@/class/usb_device/usbdev4.10
UDEV  [1138806687] add@/devices/pci0000:00/0000:00:1d.7/usb4/4-2/4-2.2
UDEV  [1138806687] add@/devices/pci0000:00/0000:00:1d.7/usb4/4-2/4-2.2/4-2.2
UDEV  [1138806687] add@/class/scsi_host/host4
UDEV  [1138806687] add@/class/usb_device/usbdev4.10
UEVENT[1138806692] add@/devices/pci0000:00/0000:00:1d.7/usb4/4-2/4-2.2/4-2.2
UEVENT[1138806692] add@/block/sdb
UEVENT[1138806692] add@/class/scsi_generic/sg1
UEVENT[1138806692] add@/class/scsi_device/4:0:0:0
UDEV  [1138806693] add@/devices/pci0000:00/0000:00:1d.7/usb4/4-2/4-2.2/4-2.2
UDEV  [1138806693] add@/class/scsi_generic/sg1
UDEV  [1138806693] add@/class/scsi_device/4:0:0:0
UDEV  [1138806693] add@/block/sdb
UEVENT[1138806694] add@/block/sdb/sdb1
UDEV  [1138806694] add@/block/sdb/sdb1
UEVENT[1138806694] mount@/block/sdb/sdb1
UEVENT[1138806697] umount@/block/sdb/sdb1</pre></div><div class="sect2" title="13.2.7. Information on Security Events: audit"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.audit"></a>13.2.7. Information on Security Events: audit<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.audit">¶</a></span></h3></div></div></div><p>
    The Linux audit framework is a complex auditing system that collects
    detailed information about all security related events. These records
    can be consequently analyzed to discover if, for example, a violation of
    security policies occurred. 
   </p></div><div class="sect2" title="13.2.8. Server Resources Used by X11 Clients: xrestop"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.xrestop"></a>13.2.8. Server Resources Used by X11 Clients: <span class="command"><strong>xrestop</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.xrestop">¶</a></span></h3></div></div></div><p>
    <span class="command"><strong>xrestop</strong></span> provides statistics for each connected X11
    client's server-side resource. The output is very similar to
    <a class="xref" href="cha.util.html#sec.util.processes.top" title="13.3.4. Table of Processes: top">Section 13.3.4, &#8220;Table of Processes: <span class="command"><strong>top</strong></span>&#8221;</a>.
   </p><pre class="screen">xrestop - Display: localhost:0
          Monitoring 40 clients. XErrors: 0
          Pixmaps:   42013K total, Other:     206K total, All:   42219K total

res-base Wins  GCs Fnts Pxms Misc   Pxm mem  Other   Total   PID Identifier
3e00000   385   36    1  751  107    18161K     13K  18175K   ?   NOVELL: SU
4600000   391  122    1 1182  889     4566K     33K   4600K   ?   amaroK - S
1600000    35   11    0   76  142     3811K      4K   3816K   ?   KDE Deskto
3400000    52   31    1   69   74     2816K      4K   2820K   ?   Linux Shel
2c00000    50   25    1   43   50     2374K      3K   2378K   ?   Linux Shel
2e00000    50   10    1   36   42     2341K      3K   2344K   ?   Linux Shel
2600000    37   24    1   34   50     1772K      3K   1775K   ?   Root - Kon
4800000    37   24    1   34   49     1772K      3K   1775K   ?   Root - Kon
2a00000   209   33    1  323  238     1111K     12K   1123K   ?   Trekstor25
1800000   182   32    1  302  285     1039K     12K   1052K   ?   kicker
1400000   157  121    1  231  477      777K     18K    796K   ?   kwin
3c00000   175   36    1  248  168      510K      9K    520K   ?   de.comp.la
3a00000   326   42    1  579  444      486K     20K    506K   ?   [opensuse-
0a00000    85   38    1  317  224      102K      9K    111K   ?   Kopete
4e00000    25   17    1   60   66       63K      3K     66K   ?   YaST Contr
2400000    11   10    0   56   51       53K      1K     55K 22061 suseplugge
0e00000    20   12    1   50   92       50K      3K     54K 22016 kded
3200000     6   41    5   72   84       40K      8K     48K   ?   EMACS
2200000    54    9    1   30   31       42K      3K     45K   ?   SUSEWatche
4400000     2   11    1   30   34       34K      2K     36K 16489 kdesu
1a00000   255    7    0   42   11       19K      6K     26K   ?   KMix
3800000     2   14    1   34   37       21K      2K     24K 22242 knotify
1e00000    10    7    0   42    9       15K    624B     15K   ?   KPowersave
3600000   106    6    1   30    9        7K      3K     11K 22236 konqueror
2000000    10    5    0   21   34        9K      1K     10K   ?   klipper
3000000    21    7    0   11    9        7K    888B      8K   ?   KDE Wallet</pre></div></div><div class="sect1" title="13.3. Processes"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.processes"></a>13.3. Processes<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.processes">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.3.1. Interprocess Communication: ipcs"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.processes.ipcs"></a>13.3.1. Interprocess Communication: <span class="command"><strong>ipcs</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.processes.ipcs">¶</a></span></h3></div></div></div><p>
    The command <span class="command"><strong>ipcs</strong></span> produces a list of the IPC resources
    currently in use:
   </p><pre class="screen">------ Shared Memory Segments --------
key        shmid      owner     perms      bytes      nattch     status
0x00000000 58261504   tux    600        393216     2          dest
0x00000000 58294273   tux    600        196608     2          dest
0x00000000 83886083   tux    666        43264      2
0x00000000 83951622   tux    666        192000     2
0x00000000 83984391   tux    666        282464     2
0x00000000 84738056   root      644        151552     2          dest

------ Semaphore Arrays --------
key        semid      owner     perms      nsems
0x4d038abf 0          tux    600        8

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages</pre></div><div class="sect2" title="13.3.2. Process List: ps"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.processes.ps"></a>13.3.2. Process List: <span class="command"><strong>ps</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.processes.ps">¶</a></span></h3></div></div></div><p>
    The command <span class="command"><strong>ps</strong></span> produces a list of processes. Most
    parameters must be written without a minus sign. Refer to <span class="command"><strong>ps
    --help</strong></span> for a brief help or to the man page for extensive help.
   </p><p>
    To list all processes with user and command line information, use
    <span class="command"><strong>ps aux</strong></span>:
   </p><pre class="screen">tux@mercury:~&gt; ps axu
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0    696   272 ?        S    12:59   0:01 init [5]
root         2  0.0  0.0      0     0 ?        SN   12:59   0:00 [ksoftirqd
root         3  0.0  0.0      0     0 ?        S&lt;   12:59   0:00 [events
[...]
tux    4047  0.0  6.0 158548 31400 ?        Ssl  13:02   0:06 mono-best
tux    4057  0.0  0.7   9036  3684 ?        Sl   13:02   0:00 /opt/gnome
tux    4067  0.0  0.1   2204   636 ?        S    13:02   0:00 /opt/gnome
tux    4072  0.0  1.0  15996  5160 ?        Ss   13:02   0:00 gnome-scre
tux    4114  0.0  3.7 130988 19172 ?        SLl  13:06   0:04 sound-juic
tux    4818  0.0  0.3   4192  1812 pts/0    Ss   15:59   0:00 -bash
tux    4959  0.0  0.1   2324   816 pts/0    R+   16:17   0:00 ps axu</pre><p>
    To check how many <span class="command"><strong>sshd</strong></span> processes are running, use the
    option <code class="option">-p</code> together with the command
    <span class="command"><strong>pidof</strong></span>, which lists the process IDs of the given
    processes.
   </p><pre class="screen">tux@mercury:~&gt; ps -p $(pidof sshd)
  PID TTY      STAT   TIME COMMAND
 3524 ?        Ss     0:00 /usr/sbin/sshd -o PidFile=/var/run/sshd.init.pid
 4813 ?        Ss     0:00 sshd: tux [priv]
 4817 ?        R      0:00 sshd: tux@pts/0</pre><p>
    The process list can be formatted according to your needs. The option
    <code class="option">-L</code> returns a list of all keywords. Enter the following
    command to issue a list of all processes sorted by memory usage:
   </p><pre class="screen">tux@mercury:~&gt; ps ax --format pid,rss,cmd --sort rss
  PID   RSS CMD
    2     0 [ksoftirqd/0]
    3     0 [events/0]
    4     0 [khelper]
    5     0 [kthread]
   11     0 [kblockd/0]
   12     0 [kacpid]
  472     0 [pdflush]
  473     0 [pdflush]
[...]
 4028 17556 nautilus --no-default-window --sm-client-id default2
 4118 17800 ksnapshot
 4114 19172 sound-juicer
 4023 25144 gnome-panel --sm-client-id default1
 4047 31400 mono-best --debug /usr/lib/beagle/Best.exe --autostarted
 3973 31520 mono-beagled --debug /usr/lib/beagle/BeagleDaemon.exe --bg --aut</pre><div class="variablelist" title="Useful ps Calls"><p class="title"><b>Useful <span class="command"><strong>ps</strong></span> Calls</b></p><dl><dt><span class="term"><span class="command"><strong>ps aux <code class="option">--sort <em class="replaceable"><code>column</code></em></code></strong></span>
     </span></dt><dd><p>
       Sort the output by <em class="replaceable"><code>column</code></em>. Replace
       <em class="replaceable"><code>column</code></em> with
      </p><table border="0" summary="Simple list" class="simplelist"><tr><td><code class="option">pmem</code> for physical memory ratio</td></tr><tr><td><code class="option">pcpu</code> for CPU ratio</td></tr><tr><td><code class="option">rss</code> for resident set size (non-swapped physical memory)</td></tr></table></dd><dt><span class="term"><span class="command"><strong>ps axo pid,%cpu,rss,vsz,args,wchan</strong></span>
     </span></dt><dd><p>
       Shows every process, their PID, CPU usage ratio, memory size
       (resident and virtual), name, and their syscall.
      </p></dd><dt><span class="term"><span class="command"><strong>ps axfo pid,args</strong></span>
     </span></dt><dd><p>
       Show a process tree.
      </p></dd></dl></div></div><div class="sect2" title="13.3.3. Process Tree: pstree"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.pstree"></a>13.3.3. Process Tree: <span class="command"><strong>pstree</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.pstree">¶</a></span></h3></div></div></div><p>
    The command <span class="command"><strong>pstree</strong></span> produces a list of processes in
    the form of a tree:
   </p><pre class="screen">tux@mercury:~&gt; pstree
init-+-NetworkManagerD
     |-acpid
     |-3*[automount]
     |-cron
     |-cupsd
     |-2*[dbus-daemon]
     |-dbus-launch
     |-dcopserver
     |-dhcpcd
     |-events/0
     |-gpg-agent
     |-hald-+-hald-addon-acpi
     |      `-hald-addon-stor
     |-kded
     |-kdeinit-+-kdesu---su---kdesu_stub---yast2---y2controlcenter
     |         |-kio_file
     |         |-klauncher
     |         |-konqueror
     |         |-konsole-+-bash---su---bash
     |         |         `-bash
     |         `-kwin
     |-kdesktop---kdesktop_lock---xmatrix
     |-kdesud
     |-kdm-+-X
     |     `-kdm---startkde---kwrapper
[...]</pre><p>
    The parameter <code class="option">-p</code> adds the process ID to a given name.
    To have the command lines displayed as well, use the <code class="option">-a</code>
    parameter.
   </p></div><div class="sect2" title="13.3.4. Table of Processes: top"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.processes.top"></a>13.3.4. Table of Processes: <span class="command"><strong>top</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.processes.top">¶</a></span></h3></div></div></div><p>
    The command <span class="command"><strong>top</strong></span>, which stands for <code class="literal">table of
    processes</code>, displays a list of processes that is refreshed
    every two seconds. To terminate the program, press <span class="keycap">Q</span>.
    The parameter <code class="option">-n 1</code> terminates the program after a
    single display of the process list. The following is an example output
    of the command <span class="command"><strong>top -n 1</strong></span>:
   </p><pre class="screen">tux@mercury:~&gt; top -n 1
top - 17:06:28 up  2:10,  5 users,  load average: 0.00, 0.00, 0.00
Tasks:  85 total,   1 running,  83 sleeping,   1 stopped,   0 zombie
Cpu(s):  5.5% us,  0.8% sy,  0.8% ni, 91.9% id,  1.0% wa,  0.0% hi,  0.0% si
Mem:    515584k total,   506468k used,     9116k free,    66324k buffers
Swap:   658656k total,        0k used,   658656k free,   353328k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      16   0   700  272  236 S  0.0  0.1   0:01.33 init
    2 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    3 root      10  -5     0    0    0 S  0.0  0.0   0:00.27 events/0
    4 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 khelper
    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
   11 root      10  -5     0    0    0 S  0.0  0.0   0:00.05 kblockd/0
   12 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid
  472 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pdflush
  473 root      15   0     0    0    0 S  0.0  0.0   0:00.06 pdflush
  475 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0
  474 root      15   0     0    0    0 S  0.0  0.0   0:00.07 kswapd0
  681 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 kseriod
  839 root      10  -5     0    0    0 S  0.0  0.0   0:00.02 reiserfs/0
  923 root      13  -4  1712  552  344 S  0.0  0.1   0:00.67 udevd
 1343 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khubd
 1587 root      20   0     0    0    0 S  0.0  0.0   0:00.00 shpchpd_event
 1746 root      15   0     0    0    0 S  0.0  0.0   0:00.00 w1_control
 1752 root      15   0     0    0    0 S  0.0  0.0   0:00.00 w1_bus_master1
 2151 root      16   0  1464  496  416 S  0.0  0.1   0:00.00 acpid
 2165 messageb  16   0  3340 1048  792 S  0.0  0.2   0:00.64 dbus-daemon
 2166 root      15   0  1840  752  556 S  0.0  0.1   0:00.01 syslog-ng
 2171 root      16   0  1600  516  320 S  0.0  0.1   0:00.00 klogd
 2235 root      15   0  1736  800  652 S  0.0  0.2   0:00.10 resmgrd
 2289 root      16   0  4192 2852 1444 S  0.0  0.6   0:02.05 hald
 2403 root      23   0  1756  600  524 S  0.0  0.1   0:00.00 hald-addon-acpi
 2709 root      19   0  2668 1076  944 S  0.0  0.2   0:00.00 NetworkManagerD
 2714 root      16   0  1756  648  564 S  0.0  0.1   0:00.56 hald-addon-stor</pre><p>
    By default the output is sorted by CPU usage (column
    <span class="guimenu">%CPU</span>, shortcut <span class="keycap">Shift</span>+<span class="keycap">P</span>). Use following shortcuts to change the
    sort field:
   </p><table border="0" summary="Simple list" class="simplelist"><tr><td><span class="keycap">Shift</span>+<span class="keycap">M</span>: Resident Memory (<span class="guimenu">RES</span>)
    </td></tr><tr><td><span class="keycap">Shift</span>+<span class="keycap">N</span>: Process ID (<span class="guimenu">PID</span>)
    </td></tr><tr><td><span class="keycap">Shift</span>+<span class="keycap">T</span>: Time (<span class="guimenu">TIME+</span>)
    </td></tr></table><p>
    To use any other field for sorting, press <span class="keycap">F</span> and select
    a field from the list. To toggle the sort order, Use <span class="keycap">Shift</span>+<span class="keycap">R</span>.
   </p><p>
    The parameter <code class="option">-U <em class="replaceable"><code>UID</code></em></code>
    monitors only the processes associated with a particular user. Replace
    <em class="replaceable"><code>UID</code></em> with the user ID of the user. Use
    <span class="command"><strong>top -U $(id -u)</strong></span> to show processes of the current user
   </p></div><div class="sect2" title="13.3.5. Modify a process' niceness: nice and renice"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.processes.nice"></a>13.3.5. Modify a process' niceness: <span class="command"><strong>nice</strong></span> and <span class="command"><strong>renice</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.processes.nice">¶</a></span></h3></div></div></div><p>
    The kernel determines which processes require more CPU time than others
    by the process' nice level, also called niceness. The higher the
    <span class="quote">&#8220;<span class="quote">nice</span>&#8221;</span> level of a process is, the less CPU time it will
    take from other processes. Nice levels range from -20 (the least
    <span class="quote">&#8220;<span class="quote">nice</span>&#8221;</span> level) to 19. Negative values can only be set by
    <code class="systemitem">root</code>.
   </p><p>
    Adjusting the niceness level is useful when running a non time-critical
    process that lasts long and uses large amounts of CPU time, such as
    compiling a kernel on a system that also performs other tasks. Making
    such a process <span class="quote">&#8220;<span class="quote">nicer</span>&#8221;</span>, ensures that the other tasks, for
    example a Web server, will have a higher priority.
   </p><p>
    Calling <span class="command"><strong>nice</strong></span> without any parameters prints the
    current niceness:
   </p><pre class="screen">tux@mercury:~&gt; nice
0</pre><p>
    Running <span class="command"><strong>nice <em class="replaceable"><code>command</code></em></strong></span>
    increments the current nice level for the given command by 10. Using
    <span class="command"><strong>nice <code class="option">-n <em class="replaceable"><code>level</code></em></code>
    <em class="replaceable"><code>command</code></em></strong></span> lets you specify a new
    niceness relative to the current one.
   </p><p>
    To change the niceness of a running process, use <span class="command"><strong>renice
    <em class="replaceable"><code>priority</code></em> <code class="option">-p <em class="replaceable"><code>process
    id</code></em></code></strong></span>, for example:
   </p><pre class="screen">renice +5 3266</pre><p>
    To renice all processes owned by a specific user, use the option
    <code class="option">-u <em class="replaceable"><code>user</code></em></code>. Process groups are
    reniced by the option <code class="option">-g <em class="replaceable"><code>process group
    id</code></em></code>.
   </p></div></div><div class="sect1" title="13.4. Memory"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.memory"></a>13.4. Memory<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.memory">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.4.1. Memory Usage: free"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.memory.free"></a>13.4.1. Memory Usage: <span class="command"><strong>free</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.memory.free">¶</a></span></h3></div></div></div><p>
    The utility <span class="command"><strong>free</strong></span> examines RAM and swap usage. Details
    of both free and used memory and swap areas are shown:
   </p><pre class="screen">tux@mercury:~&gt; free
            total       used       free     shared    buffers     cached
Mem:       2062844    2047444      15400          0     129580     921936
-/+ buffers/cache:     995928    1066916
Swap:      2104472          0    2104472</pre><p>
    The options <code class="option">-b</code>, <code class="option">-k</code>,
    <code class="option">-m</code>, <code class="option">-g</code> show the output in bytes, KB,
    MB, or GB, respectively. The parameter <code class="option">-d delay</code> ensures
    that the display is refreshed every <em class="replaceable"><code>delay</code></em>
    seconds. For example, <span class="command"><strong>free -d 1.5</strong></span> produces an update
    every 1.5 seconds.
   </p></div><div class="sect2" title="13.4.2. Detailed Memory Usage: /proc/meminfo"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.memory.meminfo"></a>13.4.2. Detailed Memory Usage: <code class="filename">/proc/meminfo</code><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.memory.meminfo">¶</a></span></h3></div></div></div><p>
    Use <code class="filename">/proc/meminfo</code> to get more detailed information
    on memory usage than with <span class="command"><strong>free</strong></span>. Actually
    <span class="command"><strong>free</strong></span> uses some of the data from this file. See an
    example output from a 64bit system below. Note that it slightly differs
    on 32bit systems due to different memory management):
   </p><pre class="screen">tux@mercury:~&gt; cat /proc/meminfo
MemTotal:        8182956 kB
MemFree:         1045744 kB
Buffers:          364364 kB
Cached:          5601388 kB
SwapCached:         1936 kB
Active:          4048268 kB
Inactive:        2674796 kB
Active(anon):     663088 kB
Inactive(anon):   107108 kB
Active(file):    3385180 kB
Inactive(file):  2567688 kB
Unevictable:           4 kB
Mlocked:               4 kB
SwapTotal:       2096440 kB
SwapFree:        2076692 kB
Dirty:                44 kB
Writeback:             0 kB
AnonPages:        756108 kB
Mapped:           147320 kB
Slab:             329216 kB
SReclaimable:     300220 kB
SUnreclaim:        28996 kB
PageTables:        21092 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     6187916 kB
Committed_AS:    1388160 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      133384 kB
VmallocChunk:   34359570939 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:     2689024 kB
DirectMap2M:     5691392 kB</pre><p>
    The most important entries are:
   </p><div class="variablelist"><dl><dt><span class="term"><span class="guimenu">MemTotal</span>
     </span></dt><dd><p>
       Total amount of usable RAM
      </p></dd><dt><span class="term"><span class="guimenu">MemFree</span>
     </span></dt><dd><p>
       Total amount of unused RAM
      </p></dd><dt><span class="term"><span class="guimenu">Buffers</span>
     </span></dt><dd><p>
       File buffer cache in RAM
      </p></dd><dt><span class="term"><span class="guimenu">Cached</span>
     </span></dt><dd><p>
       Page cache in RAM
      </p></dd><dt><span class="term"><span class="guimenu">SwapCached</span>
     </span></dt><dd><p>
       Page cache in swap
      </p></dd><dt><span class="term"><span class="guimenu">Active</span>
     </span></dt><dd><p>
       Recently used memory that normally is not reclaimed. This value is
       the sum of memory claimed by anonymous pages (listed as
       <span class="guimenu">Active(anon)</span>) and file-backed pages (listed as
       <span class="guimenu">Active(file)</span>)
      </p></dd><dt><span class="term"><span class="guimenu">Inactive</span>
     </span></dt><dd><p>
       Recently unused memory that can be reclaimed. This value is the sum
       of memory claimed by anonymous pages (listed as
       <span class="guimenu">Inactive(anon)</span>) and file-backed pages (listed as
       <span class="guimenu">Inactive(file)</span>).
      </p></dd><dt><span class="term"><span class="guimenu">SwapTotal</span>
     </span></dt><dd><p>
       Total amount of swap space
      </p></dd><dt><span class="term"><span class="guimenu">SwapFree</span>
     </span></dt><dd><p>
       Total amount of unused swap space
      </p></dd><dt><span class="term"><span class="guimenu">Dirty</span>
     </span></dt><dd><p>
       Amount of memory that will be written to disk
      </p></dd><dt><span class="term"><span class="guimenu">Writeback</span>
     </span></dt><dd><p>
       Amount of memory that currently is written to disk
      </p></dd><dt><span class="term"><span class="guimenu">Mapped</span>
     </span></dt><dd><p>
       Memory claimed with the nmap command
      </p></dd><dt><span class="term"><span class="guimenu">Slab</span>
     </span></dt><dd><p>
       Kernel data structure cache
      </p></dd><dt><span class="term"><span class="guimenu">Committed_AS</span>
     </span></dt><dd><p>
       An approximation of the total amount of memory (RAM plus swap) the
       current workload needs in the worst case.
      </p></dd></dl></div></div><div class="sect2" title="13.4.3. Process Memory Usage: smaps"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.memory.smaps"></a>13.4.3. Process Memory Usage: smaps<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.memory.smaps">¶</a></span></h3></div></div></div><p>
    Exactly determining how much memory a certain process is consuming is
    not possible with standard tools like <span class="command"><strong>top</strong></span> or
    <span class="command"><strong>ps</strong></span>. Use the smaps subsystem, introduced in Kernel
    2.6.14, if you need exact data. It can be found at
    <code class="filename">/proc/<em class="replaceable"><code>pid</code></em>/smaps</code> and
    shows you the number of clean and dirty memory pages the process with
    the ID <em class="replaceable"><code>PID</code></em> is using at that time. It
    differentiates between shared and private memory, so you are able to see
    how much memory the process is using without including memory shared
    with other processes.
   </p></div></div><div class="sect1" title="13.5. Networking"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.networking"></a>13.5. Networking<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.networking">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.5.1. Show the Network Status: netstat"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.networking.netstat"></a>13.5.1. Show the Network Status: <span class="command"><strong>netstat</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.networking.netstat">¶</a></span></h3></div></div></div><p>
    <span class="command"><strong>netstat</strong></span> shows network connections, routing tables
    (<code class="option">-r</code>), interfaces (<code class="option">-i</code>), masquerade
    connections (<code class="option">-M</code>), multicast memberships
    (<code class="option">-g</code>), and statistics (<code class="option">-s</code>).
   </p><pre class="screen">tux@mercury:~&gt; netstat -r
Kernel IP routing table
Destination     Gateway         Genmask        Flags  MSS Window  irtt Iface
192.168.2.0     *               255.255.254.0  U        0 0          0 eth0
link-local      *               255.255.0.0    U        0 0          0 eth0
loopback        *               255.0.0.0      U        0 0          0 lo
default         192.168.2.254   0.0.0.0        UG       0 0          0 eth0</pre><pre class="screen">tux@mercury:~&gt; netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR  TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0   1500   0 1624507 129056      0      0   7055      0      0      0 BMNRU
lo    16436   0   23728      0      0      0  23728      0      0      0 LRU</pre><p>
    When displaying network connections or statistics, you can specify the
    socket type to display: TCP (<code class="option">-t</code>), UDP
    (<code class="option">-u</code>), or raw (<code class="option">-r</code>). The
    <code class="option">-p</code> option shows the PID and name of the program to
    which each socket belongs.
   </p><p>
    The following example lists all TCP connections and the programs using
    these connections.
   </p><pre class="screen">mercury:~ # netstat -t -p
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address  Foreign Address       State       PID/Pro
[...]
tcp      0      0 mercury:33513    www.novell.com:www-http ESTABLISHED 6862/fi
tcp      0    352 mercury:ssh      mercury2.:trc-netpoll     ESTABLISHED 19422/s
tcp      0      0 localhost:ssh  localhost:17828         ESTABLISHED -</pre><p>
    In the following, statistics for the TCP protocol are displayed:
   </p><pre class="screen">tux@mercury:~&gt; netstat -s -t
Tcp:
    2427 active connections openings
    2374 passive connection openings
    0 failed connection attempts
    0 connection resets received
    1 connections established
    27476 segments received
    26786 segments send out
    54 segments retransmited
    0 bad segments received.
    6 resets sent
[...]
    TCPAbortOnLinger: 0
    TCPAbortFailed: 0
    TCPMemoryPressures: 0</pre></div><div class="sect2" title="13.5.2. Interactive Network Monitor: iptraf"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.networking.iptraf"></a>13.5.2. Interactive Network Monitor: <span class="command"><strong>iptraf</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.networking.iptraf">¶</a></span></h3></div></div></div><p>
    The <span class="command"><strong>iptraf</strong></span> utility is a menu based Local Area Network
    (LAN) monitor. It generates network statistics, including TCP and UDP
    counts, Ethernet load information, IP checksum errors and others.
   </p><p>
    If you enter the command without any option, it runs in an interactive
    mode. You can navigate through graphical menus and choose the statistics
    that you want <span class="command"><strong>iptraf</strong></span> to report. You can also specify
    which network interface to examine.
   </p><div class="figure"><a name="fig.util.networking.iptraf"></a><p class="title"><b>Figure 13.1. <span class="command">iptraf</span> Running in Interactive Mode</b><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#fig.util.networking.iptraf">¶</a></span></p><div class="figure-contents"><div class="mediaobject"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0" width="65%"><tr><td><img src="images/iptraf_interactive.png" width="100%" alt="iptraf Running in Interactive Mode"></td></tr></table></div></div></div><br class="figure-break"><p>
    The command <span class="command"><strong>iptraf</strong></span> understands several options and
    can be run in a batch mode as well. The following example will collect
    statistics for network interface eth0 (<code class="option">-i</code>) for 1 minute
    (<code class="option">-t</code>). It will be run in the background
    (<code class="option">-B</code>) and the statistics will be written to the
    <code class="filename">iptraf.log</code> file in your home directory
    (<code class="option">-L</code>).
   </p><pre class="screen">tux@mercury:~&gt; iptraf -i eth0 -t 1 -B -L ~/iptraf.log</pre><p>
    You can examine the log file with the <span class="command"><strong>more</strong></span> command:
   </p><pre class="screen">tux@mercury:~&gt; more ~/iptraf.log
Mon Mar 23 10:08:02 2010; ******** IP traffic monitor started ********
Mon Mar 23 10:08:02 2010; UDP; eth0; 107 bytes; from 192.168.1.192:33157 to \
 239.255.255.253:427
Mon Mar 23 10:08:02 2010; VRRP; eth0; 46 bytes; from 192.168.1.252 to \
 224.0.0.18
Mon Mar 23 10:08:03 2010; VRRP; eth0; 46 bytes; from 192.168.1.252 to \
 224.0.0.18
Mon Mar 23 10:08:03 2010; VRRP; eth0; 46 bytes; from 192.168.1.252 to \
 224.0.0.18
[...]
Mon Mar 23 10:08:06 2010; UDP; eth0; 132 bytes; from 192.168.1.54:54395 to \
 10.20.7.255:111
Mon Mar 23 10:08:06 2010; UDP; eth0; 46 bytes; from 192.168.1.92:27258 to \
 10.20.7.255:8765
Mon Mar 23 10:08:06 2010; UDP; eth0; 124 bytes; from 192.168.1.139:43464 to \
 10.20.7.255:111
Mon Mar 23 10:08:06 2010; VRRP; eth0; 46 bytes; from 192.168.1.252 to \
 224.0.0.18
--More--(7%)</pre></div></div><div class="sect1" title="13.6. The /proc File System"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.proc"></a>13.6. The <code class="filename">/proc</code> File System<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.proc">¶</a></span></h2></div></div></div><p>
   The <code class="filename">/proc</code> file system is a pseudo file system in
   which the kernel reserves important information in the form of virtual
   files. For example, display the CPU type with this command:
  </p><pre class="screen">tux@mercury:~&gt; cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Pentium(R) 4 CPU 3.40GHz
stepping        : 3
cpu MHz         : 2800.000
cache size      : 2048 KB
physical id     : 0
[...]</pre><p>
   Query the allocation and use of interrupts with the following command:
  </p><pre class="screen">tux@mercury:~&gt; cat /proc/interrupts
           CPU0
  0:    3577519          XT-PIC  timer
  1:        130          XT-PIC  i8042
  2:          0          XT-PIC  cascade
  5:     564535          XT-PIC  Intel 82801DB-ICH4
  7:          1          XT-PIC  parport0
  8:          2          XT-PIC  rtc
  9:          1          XT-PIC  acpi, uhci_hcd:usb1, ehci_hcd:usb4
 10:          0          XT-PIC  uhci_hcd:usb3
 11:      71772          XT-PIC  uhci_hcd:usb2, eth0
 12:     101150          XT-PIC  i8042
 14:      33146          XT-PIC  ide0
 15:     149202          XT-PIC  ide1
NMI:          0
LOC:          0
ERR:          0
MIS:          0</pre><p>
   Some of the important files and their contents are:
  </p><div class="variablelist"><dl><dt><span class="term"><code class="filename">/proc/devices</code>
    </span></dt><dd><p>
      Available devices
     </p></dd><dt><span class="term"><code class="filename">/proc/modules</code>
    </span></dt><dd><p>
      Kernel modules loaded
     </p></dd><dt><span class="term"><code class="filename">/proc/cmdline</code>
    </span></dt><dd><p>
      Kernel command line
     </p></dd><dt><span class="term"><code class="filename">/proc/meminfo</code>
    </span></dt><dd><p>
      Detailed information about memory usage
     </p></dd><dt><span class="term"><code class="filename">/proc/config.gz</code>
    </span></dt><dd><p>
      <span class="command"><strong>gzip</strong></span>-compressed configuration file of the kernel
      currently running
     </p></dd></dl></div><p>
   Further information is available in the text file
   <code class="filename">/usr/src/linux/Documentation/filesystems/proc.txt</code>
   (this file is available when the package
   <code class="systemitem">kernel-source</code> is installed). Find information
   about processes currently running in the
   <code class="filename">/proc/</code><em class="replaceable"><code>NNN</code></em> directories,
   where <em class="replaceable"><code>NNN</code></em> is the process ID (PID) of the
   relevant process. Every process can find its own characteristics in
   <code class="filename">/proc/self/</code>:
  </p><pre class="screen">tux@mercury:~&gt; ls -l /proc/self
lrwxrwxrwx 1 root root 64 2007-07-16 13:03 /proc/self -&gt; 5356
tux@mercury:~&gt; ls -l /proc/self/
total 0
dr-xr-xr-x 2 tux users 0 2007-07-16 17:04 attr
-r-------- 1 tux users 0 2007-07-16 17:04 auxv
-r--r--r-- 1 tux users 0 2007-07-16 17:04 cmdline
lrwxrwxrwx 1 tux users 0 2007-07-16 17:04 cwd -&gt; /home/tux
-r-------- 1 tux users 0 2007-07-16 17:04 environ
lrwxrwxrwx 1 tux users 0 2007-07-16 17:04 exe -&gt; /bin/ls
dr-x------ 2 tux users 0 2007-07-16 17:04 fd
-rw-r--r-- 1 tux users 0 2007-07-16 17:04 loginuid
-r--r--r-- 1 tux users 0 2007-07-16 17:04 maps
-rw------- 1 tux users 0 2007-07-16 17:04 mem
-r--r--r-- 1 tux users 0 2007-07-16 17:04 mounts
-rw-r--r-- 1 tux users 0 2007-07-16 17:04 oom_adj
-r--r--r-- 1 tux users 0 2007-07-16 17:04 oom_score
lrwxrwxrwx 1 tux users 0 2007-07-16 17:04 root -&gt; /
-rw------- 1 tux users 0 2007-07-16 17:04 seccomp
-r--r--r-- 1 tux users 0 2007-07-16 17:04 smaps
-r--r--r-- 1 tux users 0 2007-07-16 17:04 stat
[...]
dr-xr-xr-x 3 tux users 0 2007-07-16 17:04 task
-r--r--r-- 1 tux users 0 2007-07-16 17:04 wchan</pre><p>
   The address assignment of executables and libraries is contained in the
   <code class="filename">maps</code> file:
  </p><pre class="screen">tux@mercury:~&gt; cat /proc/self/maps
08048000-0804c000 r-xp 00000000 03:03 17753      /bin/cat
0804c000-0804d000 rw-p 00004000 03:03 17753      /bin/cat
0804d000-0806e000 rw-p 0804d000 00:00 0          [heap]
b7d27000-b7d5a000 r--p 00000000 03:03 11867      /usr/lib/locale/en_GB.utf8/
b7d5a000-b7e32000 r--p 00000000 03:03 11868      /usr/lib/locale/en_GB.utf8/
b7e32000-b7e33000 rw-p b7e32000 00:00 0
b7e33000-b7f45000 r-xp 00000000 03:03 8837       /lib/libc-2.3.6.so
b7f45000-b7f46000 r--p 00112000 03:03 8837       /lib/libc-2.3.6.so
b7f46000-b7f48000 rw-p 00113000 03:03 8837       /lib/libc-2.3.6.so
b7f48000-b7f4c000 rw-p b7f48000 00:00 0
b7f52000-b7f53000 r--p 00000000 03:03 11842      /usr/lib/locale/en_GB.utf8/
[...]
b7f5b000-b7f61000 r--s 00000000 03:03 9109       /usr/lib/gconv/gconv-module
b7f61000-b7f62000 r--p 00000000 03:03 9720       /usr/lib/locale/en_GB.utf8/
b7f62000-b7f76000 r-xp 00000000 03:03 8828       /lib/ld-2.3.6.so
b7f76000-b7f78000 rw-p 00013000 03:03 8828       /lib/ld-2.3.6.so
bfd61000-bfd76000 rw-p bfd61000 00:00 0          [stack]
ffffe000-fffff000 ---p 00000000 00:00 0          [vdso]</pre><div class="sect2" title="13.6.1. procinfo"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.proc.procinfo"></a>13.6.1. <span class="command"><strong>procinfo</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.proc.procinfo">¶</a></span></h3></div></div></div><p>
    Important information from the <code class="filename">/proc</code> file system is
    summarized by the command <span class="command"><strong>procinfo</strong></span>:
   </p><pre class="screen">tux@mercury:~&gt; procinfo
Linux 2.6.32.7-0.2-default (geeko@buildhost) (gcc 4.3.4) #1 2CPU

Memory:      Total        Used        Free      Shared     Buffers
Mem:       2060604     2011264       49340           0      200664
Swap:      2104472         112     2104360

Bootup: Wed Feb 17 03:39:33 2010    Load average: 0.86 1.10 1.11 3/118 21547

user  :       2:43:13.78   0.8%  page in :   71099181  disk 1:  2827023r 968
nice  :   1d 22:21:27.87  14.7%  page out:  690734737
system:      13:39:57.57   4.3%  page act:  138388345
IOwait:      18:02:18.59   5.7%  page dea:   29639529
hw irq:       0:03:39.44   0.0%  page flt: 9539791626
sw irq:       1:15:35.25   0.4%  swap in :         69
idle  :   9d 16:07:56.79  73.8%  swap out:        209
uptime:   6d 13:07:11.14         context :  542720687

irq  0: 141399308 timer          irq 14:   5074312 ide0
irq  1:     73784 i8042          irq 50:   1938076 uhci_hcd:usb1, ehci_
irq  4:         2                irq 58:         0 uhci_hcd:usb2
irq  6:         5 floppy [2]     irq 66:    872711 uhci_hcd:usb3, HDA I
irq  7:         2                irq 74:        15 uhci_hcd:usb4
irq  8:         0 rtc            irq 82: 178717720 0         PCI-MSI  e
irq  9:         0 acpi           irq169:  44352794 nvidia
irq 12:         3                irq233:   8209068 0         PCI-MSI  l</pre><p>
    To see all the information, use the parameter <code class="option">-a</code>. The
    parameter <code class="option">-nN</code> produces updates of the information every
    <em class="replaceable"><code>N</code></em> seconds. In this case, terminate the
    program by pressing <span class="keycap">q</span>.
   </p><p>
    By default, the cumulative values are displayed. The parameter
    <code class="option">-d</code> produces the differential values. <span class="command"><strong>procinfo
    -dn5</strong></span> displays the values that have changed in the last five
    seconds:
   </p></div></div><div class="sect1" title="13.7. Hardware Information"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.hardware"></a>13.7. Hardware Information<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.hardware">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.7.1. PCI Resources: lspci"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.hardware.lspci"></a>13.7.1. PCI Resources: <span class="command"><strong>lspci</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.hardware.lspci">¶</a></span></h3></div></div></div><div class="note"><table border="0" cellpadding="3" cellspacing="0" width="100%" summary="Note: Accessing PCI configuration."><tr class="head"><td width="32"><img alt="[Note]" src="admon/note.png"></td><th align="left">Accessing PCI configuration.</th></tr><tr><td colspan="2" align="left" valign="top"><p>
     Most operating systems require root user privileges to grant access to
     the computer's PCI configuration.
    </p></td></tr></table></div><p>
    The command <span class="command"><strong>lspci</strong></span> lists the PCI resources:
   </p><pre class="screen">mercury:~ # lspci
00:00.0 Host bridge: Intel Corporation 82845G/GL[Brookdale-G]/GE/PE \
    DRAM Controller/Host-Hub Interface (rev 01)
00:01.0 PCI bridge: Intel Corporation 82845G/GL[Brookdale-G]/GE/PE \
    Host-to-AGP Bridge (rev 01)
00:1d.0 USB Controller: Intel Corporation 82801DB/DBL/DBM \
    (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 01)
00:1d.1 USB Controller: Intel Corporation 82801DB/DBL/DBM \
    (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 01)
00:1d.2 USB Controller: Intel Corporation 82801DB/DBL/DBM \
    (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 01)
00:1d.7 USB Controller: Intel Corporation 82801DB/DBM \
    (ICH4/ICH4-M) USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 81)
00:1f.0 ISA bridge: Intel Corporation 82801DB/DBL (ICH4/ICH4-L) \
    LPC Interface Bridge (rev 01)
00:1f.1 IDE interface: Intel Corporation 82801DB (ICH4) IDE \
    Controller (rev 01)
00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) \
    SMBus Controller (rev 01)
00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM \
    (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)
01:00.0 VGA compatible controller: Matrox Graphics, Inc. G400/G450 (rev 85)
02:08.0 Ethernet controller: Intel Corporation 82801DB PRO/100 VE (LOM) \
    Ethernet Controller (rev 81)</pre><p>
    Using <code class="option">-v</code> results in a more detailed listing:
   </p><pre class="screen">mercury:~ # lspci -v
[...]
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet \
Controller (rev 02)
  Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter
  Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 19
  Memory at f0000000 (32-bit, non-prefetchable) [size=128K]
  I/O ports at d010 [size=8]
  Capabilities: [dc] Power Management version 2
  Capabilities: [e4] PCI-X non-bridge device
  Kernel driver in use: e1000
  Kernel modules: e1000</pre><p>
    Information about device name resolution is obtained from the file
    <code class="filename">/usr/share/pci.ids</code>. PCI IDs not listed in this file
    are marked <span class="quote">&#8220;<span class="quote">Unknown device.</span>&#8221;</span>
   </p><p>
    The parameter <code class="option">-vv</code> produces all the information that
    could be queried by the program. To view the pure numeric values, use
    the parameter <code class="option">-n</code>.
   </p></div><div class="sect2" title="13.7.2. USB Devices: lsusb"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.hardware.lsusb"></a>13.7.2. USB Devices: <span class="command"><strong>lsusb</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.hardware.lsusb">¶</a></span></h3></div></div></div><p>
    The command <span class="command"><strong>lsusb</strong></span> lists all USB devices. With the
    option <code class="option">-v</code>, print a more detailed list. The detailed
    information is read from the directory
    <code class="filename">/proc/bus/usb/</code>. The following is the output of
    <span class="command"><strong>lsusb</strong></span> with these USB devices attached: hub, memory
    stick, hard disk and mouse.
   </p><pre class="screen">mercury:/ # lsusb
Bus 004 Device 007: ID 0ea0:2168 Ours Technology, Inc. Transcend JetFlash \
    2.0 / Astone USB Drive
Bus 004 Device 006: ID 04b4:6830 Cypress Semiconductor Corp. USB-2.0 IDE \
    Adapter
Bus 004 Device 005: ID 05e3:0605 Genesys Logic, Inc.
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 005: ID 046d:c012 Logitech, Inc. Optical Mouse
Bus 001 Device 001: ID 0000:0000</pre></div></div><div class="sect1" title="13.8. Files and File Systems"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.file"></a>13.8. Files and File Systems<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.file">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.8.1. Determine the File Type: file"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.file.file"></a>13.8.1. Determine the File Type: <span class="command"><strong>file</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.file.file">¶</a></span></h3></div></div></div><p>
    The command <span class="command"><strong>file</strong></span> determines the type of a file or a
    list of files by checking <code class="filename">/usr/share/misc/magic</code>.
   </p><pre class="screen">tux@mercury:~&gt; file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), \
    for GNU/Linux 2.6.4, dynamically linked (uses shared libs), stripped</pre><p>
    The parameter <code class="option">-f <em class="replaceable"><code>list</code></em></code>
    specifies a file with a list of filenames to examine. The
    <code class="option">-z</code> allows <span class="command"><strong>file</strong></span> to look inside
    compressed files:
   </p><pre class="screen">tux@mercury:~&gt; file /usr/share/man/man1/file.1.gz
/usr/share/man/man1/file.1.gz: gzip compressed data, from Unix, max compression
tux@mercury:~&gt; file -z /usr/share/man/man1/file.1.gz
/usr/share/man/man1/file.1.gz: troff or preprocessor input text \
    (gzip compressed data, from Unix, max compression)</pre><p>
    The parameter <code class="option">-i</code> outputs a mime type string rather than
    the traditional description.
   </p><pre class="screen">tux@mercury:~&gt; file -i /usr/share/misc/magic
/usr/share/misc/magic: text/plain charset=utf-8</pre></div><div class="sect2" title="13.8.2. File Systems and Their Usage: mount, df and du"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.file.mount_dudf"></a>13.8.2. File Systems and Their Usage: <span class="command"><strong>mount</strong></span>, <span class="command"><strong>df</strong></span> and <span class="command"><strong>du</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.file.mount_dudf">¶</a></span></h3></div></div></div><p>
    The <span class="command"><strong>mount</strong></span> command shows which file system (device and
    type) is mounted on the related mount point:
   </p><pre class="screen">tux@mercury:~&gt; mount
/dev/sda2 on / type ext4 (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
devtmpfs on /dev type devtmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,mode=1777)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/sda3 on /home type ext3 (rw)
securityfs on /sys/kernel/security type securityfs (rw)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
gvfs-fuse-daemon on /home/tux/.gvfs type fuse.gvfs-fuse-daemon \
(rw,nosuid,nodev,user=tux)</pre><p>
    Obtain information about total usage of the file systems with the
    command <span class="command"><strong>df</strong></span>. The parameter <code class="option">-h</code> (or
    <code class="option">--human-readable</code>) transforms the output into a form
    understandable for common users.
   </p><pre class="screen">tux@mercury:~&gt; df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              20G  5,9G   13G  32% /
devtmpfs              1,6G  236K  1,6G   1% /dev
tmpfs                 1,6G  668K  1,6G   1% /dev/shm
/dev/sda3             208G   40G  159G  20% /home</pre><p>
    Display the total size of all the files in a given directory and its
    subdirectories with the command <span class="command"><strong>du</strong></span>. The parameter
    <code class="option">-s</code> suppresses the output of detailed information and
    gives only a total for each argument. <code class="option">-h</code> again
    transforms the output into a human-readable form:
   </p><pre class="screen">tux@mercury:~&gt; du -sh /opt
192M    /opt</pre></div><div class="sect2" title="13.8.3. Additional Information about ELF Binaries"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.file.readelf"></a>13.8.3. Additional Information about ELF Binaries<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.file.readelf">¶</a></span></h3></div></div></div><p>
    Read the content of binaries with the <span class="command"><strong>readelf</strong></span>
    utility. This even works with ELF files that were built for other
    hardware architectures:
   </p><pre class="screen">tux@mercury:~&gt; readelf --file-header /bin/ls
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x402540
  Start of program headers:          64 (bytes into file)
  Start of section headers:          95720 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         32
  Section header string table index: 31</pre></div><div class="sect2" title="13.8.4. File Properties: stat"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.file.stat"></a>13.8.4. File Properties: <span class="command"><strong>stat</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.file.stat">¶</a></span></h3></div></div></div><p>
    The command <span class="command"><strong>stat</strong></span> displays file properties:
   </p><pre class="screen">tux@mercury:~&gt; stat /etc/profile
  File: `/etc/profile'
  Size: 9662      	Blocks: 24         IO Block: 4096   regular file
Device: 802h/2050d	Inode: 132349      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2009-03-20 07:51:17.000000000 +0100
Modify: 2009-01-08 19:21:14.000000000 +0100
Change: 2009-03-18 12:55:31.000000000 +0100</pre><p>
    The parameter <code class="option">--file-system</code> produces details of the
    properties of the file system in which the specified file is located:
   </p><pre class="screen">tux@mercury:~&gt; stat /etc/profile --file-system
  File: "/etc/profile"
    ID: d4fb76e70b4d1746 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 2581445    Free: 1717327    Available: 1586197
Inodes: Total: 655776     Free: 490312</pre></div></div><div class="sect1" title="13.9. User Information"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.user"></a>13.9. User Information<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.user">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.9.1. User Accessing Files: fuser"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.system.fuser"></a>13.9.1. User Accessing Files: <span class="command"><strong>fuser</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.system.fuser">¶</a></span></h3></div></div></div><p>
    It can be useful to determine what processes or users are currently
    accessing certain files. Suppose, for example, you want to unmount a
    file system mounted at <code class="filename">/mnt</code>.
    <span class="command"><strong>umount</strong></span> returns "device is busy." The command
    <span class="command"><strong>fuser</strong></span> can then be used to determine what processes
    are accessing the device:
   </p><pre class="screen">tux@mercury:~&gt; fuser -v /mnt/*

                     USER        PID ACCESS COMMAND
/mnt/notes.txt       tux    26597 f....  less</pre><p>
    Following termination of the <span class="command"><strong>less</strong></span> process, which was
    running on another terminal, the file system can successfully be
    unmounted. When used with <code class="option">-k</code> option,
    <span class="command"><strong>fuser</strong></span> will kill processes accessing the file as well.
   </p></div><div class="sect2" title="13.9.2. Who Is Doing What: w"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.user.w"></a>13.9.2. Who Is Doing What: <span class="command"><strong>w</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.user.w">¶</a></span></h3></div></div></div><p>
    With the command <span class="command"><strong>w</strong></span>, find out who is logged onto the
    system and what each user is doing. For example:
   </p><pre class="screen">tux@mercury:~&gt; w
 14:58:43 up 1 day,  1:21,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
tux      :0        12:25   ?xdm?   1:23   0.12s /bin/sh /usr/bin/startkde
root     pts/4     14:13    0.00s  0.06s  0.00s w</pre><p>
    If any users of other systems have logged in remotely, the parameter
    <code class="option">-f</code> shows the computers from which they have established
    the connection.
   </p></div></div><div class="sect1" title="13.10. Time and Date"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.time"></a>13.10. Time and Date<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.time">¶</a></span></h2></div></div></div><p></p><div class="sect2" title="13.10.1. Time Measurement with time"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.time.time"></a>13.10.1. Time Measurement with <span class="command"><strong>time</strong></span><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.time.time">¶</a></span></h3></div></div></div><p>
    Determine the time spent by commands with the <span class="command"><strong>time</strong></span>
    utility. This utility is available in two versions: as a shell built-in
    and as a program (<span class="command"><strong>/usr/bin/time</strong></span>).
   </p><pre class="screen">tux@mercury:~&gt; time find . &gt; /dev/null

real    0m4.051s<a name="co.util.time.real"></a><img src="callouts/1.png" alt="1" border="0">
user    0m0.042s<a name="co.util.time.user"></a><img src="callouts/2.png" alt="2" border="0">
sys     0m0.205s<a name="co.util.time.sys"></a><img src="callouts/3.png" alt="3" border="0"></pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><a href="#co.util.time.real"><img src="callouts/1.png" alt="1" border="0"></a> </p></td><td valign="top" align="left"><p>
   The real time that elapsed from the command's start-up till it finished.
  </p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co.util.time.user"><img src="callouts/2.png" alt="2" border="0"></a> </p></td><td valign="top" align="left"><p>
   CPU time of the user as reported by the <code class="literal">times</code> system call.
  </p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co.util.time.sys"><img src="callouts/3.png" alt="3" border="0"></a> </p></td><td valign="top" align="left"><p>
   CPU time of the system as reported by the <code class="literal">times</code> system call.
  </p></td></tr></table></div></div></div><div class="sect1" title="13.11. Graph Your Data: RRDtool"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.util.rrdtool"></a>13.11. Graph Your Data: RRDtool<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool">¶</a></span></h2></div></div></div><p>
   There are a lot of data in the world around you, which can be easily
   measured in time. For example, changes in the temperature, or the number
   of data sent or received by your computer's network interface. RRDtool
   can help you store and visualize such data in detailed and customizable
   graphs.
  </p><p>
   RRDtool is available for most UNIX platforms and Linux distributions.
   openSUSE® ships RRDtool as well. Install it either with YaST or
   by entering
  </p><p>
   <span class="command"><strong>zypper <code class="option">install</code>
   <em class="replaceable"><code>rrdtool</code></em></strong></span> in the command line as
   <code class="systemitem">root</code>.
  </p><div class="tip"><table border="0" cellpadding="3" cellspacing="0" width="100%" summary="Tip"><tr class="head"><td width="32"><img alt="[Tip]" src="admon/tip.png"></td><th align="left"></th></tr><tr><td colspan="2" align="left" valign="top"><p>
    There are Perl, Python, Ruby, or PHP bindings available for RRDtool, so
    that you can write your own monitoring scripts with your preferred
    scripting language.
   </p></td></tr></table></div><div class="sect2" title="13.11.1. How RRDtool Works"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.rrdtool.howitworks"></a>13.11.1. How RRDtool Works<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool.howitworks">¶</a></span></h3></div></div></div><p>
    RRDtool is a shortcut of <span class="emphasis"><em>Round Robin Database tool</em></span>.
    <span class="emphasis"><em>Round Robin</em></span> is a method for manipulating with a
    constant amount of data. It uses the principle of a circular buffer,
    where there is no end nor beginning to the data row which is being read.
    RRDtool uses Round Robin Databases to store and read its data.
   </p><p>
    As mentioned above, RRDtool is designed to work with data that change in
    time. The ideal case is a sensor which repeatedly reads measured data
    (like temperature, speed etc.) in constant periods of time, and then
    exports them in a given format. Such data are perfectly ready for
    RRDtool, and it is easy to process them and create the desired output.
   </p><p>
    Sometimes it is not possible to obtain the data automatically and
    regularly. Their format needs to be pre-processed before it is supplied
    to RRDtool, and often you need to manipulate RRDtool even manually.
   </p><p>
    The following is a simple example of basic RRDtool usage. It illustrates
    all three important phases of the usual RRDtool workflow:
    <span class="emphasis"><em>creating</em></span> a database, <span class="emphasis"><em>updating</em></span>
    measured values, and <span class="emphasis"><em>viewing</em></span> the output.
   </p></div><div class="sect2" title="13.11.2. Simple Real Life Example"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.rrdtool.example"></a>13.11.2. Simple Real Life Example<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool.example">¶</a></span></h3></div></div></div><p>
    Suppose we want to collect and view information about the memory usage
    in the Linux system as it changes in time. To make the example more
    vivid, we measure the currently free memory for the period of 40 seconds
    in 4-second intervals. During the measuring, the three hungry
    applications that usually consume a lot of system memory have been
    started and closed: the Firefox Web browser, the Evolution e-mail
    client, and the Eclipse development framework.
   </p><div class="sect3" title="13.11.2.1. Collecting Data"><div class="titlepage"><div><div><h4 class="title"><a name="sec.util.rrdtool.example.collect"></a>13.11.2.1. Collecting Data<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool.example.collect">¶</a></span></h4></div></div></div><p>
     RRDtool is very often used to measure and visualize network traffic. In
     such case, Simple Network Management Protocol (SNMP) is used. This
     protocol can query network devices for relevant values of their
     internal counters. Exactly these values are to be stored with RRDtool.
     For more information on SNMP, see
     <a class="ulink" href="http://www.net-snmp.org/" target="_top">http://www.net-snmp.org/</a>.
    </p><p>
     Our situation is different - we need to obtain the data manually. A
     helper script <span class="command"><strong>free_mem.sh</strong></span> repetitively reads the
     current state of free memory and writes it to the standard output.
    </p><pre class="screen">tux@mercury:~&gt; cat free_mem.sh
INTERVAL=4
for steps in {1..10}
do
    DATE=`date +%s`
    FREEMEM=`free -b | grep "Mem" | awk '{ print $4 }'`
    sleep $INTERVAL
    echo "rrdtool update free_mem.rrd $DATE:$FREEMEM"
done</pre><div class="itemizedlist" title="Points to Notice"><p class="title"><b>Points to Notice</b></p><ul class="itemizedlist" type="bullet"><li class="listitem" style="list-style-type: disc"><p>
       The time interval is set to 4 seconds, and is implemented with the
       <span class="command"><strong>sleep</strong></span> command.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       RRDtool accepts time information in a special format - so called
       <span class="emphasis"><em>Unix time</em></span>. It is defined as the number of
       seconds since the midnight of January 1, 1970 (UTC). For example,
       1272907114 represents 2010-05-03 17:18:34.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The free memory information is reported in bytes with <span class="command"><strong>free
       <code class="option">-b</code></strong></span>. Prefer to supply basic units (bytes)
       instead of multiple units (like kilobytes).
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The line with the <span class="command"><strong>echo ...</strong></span> command contains the
       future name of the database file (<code class="literal">free_mem.rrd</code>),
       and together creates a command line for the purpose of updating
       RRDtool values.
      </p></li></ul></div><p>
     After running <span class="command"><strong>free_mem.sh</strong></span>, you see an output similar
     to this:
    </p><pre class="screen">tux@mercury:~&gt; sh free_mem.sh
rrdtool update free_mem.rrd 1272974835:1182994432
rrdtool update free_mem.rrd 1272974839:1162817536
rrdtool update free_mem.rrd 1272974843:1096269824
rrdtool update free_mem.rrd 1272974847:1034219520
rrdtool update free_mem.rrd 1272974851:909438976
rrdtool update free_mem.rrd 1272974855:832454656
rrdtool update free_mem.rrd 1272974859:829120512
rrdtool update free_mem.rrd 1272974863:1180377088
rrdtool update free_mem.rrd 1272974867:1179369472
rrdtool update free_mem.rrd 1272974871:1181806592</pre><p>
     It is convenient to redirect the command's output to a file with
    </p><p>
     <span class="command"><strong>sh free_mem.sh &gt; free_mem_updates.log</strong></span>
    </p><p>
     to ease its future execution.
    </p></div><div class="sect3" title="13.11.2.2. Creating Database"><div class="titlepage"><div><div><h4 class="title"><a name="sec.util.rrdtool.example.create"></a>13.11.2.2. Creating Database<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool.example.create">¶</a></span></h4></div></div></div><p>
     Create the initial Robin Round database for our example with the
     following command:
    </p><pre class="screen">rrdtool create free_mem.rrd --start 1272974834 --step=4 \
DS:memory:GAUGE:600:U:U RRA:AVERAGE:0.5:1:24</pre><div class="itemizedlist" title="Points to Notice"><p class="title"><b>Points to Notice</b></p><ul class="itemizedlist" type="bullet"><li class="listitem" style="list-style-type: disc"><p>
       This command creates a file called <code class="filename">free_mem.rrd</code>
       for storing our measured values in a Round Robin type database.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The <code class="option">--start</code> option specifies the time (in Unix time)
       when the first value will be added to the database. In this example,
       it is one less than the first time value of the
       <span class="command"><strong>free_mem.sh</strong></span> output (1272974835).
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The <code class="option">--step</code> specifies the time interval in seconds
       with which the measured data will be supplied to the database.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The <code class="literal">DS:memory:GAUGE:600:U:U</code> part introduces a new
       data source for the database. It is called
       <span class="emphasis"><em>memory</em></span>, its type is <span class="emphasis"><em>gauge</em></span>,
       the maximum number between two updates is 600 seconds, and the
       <span class="emphasis"><em>minimal</em></span> and <span class="emphasis"><em>maximal</em></span> value
       in the measured range are unknown (U).
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       <code class="literal">RRA:AVERAGE:0.5:1:24</code> creates Round Robin archive
       (RRA) whose stored data are processed with the
       <span class="emphasis"><em>consolidation functions</em></span> (CF) that calculates the
       <span class="emphasis"><em>average</em></span> of data points. 3 arguments of the
       consolidation function are appended to the end of the line .
      </p></li></ul></div><p>
     If no error message is displayed, then
     <code class="filename">free_mem.rrd</code> database is created in the current
     directory:
    </p><pre class="screen">tux@mercury:~&gt; ls -l free_mem.rrd
-rw-r--r-- 1 tux users 776 May  5 12:50 free_mem.rrd</pre></div><div class="sect3" title="13.11.2.3. Updating Database Values"><div class="titlepage"><div><div><h4 class="title"><a name="sec.util.rrdtool.example.update"></a>13.11.2.3. Updating Database Values<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool.example.update">¶</a></span></h4></div></div></div><p>
     After the database is created, you need to fill it with the measured
     data. In <a class="xref" href="cha.util.html#sec.util.rrdtool.example.collect" title="13.11.2.1. Collecting Data">Section 13.11.2.1, &#8220;Collecting Data&#8221;</a>, we
     already prepared the file <code class="filename">free_mem_updates.log</code>
     which consists of <span class="command"><strong>rrdtool update</strong></span> commands. These
     commands do the update of database values for us.
    </p><pre class="screen">tux@mercury:~&gt; sh free_mem_updates.log; ls -l free_mem.rrd
-rw-r--r--  1 tux users  776 May  5 13:29 free_mem.rrd</pre><p>
     As you can see, the size of <code class="filename">free_mem.rrd</code> remained
     the same even after updating its data.
    </p></div><div class="sect3" title="13.11.2.4. Viewing Measured Values"><div class="titlepage"><div><div><h4 class="title"><a name="sec.util.rrdtool.example.view"></a>13.11.2.4. Viewing Measured Values<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool.example.view">¶</a></span></h4></div></div></div><p>
     We have already measured the values, created the database, and stored
     the measured value in it. Now we can play with the database, and
     retrieve or view its values.
    </p><p>
     To retrieve all the values from our database, enter the following on
     the command line:
    </p><pre class="screen">tux@mercury:~&gt; rrdtool fetch free_mem.rrd AVERAGE --start 1272974830 \
--end 1272974871
          memory
1272974832: nan
1272974836: 1.1729059840e+09
1272974840: 1.1461806080e+09
1272974844: 1.0807572480e+09
1272974848: 1.0030243840e+09
1272974852: 8.9019289600e+08
1272974856: 8.3162112000e+08
1272974860: 9.1693465600e+08
1272974864: 1.1801251840e+09
1272974868: 1.1799787520e+09
1272974872: nan</pre><div class="itemizedlist" title="Points to Notice"><p class="title"><b>Points to Notice</b></p><ul class="itemizedlist" type="bullet"><li class="listitem" style="list-style-type: disc"><p>
       <code class="literal">AVERAGE</code> will fetch average value points from the
       database, because only one data source is defined
       (<a class="xref" href="cha.util.html#sec.util.rrdtool.example.create" title="13.11.2.2. Creating Database">Section 13.11.2.2, &#8220;Creating Database&#8221;</a>) with
       <code class="literal">AVERAGE</code> processing and no other function is
       available.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The first line of the output prints the name of the data source as
       defined in <a class="xref" href="cha.util.html#sec.util.rrdtool.example.create" title="13.11.2.2. Creating Database">Section 13.11.2.2, &#8220;Creating Database&#8221;</a>.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The left results column represents individual points in time, while
       the right one represents corresponding measured average values in
       scientific notation.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The <code class="literal">nan</code> in the last line stands for <span class="quote">&#8220;<span class="quote">not a
       number</span>&#8221;</span>.
      </p></li></ul></div><p>
     Now a graph representing representing the values stored in the database
     is drawn:
    </p><pre class="screen">tux@mercury:~&gt; rrdtool graph free_mem.png \
--start 1272974830 \
--end 1272974871 \
--step=4 \
DEF:free_memory=free_mem.rrd:memory:AVERAGE \
LINE2:free_memory#FF0000 \
--vertical-label "GB" \
--title "Free System Memory in Time" \
--zoom 1.5 \
--x-grid SECOND:1:SECOND:4:SECOND:10:0:%X</pre><div class="itemizedlist" title="Points to Notice"><p class="title"><b>Points to Notice</b></p><ul class="itemizedlist" type="bullet"><li class="listitem" style="list-style-type: disc"><p>
       <code class="filename">free_mem.png</code> is the file name of the graph to be
       created.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       <code class="option">--start</code> and <code class="option">--end</code> limit the time
       range within which the graph will be drawn.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       <code class="option">--step</code> specifies the time resolution (in seconds) of
       the graph.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The <code class="literal">DEF:...</code> part is a data definition called
       <span class="emphasis"><em>free_memory</em></span>. Its data are read from the
       <code class="filename">free_mem.rrd</code> database and its data source called
       <span class="emphasis"><em>memory</em></span>. The <span class="emphasis"><em>average</em></span> value
       points are calculated, because no others were defined in
       <a class="xref" href="cha.util.html#sec.util.rrdtool.example.create" title="13.11.2.2. Creating Database">Section 13.11.2.2, &#8220;Creating Database&#8221;</a>.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       The <code class="literal">LINE...</code> part specifies properties of the line
       to be drawn into the graph. It is 2 pixels wide, its data come from
       the <span class="emphasis"><em>free_memory</em></span> definition, and its color is
       red.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       <code class="option">--vertical-label</code> sets the label to be printed along
       the <span class="emphasis"><em>y</em></span> axis, and <code class="option">--title</code> sets
       the main label for the whole graph.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       <code class="option">--zoom</code> specifies the zoom factor for the graph. This
       value must be greater than zero.
      </p></li><li class="listitem" style="list-style-type: disc"><p>
       <code class="option">--x-grid</code> specifies how to draw grid lines and their
       labels into the graph. Our example places them every second, while
       major grid lines are placed every 4 seconds. Labels are placed every
       10 seconds under the major grid lines.
      </p></li></ul></div><div class="figure"><a name="util.rrdtool.example.create.graph1"></a><p class="title"><b>Figure 13.2. Example Graph Created with RRDtool</b><span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#util.rrdtool.example.create.graph1">¶</a></span></p><div class="figure-contents"><div class="mediaobject"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0" width="55%"><tr><td><img src="images/rrdtool_graph1.png" width="100%" alt="Example Graph Created with RRDtool"></td></tr></table></div></div></div><br class="figure-break"></div></div><div class="sect2" title="13.11.3. For More Information"><div class="titlepage"><div><div><h3 class="title"><a name="sec.util.rrdtool.moreinfo"></a>13.11.3. For More Information<span class="permalink"><a alt="Permalink" title="Copy Permalink" href="#sec.util.rrdtool.moreinfo">¶</a></span></h3></div></div></div><p>
    RRDtool is a very complex tool with a lot of sub-commands and command
    line options. Some of them are easy to understand, but you have to
    really <span class="emphasis"><em>study</em></span> RRDtool to make it produce the results
    you want and fine-tune them according to your liking.
   </p><p>
    Apart form RRDtool's man page (<span class="command"><strong>man 1 rrdtool</strong></span>) which
    gives you only basic information, you should have a look at the
    <a class="ulink" href="http://oss.oetiker.ch/rrdtool/" target="_top">RRDtool
    homepage</a>. There is a detailed
    <a class="ulink" href="http://oss.oetiker.ch/rrdtool/doc/index.en.html" target="_top">documentation</a>
    of the <span class="command"><strong>rrdtool</strong></span> command and all its sub-commands.
    There are also several
    <a class="ulink" href="http://oss.oetiker.ch/rrdtool/tut/index.en.html" target="_top">tutorials</a>
    to help you understand the common RRDtool workflow.
   </p><p>
    If you are interested in monitoring network traffic, have a look at
    <a class="ulink" href="http://oss.oetiker.ch/mrtg/" target="_top">MRTG</a>. It stands for
    Multi Router Traffic Grapher and can graph the activity of all sorts of
    network devices. It can easily make use of RRDtool.
   </p></div></div></div><div class="navfooter"><table width="100%" summary="Navigation footer" border="0" class="bctable"><tr><td width="80%"><div class="breadcrumbs"><p><a href="index.html"> Documentation</a><span class="breadcrumbs-sep"> &gt; </span><a href="book.opensuse.reference.html">Reference</a><span class="breadcrumbs-sep"> &gt; </span><a href="part.reference.administration.html">Administration</a><span class="breadcrumbs-sep"> &gt; </span><strong><a accesskey="p" title="Chapter 12. Installing and Configuring Fonts for the Graphical User Interface" href="cha.fontconfig.html"><span>&#9664;</span></a>  <a accesskey="n" title="Chapter 14. Upgrading the System and System Changes" href="cha.update.html"><span>&#9654;</span></a></strong></p></div></td></tr></table></div></body></html>

ACC SHELL 2018