Wednesday, 26 September 2018

Oracle SOA Database Adapter

Database adapter –

This is one of the important part of Oracle SOA. Using database adapter we can do all Database operations like insert, update, delete, select, calling a stored procedure, polling records from DB and executing Pure SQL.
To call database adapter we should do some configuration on weblogic console like creating a datasource and creating a JNDI. Now we will see how to create a datasource and JNDI.
Creating Datasource :
http://localhost:7001/console login into local weblogic console using username and password.
1) After login to console go to Services and then click on Data Sources.
image1
On this page provide a valid Datasource name. Ex : “TestDataSource”.
Give Jndi name. Ex : jdbc/db/nonxa/prod.
Database type : Can be given as per use. I am selecting here “Oracle”.
Click on Next.
image2
2) On next page select Oracle driver version as per requirement. Here I am selecting default one and click on Next.
image3
3) On next page there will not be anything to select or enter anything, just click on Next.
In the next page we should provide details like database name, host name, port, username and password.
After providing all correct details click on next.
image4
4) In the next page we should check whether provided data in last page are valid are not, for we should click on Test configuration. If provided data are correct then we will see message as Connection test succeeded. Click on next.
image5
If connection wasn’t successful then go back to previous page and make sure that valid data is entered.
5) Now select a target server, here I am selecting bam_server1. Click on finish.
image6
Now we are done with creating datasource.
Creating JNDI :
1) To start creating with JNDI, click on Deployments, after that click on DbAdapter.
image7
2) Now click on Configuration and then click on Outbound Connection Pools, after that click on New as shown picture below.
image8
3) In next page just select a checkbox and click on next.
image9
4) Give the proper name in place of JNDI name: eis/db/nonxa/qa and click on finish.
image10
5) Now we should provide Datasource name to created JNDI. Click on javax.resource.cci.ConnectionFactory.
image11
6) Click on created JNDI name : eis/db/nonxa/qa.
image12
7) In the next page we should change two properties
  1. a) xADataSourceName : As created datasource.
  2. b) sequencePreallocationSize Note : By default this value will be 50. If we keep this default value as it is then whenever we create a sequence for a table then every time that sequence value will be incremented by 50.
Ex : If initial value of sequence is 1000 then next value will 1050, 1100, 1150 and so on.
Note : Simply if we provide these two values and click on save will not work. First provide sequencePreallocationSize as 1 or as per requirement and click enter. Then next provide xADataSourceName value and again click on enter. And then click on save. If we do in this way then only changes will effective.
image13
Database Adapter :
Integration of Database Adapter
Drag a Database Adapter from component palette and drop it in exposed services.
Step 1.
image14
Click Next
Step 2.
Enter Service name and click next.
image15
Step 3.
Here click on plus icon, it will open new window to create new connection.
image16
Step 4.
Enter the required detail as provided in above image like
  1. Database username, password.
  2. Hostname
  3. Port number
  4. SID or Service name as per requirement
Before clicking OK click on Test Connection and check whether given information’s are correct. If connection is Success! then click on OK.
image17
Step 5.
In this step we should select which operation we want to do on Database.
  1. Call a stored procedure or function – If we select this then we call a selected stored procedure.
  2. Perform as operation on a Table – In this operation we can read, write, update, delete records from a table.
  3. Poll for New or Changed Records in a table – Polling records from table. Polling can be done in asynchronous/synchronous way, for that we should select one check box.
  4. Execute pure SQL – This property will allow us to write a query as per our requirement.
Note : If we select Select check box under Perform an operation on a table then we can’t select records as per our requirement because this will allow us select records as per Primary key. So if we require to select records as per for Ex : first name or last name then better use Execute Pure SQL, here we can write query as per our “where” condition.
Here I am using Insert only operation because I am going to insert data into table. Click Next
image18
Step 6.
Here select a schema from which a particular table should be selected. Click on Query which will schema and it will list of tables under it. Now select a particular table which are listed after querying and click on arrow.

