From Wiki-UX.info

How to create performance statistics charts
Jump to: navigation, search

How to create performance statistics charts

Contents

SAR Commands

sar

1. Raw sar output

# date; sar 1 5
 
Fri Jun  5 20:55:22 EDT 2009
 
HP-UX nrmdhpp2 B.11.31 U ia64    06/05/09
 
20:55:22    %usr    %sys    %wio   %idle
20:55:23      22      66       4       8
20:55:24      13      73       3      12
20:55:25      20      74       2       4
20:55:26      15      61       4      20
20:55:27      16      82       0       2
 
Average       17      71       3       9 <-- Average sample
...

2. AWK script to format the average results for GNUPLOT presentation

cat sar.out | \
awk 'BEGIN {LINE=1; printf "#Spl   Date      %%usr  %%sys  %%wio\n"; }
 { if ( NF == 5 ) {
  if($1 != "Average") DATE=$1
  if($1 == "Average") {
   printf "%-6d %s %5d %5d %5d\n", LINE, DATE, $2, $3, $4
   LINE++}
   }
 }'

Note that the idle column is removed from the chart. This column does not provided value to the chart since normally overlaps the important information of other columns.

#Spl   Date      %usr  %sys  %wio
1      20:55:27    17    71     3
2      21:00:27    20    71     3
3      21:05:27    37    60     0
4      21:10:27    17    69     2
5      21:15:27    11    68     1
6      21:20:27    14    73     3
7      21:25:27    20    68     1
8      21:30:28    18    78     1
9      21:35:28    11    76     1
10     21:40:28    19    71     1

3. GNUPlot header

<gnuplot>
set size 1, 1
set ylabel "CPU %"
set yrange [0:120]
set xlabel "Samples"
plot '-' using 1:3 title '%usr' with lines, \
     '-' using 1:4 title '%sys' with lines, \
     '-' using 1:5 title '%wio' with lines
<plotdata>
 
</plotdata>
</gnuplot>

4. Gnuplot sar graphic

GnuplotBasic Plot

sar complete script

Automatically generate the sar chart.

cat sar.out | \
awk 'BEGIN {LINE=1; printf "#Spl   Date      %%usr  %%sys  %%wio\n"; }
 { if ( NF == 5 ) {
  if($1 != "Average") DATE=$1
  if($1 == "Average") {
   printf "%-6d %s %5d %5d %5d\n", LINE, DATE, $2, $3, $4
   LINE++}
   }
 }' > sar.avg
 
cat > sar.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "$CPU %"
set yrange [0:120]
set output "sar.png"
plot "sar.avg" using 1:3 title '%usr' with lines, \
     "sar.avg" using 1:4 title '%sys' with lines, \
     "sar.avg" using 1:5 title '%wio' with lines
EOF
 
echo "Plotting sar.png."
/usr/sfw/bin/gnuplot sar.plt 2> /dev/null
 
rm *.plt
mv *.png ./images
mv *.avg ./avg

sar -b

The sar -b offer results off tu different types:

  1. Hit ratio cache
  2. Read and Writes per second

Hit Ratio cache

1. Raw sar -b output

Fri Jun  5 20:55:22 EDT 2009
 
HP-UX nrmdhpp2 B.11.31 U ia64    06/05/09
 
20:55:22 bread/s lread/s %rcache bwrit/s lwrit/s %wcache pread/s pwrit/s
20:55:23       1    1777     100      40     320      88       0       0
20:55:24       0    1456     100      41     263      84       0       0
20:55:25       0    2602     100      42     213      80       0       0
20:55:26       0    2862     100      43     355      88       0       0
20:55:27       0    1042     100      36     203      82       0       0
 
Average        0    1936     100      40     271      85       0       0 <-- Average sample
...

2. AWK script to format the average results for GNUPLOT presentation

cat sarb.out | \
awk 'BEGIN {LINE=1; printf "#Spl Date     %%rcache %%wcache\n"; }
 { if ( NF == 9 ) {
  if($1 != "Average") DATE=$1
  if($1 == "Average") {
   printf "%4d %s %7d %7d\n", LINE, DATE, $4, $7
   LINE++}
   }
 }'
