Вы находитесь на странице: 1из 99

Oracle Linux 6 Boot Camp

Oracle Linux 6 Lab Exercise

Safe Harbor Statement


The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied
upon in making purchasing decisions.
The development, release, and timing of any features or functionality described for
Oracles products remains at the sole discretion of Oracle.

Oracle Training Materials Usage Agreement


Use of this Site (Site) or Materials constitutes agreement with the following terms
and conditions:
1. Oracle Corporation (Oracle) is pleased to allow its business partner (Partner)
to download and copy the information, documents, and the online training courses
(collectively, Materials") found on this Site. The use of the Materials is restricted to
the non-commercial, internal training of the Partners employees only. The
Materials may not be used for training, promotion, or sales to customers or other
partners or third parties.
2. All the Materials are trademarks of Oracle and are proprietary information of
Oracle. Partner or other third party at no time has any right to resell, redistribute or
create derivative works from the Materials.
3. Oracle disclaims any warranties or representations as to the accuracy or
completeness of any Materials. Materials are provided "as is" without warranty of
any kind, either express or implied, including without limitation warranties of
merchantability, fitness for a particular purpose, and non-infringement.
4. Under no circumstances shall Oracle or the Oracle Authorized Delivery Partner be
liable for any loss, damage, liability or expense incurred or suffered which is claimed
to have resulted from use of this Site of Materials. As a condition of use of the
Materials, Partner agrees to indemnify Oracle from and against any and all actions,
claims, losses, damages, liabilities and expenses (including reasonable attorneys'
fees) arising out of Partners use of the Materials.
5. Reference materials including but not limited to those identified in the Boot Camp
manifest cannot be redistributed in any format without Oracle written consent.

OL 6 System Monitoring - Lab 7

Oracle Linux System Monitoring and


Troubleshooting
V1.0 January 2013

1 Introduction
System Monitoring and Troubleshooting are important topics that will help you find
performance bottlenecks, optimize performance and troubleshoot problems that
you may encounter while implementing solutions on Oracle Linux 6. While there are
several tools available for System Monitoring and Troubleshooting on Linux, we will
look at some of the important Monitoring and Troubleshooting tools that are
available for Oracle Linux 6.
With a few basic exercises we will introduce the learner to some ways to perform
troubleshooting and monitoring Oracle Linux 6 systems. Upon completion of this
lab, participants will have learned how to use some of the common troubleshooting
and monitoring tools available for Oracle Linux 6.

2 Overview
In this lab we will be practicing with some of the Oracle Linux 6 system monitoring,
data collection and troubleshooting tools.
Some of the tools/utilities that well review are listed below.

OSWatcher Tool
Sosreport Tool
System Tools: sar, iostat, vmstat, strace, top, tcpdump, ethereal(wireshark)
System Monitor GNOME Application
Kdump / Netconsole
Crash and vmcore dump
DTrace Introduction

The practice for this lab can be accomplished with a single VirtualBox Oracle Linux 6
instance with some additional installed RPM packages. You must an instance of
Oracle Linux 6.3 running in your VirtualBox environment.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 2 of 99

OL 6 System Monitoring - Lab 7


3 Pre-requisites
This lab requires the use of the following elements:

A current 64 bit laptop with at least 2GB RAM and 20GB free disk space
Operating system: A 64-bit version of Microsoft Windows, Mac OS X, Linux
or Solaris. Alternatively, a 32-bit host OS installed on a 64-bit CPU with VTx/AMD-V enabled in the BIOS.
Oracle VirtualBox Software 4.2.10 or later (with Extension Pack installed)
Oracle Linux 6.3 instance running inside VirtualBox:
o VM Image Provided by instructor or downloaded on your own
o Installed in Lab 1 of Oracle Linux 6 Boot camp

The following assumptions have been made regarding the environment where this
lab is being performed:
1. Network connectivity to the Internet is available
2. Your Oracle Linux 6.3 VirtualBox instance has been installed and youve
assigned a normal user/password and a root user password.
a. The recommended user name is student1
b. The recommended password is oracle
c. The recommended root password is oracle

4 VirtualBox lab setup


If you already have an instance of Oracle Linux 6.3 installed in VirtualBox or have
already imported the Oracle Linux 6.3 image, you can skip this section and proceed
to the Labs in Section 5. If you need to import the Oracle Linux 6.3 appliance (image
in ova file provided for this training) then complete the steps in this section before
you start with the Labs.
1 - In the VirtualBox
main window choose
File > Import
Appliance

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 3 of 99

OL 6 System Monitoring - Lab 7


2 - From the Appliance
Import Wizard click the
Open appliance..
button and navigate to
the
Oracle_Linux_6_Bootca
mp.ova file which is the
pre-built Oracle Linux
6.3 VM image you
downloaded or obtained
from the instructor

3 - Navigate to the folder


where you downloaded
or copied the Oracle
Linux 6.3 Prebuilt image
and click Open. The file
is named
Oracle_Linux_6_Bootca
mp.ova.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 4 of 99

OL 6 System Monitoring - Lab 7


4 - Choose Next on the
Appliance to import
screen

5 - Confirm the default


settings and choose
Import to begin
importing the virtual
image. If you see a
License Agreement
window, read and accept
the license.

6 - The progress bar will


show the import
progress. Usually looks
slow in the beginning
but this shouldnt take
more than a few
minutes.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 5 of 99

OL 6 System Monitoring - Lab 7


7 - Your new image has
been imported and is
ready for use. Select the
Oracle Linux 6
Bootcamp image.

8 - After your image has


finished importing select
it in the VB application
and choose Settings
and review settings.

Once you have reviewed


the settings, you can
select the image and
click the Start button to
boot Oracle Linux 6.
After booting, login as
root user and activate
your network
connection to start using
the image.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 6 of 99

OL 6 System Monitoring - Lab 7


5 Lab Exercises
5.1 OSWatcher Tool (OSWbb)
OSWatcher (OSW) has been renamed to OSWatcher Black Box (OSWbb) to prevent
confusion as there are several tools now within Oracle that share this same name.
OS Watcher Black Box (OSWbb) is a collection of UNIX shell scripts intended to
collect and archive operating system and network metrics to aid support in
diagnosing performance issues. OSWbb operates as a set of background processes
on the server and gathers OS data on a regular basis, invoking such Unix utilities as
vmstat, netstat and iostat. OSWbb consists of a series of shell scripts. OSWatcher.sh
is the main controlling executive, which spawns individual shell processes to collect
specific kinds of data, using Unix operating system diagnostic utilities.
For more information on OSWatcher Tool see the following MOS Document:
OSWatcher Black Box User Guide (Includes: [Video]) (Doc ID 301137.1)
OSWbb tool is available in two distributions:
1. A Bourne shell version of OSWbb. The Bourne shell version will be able to
run on any Oracle platform and OVM.
2. Previously OSWbb was written in ksh. Ksh is not installed by default on many
UNIX/Linux platforms.
Installation:
1) Download OSWatcher Black Box Tool from My Oracle Support. Refer to:
OSWatcher Black Box User Guide (Includes: [Video]) (Doc ID 301137.1)
Search by ID as shown in the screen shot below.

2) Install ksh shell if using ksh tar ball of OSWatcher Black Box tool if using
the ksh based distribution.
3) Install OSWatcher Black Box Tool

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 7 of 99

OL 6 System Monitoring - Lab 7


In this lab, we will download and install the ksh shell version of OSWatcher tool.
Screenshots and commands below are for Version 5.2 of OSWatcher tool. It is always
recommended to use the latest version of this tool that is available from MOS.
Download the OSWatcher oswbb5201.tar file from MOS on your system.
[root@examplehost Downloads]# pwd
/root/Downloads
[root@examplehost Downloads]# ls oswbb5201.tar
oswbb5201.tar

We will install the OSWatcher tool in /opt directory of the Oracle Linux 6.2 System.
Move the oswbb5201.tar file that was downloaded to /opt directory as shown
below.
[root@examplehost Downloads]# pwd
/root/Downloads
[root@examplehost Downloads]# ls oswbb5201.tar
oswbb5201.tar
[root@examplehost Downloads]# mv oswbb5201.tar /opt/
[root@examplehost Downloads]# cd /opt
[root@examplehost opt]# ls oswbb5201.tar
oswbb5201.tar

Extract the contents of the tar file using the tar command.
[root@examplehost opt]# tar xvf oswbb5201.tar

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 8 of 99

OL 6 System Monitoring - Lab 7

View the contents of the extracted tar file. The contents are untarred into the
/opt/oswbb directory in screenshot below.
[root@examplehost opt]# cd /opt/oswbb
[root@examplehost oswbb]# ls
analysis
iosub.sh
OSWatcher.sh
src
topaix.sh
docs
mpsub.sh
oswbba.jar
startOSWbb.sh vmsub.sh
Exampleprivate.net nfssub.sh
oswib.sh
stopOSWbb.sh
xtop.sh
gif
OSWatcherFM.sh oswnet.sh
tarupfiles.sh
[root@examplehost oswbb]#

oswrds.sh
oswsub.sh
profile
pssub.sh

The startOSWbb.sh is the main script that is used to run the OSWatcher tool. If you
have downloaded the ksh shell version of the OSWatcher tool and do not have ksh
installed on your Oracle Linux system, you will see a message similar to what is
shown below when you run the OSWatcher tool. You will not see this message if you
are using the Bourne shell version of this tool; instead the tool will start running and
collecting information.
[root@examplehost oswbb]# ./startOSWbb.sh
bash: ./startOSWbb.sh: /usr/bin/ksh: bad interpreter: No
such file or directory
[root@examplehost oswbb]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 9 of 99

