Megatest

Artifact [4ab1fc4a2b]
Login

Artifact 4ab1fc4a2bc0ae930dcb8576674d72fae4186ec1:


#!/bin/bash
#
#  Copyright 2006-2017, Matthew Welland.
# 
# This file is part of Megatest.
# 
#     Megatest is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     Megatest is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.

# Rollup counts of calls to Megatest from a logging dat file
#
# Usage: mtrept.sh file [host]

if [[ "$2"x != "x" ]];then
  host_name_grep="grep $2 | "
else
  host_name_grep=""
fi
if [[ "$1"x == "x" ]];then
  datfile=/p/fdk/gwa/$USER/.logger/all.dat
else
  datfile=$1
fi
datcopy=/tmp/$USER/all.$PID.dat

if [[ -e $datfile ]];then
   cp $datfile $datcopy
   list_runs=$(grep list-runs $datcopy |$host_name_grep wc -l)
   show_config=$(grep show-config $datcopy |$host_name_grep wc -l)
   list_targets=$(grep list-targets $datcopy |$host_name_grep wc -l)
   mt_run=$(grep ' -run ' $datcopy |$host_name_grep wc -l)
   execute=$(grep ' -execute' $datcopy|$host_name_grep wc -l)
   server=$(grep ' -server' $datcopy|$host_name_grep wc -l)
   sync_to=$(grep ' -sync-to' $datcopy|$host_name_grep wc -l)
   step=$(grep ' -step' $datcopy|$host_name_grep wc -l)
   state_status=$(grep ' -set-state-status' $datcopy|$host_name_grep wc -l)
   test_status=$(grep ' -test-status' $datcopy|$host_name_grep wc -l)
   other=$(egrep -v ' -(list-runs|show-config|list-targets|run|execute|server|sync-to|step|set-state-status|test-status)' $datcopy |$host_name_grep wc -l)
   start_time=$(head -1 $datcopy|awk '{print $1}')
   end_time=$(tail -1 $datcopy | awk '{print $1}')
   minutes=$(echo "($end_time-$start_time)/60.0" | bc)
   hours=$(echo "($minutes/60)"|bc)
   total_calls=$(cat $datcopy |$host_name_grep wc -l)
   
   if [[ $hours -gt 2 ]];then
      echo "Over $hours hour period we have;"
   else
      echo "Over $minutes minutes we have;"
   fi
   echo "    list-runs:    $list_runs"
   echo "    show-config:  $show_config"
   echo "    list-targets: $list_targets"
   echo "    execute:      $execute"
   echo "    run:          $mt_run"
   echo "    server:       $server"
   echo "    step:         $step"
   echo "    test-status:  $test_status"
   echo "    sync-to:      $sync_to"
   echo "    state-status: $state_status"
   echo "    other:        $other"
   echo "    total:        $total_calls"
else
   echo "Could not find input file $datfile"
fi