#Spl Date     %rcache %wcache
   1 20:55:27     100      85
   2 21:00:27     100      77
   3 21:05:27     100      70
   4 21:10:27     100      82
   5 21:15:27     100      76
   6 21:20:27     100      58
   7 21:25:28     100      79
   8 21:30:28     100      75
   9 21:35:28     100      85
  10 21:40:28     100      76

3. GNUPlot header

<gnuplot>
set size 1, 1
set ylabel "Cache Hit %"
set yrange [0:120]
set xlabel "Samples"
plot '-' using 1:3 title '%rcache' with lines, \
     '-' using 1:4 title '%wcache' with lines
<plotdata>
 
</plotdata>
</gnuplot>

4. Gnuplot sar graphic

GnuplotBasic Plot

Read and Writes per second

1. Use the previous raw sar -b output

2. AWK script to format the average results for GNUPLOT presentation

cat sarb.out | \
awk 'BEGIN {LINE=1; printf "#Spl Date     bread/s lread/s bwrit/s lwrit/s pread/s pwrit/s\n"; }
 { if ( NF == 9 ) {
  if($1 != "Average") DATE=$1
  if($1 == "Average") {
   printf "%4d %s %7d %7d %7d %7d %7d %7d\n", LINE, DATE, $2, $3, $5, $6, $8, $9
   LINE++}
   }
 }'
#Spl Date     bread/s lread/s bwrit/s lwrit/s pread/s pwrit/s
   1 20:55:27       0    1936      40     271       0       0
   2 21:00:27       0    3882      80     349       0       0
   3 21:05:27       0    1610     105     343       0       0
   4 21:10:27       0    1980      45     250       0       0
   5 21:15:27       0    2518      59     250       0       0
   6 21:20:27       0    2093     151     363       0       0
   7 21:25:28       0    2405      57     268       0       0
   8 21:30:28       0    2894      82     323       0       0
   9 21:35:28       0    2280      47     315       0       0
  10 21:40:28       0    1944      62     259       0       0

3. GNUPlot header

<gnuplot>
set size 1, 1
set ylabel "Blocks per Second"
set xlabel "Samples"
plot '-' using 1:3 title '%bread/s' with lines, \
     '-' using 1:4 title '%lread/s' with lines, \
     '-' using 1:5 title '%bwrit/s' with lines, \
     '-' using 1:6 title '%lwrit/s' with lines, \
     '-' using 1:7 title '%pread/s' with lines, \
     '-' using 1:8 title '%pwrit/s' with lines
<plotdata>
 
</plotdata>
</gnuplot>

4. Gnuplot sar graphic

GnuplotBasic Plot

sar -b complete script

The following scripts Automatically generate the sar -b reads and writes per second chart.

cat sarb.out | \
awk 'BEGIN {LINE=1; printf "#Spl Date     bread/s lread/s %%rcache bwrit/s lwrit/s %%wcache pread/s pwrit/s\n"; }
 { if ( NF == 9 ) {
  if($1 != "Average") DATE=$1
  if($1 == "Average") {
   printf "%-4d %s %7d %7d %7d %7d %7d %7d %7d %7d\n", LINE, DATE, $2, $3, $4, $5, $6, $7, $8, $9
   LINE++}
   }
 }' > sarb.avg
 
cat > sarb.plt<<EOF
set terminal png
set size 1, 1
set ylabel "% Hit Rate"
set yrange [0:120]
set xlabel "Samples"
set output "sarb.png"
plot "sarb.avg" using 1:5 title '%rcache' with lines, \
     "sarb.avg" using 1:8 title '%wcache' with lines
EOF
 
echo "Plotting sarb.png."
/usr/sfw/bin/gnuplot sarb.plt 2> /dev/null
 
