snapshot_script
Upload User: kvgkvg
Upload Date: 2015-05-07
Package Size: 1129k
Code Size: 8k
Development Platform:

C/C++

  1. #!/bin/sh
  2. #set -x
  3. #
  4. # This is a script to generate a quick "snapshot" of performance for a
  5. # pair of nodes. At first, it will perform the following tests:
  6. #
  7. # TCP Stream test with 56KB socket buffers and 4KB sends
  8. # TCP Stream test with 32KB socket buffers and 4KB sends
  9. # TCP Request/Response test with 1 byte requests and 1 byte responses
  10. # UDP Request/Response test with 1 byte requests and 1 byte responses
  11. # UDP Request/Response test with 516 byte requests and 4 byte responses
  12. # UDP Stream test with 32KB socket buffers and 4KB sends
  13. # UDP Stream test with 32KB socket buffers and 1KB sends
  14. #
  15. # All tests will run for sixty seconds. Confidence intervals are used
  16. # to insure the repeatability of the test. This means that the soonest
  17. # the script will be finished is 21 minutes.
  18. #
  19. # This script takes two parameters. The first parm is the name of the
  20. # remote host. It is a required parameter. The second will either
  21. # enable or disable CPU utilization measurements. It is an optional
  22. # parameter which defaults to no CPU utilization measurements.
  23. #
  24. # usage: snapshot_script hostname [CPU]
  25. #
  26. # mod 6/29/95 - echo progress information to stderr so that we can 
  27. #               see forward progress even when the results are 
  28. #               re-directed to a file
  29. #
  30. # mod 5/27/96 - switch from NETHOME to NETPERF and take the user's value
  31. #               if it is already set
  32. #
  33. # mod 8/12/96 - fix the default netperf command variable so it finds the
  34. #               executable and not the directory...
  35. #
  36. # First, let us set-up some of the defaults
  37. #
  38. # where is netperf installed, there are a few possible places:
  39. NETPERF_CMD=${NETPERF_CMD:=/opt/netperf/netperf}
  40. # there should be no more than two parms passed
  41. if [ $# -gt 2 ]; then
  42.   echo "try again, correctly -> snapshot_script hostname [CPU]"
  43.   exit 1
  44. fi
  45. if [ $# -eq 0 ]; then
  46.   echo "try again, correctly -> snapshot_script hostname [CPU]"
  47.   exit 1
  48. fi
  49. # if there are two parms, parm one it the hostname and parm two will
  50. # be a CPU indicator. actuall, anything as a second parm will cause
  51. # the CPU to be measured, but we will "advertise" it should be "CPU"
  52. if [ $# -eq 2 ]; then
  53.   REM_HOST=$1
  54.   LOC_CPU="-c"
  55.   REM_CPU="-C"
  56. fi
  57. if [ $# -eq 1 ]; then
  58.   REM_HOST=$1
  59. fi
  60. # at what port will netserver be waiting? If you decide to run
  61. # netserver at a differnet port than the default of 12865, then set
  62. # the value of PORT apropriately
  63. #NETPERF_PORT="-p some_other_portnum"
  64. NETPERF_PORT=${NETPERF_PORT:=""}
  65. # How accurate we want the estimate of performance: 
  66. #      maximum and minimum test iterations (-i)
  67. #      confidence level (99 or 95) and interval (percent)
  68. STATS_STUFF="-i 10,3 -I 99,5"
  69. # length in time of the test - should be 60 seconds
  70. NETPERF_TIME=${NETPERF_TIME:=60}
  71. # where is the bitbucket?
  72. BITBUCKET="/dev/null"
  73. # announce start of test
  74. echo Netperf snapshot script started at `date` >&2
  75. # If we are measuring CPU utilization, then we can save beaucoup time
  76. # by saving the results of the CPU calibration and passing them in
  77. # during the real tests. So, we execute the new CPU "tests" of netperf
  78. # and put the values into shell vars.
  79. case $LOC_CPU in
  80. -c) LOC_RATE=`$NETPERF_CMD $NETPERF_PORT -t LOC_CPU`;;
  81. *) LOC_RATE=""
  82. esac
  83. case $REM_CPU in
  84. -C) REM_RATE=`$NETPERF_CMD $NETPERF_PORT -t REM_CPU -H $REM_HOST`;;
  85. *) REM_RATE=""
  86. esac
  87. # We will perform three twenty second warm-up tests at this point, but
  88. # we will not display the results of those tests. This is unlikely to
  89. # make any difference in the results except right after a system
  90. # reboot, but this is supposed to be rather "general." We will do a
  91. # TCP stream and a TCP req/resp test
  92. WARM_TIME="10"
  93. $NETPERF_CMD $NETPERF_PORT -l $WARM_TIME -t TCP_STREAM -H $REM_HOST -- 
  94.   -s 32768 -S 32768 -m 4096 > ${BITBUCKET}
  95. $NETPERF_CMD $NETPERF_PORT -l $WARM_TIME -t TCP_STREAM -H $REM_HOST -- 
  96.   -s 32768 -S 32768 -m 96 > ${BITBUCKET}
  97. $NETPERF_CMD $NETPERF_PORT -l $WARM_TIME -t TCP_RR -H $REM_HOST -- 
  98.   -r 1,1 > ${BITBUCKET}
  99. # The warm-ups are complete, so perform the real tests first, the
  100. # stream tests, then the request/response
  101. echo Starting 56x4  TCP_STREAM tests at `date` >&2
  102. # a 56x4 TCP_STREAM test
  103. echo
  104. echo ------------------------------------
  105. echo Testing with the following command line:
  106. echo $NETPERF_CMD $NETPERF_PORT -t TCP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  107.   $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  108.   -s 57344 -S 57344 -m 4096
  109. echo
  110. $NETPERF_CMD $NETPERF_PORT -t TCP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  111.   $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  112.   -s 57344 -S 57344 -m 4096
  113. echo
  114. echo
  115. # a 32x4 TCP_STREAM test
  116. echo Starting 32x4  TCP_STREAM tests at `date` >&2
  117. echo
  118. echo ------------------------------------
  119. echo Testing with the following command line:
  120. echo $NETPERF_CMD $NETPERF_PORT -t TCP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  121.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  122.  -s 32768 -S 32768 -m 4096 
  123. echo
  124. $NETPERF_CMD $NETPERF_PORT -t TCP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  125.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  126.  -s 32768 -S 32768 -m 4096 
  127. echo
  128. echo
  129. # a single-byte TCP_RR
  130. echo Starting 1,1   TCP_RR     tests at `date` >&2
  131. echo
  132. echo ------------------------------------
  133. echo Testing with the following command line:
  134. echo $NETPERF_CMD $NETPERF_PORT -t TCP_RR -l $NETPERF_TIME -H $REM_HOST 
  135.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  136.  -r 1,1
  137. echo
  138. $NETPERF_CMD $NETPERF_PORT -t TCP_RR -l $NETPERF_TIME -H $REM_HOST 
  139.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  140.  -r 1,1
  141. echo
  142. echo
  143. echo Starting 1,1   UDP_RR     tests at `date` >&2
  144. echo
  145. echo ------------------------------------
  146. echo Testing with the following command line:
  147. # a single-byte UDP_RR
  148. echo $NETPERF_CMD $NETPERF_PORT -t UDP_RR -l $NETPERF_TIME -H $REM_HOST 
  149.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  150.  -r 1,1
  151. echo
  152. $NETPERF_CMD $NETPERF_PORT -t UDP_RR -l $NETPERF_TIME -H $REM_HOST 
  153.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  154.  -r 1,1
  155. echo
  156. echo
  157. # a UDP_RR test much like tftp
  158. echo Starting 512,4 UDP_RR     tests at `date` >&2
  159. echo
  160. echo ------------------------------------
  161. echo Testing with the following command line:
  162. echo $NETPERF_CMD $NETPERF_PORT -t UDP_RR -l $NETPERF_TIME -H $REM_HOST 
  163.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  164.  -r 516,4
  165. echo
  166. $NETPERF_CMD $NETPERF_PORT -t UDP_RR -l $NETPERF_TIME -H $REM_HOST 
  167.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- -r 516,4
  168. # a 32x4 UDP_STREAM test
  169. echo Starting 32x4  UDP_STREAM tests at `date` >&2
  170. echo
  171. echo ------------------------------------
  172. echo Testing with the following command line:
  173. echo $NETPERF_CMD $NETPERF_PORT -t UDP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  174.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  175.  -s 32768 -S 32768 -m 4096
  176. echo
  177. $NETPERF_CMD $NETPERF_PORT -t UDP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  178.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  179.  -s 32768 -S 32768 -m 4096
  180. echo
  181. echo
  182. # a 32x1 UDP_STREAM test
  183. echo Starting 32x1  UDP_STREAM tests at `date` >&2
  184. echo
  185. echo ------------------------------------
  186. echo Testing with the following command line:
  187. echo $NETPERF_CMD $NETPERF_PORT -t UDP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  188.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  189.  -s 32768 -S 32768 -m 1024
  190. echo
  191. $NETPERF_CMD $NETPERF_PORT -t UDP_STREAM -l $NETPERF_TIME -H $REM_HOST 
  192.  $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF -- 
  193.  -s 32768 -S 32768 -m 1024
  194. echo
  195. echo
  196. # and that's that
  197. echo Tests completed at `date` >&2
  198. echo
  199. echo If you wish to submit these results to the netperf database at
  200. echo http://www.cup.hp.com/netperf/NetperfPage.html, please submit each
  201. echo datapoint individually. Individual datapoints are separated by
  202. echo lines of dashes.