Asterisk Phone Inventory / Useragent List

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

2 thoughts on “Asterisk Phone Inventory / Useragent List”

  1. #! /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

  2. #! /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

Leave a Reply to Ernast Cancel reply

Your email address will not be published. Required fields are marked *