How To Find Open File Descriptors ( lsof , pfiles , ulimit )
I have come across the situation number of times when i need to find the open file descriptors for perticular process.
I have seen number of ppl confused about it ( including me in early days )
There are two command ppl generally uses.
- lsof
- pfiles
Both the command shows number of files opened not the file descriptors.
Here is example to prove it ,
root# /usr/local/bin/lsof -p 1281
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
oracle 1281 oracle cwd VDIR 85,101 512 29508 /volume1/export/home/oracle/app/product/10.2.0/db_1/dbs
oracle 1281 oracle txt VREG 85,101 111774824 52718 /volume1/export/home/oracle/app/product/10.2.0/db_1/bin/oracle
oracle 1281 oracle txt VREG 85,10 6904 157509 /platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap1.so.1
oracle 1281 oracle txt VREG 85,10 78360 147322 /lib/sparcv9/libmd.so.1
oracle 1281 oracle txt VREG 85,10 789176 147147 /lib/sparcv9/libm.so.2
oracle 1281 oracle txt VREG 85,10 60872 147242 /lib/sparcv9/librt.so.1
oracle 1281 oracle txt VREG 85,10 55408 147208 /lib/sparcv9/libaio.so.1
oracle 1281 oracle txt VREG 85,10 1440632 147211 /lib/sparcv9/libc.so.1
oracle 1281 oracle txt VREG 85,10 11296 147221 /lib/sparcv9/libdl.so.1
oracle 1281 oracle txt VREG 85,10 55016 147225 /lib/sparcv9/libgen.so.1
oracle 1281 oracle txt VREG 85,10 111768 147249 /lib/sparcv9/libsocket.so.1
oracle 1281 oracle txt VREG 85,10 1045928 147234 /lib/sparcv9/libnsl.so.1
oracle 1281 oracle txt VREG 85,10 17320 147228 /lib/sparcv9/libkstat.so.1
oracle 1281 oracle txt VREG 85,101 6955360 23589 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libnnz10.so
oracle 1281 oracle txt VREG 85,101 85344 23444 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libdbcfg10.so
oracle 1281 oracle txt VREG 85,101 2588472 23476 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libclsra10.so
oracle 1281 oracle txt VREG 85,101 12573632 23518 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libjox10.so
oracle 1281 oracle txt VREG 85,101 2588776 23647 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libocrutl10.so
oracle 1281 oracle txt VREG 85,101 2961888 23452 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libocrb10.so
oracle 1281 oracle txt VREG 85,101 3008296 23557 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libocr10.so
oracle 1281 oracle txt VREG 85,101 11264 23607 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libskgxn2.so
oracle 1281 oracle txt VREG 85,101 3534504 23539 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libhasgen10.so
oracle 1281 oracle txt VREG 85,101 163128 23633 /volume1/export/home/oracle/app/product/10.2.0/db_1/lib/libskgxp10.so
oracle 1281 oracle txt VREG 85,10 2896 64408 /usr/lib/sparcv9/libsched.so.1
oracle 1281 oracle txt VREG 85,10 291632 147206 /lib/sparcv9/ld.so.1
oracle 1281 oracle 0u VCHR 13,2 6815752 /devices/pseudo/mm@0:null
oracle 1281 oracle 1u VCHR 13,2 6815752 /devices/pseudo/mm@0:null
oracle 1281 oracle 2u VCHR 13,2 6815752 /devices/pseudo/mm@0:null
oracle 1281 oracle 3r VCHR 13,2 6815752 /devices/pseudo/mm@0:null
oracle 1281 oracle 4r VCHR 13,2 6815752 /devices/pseudo/mm@0:null
oracle 1281 oracle 5r VCHR 13,2 6815752 /devices/pseudo/mm@0:null
oracle 1281 oracle 6r VCHR 13,2 6815752 /devices/pseudo/mm@0:null
oracle 1281 oracle 7u IPv4 0×3001e00c800 0t0 TCP *:* (IDLE)
oracle 1281 oracle 8r VCHR 13,12 6815772 /devices/pseudo/mm@0:zero
oracle 1281 oracle 9r DOOR 0t0 54 /var/run/name_service_door (door to nscd[156]) (FA:->0×60002b9b780)
oracle 1281 oracle 10r VREG 85,101 842240 60371 /volume1/export/home/oracle/app/product/10.2.0/db_1/rdbms/mesg/oraus.msb
oracle 1281 oracle 16u IPv4 0×60014911000 0t1714671 TCP oaxgs36:1521->oaxgs36:60446 (ESTABLISHED)
oracle 1281 oracle 256u VREG 85,105 1073750016 5864 /volume5/export/db1/oradata/xgs/dbf/undotbs01.dbf
oracle 1281 oracle 257u VREG 85,105 8589942784 5867 /volume5/export/db1/oradata/xgs/dbf/stepsysdata_xgs_3.dbf
root# ls -l /proc/1281/fd/
total 18885312
c——— 1 root sys 13, 2 Sep 9 13:13 0
c——— 1 root sys 13, 2 Sep 9 13:13 1
-r–r–r– 1 oracle oinstall 842240 Oct 30 2006 10
s——— 0 root root 0 Sep 7 17:45 16
c——— 1 root sys 13, 2 Sep 9 13:13 2
-rw-r—– 1 oracle oinstall 1073750016 Sep 9 13:13 256
-rw-r—– 1 oracle oinstall 8589942784 Sep 9 13:13 257
c——— 1 root sys 13, 2 Sep 9 13:13 3
c——— 1 root sys 13, 2 Sep 9 13:13 4
c——— 1 root sys 13, 2 Sep 9 13:13 5
c——— 1 root sys 13, 2 Sep 9 13:13 6
s——— 0 root root 0 May 3 09:39 7
c——— 1 root sys 13, 12 Mar 20 11:00 8
D——— 1 root root 0 Mar 20 10:59 9
So though process 1281 has opened number of file but it has only 14 file descriptors opened.
An easy way to iterate through each processes open file descriptors is to just run a simple shell loop, substituting your particular version of ps’s arguments, like:
host # for x in `ps -ef| awk ‘{ print $2 }’`;do ls /proc/$x/fd;done
If you’re only interested in the number of open file descriptors per process, you can shorten that output up even more:
host # for x in `ps -ef| awk ‘{ print $2 }’`;do ls /proc/$x/fd|wc -l;done
Check Shell Limits for Oracle Installation on Solaris ( SPARC )
Oracle has provided one script to check whether OS is meeting pre-requirements or not.Here is script.
========================================
TIMEOK=false
TIME=`/usr/bin/ulimit -t`
if /usr/bin/test -z “$TIME”
then
/usr/bin/echo TimeNotDef
elif [ $TIME != "unlimited" ]
then
/usr/bin/echo TimeTooSmall
else
TIMEOK=true
fi
FILEOK=false
FILE=`/usr/bin/ulimit -f`
if /usr/bin/test -z “$FILE”
then
/usr/bin/echo FileNotDefined
elif [ $FILE != "unlimited" ]
then
/usr/bin/echo FileTooSmall
else
FILEOK=true
fi
DATAOK=false
DATA=`/usr/bin/ulimit -d`
if /usr/bin/test -z “$DATA”
then
/usr/bin/echo DataNotDefined
elif [ $DATA = "unlimited" ]
then
DATAOK=true
elif [ $DATA -ge 1048576 ]
then
DATAOK=true
else
/usr/bin/echo DataTooSmall
fi
STACKOK=false
STACK=`/usr/bin/ulimit -s`
if /usr/bin/test -z “$STACK”
then
/usr/bin/echo StackNotDefined
elif [ $STACK = "unlimited" ]
then
STACKOK=true
elif [ $STACK -ge 32768 ]
then
STACKOK=true
else
/usr/bin/echo StackTooSmall
fi
NOFILESOK=false
NOFILES=`/usr/bin/ulimit -n`
if /usr/bin/test -z “$NOFILES”
then
/usr/bin/echo NoFilesNotDefined
elif [ $NOFILES = "unlimited" ]
then
NOFILESOK=true
elif [ $NOFILES -ge 4096 ]
then
NOFILESOK=true
else
/usr/bin/echo NoFilesTooSmall
fi
VMEMORYOK=false
VMEMORY=`/usr/bin/ulimit -v`
if /usr/bin/test -z “$VMEMORY”
then
/usr/bin/echo VmemoryNotDefined
elif [ $VMEMORY = "unlimited" ]
then
VMEMORYOK=true
elif [ $VMEMORY -ge 4194304 ]
then
VMEMORYOK=true
else
/usr/bin/echo VmemoryTooSmall
fi
if [ $TIMEOK = true -a $FILEOK = true -a $DATAOK = true -a $STACKOK = true -a $NOFILESOK = true -a $VMEMORYOK = true ]
then
/usr/bin/echo ulimitOK
fi
====================================
For more scripts Note:334567.1
-
Recent
- Data Guard Auto startup
- Alert.log Monitoring.
- Tier1 Rule Changes
- Menu Driver ORAENV
- HOW TO APPLY CPU JAN 2009
- Trouble shoot Out Of Memory Error for Oracle
- Users to roles and system privileges
- Enterprise Manager Grid Control ( OMS Problem )
- Data Guard Diagnostic Scripts
- NetApp Too many users logged in! Please try again later.
- MySQL Replication
- Data Guard Broker Setup for MAA Architecture
-
Links
-
Archives
- June 2009 (1)
- March 2009 (2)
- January 2009 (3)
- December 2008 (4)
- November 2008 (4)
- October 2008 (6)
- September 2008 (35)
- August 2008 (3)
-
Categories
-
RSS
Entries RSS
Comments RSS