cat > sarbs.plt<<EOF
set terminal png
set size 1, 1
set ylabel "Blocks per Second"
set xlabel "Samples"
set output "sarbs.png"
plot "sarb.avg" using 1:3 title '%bread/s' with lines, \
     "sarb.avg" using 1:4 title '%lread/s' with lines, \
     "sarb.avg" using 1:6 title '%bwrit/s' with lines, \
     "sarb.avg" using 1:7 title '%lwrit/s' with lines, \
     "sarb.avg" using 1:9 title '%pread/s' with lines, \
     "sarb.avg" using 1:10 title '%pwrit/s' with lines
EOF
 
echo "Plotting sarbs.png."
/usr/sfw/bin/gnuplot sarbs.plt 2> /dev/null
 
rm *.plt
mv *.png ./images
mv *.avg avg

sar -d

The following is a description of the information provided by the sar -d command:

Report activity for each block device, e.g., disk or tape drive. One line is printed for each device that had activity during the last interval. If no devices were active, a blank line is printed. Each line contains the following data:

device: Logical name of the device and its corresponding instance. Devices are categorized into the following device types:
  • disk3: SCSI and NIO FL disks
  • sdisk: SCSI disks
%busy: Portion of time device was busy servicing a request
avque: Average number of requests outstanding for the device;
r+w/s: Number of data transfers per second (read and writes) from and to the device;
blks/s: Number of bytes transferred (in 512-byte units) from and to the device;
avwait: Average time (in milliseconds) that transfer requests waited idly on queue for the device;
avserv: Average time (in milliseconds) to service each transfer request (includes seek, rotational latency, and data transfer times) for the device.

The way that the data is collected, present some additional level of complexity to create historical performance charts. Data should be process in two in three steps:

  1. Consolidate the data into an average report: during this step, the average disk data is group based on the number sample preserving the date for reference.
  2. Split data per disk: during this step, the previous data is split by individual disk order by the sample.
  3. Chart each disk metric per disk

Consolidate the data into an average report

1. Raw sar -d output

# date; sar -d 1 5
 
Fri Jun  5 20:55:22 EDT 2009
 
sard-20090608.1608.out
Fri Jun  5 20:55:22 EDT 2009
 
HP-UX nrmdhpp2 B.11.31 U ia64    06/05/09
 
20:55:22   device   %busy   avque   r+w/s  blks/s  avwait  avserv
20:55:23    disk1    2.00    0.50       4      82    0.00    4.65
            disk3    3.00    0.50       4      82    0.00    5.85
            disk6    2.00    0.50       4      64    0.00    5.99
            disk7    4.00    0.50      20     432    0.00    3.36
            disk8    1.00    0.50       3    1440    0.00    1.24
            disk9    9.00    0.50      33     528    0.00    2.97
           disk10    6.00    0.50       4      64    0.00   14.94
           disk12    5.00    0.50      32     512    0.00    1.35
           disk13    1.00    0.50      13     144    0.00    0.32
           disk14    2.00    0.50       5      80    0.00    3.25
           disk16    6.00    0.50      20     320    0.00    3.05
           disk18    7.00    0.50      15     240    0.00    4.66
20:55:24    disk1    6.60    0.50      14     232    0.00    9.86
            disk3    3.77    0.50       7     164    0.00    8.56
            disk6    1.89    0.50       3      45    0.00    3.56
            disk9    6.60    0.50      22     347    0.00    2.83
           disk10    0.94    0.50       1      15    0.00    6.32
           disk12    4.72    0.50      21     332    0.00    2.62
           disk15    0.94    0.50      10     166    0.00    0.68
           disk16    2.83    0.50      10     166    0.00    2.81
           disk17    0.94    0.50      11     151    0.00    0.44
           disk18    2.83    0.50       8     121    0.00    4.75
20:55:25    disk1    3.16    0.50       4     162    0.00    7.70
            disk3    2.11    0.50       4     162    0.00    7.52
            disk9    6.32    0.50      23     371    0.00    2.92
           disk11    2.11    0.50      12     168    0.00    1.35
           disk12    3.16    0.50      20     320    0.00    1.16
           disk13    1.05    0.50       6      76    0.00    0.64
           disk14    1.05    0.50       3      51    0.00    1.82
           disk16    5.26    0.50      13     202    0.00    4.11
           disk18    5.26    0.50      12     185    0.00    4.52
