Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Tuesday, November 6, 2012

meminfo To know detail Memory information on *nix server


Meminfo provides information about distribution and utilization of memory.  This utilization varies on architecture of server.  All fields may not be there is all server output.

$cat /proc/meminfo

MemTotal:        8062872 kB

MemFree:          927352 kB

Buffers:          225360 kB

Cached:          6142440 kB

SwapCached:            0 kB

Active:           949748 kB

Inactive:        5816904 kB

Active(anon):     330948 kB

Inactive(anon):    68100 kB

Active(file):     618800 kB

Inactive(file):  5748804 kB

Unevictable:           0 kB

Mlocked:               0 kB

SwapTotal:       4194296 kB

SwapFree:        4194296 kB

Dirty:                44 kB

Writeback:             0 kB

AnonPages:        398812 kB

Mapped:            61616 kB

Shmem:               192 kB

Slab:             253172 kB

SReclaimable:     221144 kB

SUnreclaim:        32028 kB

KernelStack:        1936 kB

PageTables:         7340 kB

NFS_Unstable:          0 kB

Bounce:                0 kB

WritebackTmp:          0 kB

CommitLimit:     8225732 kB

Committed_AS:     862100 kB

VmallocTotal:   34359738367 kB

VmallocUsed:      289592 kB

VmallocChunk:   34359440136 kB

HardwareCorrupted:     0 kB

AnonHugePages:    342016 kB

HugePages_Total:       0

HugePages_Free:        0

HugePages_Rsvd:        0

HugePages_Surp:        0

Hugepagesize:       2048 kB

DirectMap4k:       10240 kB

DirectMap2M:     8378368 kB

Here is the detail about some of important parameters

 MemTotal: Total usable RAM (i.e. physical ram minus a few reserved bits and the kernel binary code)
 MemFree:  Free RAM portioan
 Buffers:     Temporary storage for raw disk blocks
Cached:      In-memory cache for files read
SwapCached: Memory that once was swapped out, is swapped back in but still also is in the swapfile (if memory is needed it doesn't need to be swapped out AGAIN because it is already in the swapfile. This saves I/O)
 Active: Memory that has been used more recently and usually not reclaimed unless absolutely necessary.
 Inactive: Memory which has been less recently used.  It is more eligible to be reclaimed for other purposes

SwapTotal: total amount of swap space available
SwapFree: Memory which has been evicted from RAM, and is temporarily on the disk
Dirty: Memory which is waiting to get written back to the disk
Writeback: Memory which is actively being written back to the disk
AnonPages: Non-file backed pages mapped into userspace page tables
Mapped: files which have been mmaped, such as libraries
Slab: in-kernel data structures cache
SReclaimable: Part of Slab, that might be reclaimed, such as caches
SUnreclaim: Part of Slab, that cannot be reclaimed on memory pressure
PageTables: Amount of memory dedicated to the lowest level of page tables.
NFS_Unstable: NFS pages sent to the server, but not yet committed to stable storage
Bounce: Memory used for block device "bounce buffers"
WritebackTmp: Memory used by FUSE for temporary writeback buffers
VmallocTotal: total size of vmalloc memory area
VmallocUsed: amount of vmalloc area which is used
VmallocChunk: largest contiguous block of vmalloc area which is free

Friday, July 20, 2012

Useful UNIX Command For Oracle DBA

How to kill all similar processes with single command (in this case opmn)

ps -ef | grep opmn |grep -v grep | awk ‘{print $2}’ |xargs -i kill -9 {}

Locating Files under a particular directory

find . -print |grep -i test.sql

 Using AWK in UNIX

To remove a specific column of output from a UNIX command – for example to determine the UNIX process Ids for all Oracle processes on server (second column)

ps -ef |grep -i oracle |awk '{ print $2 }'

Changing the standard prompt for Oracle Users

Edit the .profile for the oracle user

PS1="`hostname`*$ORACLE_SID:$PWD>"

 Display top 10 CPU consumers using the ps command

/usr/ucb/ps auxgw | head -11

 Show number of active Oracle dedicated connection users for a particular ORACLE_SID

ps -ef | grep $ORACLE_SID|grep -v grep|grep -v ora_|wc -l

 Display the number of CPU’s in Solaris

psrinfo -v | grep "Status of processor"|wc -l

Display the number of CPU’s in AIX

lsdev -C | grep Process|wc -l

Display RAM Memory size on Solaris

prtconf |grep -i mem

Display RAM memory size on AIX

First determine name of memory device

lsdev -C |grep mem

then assuming the name of the memory device is ‘mem0’

lsattr -El mem0

Swap space allocation and usage

Solaris : swap -s or swap -l

Aix : lsps -a

 Total number of semaphores held by all instances on server

ipcs -as | awk '{sum += $9} END {print sum}'

View allocated RAM memory segments

ipcs -pmb

Manually deallocate shared memeory segments

ipcrm -m ''

 Show mount points for a disk in AIX

lspv -l hdisk13

 Display amount of occupied space (in KB) for a file or collection of files in a directory or sub-directory

du -ks * | sort -n| tail

Display total file space in a directory

du -ks .

 Cleanup any unwanted trace files more than seven days old

find . *.trc -mtime +7 -exec rm {} \;

 Locate Oracle files that contain certain strings

find . -print | xargs grep rollback

 Locate recently created UNIX files (in the past one day)

find . -mtime -1 -print

 Finding large files on the server (more than 100MB in size)

find . -size +102400 -print

Crontab :

To submit a task every Tuesday (day 2) at 2:45PM

45 14 2 * * /opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1

To submit a task to run every 15 minutes on weekdays (days 1-5)

15,30,45 * 1-5 * * /opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1

To submit a task to run every hour at 15 minutes past the hour on weekends (days 6 and 0)

15 * 0,6 * * opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1