Sorry if this has been asked before, but can not find any info on this.
Is it possible restrict call per month for specific user???
for example, some specific users will have 30 minutes for outgoing calls per month and some will have nothing.
thx.
You can do it with an AGI script.
I think you should be able to do it direct from extensions.conf.
The main point is that Asterisk works at a much lower level than this, so it provides you with mechanisms for reading call detail records, running code at the end of a call, accessing a databases, and limiting the duration of a particular call, but you have to provide code to turn these into call limits.
I believe the one difficult thing to do is to prevent simultaneous calls taking the user over their limit.
yes you can do it easily by reading user limit time from an external database ( for example mysql ) and set the call timout according to that value .
you need one table with user extensions and time limit per month , etc ,
you can read directly from database in asterisk dialplan .
OK guys, thx for your feedback.
I thought that there is only one way, use external script, I use billing with mysql and there is row “billsec”,I create table “billing” where will be “callerid” and “all_billsec” (these row i counting from “CDR” table from row “billsec”) and I use other script where I set a max value for “all_billsec” , dialplan can be like this:
exten = > _XXXXXXXXXX,1,System(/myscript) //this script will be benchmark “all_billsec” for “callerid” with my threshold (max calling time for user per month) what i set in script, if script return value 1, dialplan will continue, if 0 dial will be denied
exten = > _XXXXXXXXXX,n,Dial(SIP/${EXTEN})
exten = > _XXXXXXXXXX,n,CDR // some CDR extensions
but there is same problem, asterisk billing is not realtime, it write to mysql after call is hangUp, this mean a dont have real “called time” in “all_billsec”, and problem no. 2 is that, asterisk can´t wait to end of my script, but is continue in dialplan ( no matter what myscript return.
omid.mohajerani your option sounds good, but i don´t know how you mean it, for example I have table “billing” (where is called time for user) and other table (where I have threshold for users), what I must have in dialplan??? How i can benchmark my threshold with all_billsec in realtime???
Sorry about my english
THX
you can read time-limit value for users directly from database by using func_odbc . follow this link voip-info.org/wiki/index.php … +func_odbc
then you can set timelimit on calls you want with the TIMEOUT(absolute) variable .
exten => _.,1,Set(TIMEOUT(absolute)=30) ; Max Call Time is 30 Seconds
exten => _.,n,Goto(from-internal,${EXTEN},1)
With this method your call limit will be realtime .
OK, thx
I try it, but it´s not working for me…App TIMEOUT(absolute)30
is include ringing time to the value what i set in parameter, its mean, that call is HangUp after 30 second ringing, doesn’t matter if call was Answered …I also try parameter L in app Dial, like Dial (SIP/${EXTEN},,L(60000[:30000][:3000]))
, its good but asterisk can´t read parameter value from mysql database…OK what i want, I have 3 sip users and one trunk to VOIP provider, I want set 30 minutes per trunk for every user, It´s possible set this threshold in MySql for every user and asterisk will check this value in dialplan???
Thx
You should be able to read the value from the database in the dialplan. Some configuraing is needed to enable database access.
You can compute the value of a Dial L parameter in the dialplan, but you must code the low leve steps yourself.
THX, yes I know, I´m trying this last 2 days. I have test table like:
+----------+--------+----------+
| name | limit | called |
+----------+--------+----------+
| 1000 | 30 | 20 |
+----------+--------+----------+
Dialplan:
1,MYSQL(Connect connid localhost user pass asterisk)
2,MYSQL(Query resultid ${connid} SELECT 'limit FROM test WHERE name = ${CALLERID(num)}')
3,Noop(resultid ${resultid} foundrow ${foundRow} )
but in asterisk console a see MYSQL("SIP/1000-0000001a", "Connect connid localhost user pass asterisk")
-- Executing [1000@internal:2] MYSQL("SIP/1000-0000001a", "Query resultid 1 SELECT 'limit FROM test WHERE name = 1000'")
-- Executing [1000@internal:3] NoOp("SIP/1000-0000001a", "resultid 2 foundrow ")
-- Executing [1000@internal:4] NoOp("SIP/1000-0000001a", ", ")
I can´t get value ‘limit’ from mysql…