image19
Step 7.
After clicking on arrow table will be moved from left hand side to right. Click OK.
image20
Step 8.
After click OK will see screen like above, click Next.
image26
Step 9.
I don’t have any relationships to be created with other table so its showing like “No Reachable Relationships”. If there two tables selected and there is relationship required then click Create… and create required relationship. Click Next >.
image22
Step 10.
Here it will show column which are present under selected table. Here we select and deselect required and not required fields and Click Next >.
image21
Step 11.
In above screen we select Sequence which is will used to generate Next Primary Key for every record which is going to be inserted. Click on Search, it will give list of Sequences from that select required Sequence. Click Next >.
image24
Step 12.
Click Finish. It will create a Database Adapter in BPEL.
image25

Oracle SOA File/FTP Adapter

Oracle SOA File/FTP Adapter
Oracle SOA File/FTP Adapter
Oracle File/FTP Adapter is one of the service component of the Oracle SOA Suite, Oracle File and FTP Adapter allows BPEL or Mediator process to exchange (i.e read or write) files on local file systems or remote file (i.e FTP or SFTP) system
Integration of FTP Adapter
Drag a FTP Adapter from component palette and drop it in exposed services
Step 1: 
Step1FTP
Click Next
Step 2:
Step2FTP
Enter Service Name and Click Next
Step 3:
Step3FTP
Click Next
Step 4:
Step4FTP
Enter JNDI Name and Click Next
Step 5:
Step5FTP
Select Get File to read file or Select Put File to write the file and Click Next
Step 6:
Step6FTP
Select either physical path and specify the incoming file directory or
Select logical name and specify the directory in config plan
Either Select or deselect delete file after successful retrieval
If required to archive the file before deleting the file, Select Archive processed files and specify either physical path or logical name
Click Next
Step 7:
Step7FTP
Enter the required file Pattern to been read and click Next
Step 8:
Step8FTP
Specify the file polling frequency in seconds
Specify the minimum File Age in seconds
Click Next
Step 9:
Step9FTP
If the file message format translation is not required then select Schema is Opaque
If required click on browse button and find the schema and click OK
Click Next
Step 10:
Step10FTP
Click Finish
Step 11:
setUp FTP Adapter configuration in SOA weblogic domain
  1. Open http://hostname:port/console
Click Deployments   –>  FTPAdapterStep1FTPConfig
2. Go to Configuration  –>  Outbound Connection Pools
Click New to create new FTP Configuration
Step2FTPConfig
3. Select javax.resource.cci.ConnectionFactory
Step03FTPConfig
Click Next
4.Enter the JNDI name and Click Finish
Step4FTPConfig
5.Now click on eis/ftp/read to enter the configuration
Step5FTPConfig
Select either Public key authentication or password authentication and
click Next
6.Enter the host name
Step6FTPConfig
Click Next
7.Enter password  and port number 21 for FTP and 22 for SFTP
Step7FTPConfig
Click Next
8.
Step8FTPConfig
Click Next
9. Enter Server Type either win for windows or unix
Step9FTPConfig
Click Next
10.Enter Username , if your using SFTP make useSftp to true
Step10FTPConfig
Click Save
11. Once Configuration is saved Update FTP Adapter
Step11FTPConfig
Select FtpAdapter and click Update
12. Select Update this application in place with new deployment plan changes
Step12FTPConfig
Click next
13.
Step13FTPConfig
Click Finish
14.Once update is done click Activate Changes
Step14FTPConfig

Wednesday, 12 September 2018

How to move the central Inventory (oraInventory) to another location.

How to move the central Inventory (oraInventory) to another location.


Solution On Unix:

Find the current location of the central inventory (normally $ORACLE_BASE/oraInventory):

For example:

find /home/oracle -name oraInventory -print

 /u01/app/oracle/oraInventory

Open the oraInst.loc file in /var/opt/oracle and check the value of inventory_loc

cat /var/opt/oracle/oraInst.loc

inventory_loc=/u01/app/oracle/oraInventory inst_group=oinstall

Remark: The oraInst.loc file is simply a pointer to the location of the central inventory (oraInventory)

Copy the oraInventory directory to the destination directory

cp -Rp /home/oracle/oraInventory /app/oracle

Edit the oraInst.loc file to point to the new location