20:55:26    disk1    4.00    0.50       8     162    0.00    5.53
            disk3    4.00    0.50       6     154    0.00    6.17
            disk5    1.00    0.50       5    2852    0.00    1.09
            disk6    2.00    0.50       5      80    0.00    5.04
            disk9   10.00    0.50      46     736    0.00    2.05
           disk10    2.00    0.50       4      64    0.00    4.24
           disk12    2.00    0.50      25     400    0.00    1.02
           disk14    1.00    0.50       2      32    0.00    6.48
           disk16    5.00    0.50      14     224    0.00    3.14
           disk18   10.00    0.50      22     352    0.00    4.33
           disk19    1.00    0.50      15     192    0.00    0.45
20:55:27    disk1    3.96    0.50       8     111    0.00    4.38
            disk3    3.96    0.50       8     111    0.00    4.49
            disk5    0.99    0.50      10    1446    0.00    0.62
            disk6    1.98    0.50       3      48    0.00    7.49
            disk9    2.97    0.50      16     253    0.00    2.27
           disk10    0.99    0.50       3      48    0.00    5.89
           disk14    0.99    0.50       2      32    0.00    5.02
           disk16    0.99    0.50       5      79    0.00    1.72
           disk18    2.97    0.50       7     111    0.00    4.69
 
Average     disk1    3.98    0.50       8     151    0.00    7.09 <-- Average sample
Average     disk3    3.39    0.50       6     135    0.00    6.43
Average     disk6    1.59    0.50       3      48    0.00    5.49
Average     disk7    0.80    0.50       4      86    0.00    3.36
Average     disk8    0.20    0.50       1     287    0.00    1.24
Average     disk9    6.97    0.50      28     446    0.00    2.56
Average    disk10    1.99    0.50       2      38    0.00    8.39
Average    disk12    2.99    0.50      20     312    0.00    1.52
Average    disk13    0.40    0.50       4      43    0.00    0.42
Average    disk14    1.00    0.50       2      38    0.00    3.73
Average    disk16    3.98    0.50      12     198    0.00    3.12
Average    disk18    5.58    0.50      13     201    0.00    4.53
Average    disk15    0.20    0.50       2      35    0.00    0.68
Average    disk17    0.20    0.50       2      32    0.00    0.44
Average    disk11    0.40    0.50       2      32    0.00    1.35
Average     disk5    0.40    0.50       3     859    0.00    0.78
Average    disk19    0.20    0.50       3      38    0.00    0.45
...

2. AWK script to consolidate the data into a single report sard.avg file

cat sard.out | \
# echo "#Spl    Time        device   %busy   avque   r+w/s  blks/s  avwait  avserv"; cat sard.out | \
awk 'BEGIN {COUNT=0}
 { if ( NF == 8 ) {  
  if($1 != "Average") TIME=$1
  if($1 == "Average") {
   printf "%-6d %8s %9s %7.2f %7.2f %7d %7d %7d %7d\n", COUNT, TIME, $2, $3, $4, $5, $6, $7, $8
   }
  }
 if($1 == "HP-UX") COUNT++
 }' > sard.avg
