Create batch file with below and run the script. It will list down the Useragent, Contact & Username.
asterisk -rx “sip show peers” | cut -f1 -d/ | grep -P ‘\d\d\d\d’ | grep -vP ‘(UNKNOWN|Unmonitored)’ |
while read PEER
do
asterisk -rx “sip show peer ${PEER}” |
grep -P “(Useragent|Contact|Username)”
echo “====”
done
#! /bin/bash
getUserName() {
echo $1 | cut -d : -f 1 | xargs basename
}
asterisk -rx “sip show peers” | cut -f1 -d/ | grep -P ‘\d\d\d\d’ | grep -vP ‘(UNKNOWN|Unmonitored)’ |
while read PEER
do
asterisk -rx “sip show peer $(getUserName ${PEER})” |
grep -P “(Username|Useragent|Contact)”
echo “;”
done
#! /bin/bash
rasterisk -x ‘sip show peers’ | cut -f1 -d/ | awk ‘{ print $1}’ |
while read PEER
do
rasterisk -x “sip show peer ${PEER} ” | grep Useragent
done
this modification works
#! /bin/bash
asterisk -rx “sip show peers” | cut -f1 -d/ | grep -P ‘\d\d\d’ | grep -vP ‘(UNKNOWN)’ |
while read PEER
do
asterisk -rx “sip show peer ${PEER}” |
grep -P “(Useragent|Contact|Username)”
echo “====”
done