OL 6 System Monitoring - Lab 7

If you see the above message, then you must first install the ksh shell RPM package
using the yum install ksh command.
[root@examplehost /]# yum install ksh

After installing ksh shell, you can run the which command to verify its location. By
default, you will find it installed in the /bin/ksh directory. Create a symbolic link
from /usr/bin/ksh to /bin/ksh. This link is required because the OSWbb scripts
expect to find ksh binary in the /usr/bin directory.
[root@examplehost /]# which ksh
/bin/ksh
[root@examplehost /]#
[root@examplehost /]# which ksh
/bin/ksh
[root@examplehost /]# ln -s /bin/ksh /usr/bin/ksh
[root@examplehost /]#

You can run the OSWatcher tool without specifying any options by running the
startOSWbb.sh script. This will start the script with default values are 30 seconds
and 48 hours. This means that OSWbb starts recording data at intervals of 30
seconds, and records data for 48 hours.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 10 of 99

OL 6 System Monitoring - Lab 7


To specify frequency (seconds) and duration (hours) you can pass the frequency
and duration values as arguments to the script.
# ./startOSWbb.sh [frequency duration]

Start this lab by running the OSWatcher tool script without specifying any
frequency/duration options. After it has collected 2-3 sets of data, you can stop the
script using the stopOSWbb.sh script from another terminal window. See sample
screenshots below.
[root@examplehost /]# cd /opt/oswbb
[root@examplehost oswbb]# ./startOSWbb.sh
[root@examplehost oswbb]#
Info...You did not enter a value for snapshotInterval.
Info...Using default value = 30
Info...You did not enter a value for archiveInterval.
Info...Using default value = 48
Setting the archive log directory to/opt/oswbb/archive
Testing for discovery of OS Utilities...
VMSTAT found on your system.
IOSTAT found on your system.
MPSTAT found on your system.
NETSTAT found on your system.
TOP found on your system.
Testing for discovery of OS CPU COUNT
OSWbb is looking for the CPU COUNT on your system
CPU COUNT will be used by oswbba to automatically look for
cpu problems
CPU COUNT found on your system.
CPU COUNT = 1
Discovery completed.
Starting OSWatcher Black Box v5.2.0
11:38:39 PST 2013
With SnapshotInterval = 30
With ArchiveInterval = 48

on Mon Jan 28

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 11 of 99

OL 6 System Monitoring - Lab 7


OSWatcher Black Box - Written by Carl Davis, Center of
Expertise,Oracle Corporation
For questions on install/usage please go to MOS
(Note:301137.1)
If you need further assistance or have comments or
enhancement requests you can email me Carl.Davis@Oracle.com
Data is stored in directory: /opt/oswbb/archive
Starting Data Collection...
....
....

To stop the OSWatcher tool, run the stopOSWbb.sh script from another terminal
window.
[root@examplehost oswbb]# ./stopOSWbb.sh
[root@examplehost oswbb]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 12 of 99

OL 6 System Monitoring - Lab 7


By default, the OSWatcher tool script collects all the data in the oswbb/archive
directory where it is installed. In our case, all data will be captured under the
/opt/oswbb/archive directory. Go to the archive directory and view the contents of
this directory to see the data that was captured by this tool.
[root@examplehost oswbb]# cd archive/
[root@examplehost archive]# pwd
/opt/oswbb/archive
[root@examplehost archive]# ls
oswiostat
oswmpstat
oswprvtnet oswslabinfo
oswmeminfo oswnetstat oswps
oswtop
[root@examplehost archive]#

oswvmstat

Examine the oswmeminfo directory and see the file that is captured in this
directory.

You can see that the meminfo file contains a listing of the contents of
/proc/meminfo file of your Oracle Linux system and provides memory
information. View the file using view or vi command.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 13 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost archive]# cd oswmeminfo/
[root@examplehost oswmeminfo]# ls
examplehost.com_meminfo_13.01.28.1100.dat
[root@examplehost oswmeminfo]#
[root@examplehost oswmeminfo]# vi
examplehost.com_meminfo_13.01.28.1100.dat

You can review the other directories/files and see the data captured by this tool.
Refer to screenshot below for a short description.

Now that we have looked at the basic functionality, lets proceed by looking at the
documentation and readme file of the OSWatcher tool. The documentation is
available under the oswbb/docs directory.
You can find PDF documentation file under the oswbb/docs/OSWatcher_BlackBox
directory along with the readme file.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 14 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost docs]# cd /opt/oswbb/docs
[root@examplehost docs]# ls -al
total 16
drwxr-xr-x 4 oracle oinstall 4096 Jun 15 2012 .
drwxr-xr-x 11 oracle oinstall 4096 Jan 28 11:38 ..
drwxr-xr-x 2 oracle oinstall 4096 Nov 7 08:14
OSWatcher_Black_Box
drwxr-xr-x 2 oracle oinstall 4096 Nov 7 08:17
The_Analyzer
[root@examplehost docs]#
[root@examplehost docs]# cd OSWatcher_Black_Box/
[root@examplehost OSWatcher_Black_Box]# ls
OSWatcher_Black_Box_User_Guide.pdf oswbb_README.txt
[root@examplehost OSWatcher_Black_Box]#

Read the README.txt file and practice some of the examples in this file to get
familiarised with this tool and the various options. This is left as an exercise to
perform on your own. Remember to run the stopOSWbb.sh script once you have
finished working on this lab.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 15 of 99

OL 6 System Monitoring - Lab 7

5.2 Sosreport Tool


