Advertisement
Guest User

Untitled

a guest
Apr 5th, 2011
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. Write a program that parses Apache Common Log Format log files and produces a report. Your program will take the pathname of the log file to use as a command line argument. The report will always output the following items:
  2.  
  3. Filename of the log file.
  4. Total number of bytes transferred
  5. The other report items will only be output if the appropriate command line arguments are specified:
  6.  
  7. -h: Print a help message and exit without a report. The message should look something like the following output. You can add a longer description of the program's functionality.
  8. ApacheReport: An Apache Log Parser
  9.  
  10. -h: Print a help message and exit without a report.
  11. -i: ASCII histogram of IP addresses.
  12. -u: ASCII histogram of URLs.
  13. -s: Sorted list of HTTP status codes, with percentages.
  14.  
  15. apachereport [-h] [-i] [-u] [-s] logpath
  16. -i: ASCII histogram of IP addresses
  17. Output consists of two columns, the left containing IP addresses, and the right containing a histogram showing the number of accesses from that IP address. The histogram is constructed as a string of hash marks.
  18.  
  19. 139.18.2.214 #
  20. 193.47.80.51 ##
  21. 203.199.84.66 ###
  22. 203.206.107.4 ##
  23. 62.101.126.216 ###########################
  24. 64.34.145.197 ##
  25. 65.214.44.29 #
  26. -u: ASCII histogram of URLs
  27. This option is similar to the previous option, which the difference that URLs have widely varying lengths, requiring you to truncate some of them to make the histogram readable. Add a vertical bar character at the end of a truncated URL so the reader knows what happened.
  28.  
  29. /favicon.ico ##
  30. /manual/mod/mod_autoindex.html #
  31. /perl/faq/Windows/ ##
  32. /perl/faq/Windows/ActivePerl-Winf| #
  33. /perl/faq/Windows/ActivePerl-Winf| #
  34. /perl/perlmain.html #
  35. /robots.txt ########
  36. -s: Sorted list of HTTP status codes, with percentages of URLs that resulted in each status code, which should be printed like this example:
  37. HTTP Status Codes Summary:
  38.  
  39. 200: 90%
  40. 301: 8%
  41. 401: 1%
  42. 404: 1%
  43.  
  44. Bytes transferred: 4338917
  45. Options can be specified in any order. An invocation of your program could look like any of the following examples:
  46.  
  47. $ ./apachereport cit383/test_log
  48. $ ./apachereport -u test_log
  49. $ ./apachereport -u -i /var/log/test_log
  50. $ ./apachereport -s -u ~/test_log
  51. $ ./apachereport -i -s -u ../log/test_log
  52. If incorrect command line options are specified, .e.g. a non-existent option like -f or no filename being specified, then the program must print a help message that explains how to run the program and exit.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement