#!/bin/bash
#Lee Kirkpatrick (RSA)
#This script will display the current EPS for all collection methods and a total

#Declare collection methods
declare -a cMethod=('syslog' 'windows' 'checkpoint' 'vmware' 'sdee' 'file' 'netflow' 'odbc' 'snmptrap');


#Get the current EPS for each of the above
for i in "${cMethod[@]}"
do
        eval $i=$(NwConsole -c login localhost:56001:ssl admin netwitness -c logcollection/$i/stats/eventsources ls |grep total_events_rate | awk -F "= " '{print $2}')
        if [[ $sdee == "" ]]
        then
                sdee=0
        elif [[ $syslog == "" ]]
        then
                syslog=0
        elif [[ $windows == "" ]]
        then
                windows=0
        elif [[ $checkpoint == "" ]]
        then
                checkpoint=0
        elif [[ $vmware == "" ]]
        then
                vmware=0
        elif [[ $file == "" ]]
        then
                file=0
        elif [[ $netflow == "" ]]
        then
                netflow=0
        elif [[ $odbc == "" ]]
        then
                odbc=0
        elif [[ $snmptrap == "" ]]
        then
                snmptrap=0
        fi
done


#Calculate total of all methods
total=$[$sdee+$syslog+$windows+$checkpoint+$vmware+$file+$netflow+$odbc]


#Pretty Print
#printf '%-15s %-10s\n' "Syslog: " "$syslog"
#printf '%-15s %-10s\n' "SDEE: " "$sdee"
#printf '%-15s %-10s\n' "Windows: " "$windows"
#printf '%-15s %-10s\n' "Checkpoint: " "$checkpoint"
#printf '%-15s %-10s\n' "VMWare: " "$vmware"
#printf '%-15s %-10s\n' "File: " "$file"
#printf '%-15s %-10s\n' "NetFlow: " "$netflow"
#printf '%-15s %-10s\n' "ODBC: " "$odbc"
#echo
#printf '%-15s %-10s\n' "Total: " "$total"
echo "Syslog: $syslog SDEE: $sdee Windows: $windows Checkpoint: $checkpoint VMWare: $vmware File: $file Netflow: $netflow ODBC: $ODBC Total: $total|Syslog=$syslog SDEE=$sdee Windows=$windows Checkpoint=$checkpoint VMWare=$vmware File=$file Netflow=$netflow ODBC=$odbc Total=$total;;"
exit 0
