#!/bin/bash

if [[ -z $1 ]]
then
    # echo -n 0
    exit 1
fi

HOST="$1"
USER="username"
TIMEOUT=10s
export SSHPASS="password"

CMD="show platform hardware pp active tcam utilization ucastv6 detail 0 | i Scale limit"
RAW_OUTPUT_TOTAL=`timeout $TIMEOUT sshpass -e ssh -q -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oBatchMode=no $USER@$HOST "$CMD" 2>/dev/null`
# This output usually ends in a carriage return character, which we must remove
UCASTV6_TOTAL=`echo -n $RAW_OUTPUT_TOTAL | awk -F ":" '{print $NF}' | tr -d "\r" | tr -d " "`

CMD="show platform hardware pp active tcam utilization ucastv6 detail 0 | i Current usage"
RAW_OUTPUT_USED=`timeout $TIMEOUT sshpass -e ssh -q -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oBatchMode=no $USER@$HOST "$CMD" 2>/dev/null`
# This output usually ends in a carriage return character, which we must remove
UCASTV6_USED=`echo -n $RAW_OUTPUT_USED | awk -F ":" '{print $NF}' | awk '{print $1}' | tr -d "\r"`

# Must remove new line from output for Cacti
echo -n "ucastv6_total:$UCASTV6_TOTAL ucastv6_used:$UCASTV6_USED"

