Thanks for your help. I now implemented the GotoIfTime() function on the dialplan. The goal is to have a maximum number of channels of 8 everyday, except the 10th day of the month where we should have 12 channels available. If there aren’t any free channels left, hangup.
[code]
exten => 1,1,Answer
exten => 1,2,Background(/var/lib/asterisk/sounds/it/custom/benvenuto)
exten => 1,3,Set(GROUP()=chiam_in)
exten => 1,4,Verbose(1,**** Numero chiamate ${GROUP_COUNT(chiam_in)})
exten => 1,5,GotoIfTime(*|*|10|*?1,8)
exten => 1,6,GotoIf($[${GROUP_COUNT(chiam_in)} > 8]?3,1)
exten => 1,7,Goto(1,9)
exten => 1,8,GotoIf($[$[GROUP_COUNT(chiam_in)} > 12]?3,1)
exten => 1,9,WaitExten(2)
exten => 1,10,Queue(Segreteria,t,,,600)
exten => 1,11,Background(/var/lib/asterisk/sounds/it/custom/OperatoriOccupati)
exten => 1,12,Hangup()
exten => 2,1,Answer
exten => 2,2,Dial(SIP/301&SIP/302&SIP/422&SIP/423&SIP/425&SIP/426&SIP/490&SIP/496&SIP/497&SIP/498&SIP/499,30,tTr)
exten => 2,3,Background(/var/lib/asterisk/sounds/it/custom/fuori-orario)
exten => 2,4,Hangup()
exten =>3,1,Verbose(1,***limite superato ${GROUP_COUNT(server2Trunkgroup)})
exten =>3,2,Background(/var/lib/asterisk/sounds/it/custom/OperatoriOccupati)
exten =>3,3,Set(DIALSTATUS=CHANUNAVAIL)
Unfortunately the customer is telling us that today (which is the 10th btw) there are too many channels opened and that the pbx is flooded with calls.
These are the logs of a level 9 debug on Asterisk:
Goto (code,1,1)
-- Executing [1@code:1] Answer("SIP/0110898XXX-000068XX", "") in new stack
-- Executing [1@code:2] BackGround("SIP/0110898XXX-000068XX", "/var/lib/asterisk/sounds/it/custom/benvenuto") in new stack
-- <SIP/0110898XXX-00006841> Playing '/var/lib/asterisk/sounds/it/custom/benvenuto.slin' (language 'it')
-- Channel SIP/0110898XXX-000067bc left 'simple_bridge' basic-bridge <4a5f5a86-5d85-48c1-af2d-6402e2df8c78>
== Spawn extension (code, 1, 10) exited non-zero on 'SIP/0110898XXX-000067bc'
-- Channel SIP/302-000067f8 left 'simple_bridge' basic-bridge <4a5f5a86-5d85-48c1-af2d-6402e2df8c78>
> 0x7f71440078e0 -- Strict RTP learning complete - Locking on source address 192.168.4.107:60972
-- Stopped music on hold on SIP/0110898XXX-000067e8
-- Playing periodic announcement
-- <SIP/0110898XXX-000067e8> Playing '/var/lib/asterisk/sounds/it/custom/primo-operatore.slin' (language 'it')
> 0x7f718006b8d0 -- Strict RTP learning complete - Locking on source address 83.211.227.12:51952
[Mar 10 15:21:29] NOTICE[1590][C-00001567]: chan_sip.c:10812 process_sdp: Processed audio crypto attribute without SAVP specified; accepting anyway
-- Started music on hold, class 'default', on channel 'SIP/0110898XXX-0000681a'
-- Executing [1@code:3] Set("SIP/0110898XXX-000068XX", "GROUP()=chiam_in") in new stack
-- Executing [1@code:4] Verbose("SIP/0110898XXX-000068XX", "1,**** Numero chiamate 4") in new stack
**** Numero chiamate 4
-- Executing [1@code:5] GotoIfTime("SIP/0110898XXX-000068XX", "*|*|10|*?1,8") in new stack
-- Goto (code,1,8)
[Mar 10 15:21:30] WARNING[1119][C-00001569]: pbx_variables.c:803 pbx_substitute_variables_helper_full: Error in extension logic (missing ']')
[Mar 10 15:21:30] NOTICE[1119][C-00001569]: ast_expr2.y:761 compose_func_args: argbuf allocated 9 bytes;
[Mar 10 15:21:30] NOTICE[1119][C-00001569]: ast_expr2.y:780 compose_func_args: argbuf uses 8 bytes;
[Mar 10 15:21:30] WARNING[1119][C-00001569]: ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ','; Input:
0?3,1
^
[Mar 10 15:21:30] WARNING[1119][C-00001569]: ast_expr2.fl:474 ast_yyerror: If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
-- Executing [1@code:8] GotoIf("SIP/0110898XXX-000068XX", "0") in new stack
-- Executing [1@code:9] WaitExten("SIP/0110898XXX-000068XX", "2") in new stack
== SRTCP unprotect failed on SSRC 231985813 because of authentication failure
-- Timeout on SIP/0110898XXX-000068XX, continuing...
-- Executing [1@code:10] Queue("SIP/0110898XXX-000068XX", "Segreteria,t,,,600") in new stack
-- Started music on hold, class 'default', on channel 'SIP/0110898XXX-000068XX'
-- Stopped music on hold on SIP/0110898XXX-000068XX
-- Playing periodic announcement
(...)
I’m noticing a concerning warning about a missing ‘]’ or something, but to me the GotoIfTime seems okay.
Am I not seeing something ?