#!/bin/bash
#David Waugh RSA
#This script will display the current Warehouse Connector Stream Rate for all streams.


#Get the stream names 
Perfdata=""
Output=""
TotalBehind=0
Streams=$(NwConsole -c login localhost:50020 admin netwitness -c cd warehouseconnector/streams -c ls |tail -n +9)

for mystream in $Streams
do
   behind=$(NwConsole -c login localhost:50020 admin netwitness -c cd warehouseconnector/streams -c cd $mystream -c cd stats -c ls |grep -i behind | awk -F "= " '{print $2}' | awk '{s+=$1} END {print s}')
   Output+=$mystream
   Output+=": "
   Output+=$behind
   Output+=" "
   Perfdata+=$mystream
   Perfdata+=\=
   Perfdata+=$behind
   Perfdata+=" "
   let TotalBehind=TotalBehind+$behind
done

echo $TotalBehind
exit 0