The sosreport utility collects information about a system such as hardware
configuration, software configuration, and operational state. You can also
use sosreport to enable diagnostics and analytical functions. To assist in
troubleshooting a problem, sosreport records the information in a compressed file
that you can send to a support representative.
Your system should already have Oracle sosreport package installed and ready to
use. Check to make sure you have sosreport installed on your system. If you do not
have it installed, use yum install sos to install this package.
To check if you have sosreport tool installed, you can run the following commands:
[root@examplehost /]# which sosreport
/usr/sbin/sosreport
[root@examplehost /]#
[root@examplehost /]# yum list installed | grep sos
sos.noarch
2.2-29.0.1.el6
@anaconda-OracleLinuxServer-201206261930.x86_64/6.3
[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 16 of 99

OL 6 System Monitoring - Lab 7

Run the yum info command on the sos package to see the information about this
package.
[root@examplehost /]# yum info sos

Read the man pages of sosreport tool to understand the options available for this
tool.
[root@examplehost /]# man sosreport
[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 17 of 99

OL 6 System Monitoring - Lab 7

The configuration information for sosreport tool is by default stored in


/etc/sos.conf file. On your system, examine the default settings in the
/etc/sos.conf file. You can look at the Example screenshots shown below.
[root@examplehost /]# view /etc/sos.conf
[general]
ftp_upload_url = ftp://ftp.oracle.com/support/incoming
smtp_server = None
[plugins]
#disable = rpm, selinux, dovecot
[tunables]
#rpm.rpmva = off
#general.syslogsize = 15

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 18 of 99

OL 6 System Monitoring - Lab 7

You may also want to read the man pages by running the man sos.conf command.
[root@examplehost /]# man sos.conf

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 19 of 99

OL 6 System Monitoring - Lab 7


Running the sosreport command with the l option lists all the plugins.
[root@examplehost /]# sosreport -l
sosreport (version 2.2)
The following plugins are currently enabled:
acpid
anaconda
apache
auditd
autofs
bootloader
cgroups
crontab
devicemapper
lvm, multipath)
dovecot
filesys
gdm
general
gluster
hardware
hts
information
i18n
ipa
iscsi
kdump
kernel

acpid related information


Anaconda / Installation information
Apache related information
Auditd related information
autofs server-related information
Bootloader information
cgroup subsystem information
Crontab information
device-mapper related information (dm,
dovecot server related information
information on filesystems
gdm related information
basic system information
gluster related information
hardware related information
Red Hat Hardware Test Suite related
i18n related information
IPA diagnostic information
iscsi-initiator related information
Kdump related information
kernel related information

[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 20 of 99

OL 6 System Monitoring - Lab 7

Run the sosreport tool with default options and default configuration as shown in
the example below.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 21 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# sosreport
sosreport (version 2.2)
This utility will collect some detailed information about
the hardware and setup of your Oracle Linux system.
The information is collected and an archive is packaged
under /tmp, which you can send to a support representative.
Oracle Linux will use this information for diagnostic
purposes ONLY and it will be considered confidential
information.
This process may take a while to complete.
No changes will be made to your system.
Press ENTER to continue, or CTRL-C to quit.
Please enter your first initial and last name
[examplehost]:
Please enter the case number that you are generating this
report for: 999
Running plugins. Please wait ...
Completed [54/54] ...
Creating compressed archive...
Your sosreport has been generated and saved in:
/tmp/sosreport-examplehost.999-20130114124805-840d.tar.xz
The md5sum is: 080fd7d3d779e74272b62ba1bb94840d
Please send this file to your support representative.
[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 22 of 99

OL 6 System Monitoring - Lab 7

In the above example, you can see that the sosreport tool ran all the plugins and
collected all the information. The collected information is saved as a sosreport in the
/tmp directory and the report name includes the host name, case number strings in
the file name as shown in the example screenshots.
[root@examplehost /]# cd /tmp
[root@examplehost tmp]# pwd
/tmp
[root@examplehost tmp]# ls sosreport*
sosreport-examplehost.999-20130114124805-840d.tar.xz
sosreport-examplehost.999-20130114124805-840d.tar.xz.md5
[root@examplehost tmp]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 23 of 99

OL 6 System Monitoring - Lab 7

Lets now look at the sosreport data that was collected. The report is saved as a
tar.xz file as can be seen from the file name. We will use the xz tool to uncompress
this file and then untar it using the tar command as shown below.
[root@examplehost /]# cd /tmp
[root@examplehost tmp]# pwd
/tmp
[root@examplehost tmp]# xz -d sosreport-examplehost.99920130114124805-840d.tar.xz
[root@examplehost tmp]#
[root@examplehost tmp]# tar -xvf sosreport-examplehost.99920130114124805-840d.tar
[root@examplehost tmp]#

Once the files from the sosreport have been untarred, you can view the data that is
collected by this tool. To check the files collected by the sosreport tool, look for a
directory under /tmp/ starting with hostname and containing the same timestamp
string as the tar file. See the example below and follow along on your system.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 24 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost tmp]# pwd
/tmp
[root@examplehost tmp]# cd examplehost2013011412471358196441/
[root@examplehost examplehost-2013011412471358196441]#
[root@examplehost examplehost-2013011412471358196441]# ls
boot
etc
java
lspci
pstree
sestatus
uname
chkconfig free
lib
mount
root
sos_commands uptime
date
hostname
lsb-release netstat route
sos_logs
var
df
ifconfig
lsmod
proc
sar14
sos_reports
vgdisplay
dmidecode installed-rpms lsof
ps
sbin
sys
[root@examplehost examplehost-2013011412471358196441]#
[root@examplehost examplehost-2013011412471358196441]# pwd
/tmp/examplehost-2013011412471358196441
[root@examplehost examplehost-2013011412471358196441]#

Take a look at a couple of files to get an idea of the data collected by the sosreport
tool. In the example below, we look at the uptime file and the sestatus file. The
uptime file provides system uptime information and the sestatus file provides
information about SELinux configuration of your Oracle Linux 6 system.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 25 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost examplehost-2013011412471358196441]#
[root@examplehost examplehost-2013011412471358196441]# cat
uptime
12:47:56 up 6 days, 20:01, 2 users, load average: 0.46,
0.45, 0.44
[root@examplehost examplehost-2013011412471358196441]#
[root@examplehost examplehost-2013011412471358196441]#
[root@examplehost examplehost-2013011412471358196441]#
[root@examplehost examplehost-2013011412471358196441]# cat
sestatus
SELinux status:
enabled
SELinuxfs mount:
/selinux
Current mode:
enforcing
Mode from config file:
enforcing
Policy version:
26
Policy from config file:
targeted
[root@examplehost examplehost-2013011412471358196441]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 26 of 99

OL 6 System Monitoring - Lab 7


The sestatus file was created because the selinux plugin was enabled when
sosreport was run without any options. Now, if we want to disable some plugin and
not collect some data, then we can use the n option to disable a sosreport plugin.
Lets first confirm that selinux plugin is enabled by default by running the following
command.
[root@examplehost /]# sosreport -l | grep -i selinux
selinux
selinux related information
selinux.fixfiles
off Print incorrect file context
labels
[root@examplehost /]#

Disable the selinux plugin so that information about selinux is not collected in the
sestatus file. To disable or skip a sosreport plugin, run the command using the n
option as shown below.
[root@examplehost /]# sosreport -n selinux
sosreport (version 2.2)
This utility will collect some detailed information about
the hardware and setup of your Oracle Linux system.
....
....
Please enter your first initial and last name
[examplehost]:
Please enter the case number that you are generating this
report for: 111
Running plugins. Please wait ...
Completed [53/53] ...
Creating compressed archive...

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 27 of 99

OL 6 System Monitoring - Lab 7


Your sosreport has been generated and saved in:
/tmp/sosreport-examplehost.111-20130115104015-6ae2.tar.xz
The md5sum is: d4a58684f50b56be85050e1edb7a6ae2
Please send this file to your support representative.
[root@examplehost /]#

The report created in the above run should have excluded the selinux information
and you should not see the sestatus file present in the report files. To verify this,
run the commands as shown below.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 28 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# cd /tmp
[root@examplehost tmp]# ls sosrepor*
sosreport-examplehost.111-20130115104015-6ae2.tar.xz
sosreport-examplehost.111-20130115104015-6ae2.tar.xz.md5
[root@examplehost tmp]#
[root@examplehost tmp]# xz -d sosreport-examplehost.11120130115104015-6ae2.tar.xz
[root@examplehost tmp]#
[root@examplehost tmp]# tar -xvf sosreport-examplehost.11120130115104015-6ae2.tar

See the data collected by sosreport tool.


[root@examplehost tmp]# cd examplehost2013011510391358275190/
[root@examplehost examplehost-2013011510391358275190]#
[root@examplehost examplehost-2013011510391358275190]# ls
boot
etc
java
lspci
pstree
sos_commands uptime
chkconfig free
lib
mount
root
sos_logs
var
date
hostname
lsb-release netstat route
sos_reports
vgdisplay
df
ifconfig
lsmod
proc
sar15
sys
dmidecode installed-rpms lsof
ps
sbin
uname
[root@examplehost examplehost-2013011510391358275190]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 29 of 99

OL 6 System Monitoring - Lab 7

As you can see, the sestatus file was not created in the above report. This confirms
that the selinux plugin was disabled correctly using the n option with the
sosreport command. We will not look at all the files included in this report for this
lab but you can examine all the other files at your leisure.

5.3 System Tools sar, iostat, vmstat, strace, top, tcpdump, ethereal
In this lab, we will look at some of the system tools available in Oracle Linux that can
be used for monitoring and troubleshooting problems. We will look at the common
tools sar, iostat, vmstat, strace, top, tcpdump and ethereal in this lab.
We will start with the sar command by reviewing the man pages of the sar
command and understand what all information this tool can collect on a Oracle
Linux 6 system. The sar command collects system activity reports (sar) and is part
of the sysstat package as can be seen by running the rpm command below.
[root@examplehost /]# which sar
/usr/bin/sar
[root@examplehost /]# rpm -qf /usr/bin/sar
sysstat-9.0.4-20.el6.x86_64
[root@examplehost /]#
[root@examplehost /]# man sar

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 30 of 99

OL 6 System Monitoring - Lab 7

Run the sar 3 5 command. This will capture system activity every 3 seconds for 5
iterations and show the output on the screen. Sample output shown below. Review
and understand the various parameters that are reported in the sar output.
[root@examplehost /]# sar 3 5
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
01:25:49 PM
CPU
%steal
%idle
01:25:52 PM
all
0.00
99.66
01:25:55 PM
all
0.00
99.34
01:25:58 PM
all
0.00
99.33
01:26:01 PM
all
0.00
99.67
01:26:04 PM
all
0.00
99.67
Average:
all
0.00
99.53
[root@examplehost /]#

%user

%nice

%system

%iowait

0.00

0.00

0.34

0.00

0.00

0.00

0.66

0.00

0.33

0.00

0.33

0.00

0.00

0.00

0.33

0.00

0.00

0.00

0.33

0.00

0.07

0.00

0.40

0.00

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 31 of 99

OL 6 System Monitoring - Lab 7

If you want to capture the sar output into a file, you can run the sar command with
the o option as shown below. In this example, the output is captured in binary form
in the /tmp/sar.out file.

[root@examplehost /]# sar -o /tmp/sar.out 4 3


Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_(1 CPU)
01:33:01 PM
CPU
%steal
%idle
01:33:05 PM
all
0.00
99.25
01:33:09 PM
all
0.00
99.75
01:33:13 PM
all
0.00
99.50
Average:
all
0.00
99.50
[root@examplehost /]#

%user

%nice

%system

%iowait

0.25

0.00

0.50

0.00

0.00

0.00

0.25

0.00

0.25

0.00

0.25

0.00

0.17

0.00

0.33

0.00

To read the sar output that was captured in the /tmp/sar.out file, you can run the
sar command with the f option as shown below.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 32 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# ls -l /tmp/sar.out
-rw-r--r--. 1 root root 28044 Jan 16 13:33 /tmp/sar.out
[root@examplehost /]#
[root@examplehost /]# sar -f /tmp/sar.out
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_(1 CPU)
01:33:01 PM
CPU
%steal
%idle
01:33:05 PM
all
0.00
99.25
01:33:09 PM
all
0.00
99.75
01:33:13 PM
all
0.00
99.50
Average:
all
0.00
99.50
[root@examplehost /]#

%user

%nice

%system

%iowait

0.25

0.00

0.50

0.00

0.00

0.00

0.25

0.00

0.25

0.00

0.25

0.00

0.17

0.00

0.33

0.00

To check the swap space utilization report using sar, you can use the S option of
the sar command as shown in the example below. The kbswpfree value is the
amount of free swap space in kilobytes and the kbswpused value is the amount of
used swap space in kilobytes.
For Oracle employees and authorized partners only. Do
not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 33 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# sar -S 3 4
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_(1 CPU)
01:43:39 PM kbswpfree kbswpused
%swpcad
01:43:42 PM
2064372
8
100.00
01:43:45 PM
2064372
8
100.00
01:43:48 PM
2064372
8
100.00
01:43:51 PM
2064372
8
100.00
Average:
2064372
8
100.00
[root@examplehost /]#

%swpused

kbswpcad

0.00

0.00

0.00

0.00

0.00

You can use the -r option of the sar command to check memory utilization
statistics. In this report, the kbmemfree value is the amount of free memory
available in kilobytes. The kbmemused value is the amount of used memory in
kilobytes excluding kernel.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 34 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# sar -r 3 4
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
02:02:25 PM kbmemfree kbmemused
kbcached kbcommit
%commit
02:02:28 PM
131284
758476
377152
524612
17.76
02:02:31 PM
131284
758476
377152
524612
17.76
02:02:34 PM
131284
758476
377152
524612
17.76
02:02:37 PM
131284
758476
377152
524612
17.76
Average:
131284
758476
377152
524612
17.76
[root@examplehost /]#

%memused kbbuffers
85.25

57492

85.25

57492

85.25

57492

85.25

57492

85.25

57492

We will now simulate a high CPU usage situation. Run the following yes command
on your system in a terminal window to simulate a high CPU situation.
[root@examplehost /]# yes > /dev/null

You may run the above yes command in two separate terminals windows to
increase the CPU load if needed.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 35 of 99

OL 6 System Monitoring - Lab 7


Once you have the above yes command running in a terminal window, you can then
run the sar q and sar u commands to see the high CPU utilization. Stop or kill
the yes command and then see the CPU utilization drop in the sar reports.
Examples screen shots shown below.
[root@examplehost /]# sar -u 3 10
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
02:21:11 PM
CPU
%steal
%idle
02:21:14 PM
all
0.00
75.00
02:21:17 PM
all
0.00
0.00
02:21:20 PM
all
0.00
0.00
02:21:23 PM
all
0.00
0.00
02:21:26 PM
all
0.00
0.00
02:21:29 PM
all
0.00
0.00
02:21:32 PM
all
0.00
0.00
02:21:35 PM
all
0.00
0.00
02:21:38 PM
all
0.00
0.00
02:21:41 PM
all
0.00
0.00
Average:
all
0.00
7.61
[root@examplehost /]#

%user

%nice

%system

%iowait

22.64

0.00

2.36

0.00

96.22

0.00

3.78

0.00

96.21

0.00

3.79

0.00

94.74

0.00

5.26

0.00

97.57

0.00

2.43

0.00

97.92

0.00

2.08

0.00

98.28

0.00

1.72

0.00

97.31

0.00

2.69

0.00

97.97

0.00

2.03

0.00

98.32

0.00

1.68

0.00

89.62

0.00

2.77

0.00

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 36 of 99

OL 6 System Monitoring - Lab 7

The -q option of the sar reports the queue length and load averages. The runq-sz
value is the Run queue length (number of tasks waiting for run time). A run queue
size which is greater than the number of CPUs on your system is usually indicative
of CPU bottleneck. The plist-sz value is the number of tasks in the task list.
[root@examplehost /]# sar -q 3 10
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
02:22:11
15
02:22:14
0.59
02:22:17
0.59
02:22:20
0.59
02:22:23
0.59
02:22:26
0.59
02:22:29
0.59
02:22:32
0.59
02:22:35
0.60
02:22:38
0.61

PM

runq-sz

plist-sz

ldavg-1

ldavg-5

PM

242

0.73

0.47

PM

242

0.73

0.47

PM

242

0.75

0.48

PM

241

0.77

0.49

PM

242

0.77

0.49

PM

243

0.79

0.50

PM

243

0.79

0.50

PM

243

0.89

0.52

PM

243

0.98

0.54

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

ldavg-

OL 6- Lab 07

Page 37 of 99

OL 6 System Monitoring - Lab 7

Iostat:
We will now look at the iostat command. As before, lets read the man pages of
iostat to get familiarized with this command and then use some of the options.
[root@examplehost /]# man iostat
[root@examplehost /]# which iostat
/usr/bin/iostat
[root@examplehost /]# rpm -qf /usr/bin/iostat
sysstat-9.0.4-20.el6.x86_64
[root@examplehost /]#
[root@examplehost /]# man iostat

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 38 of 99

OL 6 System Monitoring - Lab 7

Running the iostat command without any options will show the statistics since the
time the system was booted. Go through the output and review the data that this
command reports by referring to the man pages.
[root@examplehost /]# iostat
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
avg-cpu:
Device:
Blk_wrtn
sda
234322
dm-0
234168
dm-1
24

%user
0.44

%nice %system %iowait


0.00
0.25
0.05

%steal
0.00

%idle
99.26

tps

Blk_read/s

Blk_wrtn/s

Blk_read

0.53

13.48

2.67

1185116

0.62

13.12

2.66

1153234

0.00

0.03

0.00

2600

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 39 of 99

OL 6 System Monitoring - Lab 7

Running the iostat command with the c option displays just the CPU utilization
report. In the example below, it captures the data every 2 seconds for 4 times and
then exits the command.
[root@examplehost /]# iostat -c 2 4
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
avg-cpu:

%user
0.44

%nice %system %iowait


0.00
0.25
0.05

%steal
0.00

%idle
99.25

avg-cpu:

%user
1.51

%nice %system %iowait


0.00
0.50
0.00

%steal
0.00

%idle
97.99

avg-cpu:

%user
7.07

%nice %system %iowait


0.00
2.53
0.00

%steal
0.00

%idle
90.40

avg-cpu:

%user
0.50

%nice %system %iowait


0.00
0.00
0.00

%steal
0.00

%idle
99.50

[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 40 of 99

OL 6 System Monitoring - Lab 7

Running the iostat command with the d option will show devices report.
[root@examplehost /]# iostat -d 3 3
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
Device:
Blk_wrtn
sda
235482
dm-0
235328
dm-1
24
Device:
Blk_wrtn
sda
80
dm-0
80
....
....
....

tps

Blk_read/s

Blk_wrtn/s

Blk_read

0.53

13.46

2.68

1185116

0.62

13.10

2.67

1153234

0.00

0.03

0.00

2600

tps

Blk_read/s

Blk_wrtn/s

Blk_read

3.01

0.00

26.76

3.34

0.00

26.76

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 41 of 99

OL 6 System Monitoring - Lab 7

Using the p option with the iostat command, you can specify a device name for
which you want to see the report. A sample output is shown below.
[root@examplehost /]# iostat -p sda 2 2
Linux 2.6.39-300.17.3.el6uek.x86_64 (examplehost.com)
01/16/2013
_x86_64_ (1 CPU)
avg-cpu:

%user
0.44

Device:
Blk_wrtn
sda
236298
sda1
130
sda2
236168
avg-cpu:

%user
0.50

%nice %system %iowait


0.00
0.25
0.05

%steal
0.00

%idle
99.25

tps

Blk_read/s

Blk_wrtn/s

Blk_read

0.53

13.44

2.68

1185116

0.01

0.31

0.00

27130

0.49

13.12

2.68

1156754

%nice %system %iowait


0.00
0.50
0.00

%steal
0.00

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

%idle
99.01

OL 6- Lab 07

Page 42 of 99

OL 6 System Monitoring - Lab 7


Device:
Blk_wrtn
sda
0
sda1
0
sda2
0

tps

Blk_read/s

Blk_wrtn/s

Blk_read

0.00

0.00

0.00

0.00

0.00

0.00

0.00

0.00

0.00

[root@examplehost /]#

If you wish you can explore more options of the iostat command by trying them out
on your leisure.
Vmstat:
Let us now look at the vmstat command and begin by reading the man pages.
[root@examplehost /]# which vmstat
/usr/bin/vmstat
[root@examplehost /]# man vmstat

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 43 of 99

OL 6 System Monitoring - Lab 7

Run the vmstat command on your system and examine the output. Note that this
report includes CPU, memory, swap, IO and system information.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 44 of 99

OL 6 System Monitoring - Lab 7

[root@examplehost /]# vmstat 3 5


procs -----------memory---------- ---swap-- -----io---- -system-- -----cpu----r b
swpd
free
buff cache
si
so
bi
bo
in
cs us sy id wa st
0 0
8 126728 59116 379372
0
0
7
1
75 140 0 0 99 0 0
0 0
8 126712 59116 379372
0
0
0
0
73 143 0 0 100 0 0
0 0
8 126712 59116 379372
0
0
0
0
77 163 1 0 99 0 0
0 0
8 126712 59116 379372
0
0
0
0
76 148 0 0 100 0 0
0 0
8 126712 59116 379372
0
0
0
3
66 129 0 0 100 0 0
[root@examplehost /]#

Examine the output in the above screenshot and see the si and so have 0 value.
This means no swap activity is taking place. Also, notice the CPU is almost idle (look
at the id column) and this is indicative of an idle system with little activity.
We will now run the vmstat command using the a option. The a option shows
information about active and inactive memory in the report as seen in the sample
output below.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 45 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# vmstat -a 2 4
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
8 126588 331000 262432
0
0
7
1
75 140 0 0 99 0 0
0 0
8 126572 331008 262456
0
0
0
0
72 139 0 0 100 0 0
0 0
8 126572 331008 262456
0
0
0
0
74 142 0 0 99 0 0
0 0
8 126572 331008 262484
0
0
0
0
74 144 0 1 100 0 0
[root@examplehost /]#

Notice that unlike the sar command, the vmstat output does not log the timestamp
in the report if you do not specify the t option. Example report with t option
shows the timestamp information getting reported.
[root@examplehost /]# vmstat -t 2 3
procs -----------memory---------- ---swap-- -----io---- -system-- -----cpu------ ---timestamp--r b
swpd
free
buff cache
si
so
bi
bo
in
cs us sy id wa st
0 0
8 126432 59276 379388
0
0
7
1
75 140 0 0 99 0 0
2013-01-16 15:00:23 PST
0 0
8 126416 59276 379388
0
0
0
0
78 148 0 0 99 0 0
2013-01-16 15:00:25 PST
0 0
8 126432 59276 379388
0
0
0
0
70 141 0 0 100 0 02013-01-16 15:00:27 PST
[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 46 of 99

OL 6 System Monitoring - Lab 7

Strace:
The strace command is used to capture system calls and signals of a running
process or a process being launched. Start by reading the man pages as always.
[root@examplehost /]# which strace
/usr/bin/strace
[root@examplehost /]# man strace
In this lab, we will run strace against a running process and capture the output and
also run strace before launching a process. We will not go into the details of
analyzing strace output but you should take a look at the data collected by strace
and see the system calls a process or an application makes when it runs. This strace
command usually comes in handy when you are trying to launch an application and
it is failing to start.
Run the strace command against a running process like firefox on your system as
shown below. Terminate the strace command after capturing the output for about
3-5 seconds using Control-C. You can view the output of strace command collected
in the /tmp/strace_ffox.out file using the view or vi command.
[root@examplehost /]# ps -ef | grep firefox
root
6974
1 1 15:11 ?
00:00:15
/usr/lib64/firefox/firefox
root
7088 6339 0 15:29 pts/1
00:00:00 grep
firefox
[root@examplehost /]#
[root@examplehost /]# strace -o /tmp/strace_ffox.out -p
6974
Process 6974 attached - interrupt to quit
^CProcess 6974 detached
[root@examplehost /]#
[root@examplehost /]# vi /tmp/strace_ffox.out

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 47 of 99

OL 6 System Monitoring - Lab 7

To run the strace when you launch a process/application, you can simply start the
process/application with the strace command first and then the application name.
In the example below, we will start the gedit editor and trace the system calls of
this application using the strace command. The trace will be captured in the
/tmp/strace_gedit.out file. Examine the /tmp/strace_gedit.out file to see what all
system calls were logged.
[root@examplehost /]# strace -o /tmp/strace_gedit.out gedit
[root@examplehost /]#
[root@examplehost /]# vi /tmp/strace_gedit.out

Top:
The top command provides a dynamic real time view of a Linux system. It is a very
good and useful tool to identify system performance related issues. Read the man
pages and then try out the top command on your Oracle Linux 6 systems.
[root@examplehost /]# which top
/usr/bin/top
[root@examplehost /]# rpm -qf /usr/bin/top
procps-3.2.8-23.el6.x86_64
[root@examplehost /]#
[root@examplehost /]# man top

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 48 of 99

OL 6 System Monitoring - Lab 7

Run the top command without any arguments and observe the system real time
view that it provides.
[root@examplehost /]# top

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 49 of 99

OL 6 System Monitoring - Lab 7

Running the top command with n option will exit the top command after n
iterations. Without this option, the top command keeps displaying the real time
system activity.
[root@examplehost /]# top -n 3
To see the processes or activity of a particular user on the system, you can run the
top command with u option. In the example below, student1 activity on the
system is being reported by top command.
[root@examplehost /]# top -u student1

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 50 of 99

OL 6 System Monitoring - Lab 7

We will now simulate a high CPU utilization situation by running the yes command
as we did earlier in another lab. Run the yes command as student1 user on a
terminal window as shown below. In another terminal window, run the top
command and notice the high CPU utilization process and the user name.
[student1@examplehost /]# yes > /dev/null
[root@examplehost /]# top

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 51 of 99

OL 6 System Monitoring - Lab 7


Notice in the above output that top by default sorts processes on CPU usage. You
can see that student1 is running the yes command which is taking about 91.3 %
CPU on this system. As you read in the man pages of top, this command is
interactive. Click the upper case M in the top output and it will re-sort the output
and sort the processes based on memory (%MEM). See the example below.

There are some other interactive options for sorting. Some of them are listed below:
Sort command option
A
M
N
P
T

Sorted Field
start time (non-display)
%MEM
PID
%CPU
TIME+

You can try using these interactive sort options in the top terminal window to see
the results.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 52 of 99

OL 6 System Monitoring - Lab 7


Tcpdump:
The tcpdump tool is a network analysis tool that prints out a description of the
contents of packets on a network interface. This is a useful tool for understanding of
TCP/IP packets and investigating network related issues. You can capture the traffic
based on specified filters. Many people prefer to use higher level analysis tools such
as Wireshark (Ethereal), but we will look at both these tools in this lab.
[root@examplehost /]# which tcpdump
/usr/sbin/tcpdump
[root@examplehost /]# rpm -qf /usr/sbin/tcpdump
tcpdump-4.0.0-3.20090921gitdf3cb4.2.el6.x86_64
[root@examplehost /]#
[root@examplehost /]# man tcpdump
[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 53 of 99

OL 6 System Monitoring - Lab 7


You can print the list of network interfaces using the D option:
[root@examplehost /]# tcpdump -D
1.eth0
2.usbmon1 (USB bus number 1)
3.any (Pseudo-device that captures on all interfaces)
4.lo
[root@examplehost /]#

Capture the network traffic for a host by specifying the hostname. For example, to
capture network traffic for host ludic.us.oracle.com, type the following command.
Note: Use a different hostname that is available on your network rather than
using the one that is listed in the examples below for this lab.
[root@examplehost /]# tcpdump host ludic.us.oracle.com
tcpdump: verbose output suppressed, use -v or -vv for full
protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture
size 65535 bytes

To capture network traffic for host ludic.us.oracle.com via network interface device
eth0, type the following command:

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 54 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# tcpdump -i eth0 -n host
ludic.us.oracle.com
tcpdump: verbose output suppressed, use -v or -vv for full
protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture
size 65535 bytes
11:41:42.920549 IP 10.0.2.15.45301 > 10.132.188.56.ssh:
Flags [S], seq 1750434830, win 14600, options [mss
1460,sackOK,TS val 163262965 ecr 0,nop,wscale 7], length 0
11:41:42.957141 IP 10.132.188.56.ssh > 10.0.2.15.45301:
Flags [S.], seq 379136001, ack 1750434831, win 65535,
options [mss 1460], length 0

To capture HTTP protocol traffic via TCP port 80, use the following command:
[root@examplehost /]# tcpdump port 80

To print all IP packets between host ludic and any host except host coolwaters:
[root@examplehost /]# tcpdump ip host ludic and not
coolwaters

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 55 of 99

OL 6 System Monitoring - Lab 7

To capture the network traffic output to a file, you can use the w option and specify
the file name. In the example below, the output is captured in the
/tmp/tcpdump.out file.
[root@examplehost /]# tcpdump -w /tmp/tcpdump.out
tcpdump: listening on eth0, link-type EN10MB (Ethernet),
capture size 65535 bytes

Use the Control-C to break out of tcpdump command after a few seconds of
capture. Verify that you have file /tmp/tcpdump.out with some data captured.

To read the file in which network traffic data was captured, you can use the r
option of the tcpdump command:
[root@examplehost /]#
[root@examplehost /]# tcpdump -r /tmp/tcpdump.out
reading from file /tmp/tcpdump.out, link-type EN10MB
(Ethernet)
11:55:18.800306 IP 10.0.2.15.18632 >
....

..

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 56 of 99

OL 6 System Monitoring - Lab 7

You can increase the verbosity level of the data captured by using the v, -vv, -vvv
options and try running the above commands.
Ethereal/Wireshark:
Ethereal is now Wireshark. Wireshark (ethereal) is a network protocol analyzer
tool. It lets you capture and interactively browse the traffic running on a computer
network.
We will first install the Wireshark RPM package on our Oracle Linux 6.3 instance. To
install the package, run the yum install wireshark command. This will install the
command line too tethereal and other binaries in this package. If you want to install
the GUI packages, then you should also install the wireshark-gnome package. We
will install both these packages.
[root@examplehost /]# yum install wireshark
Loaded plugins: refresh-packagekit, security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wireshark.x86_64 0:1.2.15-2.0.1.el6_2.1 will
be installed
--> Processing Dependency: libsmi.so.2()(64bit) for
package: wireshark-1.2.15-2.0.1.el6_2.1.x86_64
--> Running transaction check
---> Package libsmi.x86_64 0:0.4.8-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================
================================
Package
Arch
Version
Repository
Size
==========================================================

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 57 of 99

OL 6 System Monitoring - Lab 7


=================================
Installing:
wireshark
x86_64
1.2.15-2.0.1.el6_2.1
ol6_latest
11 M
Installing for dependencies:
libsmi
x86_64
0.4.8-4.el6
ol6_latest
2.4 M
Transaction Summary
===========================================================
================================
Install
2 Package(s)
Total download size: 13 M
Installed size: 74 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): libsmi-0.4.8-4.el6.x86_64.rpm
| 2.4 MB
00:00
(2/2): wireshark-1.2.15-2.0.1.el6_2.1.x86_64.rpm
| 11 MB
00:01
--------------------------------------------------------------------------------------------Total
4.7 MB/s | 13 MB
00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libsmi-0.4.8-4.el6.x86_64
1/2
Installing : wireshark-1.2.15-2.0.1.el6_2.1.x86_64
2/2
Verifying : wireshark-1.2.15-2.0.1.el6_2.1.x86_64
1/2
Verifying : libsmi-0.4.8-4.el6.x86_64
2/2
Installed:
wireshark.x86_64 0:1.2.15-2.0.1.el6_2.1
Dependency Installed:
libsmi.x86_64 0:0.4.8-4.el6
Complete!
[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 58 of 99

OL 6 System Monitoring - Lab 7

Once the wireshark package has been installed, you can run the following
commands. Running the yum info command provides details of the package.
[root@examplehost /]# yum info wireshark
Loaded plugins: refresh-packagekit, security
Installed Packages
Name
: wireshark
Arch
: x86_64
Version
: 1.2.15
Release
: 2.0.1.el6_2.1
Size
: 57 M
Repo
: installed
From repo
: ol6_latest
Summary
: Network traffic analyzer
URL
: http://www.wireshark.org/
License
: GPL+
Description : Wireshark is a network traffic analyzer for
Unix-ish operating systems.
: This package lays base for libpcap, a packet
capture and filtering library, contains command-line
utilities, contains plugins and documentation for
wireshark. A graphical user interface is packaged
: separately to GTK+ package.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 59 of 99

OL 6 System Monitoring - Lab 7

And using rpm ql option we can check the files included in this package.
[root@examplehost /]# rpm -ql wireshark | grep bin
/usr/sbin/capinfos
/usr/sbin/dftest
/usr/sbin/dumpcap
/usr/sbin/editcap
/usr/sbin/mergecap
/usr/sbin/randpkt
/usr/sbin/rawshark
/usr/sbin/tethereal
/usr/sbin/text2pcap
/usr/sbin/tshark
/usr/share/wireshark/radius/dictionary.bintec
[root@examplehost /]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 60 of 99

OL 6 System Monitoring - Lab 7


The tethereal tool is the command line tool that can be used to dump and analyze
network traffic. You can check the options for this tool using the tethereal h
command.
[root@examplehost /]# tethereal -h
TShark 1.2.15
Dump and analyze network traffic.
See http://www.wireshark.org for more information.
Copyright 1998-2011 Gerald Combs <gerald@wireshark.org> and
contributors. This is free software; see the source for
copying conditions. There is NO warranty; not even for
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Usage: tshark [options] ...
Capture interface:
-i <interface>
first non-loopback)
-f <capture filter>
syntax
-s <snaplen>
65535)
-p
mode
-y <link type>
appropriate)
-D
exit
-L
of iface and exit
.....
.....

name or idx of interface (def:


packet filter in libpcap filter
packet snapshot length (def:
don't capture in promiscuous
link layer type (def: first
print list of interfaces and
print list of link-layer types

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 61 of 99

OL 6 System Monitoring - Lab 7

To display the network interfaces available on the system, use the D option of the
tethereal command.
[root@examplehost /]# tethereal -D
1. eth0
2. usbmon1 (USB bus number 1)
3. any (Pseudo-device that captures on all interfaces)
4. lo
[root@examplehost /]#

In this lab, we will use the GUI interface of wireshark application. But if you are
more interested in the command line interface, feel free to use the tethereal
command and other binaries included in this wireshark package.
To install the Wireshark GUI application, run the yum install wireshark-gnome
command as shown below.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 62 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost /]# yum install wireshark-gnome
Loaded plugins: refresh-packagekit, security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wireshark-gnome.x86_64 0:1.2.15-2.0.1.el6_2.1
will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================
===================================
Package
Arch
Version
Repository
Size
===========================================================
===================================
Installing:
wireshark-gnome
x86_64
1.2.152.0.1.el6_2.1
ol6_latest
631 k
Transaction Summary
===========================================================
===================================
Install
1 Package(s)
Total download size: 631 k
Installed size: 2.0 M
Is this ok [y/N]: y

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 63 of 99

OL 6 System Monitoring - Lab 7

Once the Wireshark GUI application has been installed, you can verify that it is
installed on your system and also read the man pages before you begin using this
application.
[root@examplehost /]# which wireshark
/usr/sbin/wireshark
[root@examplehost /]#
[root@examplehost /]# man wireshark

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 64 of 99

OL 6 System Monitoring - Lab 7

Run the /usr/sbin/wireshark application in your Oracle Linux Desktop


environment to start the Wireshark GUI application.
[root@examplehost /]# /usr/sbin/wireshark

Alternatively, you can also find this application under the Applications -> Internet
->Wireshark Network Analyzer menu.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 65 of 99

OL 6 System Monitoring - Lab 7

You should now see the Wireshark Network Analyzer application window similar to
what is shown below.

You can select an interface like eth0 and start the capture of network packets.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 66 of 99

OL 6 System Monitoring - Lab 7

If you want to just capture the HTTP protocol traffic on the eth0 network interface,
you can click the Filter button and set the filter to HTTP.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 67 of 99

OL 6 System Monitoring - Lab 7

After selecting the filter and network interface, you can begin the capture of this
network traffic. Examine the data being collected by this tool. You can see that it has
Source IP, Destination IP, and Protocol IP information for all packets. You can sort
based on Destination IP or any other fields. Try sorting the data and playing and
understanding the information that this tool collects.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 68 of 99

OL 6 System Monitoring - Lab 7

You can save the output in a file and open it later for reading the file. In the example
screenshot shown below, we capture the network data in MyWiresharkOutput file
and save it on the /tmp file system.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 69 of 99

OL 6 System Monitoring - Lab 7

You can read the saved /tmp/MyWiresharkOutput file later at any time using the
Wireshark GUI application. In fact, the Wireshark tool can read/import network
data captured in several formats like libcap, tcpdump, snoop, etc. There is no need to
tell Wireshark the type of file you are reading as it can figure out the file format by
opening the file.
To open a file, click the blue file folder icon in the GUI as shown below.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 70 of 99

OL 6 System Monitoring - Lab 7

There is a lot more to play around and explore with Wireshark tool. We will let you
explore and try out more things on your own. This concludes the lab for Wireshark
tool.

5.4 System Monitor GNOME Application


If you have the GNOME Desktop environment installed on Oracle Linux 6.3, there is
one more useful application that is available to you. It is the System Monitor
application. You can run the System Monitor application from the Applications ->
System Tools -> System Monitor menu option.
Alternatively, you can run it from the command line using the gnome-systemmonitor command.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 71 of 99

OL 6 System Monitoring - Lab 7

The System Monitor application enables you to display basic system information
and monitor system processes, usage of system resources, and file systems.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 72 of 99

OL 6 System Monitoring - Lab 7


The System Monitor window contains four tabbed sections: System, Processes,
Resources, and File Systems. See screenshots below.

You can use Edit -> Preferences option to configure the information fields that you
want to be displayed for the Processes running on the system. Similarly, you can
also configure some settings under the Resources and File Systems tab.
Enclosed below is a screenshot of the Resources tab where you can see CPU,
Memory, and Network performance graphs. We will not spend too much time on
this tool as most of it is self-explanatory.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 73 of 99

OL 6 System Monitoring - Lab 7

5.5 Kdump / Netconsole


In this lab, we will look at Kdump and Netconsole tools that can be used for
debugging and troubleshooting on Oracle Linux 6 systems.
Kdump:
Kdump is an advanced crash dumping mechanism. When enabled, the system is
booted from the context of another kernel. This second kernel reserves a small
amount of memory, and its only purpose is to capture the core dump image in case
the system crashes. Since being able to analyze the core dump helps significantly to
determine the exact cause of the system failure, it is strongly recommended to have
this feature enabled.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 74 of 99

OL 6 System Monitoring - Lab 7


There are three common ways of configuring the kdump service:
When FirstBoot tool is run after initial installation
Using the Kernel Dump Configuration graphical utility
Manually using command line option system-config-kdump
Since we already have a running instance of Oracle Linux 6.3, we will not look at
FirstBoot tool configuration. But you can refer to the screen shots in the Install lab
that show the FirstBoot tool screens including the Kdump configuration screen.
Before we look at configuring the kdump service, make sure you have the kexectools package installed as this is needed for kdump configuration.
If you do not have the kexec-tools package installed, you should install it first using
the yum install kexec-tools command.
Note: The diskdump service sets up the kernel to save a memory image to the
specified partition at the time of system panic etc. The diskdumputils package for
diskdump was used in older versions of Oracle/RedHat Linux and that package has
been obsoleted by kexec-tools package.
Kdump Configuration using Graphical User Interface:
You can launch the GUI utility from the System -> Administration -> Kernel crash
dumps option on your Oracle Linux 6.3 assuming that you have the Desktop GUI
packages installed on your system. We installed the Desktop packages as part of
Install lab of the boot camp.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 75 of 99

OL 6 System Monitoring - Lab 7


Clicking the Kernel crash dumps menu option as shown above will launch the
kdump configuration graphical utility. In the example below, it shows that kdump is
not enabled.

Click the Enable button to enable the kdump service. Remember to click Apply
after enabling the kdump service. You should see the following screen if kdump is
already enabled. If you see an error stating "Starting kdump:[FAILED], then you
may have to reboot your system. This is because when you enable kdump it has to
create the kdump initial ramdisk and a reboot can create the kdump initial ramdisk.
Verify after reboot and confirm by running the tool again that the kdump service has
been enabled.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 76 of 99

OL 6 System Monitoring - Lab 7

Review the Basic settings, Target settings, Filtering settings, Expert settings in the
Kernel Dump Configuration application window. Sample screenshots shown below.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 77 of 99

OL 6 System Monitoring - Lab 7

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 78 of 99

OL 6 System Monitoring - Lab 7


Observe the following settings on your system:
Amount of memory reserved for kdump in above example is 128 MB
Local system /var/crash is the default location where the vmcore file is
created upon a crash
Filtering settings show the level of information included in the vmcore file
This amount of memory is represented by the crashkernel option and is appended
to the kernel line in the GRUB configuration file (/boot/grub/grub.conf) as follows:
kernel /vmlinuz-2.6.39-300.17.3.el6uek ..... crashkernel=128M
You can select a raw device or network location for saving vmcore files that are
generated upon a crash.
NOTE: You must reboot your system if kdump is enabled from a disabled state or if
you change some of the parameters like the amount of memory reserved for kdump.
The command line method of configuring kdump is to use the system-configkdump utility as shown below. Running this utility on a Desktop GUI environment
will launch the same application window as we saw earlier.
[root@examplehost /]# which system-config-kdump
/usr/bin/system-config-kdump
[root@examplehost /]#
[root@examplehost /]# system-config-kdump

The /etc/kdump.conf file is the configuration file for the kdump crash collection
service. This is the file where the kdump configuration information is stored. You
can read the man pages of the kdump.conf to get all the details.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 79 of 99

OL 6 System Monitoring - Lab 7

Examine the /etc/kdump.conf file on your system by opening it using the view
command.

Check the status of the kdump service using the following command:

If the kdump service is not operational you can start this service as shown below:

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 80 of 99

OL 6 System Monitoring - Lab 7


Alternatively, to start the service and check the status, you can use the commands as
shown in the screenshot below.

Again, remember to reboot the system if you have to enable the kdump service or
have made some major configuration changes.
Netconsole:
The netconsole utility allows system console messages to be redirected across the
network to another server. When a Linux system experiences critical or fatal issues,
relevant console/message log capture is often lost because the system crashes and
reboots. In such situations, you are unable to retrieve the logs of the incident which
caused the issue from the affected system. The lack of diagnostic logs usually means
that you cannot easily debug the problem. In such situations, you can configure
Netconsole utility to send/redirect system console messages over the network to a
designated server in the event of a fatal issue. The netconsole capture tool redirects
system console messages from the affected system to another on the network. It is a
light-weight and non-intrusive logging capture tool that helps prevent against the
loss of important console messages, especially those produced during a failure.
There are two systems involved in setting up netconsole:
Netconsole Server system that receives the console messages
Netconsole Client system that sends the console messages to configured
server
Messages received by the netconsole server may be logged to its system log.
We will not be doing a lab on netconsole utility in this training. If you wish to learn
and explore this tool further, you can refer to the following My Oracle Support
document:
Doc ID 793684.1 - Netconsole: Dumping System Console Messages Across the
Network

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 81 of 99

OL 6 System Monitoring - Lab 7


5.6 Crash and vmcore dump
Crash is a tool to analyse Linux crash dump data or a live system. Crash is a tool for
interactively analyzing the state of the Linux system while it is running, or after a
kernel crash has occurred and a core dump has been created by the netdump,
diskdump, kdump, or xendump facilities.
You system should already have the crash tool installed. If you do not have crash
installed, you can install using the yum install crash command.

Start by reading the man pages of crash command.

To analyze crash dumps on Oracle Linux 6 systems, you will need the kerneldebuginfo packages for the version of the kernel that you are running. In the
example below, we are running x86_64 bit UEK R2 kernel with version number
2.6.39-300.17.3.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 82 of 99

OL 6 System Monitoring - Lab 7

This means we will need the kernel-debuginfo packages corresponding to this


kernel version if we have run crash against a vmcore file generated on this system.
You can get the kernel-debuginfo RPM packages for your kernel version from the
following location:
https://oss.oracle.com/ol6/debuginfo/
In our example, we are using x86_64 bit UEK R2 kernel with version number
2.6.39-300.17.3, so we will get the debug kernel RPMs shown below:
[root@examplehost Downloads]# uname -a
Linux examplehost.com 2.6.39-300.17.3.el6uek.x86_64 #1 SMP
Wed Dec 19 06:28:03 PST 2012 x86_64 x86_64 x86_64 GNU/Linux
Download the UEK kernel debuginfo RPM files from:
http://oss.oracle.com/ol6/debuginfo
[root@examplehost Downloads]#
[root@examplehost Downloads]# ls
kernel-uek-debuginfo-2.6.39-300.17.3.el6uek.x86_64.rpm
kernel-uek-debuginfo-common-2.6.39-300.17.3.el6uek.x86_64.rpm
[root@examplehost Downloads]#

Once you have downloaded the uek-debuginfo RPMS for your kernel, you can run
the following rpm commands to install these 2 RPM packages.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 83 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost Downloads]# rpm -ivh kernel-uekdebuginfo-common-2.6.39-300.17.3.el6uek.x86_64.rpm
Preparing...
########################################### [100%]
1:kernel-uek-debuginfoco########################################### [100%]
[root@examplehost Downloads]#
[root@examplehost Downloads]#
[root@examplehost Downloads]# rpm -ivh kernel-uekdebuginfo-2.6.39-300.17.3.el6uek.x86_64.rpm
Preparing...
########################################### [100%]
1:kernel-uek-debuginfo-2.6
########################################### [100%]
[root@examplehost Downloads]#

Now that we have the crash utility and the kernel-debuginfo RPM packages
installed, we are ready and all setup. If your Oracle Linux 6.3 system experiences a
crash now, it should generate a vmcore file for the crash in the /var/crash
directory. The vmcore file will be inside a time-stamped directory inside of
/var/crash directory.
NOTE: Please do not try the remainder of this lab on any production or critical
Oracle Linux 6 system unless you are familiar with all these commands and
tools.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 84 of 99

OL 6 System Monitoring - Lab 7


To test and try out the crash utility, you can force a crash and creation of vmcore
file by running the following commands.
It is recommended to run these commands at run level 3 (init level 3) on a test/lab
setup (do not try on production systems):
[root@examplehost /]# init 3
This should stop your Desktop (gnome) environment and take you to text based
login interface. Login to your Oracle Linux 6 system as root user and run the
commands shown below.
[root@examplehost /]# echo 1 > /proc/sys/kernel/sysrq
[root@examplehost /]# echo c > /proc/sysrq-trigger

After running the above commands, the system will crash and create a vmcore file in
the /var/crash directory. It will also reboot after the crash. Change directory and
locate the vmcore file on your system as shown in the example below.
[root@examplehost /]# cd /var/crash
[root@examplehost crash]# ls
127.0.0.1-2013-01-15-11:40:06 127.0.0.1-2013-01-1513:10:06
[root@examplehost crash]# cd 127.0.0.1-2013-01-1513\:10\:06/
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]# ls -l
total 41204
-rw-------. 1 root root 42187698 Jan 15 13:10 vmcore
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 85 of 99

OL 6 System Monitoring - Lab 7


You can check the OS release information by running the crash command with the
osrelease option as shown below. This is to check the kernel version of the vmcore
file and then make sure that the core file is analyzed using the matching version
kernel-debuginfo files as shown in the screenshots below. You should have already
downloaded and installed the kernel debguginfo files earlier in this lab.
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]# pwd
/var/crash/127.0.0.1-2013-01-15-13:10:06
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]# ls
vmcore
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]# crash -osrelease vmcore
2.6.39-300.17.3.el6uek.x86_64
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]# rpm -qa |
grep uek-debug
kernel-uek-debuginfo-2.6.39-300.17.3.el6uek.x86_64
kernel-uek-debuginfo-common-2.6.39-300.17.3.el6uek.x86_64
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]#

