Pages

Saturday, August 25, 2007

Linux check memory usage

Free command

Display free memory size in MB:
[root@ofdev ~]#free -m

Output:

             total       used       free     shared    buffers     cached
Mem:           750        625        125          0         35        335
-/+ buffers/cache:        254        496
Swap:          956          0        956

Displays a line containing the totals memory in MB:

[root@ofdev ~]#free -t -m

Output:

    total       used       free     shared    buffers     cached
Mem:           750        625        125          0         35        335
-/+ buffers/cache:        253        496
Swap:          956          0        956
Total:        1707        625       1082

Top command

Type top command at shell prompt:
[root@ofdev ~]#top


Current memory usage command

[root@ofdev ~]#free -m | grep "Mem:" | awk '{ print "Total memory (used+free): " $3 " + " $4 " = " $2 }'
 

Find Out The Top 10 Memory Consuming Process

[root@ofdev ~]#ps -auxf | sort -nr -k 4 | head -10  

PID  & IP address 

process Id and commands in a hierarchy this command will gives output of the pid that connected programs 
remote ipaddress  
 
[root@ofdev ~]#ps -e -o pid,args --forest
 
output should be
29660 /usr/libexec/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf-ior-fd=19
29661 /usr/libexec/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_NotificationAreaApplet_Factory --oaf-ior-fd=28
29663 /usr/libexec/gdm-user-switch-applet --oaf-activate-iid=OAFIID:GNOME_FastUserSwitchApplet_Factory --oaf-ior-fd=34
27712 gnome-terminal
27713  \_ gnome-pty-helper
27714  \_ bash
27837  |   \_ vi printer
28485  \_ bash
27831 /usr/libexec/gvfsd-metadata
28938 /usr/libexec/gvfsd-metadata
 3163 cupsd -C /etc/cups/cupsd.conf
18552 /u01/finsys/apps/tech_st/10.1.2/bin/frmweb server webfile=HTTP-0,0,1,default,192.168.100.58 

Display memory map

[root@ofdev ~]#pmap 5732
 
output should be
0000000000400000    248K r-x--  /usr/sbin/hald
000000000063d000     16K rw---  /usr/sbin/hald
0000000000641000      8K rw---    [ anon ]
0000000000840000      8K rw---  /usr/sbin/hald
0000000018b0d000   1908K rw---    [ anon ]
00000038f8800000    112K r-x--  /lib64/ld-2.5.so
00000038f8a1b000      4K r----  /lib64/ld-2.5.so
00000038f8a1c000      4K rw---  /lib64/ld-2.5.so
00000038f8c00000   1332K r-x--  /lib64/libc-2.5.so
 
[root@ofdev ~]#pmap -x 5732
 
output should be 
 
00002b145cbbd000       8       -       -       - rw---    [ anon ]
00002b145cbbf000      28       -       -       - r--s-  gconv-modules.cache
00002b145cbcf000      24       -       -       - rw---    [ anon ]
00002b145cbd5000      40       -       -       - r-x--  libnss_files-2.5.so
00002b145cbdf000    2044       -       -       - -----  libnss_files-2.5.so
00002b145cdde000       4       -       -       - r----  libnss_files-2.5.so
00002b145cddf000       4       -       -       - rw---  libnss_files-2.5.so
00002b145cde0000     964       -       -       - rw---    [ anon ]
00007fff3fb08000      84       -       -       - rw---    [ stack ]
ffffffffff600000    8192       -       -       - -----    [ anon ]
----------------  ------  ------  ------  ------
total kB           39764       -       -       -
 

 


No comments:

Post a Comment