Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
- #
- # v0.1, 2008-10-15
- # This script aims at combining tshark and awk to collect quick and useful
- # statistics about NFSv3 calls from a capture file.
- #
- # Author: Fabio Olive Leite <fleite@redhat.com>
- #
- # This copyrighted material is made available to anyone wishing to use,
- # modify, copy, or redistribute it subject to the terms and conditions
- # of the GNU General Public License, version 2. A copy of the license
- # can be obtained from http://www.gnu.org/.
- #
- # TODO: Supporting V2, V3 and V4 calls in separate sections of the output
- # TODO: Calculate percentage of each call type relative to total call count
- die() {
- echo $*
- exit 1
- }
- [ $# -eq 1 ] || die "Usage: $0 pcap_file"
- [ -r $1 ] || die "Cannot read $1!"
- [ -x /usr/bin/which ] || die 'Need /usr/bin/which to find my dependencies!'
- TSHARK=$(/usr/bin/which tshark)
- [ -n "$TSHARK" ] || die 'Need tshark, please install tshark (or maybe wireshark)'
- AWK=$(/usr/bin/which awk)
- [ -n "$AWK" ] || die 'Need AWK, please install it!'
- #echo tshark: $TSHARK
- #echo awk: $AWK
- #echo File: $1
- $TSHARK -r $1 -R "nfs.procedure_v3 and rpc.time" -e nfs.procedure_v3 -e rpc.time -T fields | $AWK '
- BEGIN {
- name[0] = "NULL";
- name[1] = "GETATTR";
- name[2] = "SETATTR";
- name[3] = "LOOKUP";
- name[4] = "ACCESS";
- name[5] = "READLINK";
- name[6] = "READ";
- name[7] = "WRITE";
- name[8] = "CREATE";
- name[9] = "MKDIR";
- name[10] = "SYMLINK";
- name[11] = "MKNOD";
- name[12] = "REMOVE";
- name[13] = "RMDIR";
- name[14] = "RENAME";
- name[15] = "LINK";
- name[16] = "READDIR";
- name[17] = "READDIRPLUS";
- name[18] = "FSSTAT";
- name[19] = "FSINFO";
- name[20] = "PATHCONF";
- name[21] = "COMMIT";
- };
- {
- count[$1]++;
- sum[$1] += $2;
- if ($1 in min) {
- if ($2 < min[$1]) {
- min[$1] = $2;
- };
- } else {
- min[$1] = $2;
- }
- if ($2 > max[$1]) { max[$1] = $2; };
- };
- END {
- print "NFSv3 Call Count Min Avg Max"
- for (op = 0; op <= 21; op++) {
- if (op in count) {
- printf "%-12s %8d %.6f %.6f %.6f\n",
- name[op], count[op], min[op],
- sum[op]/count[op], max[op];
- }
- }
- };
- '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement