home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / bind-contrib.tar.gz / bind-contrib.tar / contrib / misc / graphstats / text0000.txt < prev   
Encoding:
Text File  |  1996-10-25  |  6.7 KB  |  202 lines

  1.  
  2.  
  3. Hi Paul,
  4.  
  5. I developed this script to help monitor the load on a 4.9.3 server I
  6. was testing.  I thought it could possibly be of use to others.
  7.  
  8. The script uses awk and sed to analyze syslog XSTATS entries for the
  9. currently running named process.
  10.  
  11. The results are formatted for an X11 graphing utility called "xgraph".
  12. I've located a couple of sites that carry the source for xgraph:
  13.  
  14.     http://sir.univ-rennes1.fr/pub/X11/contrib/
  15.     http://138.253.42.172/hpux/X11/Graphics/xgraph-1.1.html (HP-UX port)
  16.  
  17. It would be quite simple to modify the script output for any other
  18. utility that reads in ASCII files containing "X Y" data pairs.  The
  19. format of the script output is currently:
  20.  
  21.     "<Data Name>
  22.     Xval Yval
  23.     Xval Yval
  24.  
  25. Where '"<Data Name>' is the xgraph specific data item.  Double line graph
  26. data consists of two data groups separated by a single blank line:
  27.  
  28.     "Req per min
  29.     Xval Yval
  30.     Xval Yval
  31.  
  32.     "Avg.
  33.     Xval Yval
  34.     Xval Yval
  35.  
  36.  
  37. Currently the script produces data for two graphs:
  38.  
  39.     *  Requests per minute
  40.     *  Percentage of received requests forwarded
  41.  
  42. The X axis in both graphs is time, in days.  The "forwarded" graph
  43. also plots an averaged line to show the overall trend.
  44.  
  45.  
  46. Take Care,
  47.  
  48. Nigel.
  49.  
  50. -------------------------------- Cut Here ------------------------------------
  51. #! /usr/bin/ksh
  52. ##############################################################################
  53. #
  54. # Script Name : "bindgraph"
  55. # Version     : 2.1P
  56. # Author      : Nigel Campbell (nigelc@cup.hp.com)
  57. # Date        : 6/7/96
  58. #
  59. #############################################################################
  60. #
  61. # Note : This script uses sed, awk and requires a shell that can deal
  62. #        with the backslash line continuation character "\".
  63. #
  64. #        Paths to the syslog file and named.pid file may need modification
  65. #        for your platform.  This script is useful for named 4.9.3
  66. #        compiled with the XSTATS option.                    =====
  67. #
  68. # Please send any comments, enhancements, or suggestions to nigelc@cup.hp.com
  69. #
  70. ##############################################################################
  71.  
  72. ##############################################################################
  73. #
  74. # User Modifiable Variables
  75. #
  76. ##############################################################################
  77.  
  78. PIDFILE="/var/run/named.pid"
  79. SYSLOG="/var/adm/syslog/syslog.log"
  80.  
  81. REQ_GRAPH="/tmp/req_graph"
  82. FWD_GRAPH="/tmp/fwd_graph"
  83.  
  84. ##############################################################################
  85. #
  86. # Non User Modifiable Variables
  87. #
  88. ##############################################################################
  89.  
  90. PID=`cat $PIDFILE`
  91. PIDPATTERN=$PID]
  92.  
  93. ##############################################################################
  94. #
  95. #  Analyze the XSTATS entries recorded for the running named process to
  96. #  calculate the number of Requests received between XSTATS events (logged
  97. #  hourly) over time.  Gives a feel for how busy the server is over time.
  98. #  The XSTATS entries are logged in the syslog file.
  99. #
  100. #  XSTATS parameters: $7 = Current time (in seconds since epoch)
  101. #              $8 = named process start time (in seconds since epoch)
  102. #              $9 = Cumulative number of Queries (RQ) rcvd since start.
  103. #
  104. #  The results file will contain final data for Requests Per Min over
  105. #  time (in days).  Again, the results are formatted for a graphing utility
  106. #  called "xgraph":
  107. #
  108. #  "Data
  109. #  0 0
  110. #  <time in days> <requests per min>
  111. #  <time in days> <requests per min>
  112. #
  113. ##############################################################################
  114.  
  115. echo "\042Data" > $REQ_GRAPH
  116. echo "0 0" >> $REQ_GRAPH
  117. fgrep XSTATS $SYSLOG | grep $PIDPATTERN |                                     \
  118.  sed "s/RQ=//" |                                                              \
  119.  awk '{nowtime=$7}
  120.       {starttime=$8}
  121.       {querytotal=$9}
  122.       {mins=(nowtime-starttime)/60}
  123.       {print ((mins/60)/24), int(((querytotal-oldtot)/((mins-oldmins)/60)/60))}
  124.       {oldmins=mins}
  125.       {oldtot=querytotal}' >> $REQ_GRAPH
  126.  
  127. ##############################################################################
  128. #
  129. #  Using the XSTATS data for the running named process, calculate what
  130. #  percentage of Requests received (see above) had to be forwarded
  131. #  (answer wasn't available in cache/locally).
  132. #  May give an idea of how well the cache is performing.  This data is
  133. #  also averaged to provide a separate "trend" line.
  134. #
  135. #  XSTATS parameters: $7 = Current time (in seconds since epoch)
  136. #                     $8 = named process start time (in seconds since epoch)
  137. #              $9 = Cumulative number of Queries (RQ) rcvd since start.
  138. #             $13 = Cumulative number of Queries forwarded (RFwdQ)
  139. #               since start.
  140. #
  141. #  The results file will contain final data of % of incoming requests
  142. #  forwarded over time (in days).  A running average is also calculated
  143. #  (based on an average of the current and previous 9 data points)
  144. #  to produce a second, smoother, trend line.  The x axis is shifted
  145. #  the required amount to take account of the averaging process used.
  146. #  In this case, (10 samples/2), which is 5 hrs since an XSTATS entry
  147. #  is logged every hour.
  148. #
  149. #  The results file is formatted for use with the "xgraph" utility and
  150. #  has the format:
  151. #
  152. #  "Data
  153. #  0 0
  154. #  <time in days since named started> <% of requests forwarded>
  155. #  <time in days since named started> <% of requests forwarded>
  156. #
  157. #  "Avg.
  158. #  <time in days since named started> <% of requests forwarded, averaged>
  159. #  <time in days since named started> <% of requests forwarded, averaged>
  160. #
  161. #
  162. ##############################################################################
  163.  
  164. echo "\042Data" > $FWD_GRAPH
  165. echo "0 0" >> $FWD_GRAPH
  166. fgrep XSTATS $SYSLOG | grep $PIDPATTERN |                                     \
  167.        sed "s/RFwdQ=//" | sed "s/RQ=//" |                                     \
  168.        awk '{mins=($7-$8)/60}
  169.             {percent=(($13-oldforwardedtot)/($9-oldqueriestot))*100}
  170.             {print ((mins/60)/24), percent}
  171.         {oldmins=mins}
  172.         {oldforwardedtot=$13}
  173.         {oldqueriestot=$9}' >> $FWD_GRAPH
  174.  
  175. echo ""  >> $FWD_GRAPH
  176.  
  177. echo "\042Avg." >> $FWD_GRAPH
  178. fgrep XSTATS $SYSLOG | grep $PIDPATTERN |                                     \
  179.         sed "s/RFwdQ=//" | sed "s/RQ=//" |                                    \
  180.         awk '{mins=($7-$8)/60}
  181.          {percent=(($13-oldforwardedtot)/($9-oldqueriestot))*100}
  182.          {if (samples==0) samples=2}
  183.              {if (samples>10) samples=10}
  184.          {if ((((mins/60)-5)/24) > 0)
  185.           print (((mins/60)-5)/24), ((percent+e+f+g+h+i+j+k+l+m)/samples)}
  186.              {samples++}
  187.          {oldmins=mins}
  188.          {oldforwardedtot=$13}
  189.          {oldqueriestot=$9}
  190.          {m=l}
  191.          {l=k}
  192.          {k=j}
  193.          {j=i}
  194.          {i=h}
  195.          {h=g}
  196.              {g=f}
  197.          {f=e}
  198.          {e=percent}' >> $FWD_GRAPH
  199.  
  200. ##############################################################################
  201.  
  202.