Now that we have all the things we need, we can examine and analyze the vmcore
file to debug and find the cause of the crash. Since debugging system crash files
(vmcore files) is an advanced topic, we will not cover that in this boot camp. But if
you are interested, you can read the vmcore file using the crash command as shown
below and run the bt command on crash prompt to examine the stack trace. Refer
to man pages for more options available on the crash prompt.
[root@examplehost 127.0.0.1-2013-01-15-13:10:06]# crash
/usr/lib/debug/lib/modules/2.6.39300.17.3.el6uek.x86_64.debug/vmlinux /boot/System.map2.6.39-300.17.3.el6uek.x86_64 ./vmcore

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 86 of 99

OL 6 System Monitoring - Lab 7

If crash is able to open and read the vmcore file properly, you should see
information similar to what is shown in the screenshot below.

You can run some commands at the crash prompt like bt to look at the stack trace
or ps to see process information. We will not go into details of crash command or
debugging kernel crashes as that is an advanced topic and requires more time.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 87 of 99

OL 6 System Monitoring - Lab 7

We learned about to enable crash dumps, install debug kernel rpm packages needed
for crash analysis and also looked at opening/reading a vmcore crash file. This
concludes the lab on crash command.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 88 of 99

OL 6 System Monitoring - Lab 7


5.7 DTrace Introduction
DTrace is a comprehensive dynamic tracing facility that was first developed for the
Oracle Solaris operating system, and subsequently ported to Oracle Linux. DTrace
allows you to explore your system to understand how it works, to track down
performance problems across many layers of software, or to locate the causes of
aberrant behavior.
Using DTrace, you can record data at locations of interest in the kernel,
called probes. A probe is a location to which DTrace can bind a request to perform a
set of actions, such as recording a stack trace, a timestamp, or the argument to a
function. Probes function like programmable sensors that record information. When
a probe is triggered, DTrace gathers data from it and reports the data back to you.
Using DTrace's D programming language, you can query the system probes to
provide immediate, concise answers to arbitrary questions that you formulate.
Since DTrace is a huge topic and it is not possible to cover this in this short training,
we will just introduce you to this topic. We will just look at how DTrace can be
installed and enabled in Oracle Linux 6.3 release. We will also verify that it works
using a simple example but we will not go into details of tracing and debugging
using DTrace in this training.
Installing DTrace packages:
DTrace packages are available from ULN and you need a CSI number with valid
support contract to download the DTrace packages.
NOTE: If you do not have access to ULN then you may not be able to install DTrace and
perform this lab.
DTrace packages can be installed using yum and connecting to the ULN repository.
Run the following yum command to search for DTrace packages. Once DTrace
packages have been installed, you can find the Release notes in the
/usr/share/doc/dtrace* directory.
Note 1: At the time of creation of this document, the DTrace RPMs install a
dependent UEK kernel version along with the rest of the packages. The kernel
version installed by DTrace is 2.6.39-201.0.2.el6uek.x86_64 which is different from
the one that was originally installed. Because of change of kernel versions, your
VirtualBox Guest additions integration may stop working. You will need to use the
host key to switch between host and guest operations after installation of DTrace.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 89 of 99

