Saturday, March 22, 2014

Unix - Memory and Disk Usages

  • Statistics of process, virtual memory, disk, trap and cpu activity:

    # vmstat -m

             Type InUse MemUse HighUse Requests  Size(s)
           USBdev    32     3K       -       50  32,64,128,256,2048
              USB    56    18K       -       95  16,32,64,128,512,2048,4096
           isadev    10     1K       -       10  64
         ppbusdev     3     1K       -        3  128
             cdev     7     1K       -        7  128
          entropy  1024    64K       -     1024  64
            sigio     1     1K       -        1  32
         filedesc    46    12K       -   291905  16,32,256,512,2048
          kdtrace   248    54K       -   273670  64,256
             kenv    83     7K       -       92  16,32,64,128,4096
    ...
    

  • Swap memory usage

    # swapinfo

    Device          1K-blocks     Used    Avail Capacity
    /dev/ada0p3       4194304      424  4193880     0%

  • Top processes on the system

    # top -d1

    last pid: 73598;  load averages:  0.00,  0.00,  0.00                                                                           
    26 processes:  1 running, 25 sleeping
    CPU:     % user,     % nice,     % system,     % interrupt,     % idle
    Mem: 114M Active, 1683M Inact, 234M Wired, 121M Cache, 91M Buf, 843M Free
    Swap: 4096M Total, 424K Used, 4095M Free
    
      PID USER  THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU COMMAND
     1130 root    1  20    0 11296K  2944K select  0   0:39  0.00% sendmail
     1137 root    1  20    0  9584K  1380K nanslp  0   0:10  0.00% cron
     1003 root    1  20    0  9544K  1300K select  1   0:05  0.00% syslogd
    70226 vijay   1  20    0 15852K  4200K select  1   0:03  0.00% sshd
    70186 root    1  20    0 15852K  3992K select  0   0:03  0.00% sshd
      928 root    1  29    0  9544K  1364K select  0   0:02  0.00% dhclient
      966 _dhcp   1  20    0  9544K  1408K select  1   0:01  0.00% dhclient
      813 root    1  20    0 12132K  2868K select  1   0:01  0.00% devd
     1133 smmsp   1  20    0 11296K  2816K pause   1   0:01  0.00% sendmail
    71182 root    1  20    0 11256K  2940K select  1   0:01  0.00% ntpd
    70223 root    1  20    0 15852K  4056K select  1   0:00  0.00% sshd
     1127 root    1  20    0 13096K  3148K select  1   0:00  0.00% sshd
    70189 root    1  20    0 10864K  3188K pause   0   0:00  0.00% csh
     1183 root    1  20   -4 10092K  1868K ttyin   1   0:00  0.00% login
    73598 root    1  20    0  9872K  2008K CPU1    1   0:00  0.00% top
     1185 root    1  52    0  9544K  1240K ttyin   1   0:00  0.00% getty
     1187 root    1  52    0  9544K  1240K ttyin   1   0:00  0.00% getty
     1189 root    1  52    0  9544K  1240K ttyin   0   0:00  0.00% getty
     1188 root    1  52    0  9544K  1240K ttyin   0   0:00  0.00% getty
    ...
    

  • Finding size of folders (total size of files and subfolders underneath)

    • # du –sh myfolder

    • # du –sh * => Size of all the folders in the current directory

    • # du –sk | sort –n => Size of folders, sorted by size (k  kilo byte. h gives false sorting results)