echo "#Spl    Time        device   %busy   avque   r+w/s  blks/s  avwait  avserv"; cat sard.avg
#Spl   Time        device   %busy   avque   r+w/s  blks/s  avwait  avserv
1      20:55:27     disk1    3.98    0.50       8     151       0       7
1      20:55:27     disk3    3.39    0.50       6     135       0       6
1      20:55:27     disk6    1.59    0.50       3      48       0       5
1      20:55:27     disk7    0.80    0.50       4      86       0       3
1      20:55:27     disk8    0.20    0.50       1     287       0       1
1      20:55:27     disk9    6.97    0.50      28     446       0       2
1      20:55:27    disk10    1.99    0.50       2      38       0       8
1      20:55:27    disk12    2.99    0.50      20     312       0       1
1      20:55:27    disk13    0.40    0.50       4      43       0       0
1      20:55:27    disk14    1.00    0.50       2      38       0       3
1      20:55:27    disk16    3.98    0.50      12     198       0       3
1      20:55:27    disk18    5.58    0.50      13     201       0       4
1      20:55:27    disk15    0.20    0.50       2      35       0       0
1      20:55:27    disk17    0.20    0.50       2      32       0       0
1      20:55:27    disk11    0.40    0.50       2      32       0       1
1      20:55:27     disk5    0.40    0.50       3     859       0       0
1      20:55:27    disk19    0.20    0.50       3      38       0       0
2      21:00:27     disk1    3.99    1.83       8     115       5      18
2      21:00:27     disk3    3.79    1.50       7     113       6      21
2      21:00:27     disk6    2.59    0.50       3      54       0       6
2      21:00:27     disk7    2.20    0.50      29     323       0       0
2      21:00:27     disk9    6.79    0.50      11     182       0       5
2      21:00:27    disk10    5.79    0.50       9     147       0       6
2      21:00:27    disk11    2.99    0.50      18     533       0       2
2      21:00:27    disk12    6.79    0.50      10     163       0       6
2      21:00:27    disk13    3.19    0.50      25    1110       0       1
2      21:00:27    disk14    4.19    0.50       6      93       0       7
2      21:00:27    disk16    4.19    0.50       8     121       0       5
2      21:00:27    disk18    2.79    0.50       4      64       0       7
2      21:00:27    disk19    1.20    0.50      24     228       0       0
2      21:00:27     disk8    0.40    0.50       3      28       0       0
2      21:00:27    disk15    0.60    0.50       5     236       0       0
2      21:00:27    disk17    0.20    0.50       1      16       0       0
2      21:00:27    disk21    0.40    0.50       2      51       0       0
2      21:00:27     disk5    0.20    0.50       2      14       0       0
...

Split data per disk:

Once you have consolidate the average samples per disk, proceed to create individual disk reports. This step will split the sample data by each individual disk of the report.

The following script will create .sard files for each disk in the report.

for device in `sort -k 3,3 sard.avg | \
awk 'BEGIN {DEVICE="foo"} {if ($3 != DEVICE) {printf "%s ", $3; DEVICE = $3 }}'`
do
echo "Exporting $device..."
echo "#Spl   Time        device   %busy   avque   r+w/s  blks/s  avwait  avserv" > $device.sard
/usr/xpg4/bin/awk -v disk="$device" '$3 == disk {print $0}' sard.avg >> $device.sard
done
# head -n 11 disk1.sard
#Spl   Time        device   %busy   avque   r+w/s  blks/s  avwait  avserv
1      20:55:27     disk1    3.98    0.50       8     151       0       7
2      21:00:27     disk1    3.99    1.83       8     115       5      18
3      21:05:27     disk1    5.79    0.50       9     129       0      10
4      21:10:27     disk1    4.38    0.50       7     113       0       7
5      21:15:27     disk1    7.97    1.01      13     177       2      16
6      21:20:27     disk1    8.22    0.50      11     170       0      11
7      21:25:27     disk1   10.38    0.76      16     206       2      16
8      21:30:28     disk1    7.16    0.68      13     217       1      15
9      21:35:28     disk1    8.98    0.72      16     245       1      14
10     21:40:28     disk1    7.40    1.63      12     168       4      20

sar -d complete script

# The following scripts create png charts based on .sard files reports
# using gnuplot utilitiities. Designed for Solaris 10.
#
# Create consolidate report
cat sard.out | \
# echo "#Spl    Time        device   %busy   avque   r+w/s  blks/s  avwait  avserv"; cat sard.out | \
awk 'BEGIN {COUNT=0}
 { if ( NF == 8 ) {  
  if($1 != "Average") TIME=$1
  if($1 == "Average") {
   printf "%-6d %8s %9s %7.2f %7.2f %7d %7d %7d %7d\n", COUNT, TIME, $2, $3, $4, $5, $6, $7, $8
   }
  }
 if($1 == "HP-UX") COUNT++
 }' > sard.avg
 
