Maxcall per user with PJSIP

Hi all,

with SIP there were a special field, called call-limit.
We cannot find something like that with PJSIP.

We manage to to things using group() and group_count(), it is not easy as we have to managed for caller AND callee.
We are using database to set max call per users
But if you add pickup this is more complicated :slight_smile:
We managed to do some things but we’d like to know if there is a better (more simple!) way ?

Do you know if there is a function that returns the number of channel where a user is
Something like count_chan(PJSIP/bob) would be perfect !

Thanks a lot

I don’t know if such function exist, but you can create your own function using :
Asterisk core show channels command, grep,wc, and shell ()

Hi and thanks for this reply

This means that we can use asterisk and linux command into dialplan ? I’ll have a look at it.
But won’t it be to slow to call such command to count how many calls a user have just to decide if we send the call or not ?

As you are not querying a DB the command reply and processing is extremely fast

Also don’t know if there is a better way, but you can simplify your command pipeline from:

asterisk -x 'core show channels' | grep SIP/poly-77a1 | wc --lines


asterisk -x 'core show channels' | grep --count SIP/poly-77a1

and save a couple of milliseconds :slight_smile:

Many thanks for that !
This seems more easy and accurate than using group() and group_count() that has problem with pickup.

Just one weird thing :

alice calls bob
charlie pickup bob

if we do :

asterisk -x 'core show channels' | grep --count PJSIP/user

for user= alice, bob and charlie, we get 1 (bob should be at 0, no ?)

But if we do (change core by pjsip) :

asterisk -x 'pjsip show channels' | grep --count PJSIP/user

for user= alice and charlie we got 1
for user = bob we get 0 what is correct

Then when picking up someone, something remain into the core and this is what we saw when usings group()

I wonder how others people are doing to have a call limit for each case : call between A and B, pickup, transfert, conference, and so on.

We will try with above commands and see how it goes

Thanks to both of you !!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.