github.com/vmware/govmomi@v0.37.1/scripts/debug-ls.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright (c) 2014 VMware, Inc. All Rights Reserved.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -e
    18  
    19  # This script shows for every request in a debug trace how long it took
    20  # and the name of the request body.
    21  
    22  function body-name {
    23    (
    24      xmllint --shell $1 <<EOS
    25      setns soapenv=http://schemas.xmlsoap.org/soap/envelope/
    26      xpath name(//soapenv:Body/*)
    27  EOS
    28    )  | head -1 | sed 's/.*Object is a string : \(.*\)$/\1/'
    29  }
    30  
    31  if [ -n "$1" ]; then
    32    cd $1
    33  fi
    34  
    35  for req in $(find . -name '*.req.xml'); do
    36    base=$(basename $req .req.xml)
    37    session=$(echo $base | awk -F'-' "{printf \"%d\", \$1}")
    38    number=$(echo $base | awk -F'-' "{printf \"%d\", \$2}")
    39    client_log=$(dirname $req)/${session}-client.log
    40    took=$(awk "/ ${number} took / { print \$4 }" ${client_log})
    41  
    42    printf "%s %8s: %s\n" ${base} ${took} $(body-name $req)
    43  done