Skip to content

Instantly share code, notes, and snippets.

@aweher
Last active December 21, 2015 10:39
Show Gist options
  • Save aweher/6293729 to your computer and use it in GitHub Desktop.
Save aweher/6293729 to your computer and use it in GitHub Desktop.
Count PPPoE clients per VLAN in a Cisco BRAS
#!/bin/bash
if [ $1 ]; then
THEFILE=`date +%s`
COMMAND=`rsh $1 show pppoe session | grep "VLAN: " | awk '{print $3}' | sed s/:// > /tmp/$THEFILE`;
LIST=`cat /tmp/$THEFILE | sort -uh | xargs`;
TOTAL=0
for ITEM in $LIST; do
CANT=`grep $ITEM /tmp/$THEFILE | wc -l`;
echo "VLAN $ITEM has $CANT clients";
TOTAL=$[ $TOTAL + $CANT ];
done
rm /tmp/$THEFILE;
else
echo "Usage: $0 {BRAS_IP}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment