Hi, I am trying to get a SIP extension's status without actually making a call. I am using sofia-sip's "options" example utility and the sip clients are SJphone softphones.
dave cantera
2007-Dec-02 15:25 UTC
[asterisk-users] get SIP extension status without calling it
vieri, you can get sip status with the following shell script... I named it 'sipshowpeer'... to execute, chmod 755 sipshowpeers daveC --------------------------< cut here >------------------------- #!/bin/sh # sipshowpeers # # show current asterisk SIP peers asterisk -r -x 'sip show peers' | awk ' BEGIN{ #Name/username Host Dyn Nat ACL Port Status # $1 $2 $3 $4 $5 $6 $7 } { name=$1 host=$2 dyn=$3 nat=$4 acl=$5 port=$6 status=$7 printf("%14.14s %18.18s %14.14s %14.14s %s\n",$1,$2,$3,$4,$5,$6,$7) } END{ printf("Done...\n") }' #502 (Unspecified) D 0 Unmonitored #501 (Unspecified) D 0 Unmonitored #403 10.10.15.43 5060 Unmonitored #402 10.10.15.42 5060 Unmonitored #401/401 192.168.15.100 D 5062 Unmonitored #301/301 192.168.15.31 D 5060 Unmonitored #300/300 192.168.15.31 D 5060 Unmonitored ------------------------------< cut here >------------------------------------------------------- Vieri wrote:> Hi, > > I am trying to get a SIP extension's status without > actually making a call. > > I am using sofia-sip's "options" example utility and > the sip clients are SJphone softphones. > > >From Asterisk I run the "options" utility and query a > sip extension at 10.215.147.240. I get: > > # ./options -1 --all sip:10.215.147.240 > SIP/2.0 501 Not Implemented > Via: SIP/2.0/UDP > 10.215.144.27:38098;branch=z9hG4bKUKS02S3F8H8ZS;received=10.215.144.27 > From: <sip:10.215.144.27>;tag=U3DKgF7HgFKXH > To: "unknown" <sip:10.215.147.240>;tag=614733430 > Call-ID: b6968197-1b7d-122b-0ab0-00c09f10e472 > CSeq: 92182805 OPTIONS > Content-Length: 0 > Server: SJphone/1.65.377a (SJ Labs) > > I guess that the softphone should be answering with a > 2xx code followed by a status description? > So I tried with the INVITE method and set DND on the > SIP extension: > > # ./options -1 --all --method INVITE > sip:10.215.147.240 > SIP/2.0 486 Busy Here > Via: SIP/2.0/UDP > 10.215.144.27:38098;branch=z9hG4bK5Z3BS8F737t0e;received=10.215.144.27 > From: <sip:10.215.144.27>;tag=590Z1ND8B6XpN > To: "unknown" <sip:10.215.147.240>;tag=1a2d77b524 > Call-ID: 668ad4fa-1b7e-122b-fcb6-00c09f10e472 > CSeq: 92182952 INVITE > Content-Length: 0 > Server: SJphone/1.65.377a (SJ Labs) > > The above would suit me fine because I get a "486 Busy > Here" response. > However, if DND is off then I get: > > # ./options -1 --all --method INVITE > sip:10.215.147.240 > SIP/2.0 180 Ringing > > and the SIP extension actually "rings", as > expected.(but this is undesireable) > > Now, does someone know another way to get the status > (ie. does it accept calls or not?) without making the > extension "ring"? > > Thanks > > Vieri > > > > ____________________________________________________________________________________ > Be a better pen pal. > Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ > > _______________________________________________ > --Bandwidth and Colocation Provided by http://www.api-digital.com-- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users > > > >-- My wife's sister is in California. I should buy her a Videophone2008! Truly, The Next Best Thing to Being There! -- WorldWideVideoPhones.com 856.380.0894
I also tried: # ./options -1 -a sip:4064 at 192.168.250.1:5072 but still received a SIP/2.0 200 OK Via: SIP/2.0/UDP 10.215.144.27:38102;branch=z9hG4bKFB4rQrr5aXp9H From: <sip:10.215.144.27>;tag=FF1tQy74X81rm To: <sip:4064 at 192.168.250.1>;tag=1639856599 Call-ID: 83259dd2-1b9e-122b-10a3-00c09f10e472 CSeq: 92189848 OPTIONS Supported: replaces, path, timer User-Agent: Grandstream GXW-4008 V1.2A 1.0.0.67 Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE Content-Length: 0 Is Grandstream GXW-4008 not 100% SIP compliant, too? --- Vieri <rentorbuy at yahoo.com> wrote:> > --- Tilghman Lesher > <tilghman at mail.jeffandtilghman.com> wrote: > > > OPTIONS is the right type of request > > Suppose that the user agent is not a softphone but a > gateway such as the Grandstream GXW-4008 ATA. > One of the FXS-port-connected phones of the gateway > has DND turned on. > IF I send an OPTIONS request then the UA always > answers with a 200 ok even if the extension is > actually busy. > > In this particular case, how does one get the status > of an extension "behind a user agent/gateway"? (am I > writing the sip url correctly in the sofia-sip > options > utility below?) > > ("database show dnd" does not yield anything) > > # ./options -1 -a sip:4064 at 192.168.250.1 > SIP/2.0 200 OK > Via: SIP/2.0/UDP > 10.215.144.27:38102;branch=z9hG4bKF8F0cQa7N9cva > From: <sip:10.215.144.27>;tag=Fcj2gFcX9ctpg > To: <sip:4064 at 192.168.250.1>;tag=1260250638 > Call-ID: 3cb23664-1b9c-122b-6393-00c09f10e472 > CSeq: 92189360 OPTIONS > Supported: replaces, path, timer > User-Agent: Grandstream GXW-4008 V1.2A 1.0.0.67 > Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, > NOTIFY, INFO, REFER, UPDATE > Content-Length: 0 > > -------- > On the asterisk cli: > > CLI> sip show peers > Name/username Host Dyn Nat > ACL > Port Status > 4444/4444 192.168.250.1 D N > > 5060 OK (8 ms) > 4173/4173 (Unspecified) D N > > 0 UNKNOWN > 4172/4172 (Unspecified) D N > > 0 Unmonitored > 4171/4171 (Unspecified) D N > > 0 Unmonitored > 4170/4170 (Unspecified) D N > > 0 Unmonitored > 4065/4065 192.168.250.1 D N > > 6074 OK (8 ms) > 4064/4064 192.168.250.1 D N > > 5072 OK (8 ms) > 4063/4063 192.168.250.1 D N > > 5068 OK (8 ms) > 4061/4061 192.168.250.1 D N > > 5070 OK (8 ms) > 4059/4059 (Unspecified) D N > > 0 Unmonitored > 4058/4058 (Unspecified) D N > > 0 UNKNOWN > 4057/4057 (Unspecified) D N > > 0 UNKNOWN > 4056/4056 (Unspecified) D N > > 0 UNKNOWN > 4055/4055 (Unspecified) D N > > 0 Unmonitored > 4054/4054 (Unspecified) D N > > 0 UNKNOWN > 4053/4053 10.215.147.240 D N > > 5060 OK (139 ms) > 4052/4052 (Unspecified) D N > > 0 Unmonitored > 4022/4022 192.168.250.1 D N > > 5062 OK (8 ms) > 4013/4013 (Unspecified) D N > > 0 UNKNOWN > 4012/4012 (Unspecified) D N > > 0 UNKNOWN > 4004/4004 (Unspecified) D N > > 0 UNKNOWN > 4003/4003 10.215.145.170 D N > > 5060 OK (1 ms) > 4002/4002 (Unspecified) D N > > 0 UNKNOWN > 23 sip peers [14 online , 9 offline] > > CLI> sip show peer 4064 > CLI> > > * Name : 4064 > Secret : <Set> > MD5Secret : <Not set> > Context : from-internal > Subscr.Cont. : <Not set> > Language : es > AMA flags : Unknown > CallingPres : Presentation Allowed, Not Screened > Callgroup : 2 > Pickupgroup : 2 > Mailbox : 4064 at device > VM Extension : asterisk > LastMsgsSent : 0/0 > Call limit : 0 > Dynamic : Yes > Callerid : "device" <4064> > Expire : 22569 > Insecure : no > Nat : Always > ACL : No > CanReinvite : No > PromiscRedir : No > User=Phone : No > Trust RPID : No > Send RPID : No > DTMFmode : rfc2833 > LastMsg : 0 > ToHost : > Addr->IP : 192.168.250.1 Port 5072 > Defaddr->IP : 0.0.0.0 Port 5060 > Def. Username: 4064 > SIP Options : (none) > Codecs : 0x400 (ilbc) > Codec Order : (ilbc) > Status : OK (8 ms) > Useragent : Grandstream GXW-4008 V1.2A > 1.0.0.67 > Reg. Contact : sip:4064 at 192.168.250.1:5072____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
I tried another popular user agent: X-Lite. I dialed *78 which in */FreePBX turns DND on AND I pushed the DND button on the softphone. # asterisk -vvvr CLI> database show dnd /DND/4053 : YES Despite all this when I send an OPTIONS request I always get a "200 ok" reply. Is X-Lite also "broken" with respect to the SIP RFC? Or am I doing things wrong? # ./options -1 -a --method OPTIONS sip:4053 at 10.215.147.240:6486 SIP/2.0 200 OK Via: SIP/2.0/UDP 10.215.144.27:38102;branch=z9hG4bKZDm0j0KD5BSBQ Contact: <sip:10.215.147.240:6486> To: <sip:4053 at 10.215.147.240>;tag=681c6278 From: <sip:10.215.144.27>;tag=Z1QHmBt52Dp1Q Call-ID: 6b9f7f35-1ba1-122b-d4b7-00c09f10e472 CSeq: 92190473 OPTIONS Accept: application/sdp Accept-Language: en Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO User-Agent: X-Lite release 1011s stamp 41150 Content-Length: 0 CLI> sip show peer 4053 INF-VOIP*CLI> * Name : 4053 Secret : <Set> MD5Secret : <Not set> Context : from-internal Subscr.Cont. : <Not set> Language : es AMA flags : Unknown CallingPres : Presentation Allowed, Not Screened Callgroup : 2 Pickupgroup : 2 Mailbox : 4053 at device VM Extension : asterisk LastMsgsSent : 0/0 Call limit : 0 Dynamic : Yes Callerid : "device" <4053> Expire : 3597 Insecure : no Nat : Always ACL : No CanReinvite : No PromiscRedir : No User=Phone : No Trust RPID : No Send RPID : No DTMFmode : rfc2833 LastMsg : 0 ToHost : Addr->IP : 10.215.147.240 Port 6486 Defaddr->IP : 0.0.0.0 Port 5060 Def. Username: 4053 SIP Options : (none) Codecs : 0x400 (ilbc) Codec Order : (ilbc) Status : OK (169 ms) Useragent : X-Lite release 1011s stamp 41150 Reg. Contact : sip:4053 at 10.215.147.240:6486;rinstance=ff64e47c4f35bdef ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs ____________________________________________________________________________________ Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/
Richard Revels
2007-Dec-02 23:07 UTC
[asterisk-users] get SIP extension status without calling it
In the sip.conf entry assign a context. In that context, hint the extension i.e. exten => 7302,hint,SIP/7302. Before you get ready to dial, or whatever, do chanisavail i.e. exten => _1XXXX,n(CheckUse),ChanIsAvail(SIP/${EXTEN:1},js) exten => _1XXXX,n,Playback(beep) exten => _1XXXX,n,Dial(SIP/${EXTEN},2) exten => _1XXXX,n,Goto(result-${DIALSTATUS},${EXTEN},1) exten => _1XXXX,CheckUse+101,SayDigits(${EXTEN:1}) exten => _1XXXX,CheckUse+102,Playback(vm-isonphone) exten => _1XXXX,CheckUse+103,Hangup() This is from the paging stuff. It checks the primary extension before ringing the auto answer extension of the phone. I seem to remember it detecting DND as well for the Cisco 7960. I don't see it in this message but I seem to remember seeing somewhere in this thread that the goal is to keep people from being in a queue forever. Why not just set a time limit on the queue and play back "all operators busy" and hang up if a call hits that limit? Richard On Dec 2, 2007, at 8:51 AM, Vieri wrote:> Hi, > > I am trying to get a SIP extension's status without > actually making a call. > > I am using sofia-sip's "options" example utility and > the sip clients are SJphone softphones. > > From Asterisk I run the "options" utility and query a > sip extension at 10.215.147.240. I get: > > # ./options -1 --all sip:10.215.147.240 > SIP/2.0 501 Not Implemented > Via: SIP/2.0/UDP > 10.215.144.27:38098;branch=z9hG4bKUKS02S3F8H8ZS;received=10.215.144.27 > From: <sip:10.215.144.27>;tag=U3DKgF7HgFKXH > To: "unknown" <sip:10.215.147.240>;tag=614733430 > Call-ID: b6968197-1b7d-122b-0ab0-00c09f10e472 > CSeq: 92182805 OPTIONS > Content-Length: 0 > Server: SJphone/1.65.377a (SJ Labs) > > I guess that the softphone should be answering with a > 2xx code followed by a status description? > So I tried with the INVITE method and set DND on the > SIP extension: > > # ./options -1 --all --method INVITE > sip:10.215.147.240 > SIP/2.0 486 Busy Here > Via: SIP/2.0/UDP > 10.215.144.27:38098;branch=z9hG4bK5Z3BS8F737t0e;received=10.215.144.27 > From: <sip:10.215.144.27>;tag=590Z1ND8B6XpN > To: "unknown" <sip:10.215.147.240>;tag=1a2d77b524 > Call-ID: 668ad4fa-1b7e-122b-fcb6-00c09f10e472 > CSeq: 92182952 INVITE > Content-Length: 0 > Server: SJphone/1.65.377a (SJ Labs) > > The above would suit me fine because I get a "486 Busy > Here" response. > However, if DND is off then I get: > > # ./options -1 --all --method INVITE > sip:10.215.147.240 > SIP/2.0 180 Ringing > > and the SIP extension actually "rings", as > expected.(but this is undesireable) > > Now, does someone know another way to get the status > (ie. does it accept calls or not?) without making the > extension "ring"? > > Thanks > > Vieri > > > > > ____________________________________________________________________________________ > Be a better pen pal. > Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ > > _______________________________________________ > --Bandwidth and Colocation Provided by http://www.api-digital.com-- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20071202/49caa7cc/attachment.htm