OL 6 System Monitoring - Lab 7


Note 2: Oracle Linux 6.5 includes UEK R3 kernel by default for x86-64 platforms.
Starting UEK R3 kernel, DTrace support has now been integrated in the default
kernel. This means you no longer need to install a separate DTrace enabled kernel if
you are using UEK R3 kernel to do this lab.
Note: Create a snapshot of your Virtual Machine in VirtualBox before installing
DTrace packages.

[root@examplehost]# yum search dtrace


Loaded plugins: refresh-packagekit, security
============================= N/S Matched: dtrace
==============================
dtrace-modules-2.6.39-201.0.2.el6uek.x86_64 : dtrace module
dtrace-utils.x86_64 : DTrace user interface.
dtrace-utils-devel.x86_64 : DTrace development headers.
kernel-uek-dtrace.x86_64 : The Linux kernel for DTrace
kernel-uek-dtrace-debug.x86_64 : The Linux kernel compiled
with extra debugging
: enabled
kernel-uek-dtrace-debug-devel.x86_64 : Development package
for building kernel
: modules to match the
debug kernel
kernel-uek-dtrace-devel.x86_64 : Development package for
building kernel modules
: to match the kernel
kernel-uek-dtrace-firmware.x86_64 : Firmware files used by
the Linux kernel
kernel-uek-dtrace-headers.x86_64 : Header files for the
Linux kernel for use by
: glibc
libdtrace-ctf.x86_64 : Compact Type Format library.
libdtrace-ctf-devel.x86_64 : Compact Type Format
development headers.
Name and summary matches only, use "search all" for
everything.
[root@examplehost]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 90 of 99