For example:

vi /var/opt/oracle/oraInst.loc

inventory_loc=/app/oracle/oraInventory inst_group=dba

Tuesday, 14 August 2018

WebLogic Server is not Releasing the Storage after Log Rotation (Doc ID 2429822.1)

WebLogic Server is not Releasing the Storage after Log Rotation (Doc ID 2429822.1)

APPLIES TO:
Oracle WebLogic Server - Version 12.1.3.0.0 and later
Information in this document applies to any platform.
SYMPTOMS
On WebLogic Server (WLS) 12.1.3, JVM process is not releasing storage after log files are deleted.

You have applied patch 27357612 along with the latest PSU

But lsof command still shows wls log files


lsof /filenet|grep -i deleted
startWebL 99994 weblogic 1w REG 253,6 103399 1710660 /Oracle_Home/domain_name/servers/cpe_server1/logs/xxx_server1.out00177 (deleted)
startWebL 99994 weblogic 2w REG 253,6 103399 1710660 /Oracle_Home/domain_name/servers/servers/cpe_server1/logs/xxx_server1.out00177 (deleted)
java 100053 weblogic 630w REG 253,6 103759 1710856 /Oracle_Home/domain_name/servers/servers/cpe_server1/logs/xxx_server1.out00178 (deleted)



CAUSE
This issue was caused due to an incomplete fix in the Bug 27357612


SOLUTION
1. If already applied, remove patch 27357612

2. Apply patch 27896715

Monday, 23 July 2018

RPM Package Commands

1. How to Check an RPM Signature Package
Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is OK.
Use the following command with –checksig (check signature) option to check the signature of a package called pidgin.

[root@tecmint]# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK

2. How to Install an RPM Package
For installing an rpm software package, use the following command with -i option.
For example, to install an rpm package called pidgin-2.7.9-5.el6.2.i686.rpm.

[root@tecmint]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm
Preparing...                ########################################### [100%]
1:pidgin                 ########################################### [100%]
RPM command and options

-i : install a package
-v : verbose for a nicer display
-h: print hash marks as the package archive is unpacked.

3. How to check dependencies of RPM Package before Installing
Let’s say you would like to do a dependency check before installing or upgrading a package.
For example, use the following command to check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package.
It will display the list of dependencies of package.

[root@tecmint]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm
/usr/bin/python2.4
python >= 2.3
python(abi) = 2.4
python-crypto >= 2.0
python-psyco
python-twisted >= 2.0
python-zopeinterface
rpmlib(CompressedFileNames) = 2.6
RPM command and options

-q : Query a package
-p : List capabilities this package provides.
-R: List capabilities on which this package depends..

4. How to Install a RPM Package Without Dependencies
If you know that all needed packages are already installed and RPM is just being stupid,
you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.

[root@tecmint]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm
Preparing...                ########################################### [100%]
1:BitTorrent             ########################################### [100%]
The above command forcefully install rpm package by ignoring dependencies errors,
but if those dependency files are missing, then the program will not work at all, until you install them.

5. How to check an Installed RPM Package
Using -q option with package name, will show whether an rpm installed or not.

[root@tecmint]# rpm -q BitTorrent
BitTorrent-5.2.2-1.noarch

6. How to List all files of an installed RPM package
To view all the files of an installed rpm packages, use the -ql (query list) with rpm command.

[root@tecmint]# rpm -ql BitTorrent
/usr/bin/bittorrent
/usr/bin/bittorrent-console
/usr/bin/bittorrent-curses
/usr/bin/bittorrent-tracker
/usr/bin/changetracker-console
/usr/bin/launchmany-console
/usr/bin/launchmany-curses
/usr/bin/maketorrent
/usr/bin/maketorrent-console
/usr/bin/torrentinfo-console

7. How to List Recently Installed RPM Packages
Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.

