#!/usr/bin/ksh
#
# Sample script to gather, merge and sort mmfs.log files
# from nodes listed in file /tmp/gpfs.allnodes
#
# /tmp/gpfs.allnodes has been created by the user of this script
# and contains the host names of the nodes that the 
# mmfs.log files are required from.  No blank lines.
#
# Output file is called: /tmp/logs.sorted on node script is executes from
#
# Assumes proper rsh execution environment (.rhosts files configured)
#
# -----------------------------------------------------------------------
#
rm /tmp/logs.merged 2>/dev/null      # remove the intermediate file
#
for node in $(cat /tmp/gpfs.allnodes)   # loop through all nodes in file
do
  echo Gathering mmfs logs on node $node
#
# Change the date below for the date of interest for problem determination
# Ensure date pattern matches date of interest in logs
#
  rsh $node "grep -h \"Nov  3\" /var/adm/ras/mmfs.log*" > /tmp/${node}.output
  if [[ -s /tmp/${node}.output ]] then
    cat /tmp/${node}.output | \
    while read line
      do
        echo $node $line >> /tmp/logs.merged    # add hostname to beginning of line
      done
  fi
done
#
# sort the merged logs by the date field
#
if [[ -s /tmp/logs.merged ]] then
  sort -k 4,5 /tmp/logs.merged > /tmp/logs.sorted
  echo sort return code $?
fi
#
exit 