OL 6 System Monitoring - Lab 7

As mentioned earlier, it is recommended to create a snapshot of your Virtual


Machine before you install DTrace packages.
Install the DTrace packages using the yum command as shown below. The
advantage of using yum is helpful in this situation because, yum can resolve all
dependencies and install all the needed packages for DTrace.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 91 of 99

OL 6 System Monitoring - Lab 7


[root@examplehost]# yum install dtrace-utils
Loaded plugins: refresh-packagekit, security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dtrace-utils.x86_64 0:0.3.2-1.el6 will be
installed
--> Processing Dependency: dtrace-kernel-interface = 1 for
package: dtrace-utils-0.3.2-1.el6.x86_64
--> Processing Dependency: libdtrace-ctf for package:
dtrace-utils-0.3.2-1.el6.x86_64
---> Package libdtrace-ctf.x86_64 0:0.3.2-1 will be
installed
....
....
--> Finished Dependency Resolution
...
...
...
Total download size: 40 M
Installed size: 175 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): dtrace-modules-2.6.39-201.0.2.el6uek-0.3.21.el6.x86_64.rp | 935 kB
00:02
(2/5): dtrace-utils-0.3.2-1.el6.x86_64.rpm
| 255 kB
00:00
(3/5): kernel-uek-dtrace-2.6.39-201.0.2.el6uek.x86_64.rpm
| 36 MB
01:34
(4/5): kernel-uek-dtrace-firmware-2.6.39201.0.2.el6uek.x86_64.rp | 2.8 MB
00:07
(5/5): libdtrace-ctf-0.3.2-1.x86_64.rpm
| 26 kB
00:00
----------------------------------------------------------....
....
Dependency Installed:
dtrace-modules-2.6.39-201.0.2.el6uek.x86_64 0:0.3.2-1.el6
kernel-uek-dtrace.x86_64 0:2.6.39-201.0.2.el6uek
kernel-uek-dtrace-firmware.x86_64 0:2.6.39-201.0.2.el6uek
libdtrace-ctf.x86_64 0:0.3.2-1
Complete!
[root@examplehost]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 92 of 99