#Split date per disk
for device in `sort -k 3,3 sard.avg | \
awk 'BEGIN {DEVICE="foo"} {if ($3 != DEVICE) {printf "%s ", $3; DEVICE = $3 }}'`
do
echo "Exporting $device..."
echo "#Spl   Time        device   %busy   avque   r+w/s  blks/s  avwait  avserv" > $device.sard
awk -v disk="$device" '$3 == disk {print $0}' sard.avg >> $device.sard
done
 
# Process individual disks reports
for device in `ls *.sard | awk -F"." '{print $1}' | sort`
do
 
# BUSY
cat > busy.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set yrange [0:100]
set ylabel "${device}"
set output "${device}-busy.png"
plot "$device.sard" using 1:4 title "%busy" with lines
EOF
 
echo "Plotting ${device}-busy.png."
gnuplot busy.plt 2> /dev/null
 
# AVQUE
cat > avque.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "${device}"
set output "${device}-avque.png"
plot "$device.sard" using 1:5 title "avque" with lines
EOF
 
echo "Plotting ${device}-avque.png."
gnuplot avque.plt 2> /dev/null
 
# R+W/S
cat > rw.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "${device}"
set output "${device}-rw.png"
plot "$device.sard" using 1:6 title "r+w/s" with lines
EOF
 
echo "Plotting ${device}-rw.png."
gnuplot rw.plt 2> /dev/null
 
# BLKS/S
cat > blks.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "${device}"
set output "${device}-blks.png"
plot "$device.sard" using 1:7 title "blks/s" with lines
EOF
 
echo "Plotting ${device}-blks.png."
gnuplot blks.plt 2> /dev/null
 
# AVWAIT
cat > avwait.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "${device}"
set output "${device}-avwait.png"
plot "$device.sard" using 1:8 title "avwait/s" with lines
EOF
 
echo "Plotting ${device}-avwait.png."
gnuplot avwait.plt 2> /dev/null
 
# AVSERV
cat > avserv.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "${device}"
set output "${device}-avserv.png"
plot "$device.sard" using 1:9 title "avserv/s" with lines
EOF
 
echo "Plotting ${device}-avserv.png."
gnuplot avserv.plt 2> /dev/null
 
done
 
rm *.plt *.sard
mv *.png ./images/sard
mv *.avg ./avg

The script may create a very larger number for charts, directly proportional to the number of disks in the report. The following sard.tar archive contains an chart dataset.

sar -c

The following is a description of the information provided by the sar -c command:

Report system calls:

scall/s: Number of system calls of all types per second;
sread/s: Number of read() and/or readv() system calls per second;
swrit/s: Number of write() and/or writev() system calls per second;
fork/s: Number of fork() and/or vfork() system calls per second;
exec/s: Number of exec() system calls per second;
rchar/s: Number of characters transferred by read system calls block devices only) per second;
wchar/s: Number of characters transferred by write system calls (block devices only) per second.

The values reported by the rchar/s and wchar/s are normally one or two orders of magnitud of the other values, what requires presenting the information in different charts.

1. Raw sar -c output

# date; sar 1 5
 
Wed Jun 10 19:18:08 EDT 2009
 
HP-UX nrmdhpp2 B.11.31 U ia64    06/10/09
 
19:18:08 scall/s  sread/s  swrit/s   fork/s   exec/s  rchar/s  wchar/s
19:18:09   30585      983      184    13.59    11.65  13532706  1617522
19:18:10   26330      898      159    15.00    10.00  7673856  1367040
19:18:11   30216     1739      768    20.00    12.00  15409152  1158144
19:18:12   38325     1326      279    33.66    27.72  15265711  1140594
19:18:13   35814     1857      437    77.55    64.29  13718466  1380310
 
Average    32242     1356      364    31.67    24.90  13123904  1333852 <-- Average sample

2. AWK script to format the average results for GNUPLOT presentation

