[quote=“ambiorixg12”]
Let me know if you need some additional help.[/quote]
Yep, I think I need help, if it doesn’t bother you
I write it to the extensions_custom.conf file
exten => _X.,1,Answer()
exten => _X.,n,NoOp(${STRFTIME(${EPOCH},,%m)})
exten => _X.,n,Set(MONTH=${STRFTIME({$EPOCH},,%m)})
exten => _X.,n,NoOp(Current month is ${MONTH})
exten => _X.,n,Set(TOTALMINUTE=${SHELL(mysql --user=root --password='123456789' asterisk -e 'SELECT sum('billsec') AS totalminute from cdr WHERE 'disposition' = "ANSWERED" AND month(calldate)="${MONTH}" LIMIT 1')})
exten => _X.,n,NoOp(no filter apply ${TOTALMINUTE})
exten => _X.,n,NoOp(filter applied ${TOTALMINUTE:12:-1})
exten => _X.,n,GotoIf($["${T}"<"100"]?yes:no)
exten => _X.,n(yes),Dial(SIP/${EXTEN}@${sipnet},25)
exten => _X.,n,Hangup()
exten => _X.,n(no),Playback(limit-simul-calls)
exten => _X.,n,Hangup()
I don’t know the syntax of shell function, couldn’t find anything helpful in google
Only this onehttp://www.voip-info.org/wiki/view/Asterisk+func+shell, but there are no any example of connecting to mysql.
But I think problem isn’t here.
Here is log
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
-- Executing [301@from-internal:1] Answer("SIP/302-00000005", "") in new stack
-- Executing [301@from-internal:2] NoOp("SIP/302-00000005", "01") in new stack
-- Executing [301@from-internal:3] Set("SIP/302-00000005", "MONTH=01") in new stack
-- Executing [301@from-internal:4] NoOp("SIP/302-00000005", "Current month is 01") in new stack
-- Executing [301@from-internal:5] Set("SIP/302-00000005", "TOTALMINUTE=totalminute
91
") in new stack
-- Executing [301@from-internal:6] NoOp("SIP/302-00000005", "no filter apply totalminute
91
") in new stack
-- Executing [301@from-internal:7] NoOp("SIP/302-00000005", "filter applied 91") in new stack
-- Executing [301@from-internal:8] GotoIf("SIP/302-00000005", "1?yes:no") in new stack
-- Goto (from-internal,301,9)
-- Executing [301@from-internal:9] Dial("SIP/302-00000005", "SIP/301@,25") in new stack
== Everyone is busy/congested at this time (1:0/0/1)
-- Executing [301@from-internal:10] Hangup("SIP/302-00000005", "") in new stack
== Spawn extension (from-internal, 301, 10) exited non-zero on 'SIP/302-00000005'
-- Executing [h@from-internal:1] Macro("SIP/302-00000005", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/302-00000005", "1?endmixmoncheck") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] NoOp("SIP/302-00000005", "End of MIXMON check") in new stack
-- Executing [s@macro-hangupcall:10] GotoIf("SIP/302-00000005", "1?nomeetmemon") in new stack
-- Goto (macro-hangupcall,s,28)
-- Executing [s@macro-hangupcall:28] NoOp("SIP/302-00000005", "End of MEETME check") in new stack
-- Executing [s@macro-hangupcall:29] GotoIf("SIP/302-00000005", "1?noautomon") in new stack
-- Goto (macro-hangupcall,s,34)
-- Executing [s@macro-hangupcall:34] NoOp("SIP/302-00000005", "TOUCH_MONITOR_OUTPUT=") in new stack
-- Executing [s@macro-hangupcall:35] GotoIf("SIP/302-00000005", "1?noautomon2") in new stack
-- Goto (macro-hangupcall,s,41)
-- Executing [s@macro-hangupcall:41] NoOp("SIP/302-00000005", "MONITOR_FILENAME=") in new stack
-- Executing [s@macro-hangupcall:42] GotoIf("SIP/302-00000005", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,45)
-- Executing [s@macro-hangupcall:45] GotoIf("SIP/302-00000005", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,48)
-- Executing [s@macro-hangupcall:48] GotoIf("SIP/302-00000005", "1?theend") in new stack
-- Goto (macro-hangupcall,s,50)
-- Executing [s@macro-hangupcall:50] AGI("SIP/302-00000005", "hangup.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hangup.agi
-- <SIP/302-00000005>AGI Script hangup.agi completed, returning 0
-- Executing [s@macro-hangupcall:51] Hangup("SIP/302-00000005", "") in new stack
== Spawn extension (macro-hangupcall, s, 51) exited non-zero on 'SIP/302-00000005' in macro 'hangupcall'
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/302-00000005'
-- Remote UNIX connection
-- Remote UNIX connection disconnected
dhcp-192-168-168-30*CLI> exit
I see that it found Month correctly Executing [301@from-internal:4] NoOp("SIP/302-00000005", "Current month is 01") in new stack
And it counts totalminute correctly, I presume
Executing [301@from-internal:6] NoOp("SIP/302-00000005", "no filter apply totalminute
91
I think maybe error is here
Maybe trunk name is wrong?
But for now I have only one trunk called "sipnet"
I don’t know what I’m exactly doing wrong, but it doesn’t work.