OL 6 System Monitoring - Lab 7

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 93 of 99

OL 6 System Monitoring - Lab 7


Reboot the system after installing the DTrace packages. Once the DTrace packages
have been installed and system has been rebooted, you can run the man dtrace
command and go through the man pages before trying it out.
[root@examplehost /]# man dtrace
[root@examplehost /]#

Running the dtrace command without any flags lists the dtrace command line
options too.
[root@examplehost /]# dtrace
Usage: dtrace [-32|-64] [-aACeFGhHlqSvVwZ] [-b bufsz] [-c
cmd] [-D name[=def]]
[-I path] [-L path] [-o output] [-p pid] [-s script]
[-U name]
[-x opt[=val]] [-X a|c|s|t]
[-P provider [[ predicate ] action ]]
[-m [ provider: ] module [[ predicate ] action ]]
[-f [[ provider: ] module: ] func [[ predicate ]
action ]]

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 94 of 99

OL 6 System Monitoring - Lab 7

Loading DTrace Kernel Modules:


Once you have installed the DTrace RPM packages, you will have to load the kernel
modules. You can find the available kernel modules in the directory corresponding
to the DTrace kernel that is being used.

You may have to reboot the system after installing the system as DTrace packages
are kernel dependent before you run the following commands. The modprobe
command is used to load the kernel modules as shown below. The example shown
below loads only two modules.
[root@examplehost
[root@examplehost
[root@examplehost
[root@examplehost

Desktop]# modprobe dtrace


Desktop]#
Desktop]# modprobe systrace
Desktop]#

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 95 of 99