cat sarc.out | \
awk 'BEGIN {LINE=1; printf "#Spl   Time      scall/s  sread/s  swrit/s   fork/s   exec/s  rchar/s  wchar/s\n"; }
 { if ( NF == 8 ) {
  if($1 != "Average") TIME=$1
  if($1 == "Average") {
   printf "%-6d %8s %8d %8d %8d %8.2d %8.2d %8d %8d\n", LINE, TIME, $2, $3, $4, $5, $6, $7, $8
   LINE++}
   }
 }'
#Spl   Time      scall/s  sread/s  swrit/s   fork/s   exec/s  rchar/s  wchar/s
1      19:18:13    32242     1356      364       31       24 13123904  1333852
2      19:23:13    64828     2222      658       33       26 21726348  1620005
3      19:28:13    47705     1885      510       33       24 24916168  1943556
4      19:33:13   120609     5039     2585       26       18 21815508  1928907
5      19:38:13    74022     2791     1065       27       22 18381910  2164854
6      19:43:13    62038     2582      700       34       30 24414512  1897556
7      19:48:14    76830     3624     1295       50       46 20951199  1933107
8      19:53:14    26990     1111      235       14       08 11147013  1007681
9      19:58:14    29286     1200      259       18       12 11402994  1028905
10     20:03:14    39758     1565      361       25       18 18473904  1596379

3. GNUPlot headers

<gnuplot>
set size 1, 1
set ylabel "Blocks per Second"
set xlabel "Samples"
plot '-' using 1:3 title 'scall/s' with lines, \
     '-' using 1:4 title 'sread/s' with lines, \
     '-' using 1:5 title 'swrit/s' with lines, \
     '-' using 1:6 title 'fork/s' with lines, \
     '-' using 1:7 title 'exec/s' with lines
<plotdata>
 
</plotdata>
</gnuplot>
<gnuplot>
set size 1, 1
set ylabel "Blocks per Second"
set xlabel "Samples"
plot '-' using 1:8 title 'rchar/s' with lines, \
     '-' using 1:9 title 'wchar/s' with lines
<plotdata>
 
</plotdata>
</gnuplot>

4. Gnuplot sar -c charts:

GnuplotBasic Plot

GnuplotBasic Plot

sar -c complete script

# The following scripts create png charts based on sar -c HP-UX outputs
# Designed for Solaris 10.
#
# Create consolidate report
cat sarc.out | \
awk 'BEGIN {LINE=1; printf "#Spl   Time      scall/s  sread/s  swrit/s   fork/s   exec/s  rchar/s  wchar/s\n"; }
 { if ( NF == 8 ) {
  if($1 != "Average") TIME=$1
  if($1 == "Average") {
   printf "%-6d %8s %8d %8d %8d %8.2d %8.2d %8d %8d\n", LINE, TIME, $2, $3, $4, $5, $6, $7, $8
   LINE++}
   }
 }' > sarc.avg
 
# CALLS
cat > calls.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "Calls per Second"
set output "sarc-calls.png"
plot "sarc.avg" using 1:3 title 'scall/s' with lines, \
     "sarc.avg" using 1:4 title 'sread/s' with lines, \
     "sarc.avg" using 1:5 title 'swrit/s' with lines, \
     "sarc.avg" using 1:6 title 'fork/s' with lines, \
     "sarc.avg" using 1:7 title 'exec/s' with lines
EOF
 
echo "Plotting sarc-calls.png."
/usr/sfw/bin/gnuplot calls.plt 2> /dev/null
 
# CHARACTERS
cat > characters.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set ylabel "Characters per Second"
set output "sarc-characters.png"
plot "sarc.avg" using 1:8 title 'rchar/s' with lines, \
     "sarc.avg" using 1:9 title 'wchar/s' with lines
EOF
 
echo "Plotting sarc-characters.png."
/usr/sfw/bin/gnuplot characters.plt 2> /dev/null
 
rm *.plt
mv *.png ./images
mv *.avg ./avg

sar -w

The following is a description of the information provided by the sar -w command:

Report system swapping and switching activity:

swpin/s: Number of process swapins per second
swpot/s: Number of process swapouts per second
bswin/s: Number of 512-byte units transferred for swapins per second
bswot/s: Number of 512-byte units transferred for swapouts per second
pswch/s: Number of process context switches per second.