[root@tecmint]# rpm -qa --last
BitTorrent-5.2.2-1.noarch                     Tue 04 Dec 2012 05:14:06 PM BDT
pidgin-2.7.9-5.el6.2.i686                     Tue 04 Dec 2012 05:13:51 PM BDT
cyrus-sasl-devel-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:06 PM BDT
cyrus-sasl-2.1.23-13.el6_3.1.i686             Tue 04 Dec 2012 04:43:05 PM BDT
cyrus-sasl-md5-2.1.23-13.el6_3.1.i686         Tue 04 Dec 2012 04:43:04 PM BDT
cyrus-sasl-plain-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:03 PM BDT

8. How to List All Installed RPM Packages
Type the following command to print the all the names of installed packages on your Linux system.

[root@tecmint]# rpm -qa
initscripts-9.03.31-2.el6.centos.i686
polkit-desktop-policy-0.96-2.el6_0.1.noarch
thunderbird-17.0-1.el6.remi.i686

9. How to Upgrade a RPM Package
If we want to upgrade any RPM package “–U” (upgrade) option will be used.
One of the major advantages of using this option is that it will not only upgrade the latest version of any package,
but it will also maintain the backup of the older package
so that in case if the newer upgraded package does not run the previously installed package can be used again.

[root@tecmint]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
Preparing...                ########################################### [100%]
1:nx                     ########################################### [100%]

10. How to Remove a RPM Package
To un-install an RPM package, for example we use the package name nx, not the original package name nx-3.5.0-2.el6.centos.i686.rpm.
The -e (erase) option is used to remove package.

[root@tecmint]# rpm -evv nx

11. How to Remove an RPM Package Without Dependencies
The –nodeps (Do not check dependencies) option forcefully remove the rpm package from the system.
But keep in mind removing particular package may break other working applications.

[root@tecmint]# rpm -ev --nodeps vsftpd

12. How to Query a file that belongs which RPM Package
Let’s say, you have list of files and you would like to find out which package belongs to these files.
For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.

[root@tecmint]# rpm -qf /usr/bin/htpasswd
httpd-tools-2.2.15-15.el6.centos.1.i686

13. How to Query a Information of Installed RPM Package
Let’s say you have installed an rpm package and want to know the information about the package.
The following -qi (query info) option will print the available information of the installed package.

[root@tecmint]# rpm -qi vsftpd
Name        : vsftpd                                   Relocations: (not relocatable)
Version     : 2.2.2                                   Vendor: CentOS
Release     : 11.el6                                   Build Date: Fri 22 Jun 2012 01:54:24 PM BDT
Install Date: Mon 17 Sep 2012 07:55:28 PM BDT      Build Host: c6b8.bsys.dev.centos.org
Group       : System Environment/Daemons           Source RPM: vsftpd-2.2.2-11.el6.src.rpm
Size        : 351932                               License: GPLv2 with exceptions
Signature   : RSA/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://vsftpd.beasts.org/
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.

14. Get the Information of RPM Package Before Installing
You have download a package from the internet and want to know the information of a package before installing.
For example, the following option -qip (query info package) will print the information of a package sqlbuddy.

[root@tecmint]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm
Name        : sqlbuddy                     Relocations: (not relocatable)
Version     : 1.3.3                        Vendor: (none)
Release     : 1                            Build Date: Wed 02 Nov 2011 11:01:21 PM BDT
Install Date: (not installed)              Build Host: rpm.bar.baz
Group       : Applications/Internet        Source RPM: sqlbuddy-1.3.3-1.src.rpm
Size        : 1155804                      License: MIT
Signature   : (none)
Packager    : Erik M Jacobs
URL         : http://www.sqlbuddy.com/
Summary     : SQL Buddy รข Web based MySQL administration
Description :
SQLBuddy is a PHP script that allows for web-based MySQL administration.

15. How to Query documentation of Installed RPM Package
To get the list of available documentation of an installed package,
use the following command with option -qdf (query document file) will display the manual pages related to vmstat package.

[root@tecmint]# rpm -qdf /usr/bin/vmstat
/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
/usr/share/doc/procps-3.2.8/TODO

16. How to Verify a RPM Package
Verifying a package compares information of installed files of the package against the rpm database.
The -Vp (verify package) is used to verify a package.