OL 6 System Monitoring - Lab 7

To verify if DTrace is working on your system, you can try the dtrace command
first by listing the probes and providers using the l option.
[root@examplehost /]# dtrace -l

To list the probes for a particular provider (syscall in example below), you can use
the dtrace command with the P option as shown below.
[root@examplehost /]# dtrace l P syscall | more

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 96 of 99

OL 6 System Monitoring - Lab 7

Probes are enabled with the dtrace command. DTrace performs the associated
action when the probe fires. The default action indicates only that the probe fired.
No other data is recorded. You can enable (and list) probes by provider (-P), by
name (-n), by function (-f), and by module (-m).
Try the following syscall provider Dtrace example. In the example below, we first
find out the PID of the Firefox browser on the system and then run dtrace
command with n option to list and count syscalls. The syntax for probes is as
follows:
provider:module:function:name
Note: The PID on your system will be different from the one shown in this example.
[root@examplehost /]# ps -ef| grep firefox
root
2447
1 17 16:25 ?
00:00:01
/usr/lib64/firefox/firefox
root
2485 2253 0 16:25 pts/0
00:00:00 grep
firefox
[root@examplehost /]#
Find the pid of your Firefox application and then substitute that with the pid value
shown in the example below. Use Control-C to exit from the dtrace command. In
the example below, we use the syscall provider and the probe name is entry.

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 97 of 99

OL 6 System Monitoring - Lab 7

[root@examplehost /]# dtrace -n syscall:::entry'/pid == 2447/{


@syscalls[probefunc] = count(); }'
dtrace: description 'syscall:::entry' matched 296 probes
^C
clone
epoll_ctl
exit_group
getpeername
getuid
mkdir
pipe
sendto
setsockopt
setsockopt
statfs
connect
ftruncate
rename
socket
getsockname
newuname
fsync
getdents
kill
readlink
unlink
pread64
lseek
mprotect
newlstat
newfstat
access
fcntl
write
mmap
open
close
munmap
newstat
futex
madvise
writev
poll
read
[root@examplehost /]#

1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
3
3
4
4
5
6
7
9
11
13
15
30
35
39
51
59
68
73
80
159
553
775
923
3259
3938

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 98 of 99

OL 6 System Monitoring - Lab 7

This confirms that DTrace is installed and working correctly. For more details and
practicing DTrace on Oracle Linux 6.3, refer to the following documentation:
Oracle Linux DTrace Documentation
Oracle Linux Dynamic Tracing Guide

6 Lab Summary
In this lab you learned about some of the System Monitoring and Troubleshooting
tools like OSWatcher tool, Sosreport tool, system tools (vmstat, top, iostat, strace
etc). We looked at Kdump and Crash to debug kernel crashes. We also introduced
you to DTrace. Theres a ton more to troubleshooting and monitoring in Oracle
Linux 6. See the references section below on how to go deeper in your knowledge
and discover all the powerful debugging and troubleshooting tools available for
Oracle Linux 6.

7 References
For more information and next steps, please consult additional resources: Click the
hyperlinks to access the resource.
Performance Tuning Guide
Support Diagnostic Tools
Oracle Linux Dynamic Tracing Guide

For Oracle employees and authorized partners only. Do


not distribute to third parties.
2013 Oracle Corporation

OL 6- Lab 07

Page 99 of 99

Вам также может понравиться