Call Tracing: Using calltrace.sh to Parse the Logs

From DocWiki

Revision as of 22:11, 10 June 2009 by Cchetty (Talk | contribs)
Jump to: navigation, search

Using calltrace.sh to Parse the Logs

Problem Summary You know the Call GUID and you need to trace one call.
Error Message None.
Possible Cause Use the following shell script to quickly parse the logs and trace the required call.
Recommended Action Obtain the logs and use the following bash shell script to grab the important lines from the runtime logs.

To run the script

  1. Copy the log files to a computer that can run the script. The computer must be able to run a bash script.
  2. Change your working directory to the location of the logs.
  3. Run <location of script>/calltrach.sh <guid>

Three files are created:

  • <guid>.txt displays the lines with the guid in them
  • <guid>.fgrep.txt displays the strings used to search with, guid, contactid, mpi interaction ids
  • <guid>.fulltrace.txt contains the complete call trace with any of the above strings in them
Note Note: This script can take a long time to run based on the size of the logs. It will search overzipped logs and has to traverse the entire set of logs twice, the first to get the right parameters,the second to get the full call trace. For example, with 5GB of zipped logs (close to 50GBunzipped), on a powerful server, this took approximately 10-15 minutes to complete.
calltrace.sh
------------
#!/bin/bash

#Do full grep over all logs for this GUID provided
zgrep $1 MMCA-runtime* > $1.txt

#Find all interaction ids over previously grepped logs by getting 10th param on
SEND_NEW_INTERACTION_REQ lines
GET_INTERACTION_IDS=$(grep SEND_NEW_INTERACTION_REQ $1.txt | cut -f10 -d'[' | cut -f1 -d']' | cut -f2 -d '=')

#get Contact id from guid log on CONTACT_CREATED line
CONTACT_ID=$(grep CM-6-CONTACT_CREATED $1.txt | cut -f2 -d'[' | cut -f1 -d']' | cut -f2 -d '=')

#Use array to iterate over any interactions created for this guid, usually there are 2, but there may be 1 or more than 2
declare -a MPI_INTERACTION_ID
MPI_INTERACTION_ID=($GET_INTERACTION_IDS)

echo "Contact ID = $CONTACT_ID"

#Echo search strings to new file
echo $CONTACT_ID > $1.fgrepsearch.txt
echo $1 >> $1.fgrepsearch.txt

for interaction in "${MPI_INTERACTION_ID[@]}" ; do 
    echo "found interaction $interaction" 
    echo $interaction >> $1.fgrepsearch.txt
done

#use search strings in file to get all details of call trace and output to fulltrace file
zfgrep -h -f $1.fgrepsearch.txt MMCA-runtime* > $1.fulltrace.txt 
Release Release 7.6(1)
Associated CDETS # None.

Rating: 0.0/5 (0 votes cast)

Personal tools