1. Raw sar -w output

# date; sarw.out
Wed Jun 10 19:18:08 EDT 2009
 
HP-UX nrmdhpp2 B.11.31 U ia64    06/10/09
 
19:18:08 swpin/s bswin/s swpot/s bswot/s pswch/s
19:18:09    0.00     0.0    0.00     0.0    2369
19:18:10    0.00     0.0    0.00     0.0    2131
19:18:11    0.00     0.0    0.00     0.0    2309
19:18:12    0.00     0.0    0.00     0.0    2991
19:18:13    0.00     0.0    0.00     0.0    2701
 
Average     0.00     0.0    0.00     0.0    2501 <-- Average sample

2. AWK script to format the average results for GNUPLOT presentation

cat sarw.out | \
awk 'BEGIN {LINE=1; printf "#Spl   Time     swpin/s bswin/s swpot/s bswot/s pswch/s\n"; }
 { if ( NF == 6 ) {
  if($1 != "Average") TIME=$1
  if($1 == "Average") {
   printf "%-6d %8s %7.2f %7.2f %7.2f %7.2f %7d\n", LINE, TIME, $2, $3, $4, $5, $6
   LINE++}
   }
 }'
#Spl   Time     swpin/s bswin/s swpot/s bswot/s pswch/s
1      19:18:13    0.00    0.00    0.00    0.00    2501
2      19:23:13    0.00    0.00    0.00    0.00    5959
3      19:28:13    0.00    0.00    0.00    0.00    4785
4      19:33:13    0.00    0.00    0.00    0.00    9329
5      19:38:13    0.00    0.00    0.00    0.00    6921
6      19:43:13    0.00    0.00    0.00    0.00    5346
7      19:48:14    0.00    0.00    0.00    0.00    6415
8      19:53:14    0.00    0.00    0.00    0.00    2376
9      19:58:14    0.00    0.00    0.00    0.00    2637
10     20:03:14    0.00    0.00    0.00    0.00    3326

3. GNUPlot headers

<gnuplot>
set size 1, 1
set ylabel "Blocks per Second"
set xlabel "Samples"
plot '-' using 1:3 title 'swpin/s' with lines, \
     '-' using 1:4 title 'bswin/s' with lines, \
     '-' using 1:5 title 'swpot/s' with lines, \
     '-' using 1:6 title 'bswot/s' with lines, \
     '-' using 1:7 title 'pswch/s' with lines
<plotdata>
 
</plotdata>
</gnuplot>

4. Gnuplot sar -c charts:

GnuplotBasic Plot

sar -w complete script

# The following scripts create png charts based on sar -c HP-UX outputs
# Designed for Solaris 10.
#
# Create consolidate report
cat sarw.out | \
awk 'BEGIN {LINE=1; printf "#Spl   Time     swpin/s bswin/s swpot/s bswot/s pswch/s\n"; }
 { if ( NF == 6 ) {
  if($1 != "Average") TIME=$1
  if($1 == "Average") {
   printf "%-6d %8s %7.2f %7.2f %7.2f %7.2f %7d\n", LINE, TIME, $2, $3, $4, $5, $6
   LINE++}
   }
 }' > sarw.avg
 
cat > calls.plt<<EOF
set terminal png
set size 1,1
set xlabel "Samples"
set output "sarw.png"
plot "sarw.avg" using 1:3 title 'swpin/s' with lines, \
     "sarw.avg" using 1:4 title 'bswin/s' with lines, \
     "sarw.avg" using 1:5 title 'swpot/s' with lines, \
     "sarw.avg" using 1:6 title 'bswot/s' with lines, \
     "sarw.avg" using 1:7 title 'pswch/s' with lines
EOF
 
echo "Plotting sarw.png."
/usr/sfw/bin/gnuplot calls.plt 2> /dev/null
 
rm *.plt
mv *.png ./images
mv *.avg ./avg

Reference

Authors

This page was last modified on 21 September 2009, at 18:12. This page has been accessed 4,183 times.