Useful command Unix Part 2


sar command :

The sar command is useful to monitor performance for cpu, memory and i/o.


#sar -u 2 6
SunOS testing 5.10 Generic_150400-11 sun4u    09/22/2015

11:14:42    %usr    %sys    %wio   %idle
11:14:44      11       3       0      86
11:14:46      20       2       0      79
11:14:48      21       4       0      75
11:14:50      20       3       0      76
11:14:52      17       4       0      79
11:14:55      16       1       0      83

Average       18       3       0      80



Display the accumulated time CPU usage for every 2 seconds and 6 times. You should focus on %idle to see cpu load, when higher less cpu load.


#sar -r 2 6

Display memory free and used every 2 second and 5 times. You should focus on kbmemfree and kbmemused for free and used memory.


SunOS testing 5.10 Generic_150400-11 sun4u    09/22/2015

11:16:02 freemem freeswap
11:16:04 1298575  4204592
11:16:06 1298238  4199072
11:16:08 1298502  4211904
11:16:10 1298812  4219800
11:16:12 1298712  3923088
11:16:14 1298294  4202832

Average  1298522  4160215



freemem :The average number of memory pages that are available to user processes over the intervals sampled by the command. Page size is machine-dependent.

freeswap :The number of 512-byte disk blocks that are available for page swapping.




#sar -d 1 1

SunOS testing 5.10 Generic_150400-11 sun4u    09/22/2015

11:27:36   device        %busy   avque   r+w/s  blks/s  avwait  avserv

11:27:37   md10              0     0.0       0       0     0.0     0.0
           md11              0     0.0       0       0     0.0     0.0
           md12              0     0.0       0       0     0.0     0.0
           md20              0     0.0       0       0     0.0     0.0
           md21              0     0.0       0       0     0.0     0.0
           md22              0     0.0       0       0     0.0     0.0
           md50              0     0.0       0       0     0.0     0.0
           md51              0     0.0       0       0     0.0     0.0
           md52              0     0.0       0       0     0.0     0.0
           ssd172            7     0.3      53   13003     0.0     5.1
           ssd172,a          7     0.3      53   13003     0.0     5.1
           ssd172,h          0     0.0       0       0     0.0     0.0
           ssd173            8     0.3      56   13770     0.0     5.6
           ssd173,a          8     0.3      56   13770     0.0     5.6
           ssd198            7     0.3      48   11581     0.0     5.8
           ssd198,a          7     0.3      48   11581     0.0     5.8
           ssd198,h          0     0.0       0       0     0.0     0.0
           ssd199            6     0.2      19    4451     0.0    10.2
           ssd199,a          6     0.2      19    4451     0.0    10.2
           ssd199,h          0     0.0       0       0     0.0     0.0
           ssd200            7     0.2      24    5785     0.0    10.2
           ssd200,a          7     0.2      24    5785     0.0    10.2
           ssd200,h          0     0.0       0       0     0.0     0.0
           ssd201            6     0.2      27    6306     0.0     7.9
           ssd201,a          6     0.2      27    6306     0.0     7.9
           ssd201,h          0     0.0       0       0     0.0     0.0


device :Name of the disk device that is being monitored.

%busy : Portion of time the device was busy servicing a transfer request.

avque :Average number of requests during the time the device was busy servicing a transfer request.

r+w/s : Number of read-and-write transfers to the device, per second.

blks/s :Number of 512-byte blocks that are transferred to the device, per second.

avwait : Average time, in milliseconds, that transfer requests wait idly in the queue. This time is measured only when the queue is occupied.

avserv : Average time, in milliseconds, for a transfer request to be completed by the device. For disks, this value includes seek times, rotational latency times, and data transfer times.




Run queue and load average

#sar -q 2 10

SunOS testing 5.10 Generic_150400-11 sun4u    09/22/2015

11:38:20 runq-sz %runocc swpq-sz %swpocc
11:38:22     0.0       0     0.0       0
11:38:24     0.0       0     0.0       0
11:38:26     1.0      50     0.0       0
11:38:28     0.0       0     0.0       0
11:38:30     0.0       0     0.0       0
11:38:32     1.0     100     0.0       0
11:38:34     0.0       0     0.0       0
11:38:36     0.0       0     0.0       0
11:38:38     0.0       0     0.0       0
11:38:40     0.0       0     0.0       0

Average      1.0      15     0.0       0

runq-sz :The number of kernel threads in memory that are waiting for a CPU to run. Typically, this value should be less than 2. Consistently higher values mean that the system might be CPU-bound.

%runocc : The percentage of time that the dispatch queues are occupied.

swpq-sz :The average number of swapped out processes.

%swpocc : The percentage of time in which the processes are swapped out.



vmstat command


It reports virtual memory statistics and information about system such CPU load, paging, number of context switches, device interrupts, and system calls.

#vmstat 1 10
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr m1 m1 m1 m2   in   sy   cs us sy id
 0 0 0 3018960 11074136 287 2847 12 1 1 0 0 2  2  2  0 9683 127596 10864 11 2 86
 0 0 0 2853144 11063040 587 3798 0 0 0 0 0  8  8  8  0 7337 142371 8786 11 5 84
 0 0 0 2856896 11062448 246 2380 0 0 0 0 0 572 565 565 0 9702 154293 9603 10 5 84
 0 0 0 2868656 11072240 128 1049 0 0 0 0 0  0  0  0  0 9120 67693 8971 10 3 87
 0 0 0 2877528 11075584 556 3388 0 0 0 0 0  0  0  0  0 10365 67070 10940 10 3 86
 0 0 0 2879544 11077112 845 5165 0 0 0 0 0  0  0  0  0 9117 80853 9544 12 4 84
 0 0 0 2879576 11075872 1093 4269 0 0 0 0 0 0  0  0  0 8529 62231 8661 7  6 87
 0 0 0 2873152 11071664 484 3636 0 0 0 0 0  0  0  0  0 13477 88267 17654 10 3 86
 0 0 0 2878416 11076648 225 1691 0 0 0 0 0  0  0  0  0 6958 95083 7749 12 2 86
 0 0 0 2882112 11078760 164 1618 0 0 0 0 0  0  0  0  0 8933 70594 9502 11 2 88



Refresh the information each one seconds, focus on first column "r", if it value exceed the the number of CPUs on the server this means that task are forced to wait for executed.

r : The number of kernel threads in the dispatch queue
b : The number of blocked kernel threads that are waiting for resources
w : The number of swapped out LWPs that are waiting for processing resources to finish
swap : Available swap space
free : Size of the free list
re : Pages reclaimed
mf : Minor faults and major faults
pi : Kbytes paged in
po : Kbytes paged out
fr : Kbytes freed
de : Anticipated memory that is needed by recently swapped-in processes
sr : Pages scanned by the page daemon not currently in use. If sr does not equal zero, the page daemon has been running.
in : Interrupts per second
sy : System calls per second
cs : CPU context switch rate
us : User time
sy : System time
id : Idle time





 





Comments