Asterisk – count OK lines of peers – send warning email if too small

#!/bin/bash

total=`/usr/sbin/asterisk -rx 'sip show peers' |/bin/grep OK |/usr/bin/wc -l`

echo $total

if [ "$total" -gt 10000 ];
then
    echo "good number";
else
    /bin/mail -s "ONLY ${total} phones on pbx17" support@wuyifan.com <<EOF
    pbx17 [ sip show peers, OK lines = ${total}) ]
EOF
fi;