Guest User

Untitled

a guest
Jan 22nd, 2013
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
  4. #
  5. # v0.1, 2008-10-15
  6. # This script aims at combining tshark and awk to collect quick and useful
  7. # statistics about NFSv3 calls from a capture file.
  8. #
  9. # Author: Fabio Olive Leite <fleite@redhat.com>
  10. #
  11. # This copyrighted material is made available to anyone wishing to use,
  12. # modify, copy, or redistribute it subject to the terms and conditions
  13. # of the GNU General Public License, version 2. A copy of the license
  14. # can be obtained from http://www.gnu.org/.
  15. #
  16. # TODO: Supporting V2, V3 and V4 calls in separate sections of the output
  17. # TODO: Calculate percentage of each call type relative to total call count
  18.  
  19. die() {
  20. echo $*
  21. exit 1
  22. }
  23.  
  24. [ $# -eq 1 ] || die "Usage: $0 pcap_file"
  25.  
  26. [ -r $1 ] || die "Cannot read $1!"
  27.  
  28. [ -x /usr/bin/which ] || die 'Need /usr/bin/which to find my dependencies!'
  29.  
  30. TSHARK=$(/usr/bin/which tshark)
  31. [ -n "$TSHARK" ] || die 'Need tshark, please install tshark (or maybe wireshark)'
  32.  
  33. AWK=$(/usr/bin/which awk)
  34. [ -n "$AWK" ] || die 'Need AWK, please install it!'
  35.  
  36. #echo tshark: $TSHARK
  37. #echo awk: $AWK
  38. #echo File: $1
  39.  
  40. $TSHARK -r $1 -R "nfs.procedure_v3 and rpc.time" -e nfs.procedure_v3 -e rpc.time -T fields | $AWK '
  41. BEGIN {
  42. name[0] = "NULL";
  43. name[1] = "GETATTR";
  44. name[2] = "SETATTR";
  45. name[3] = "LOOKUP";
  46. name[4] = "ACCESS";
  47. name[5] = "READLINK";
  48. name[6] = "READ";
  49. name[7] = "WRITE";
  50. name[8] = "CREATE";
  51. name[9] = "MKDIR";
  52. name[10] = "SYMLINK";
  53. name[11] = "MKNOD";
  54. name[12] = "REMOVE";
  55. name[13] = "RMDIR";
  56. name[14] = "RENAME";
  57. name[15] = "LINK";
  58. name[16] = "READDIR";
  59. name[17] = "READDIRPLUS";
  60. name[18] = "FSSTAT";
  61. name[19] = "FSINFO";
  62. name[20] = "PATHCONF";
  63. name[21] = "COMMIT";
  64. };
  65.  
  66. {
  67. count[$1]++;
  68. sum[$1] += $2;
  69. if ($1 in min) {
  70. if ($2 < min[$1]) {
  71. min[$1] = $2;
  72. };
  73. } else {
  74. min[$1] = $2;
  75. }
  76. if ($2 > max[$1]) { max[$1] = $2; };
  77. };
  78.  
  79. END {
  80. print "NFSv3 Call Count Min Avg Max"
  81. for (op = 0; op <= 21; op++) {
  82. if (op in count) {
  83. printf "%-12s %8d %.6f %.6f %.6f\n",
  84. name[op], count[op], min[op],
  85. sum[op]/count[op], max[op];
  86. }
  87. }
  88. };
  89. '
RAW Paste Data