[root@tecmint downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm
S.5....T.  c /etc/httpd/conf.d/sqlbuddy.conf

17. How to Verify all RPM Packages
Type the following command to verify all the installed rpm packages.

[root@tecmint]# rpm -Va
S.5....T.  c /etc/rc.d/rc.local
.......T.  c /etc/dnsmasq.conf
.......T.    /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf
S.5....T.  c /etc/yum.conf
S.5....T.  c /etc/yum.repos.d/epel.repo

18. How to Import an RPM GPG key
To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key.

[root@tecmint]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

19. How to List all Imported RPM GPG keys
To print all the imported GPG keys in your system, use the following command.

[root@tecmint]# rpm -qa gpg-pubkey*
gpg-pubkey-0608b895-4bd22942
gpg-pubkey-7fac5991-4615767f
gpg-pubkey-0f2672c8-4cd950ee
gpg-pubkey-c105b9de-4e0fd3a3
gpg-pubkey-00f97f56-467e318a
gpg-pubkey-6b8d79e6-3f49313d
gpg-pubkey-849c449f-4cb9df30

20. How To rebuild Corrupted RPM Database
Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So,
at the time we need to rebuild the rpm database and restore it with the help of following command.

[root@tecmint]# cd /var/lib
[root@tecmint]# rm __db*
[root@tecmint]# rpm --rebuilddb

[root@tecmint]# rpmdb_verify Packages

VMstat Example Commands

10+ “vmstat” Command Usage Examples in Linux
----------------------------------------------
This tutorial explains Linux “vmstat” command, options and its usage with examples.

vmstat – Virtual Memory Statistics
Description:
vmstat command is used to report virtual memory statistics. vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.

Synopsis:
vmstat [-a] [-n] [-t] [-S unit] [delay [ count]] vmstat [-s] [-n] [-S unit] vmstat [-m] [-n] [delay [ count]] vmstat [-d] [-n] [delay [ count]] vmstat [-p disk partition] [-n] [delay [ count]] vmstat [-f] vmstat [-V]

OPTIONS:

-a
switch displays active/inactive memory, given a 2.5.41 kernel or better.
-f
switch displays the number of forks since boot. This includes the fork, vfork, and clone system calls, and is equivalent to the total number of tasks created. Each process is represented by one or more tasks, depending on thread usage. This display does not repeat.
-t
switch adds timestamp to the output.
-m
switch displays slabinfo.
-n
switch causes the header to be displayed only once rather than periodically.
-s
switch displays a table of various event counters and memory statistics. This display does not repeat.
delay
delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
count
number of updates. If no count is specified and delay is defined, count defaults to infinity.
-d
reports disk statistics (2.5.70 or above required)
-w
enlarges field width for big memory sizes
-p
followed by some partition name for detailed statistics (2.5.70 or above required)
-S
followed by k or K or m or M switches outputs between 1000, 1024, 1000000, or 1048576 bytes
-V
switch results in displaying version information.

Examples:

1) Simple example along-with field descriptions
------------------------------------------------
$ vmstat
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 305416 260688  29160 2356920   2    2     4     1    0  0  6  1 92  2  0

Field Description For Vm Mode
-------------------------------
Procs

r: The number of processes waiting for run time.
b: The number of processes in uninterruptible sleep.

Memory

swpd: the amount of virtual memory used.
free: the amount of idle memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache.
inact: the amount of inactive memory. (-a option)
active: the amount of active memory. (-a option)

Swap

si: Amount of memory swapped in from disk (/s).
so: Amount of memory swapped to disk (/s).

IO

bi: Blocks received from a block device (blocks/s).
bo: Blocks sent to a block device (blocks/s).

System

in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

CPU

These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

2) To execute every 2 seconds for 10 times, do the following.
You don’t need to press Ctrl-C in this case. After executing 10 times,
it will stop automatically.
-------------------------------------------------------------
$ vmstat 2 10
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in cs us sy id wa st
 1  0      0 537144 182736 6789320   0    0     0     0    1  1  0  0 100  0  0
 0  0      0 537004 182736 6789320   0    0     0     0   50 32  0  0 100  0  0
..

3) Using vmstat, this next command will grep the memory and give a good overview of the memory used in the computer.
-------------------------------------------------------------
$ vmstat -s -S M | grep mem

