home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / radi116c.zip / radius116c / runstats / userhist.cmd < prev    next >
OS/2 REXX Batch file  |  1998-05-10  |  4KB  |  154 lines

  1. /* UserHist.cmd: Create a simple histogram of number of users logged in.
  2.    As written here, it just graphs the total users among all servers.
  3. */
  4.  
  5.  
  6. /* Initialize global variables */
  7. TRUE=1
  8. FALSE=0
  9.  
  10. /* Load REXXUTIL */
  11. CALL rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  12. CALL sysloadfuncs
  13.  
  14.  
  15. /* -------------CONFIGURATION SECTION --------------------- */
  16. /* Directory where 'runstats.exe' is executed from */
  17. statsDir="C:\runstats\"
  18.  
  19. statsFile="con"
  20. /* Flag whether to rotate runstats log each time this program runs */
  21. rotateStatsLogs=FALSE
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. /* --------------------- BEGIN -------------------------------------- */
  30.  
  31.   CALL SystemStatistics
  32.  
  33.   Say "Done"
  34.  
  35. EXIT 0
  36.  
  37.  
  38.  
  39.  
  40. /* =================== Provide Histogram of how many on and data rates.========= */
  41. SystemStatistics:
  42.  
  43.   call LineOut StatsFile, ""
  44.   call LineOut StatsFile, "----------------------------------"
  45.   call LineOut StatsFile, "SYSTEM Statistics"
  46.   call LineOut StatsFile, ""
  47.  
  48.   statsLogfile=statsDir || "runstats.lo"
  49.  
  50.   if rotateStatsLogs then do
  51.      "@del "statsLogfile"8 2>nul"
  52.      do i=0 TO 7
  53.        "@ren "statsLogfile||7-i" runstats.lo"8-i" 2>nul"
  54.      end
  55.    
  56.      "@ren "statsLogFile"g runstats.lo1"
  57.    
  58.      statsLogFile=statsLogFile"1"
  59.   end
  60.   else do
  61.      statsLogFile=statsLogFile"g"
  62.   end
  63.      
  64.  
  65.   /* Clear count bins */
  66.   do bin=0 to 23
  67.      sum.bin=0
  68.      entries.bin=0
  69.      min.bin=99999
  70.      max.bin=0
  71.   end
  72.   DO WHILE LINES(statsLogFile) > 0
  73.      line=LINEIN(statsLogFile)
  74.      parse VAR line '[' yy '/' mm '/' dd ':' hh ':' mm ':' ss ']' line
  75.      if (line <> "") then do
  76.         line=STRIP(line,"B")
  77.         hh=hh+0 /* Strip off leading zero */
  78.         total=0
  79.         DO WHILE (line <> "")
  80.           parse VAR line serverCount line
  81.           if serverCount <> "" then do
  82.              total=total+serverCount
  83.           end
  84.         END
  85.         entries.hh=entries.hh+1
  86.         sum.hh=sum.hh+total
  87.         if total < min.hh then do
  88.            min.hh=total
  89.         end
  90.         if total > max.hh then do
  91.            max.hh=total
  92.         end
  93.      end
  94.   END
  95.   Error=STREAM(statsLogFile,C,'CLOSE')
  96.  
  97.   /* Determine range (customers per cell) */
  98.   range=0
  99.   do bin=0 to 23
  100.      if max.bin > range then do
  101.         range=max.bin
  102.      end
  103.   end
  104.   NumCells=50
  105.   if range < NumCells then do
  106.      cusPerCell=1
  107.   end
  108.   else do
  109.     cusPerCell=range/NumCells
  110.   end
  111.  
  112.   call LineOut StatsFile, "Hourly Summary: Customer logins sampled once per 5 minutes"
  113.   call LineOut StatsFile, "-------------------------------"
  114.   call LineOut StatsFile, ""
  115.   call LineOut StatsFile, "Each unit (*) represents "FORMAT(cusPerCell,,1)" customers, (|) represent Min and Max"
  116.   call LineOut StatsFile, ""
  117.   call LineOut StatsFile, "hr: Min. Avg. Max. customers:"
  118.   call LineOut StatsFile, "--  ---------------"
  119.   do bin=0 TO 23
  120.      if entries.bin=0 then do
  121.         average=0
  122.         min.bin=0
  123.      end
  124.      else do
  125.         average=sum.bin/entries.bin
  126.      end
  127.      line=FORMAT(bin,2)":"FORMAT(min.bin,5,0)||FORMAT(average,5,0)||FORMAT(max.bin,5,0)": "
  128.      if max.bin > 0 then do
  129.         minPos=FORMAT(min.bin / cusPerCell,,0)
  130.         avePos=FORMAT(average / cusPerCell,,0)
  131.         maxPos=FORMAT(max.bin / cusPerCell,,0)
  132.         if minPos>0 then do
  133.           line=line||COPIES("*",minPos-1)
  134.           line=line||"|"
  135.         end
  136.         if avePos > minPos then do
  137.           line=line||COPIES("*",(avePos-minPos))
  138.         end
  139.         if maxPos > avePos then do
  140.            line=line||COPIES(" ",maxPos-avePos-1)||"|"
  141.         end
  142.      end
  143.      call LineOut StatsFile, line
  144.   end
  145.  
  146.   call LineOut StatsFile, "-------------------------------"
  147.   call LineOut StatsFile, ""
  148.   /* Close output file */
  149.   call LineOut StatsFile
  150.  
  151.   return
  152.  
  153.  
  154.