5965 M total memory
5136 M used memory
3580 M active memory
1176 M inactive memory
829 M free memory
474 M buffer memory

4) Display active and inactive memory
---------------------------------------
By default vmstat doesn’t display this information. Use option -a, to display active and inactive memory information as shown below.

$ vmstat -a
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 305416 253820 1052680 2688928    2    2     4     1    0    0  6  1 92  2  0

5) Display number of forks since last boot
--------------------------------------------
This displays all the fork system calls made by the system since the last boot. This displays all fork, vfork, and clone system call counts.

$ vmstat -f
     81651975 forks

6) Display timestamp
----------------------------
When you use vmstat to monitor the memory usage repeately, it would be nice to see the
timestap along with every line item. Use option -t to display the time stamp as shown below.

$ vmstat -t 1 100
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      0 3608728 148368 3898200    0    0     0     0    1    1  0  0 100  0  0     2011-07-09 21:16:28 PDT
 0  0      0 3608728 148368 3898200    0    0     0     0   60   15  0  0 100  0  0     2011-07-09 21:16:29 PDT
 0  0      0 3608712 148368 3898200    0    0     0     0   32   28  0  0 100  0  0     2011-07-09 21:16:30 PDT

7) Display slab info
--------------------
Use option -m, to display the slab info as shown below.

$ vmstat -m
Cache                       Num  Total   Size  Pages
fib6_nodes                    5    113     32    113
ip6_dst_cache                 4     15    256     15
ndisc_cache                   1     15    256     15
RAWv6                         7     10    768      5
UDPv6                         0      0    640      6
tw_sock_TCPv6                 0      0    128     30
...

8) Display statistics in a table format
----------------------------------------
Instead of displays the values in the record format, you can display the output of vmstat in table format using option -s as shown below.

$ vmstat -s
      4149928  total memory
      3864824  used memory
      2606664  active memory
      1098180  inactive memory
       285104  free memory
        19264  buffer memory
      2326692  swap cache
      4192956  total swap
       274872  used swap
      3918084  free swap
   1032454000 non-nice user cpu ticks
        14568 nice user cpu ticks
     89482270 system cpu ticks
  16674327143 idle cpu ticks
    368965706 IO-wait cpu ticks
      1180468 IRQ cpu ticks
..

9) Display disk statistics
-------------------------------------
Use option -d to display the disk statistics as shown below. This displays the reads, writes, and I/O statistics of the disk.

$ vmstat -d
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
sda   153189971 69093708 2719150864 737822879 329617713 157559204 3965687592 4068577985      0 1102243
sdb   501426305 97099356 2345472425 731613156 419220973 533565961 2661869460 1825174087      0 1510434
sdc   884213459 22078974 513390701 452540172 127474901 8993357 2411187300 2133226954      0 1569758

10) Changing width of output
The default output without increasing the width is shown below.
-------------------------------------------------------------
$ vmstat 1 3
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      0 3608688 148368 3898204    0    0     0     0    1    1  0  0 100  0  0
 0  0      0 3608804 148368 3898204    0    0     0     0   72   30  0  0 100  0  0
 0  0      0 3608804 148368 3898204    0    0     0     0   60   27  0  0 100  0  0

Use option -w to increase the width of the output columns as shown below. This give better readability.

$ vmstat -w 1 3
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          0    3608712     148368    3898204    0    0     0     0    1    1   0  0 100  0  0
 0  0          0    3608712     148368    3898204    0    0     0     0   93   23   0  0 100  0  0
 0  0          0    3608696     148368    3898204    0    0     0     0   35   34   0  0 100  0  0

11) Display statistics for a partition
------------------------------------------
To display the disk I/O statistics of a specific disk partition use option -p as shown below.

$ vmstat -p sdb1
sdb1          reads   read sectors  writes    requested writes
           501423248 2345417917  419221612 2661885948
  
12) Display in MB
---------------------
By default vmstat displays the memory information in kb. To disply in MB, use the option “-S m” as shown below.

$ vmstat -S m
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    281    288     19   2386    0    0     4     1    0    0  6  1 92  2  0