Asterisk Wrong Billsec - server

The problem is this: I have an Asterisk server, with a custom context to count and set limit call time to the extensions. I see that the Billsec values on the DB, is wrong, because it is counting since the call is ringing, not when the call is answered.
Can you help me please. My server has a SIP trunk to make the calls
Here's the flow of the call
Net Flow
And here's the output of elastix with verbose
-- Executing [XXXXXXXXXX#from-internal:1] Macro("SIP/14105-000000b2", "user-callerid,LIMIT,EXTERNAL,") in new stack
-- Executing [s#macro-user-callerid:1] Set("SIP/14105-000000b2", "TOUCH_MONITOR=1526653901.192") in new stack
-- Executing [s#macro-user-callerid:2] Set("SIP/14105-000000b2", "AMPUSER=14105") in new stack
-- Executing [s#macro-user-callerid:3] GotoIf("SIP/14105-000000b2", "0?report") in new stack
-- Executing [s#macro-user-callerid:4] ExecIf("SIP/14105-000000b2", "1?Set(REALCALLERIDNUM=14105)") in new stack
-- Executing [s#macro-user-callerid:5] Set("SIP/14105-000000b2", "AMPUSER=14105") in new stack
-- Executing [s#macro-user-callerid:6] GotoIf("SIP/14105-000000b2", "0?limit") in new stack
-- Executing [s#macro-user-callerid:7] Set("SIP/14105-000000b2", "AMPUSERCIDNAME=HERE'S_EXTENSION") in new stack
-- Executing [s#macro-user-callerid:8] GotoIf("SIP/14105-000000b2", "0?report") in new stack
-- Executing [s#macro-user-callerid:9] Set("SIP/14105-000000b2", "AMPUSERCID=14105") in new stack
-- Executing [s#macro-user-callerid:10] Set("SIP/14105-000000b2", "__DIAL_OPTIONS=tr") in new stack
-- Executing [s#macro-user-callerid:11] Set("SIP/14105-000000b2", "CALLERID(all)="HERE'S_EXTENSION" <14105>") in new stack
-- Executing [s#macro-user-callerid:12] GotoIf("SIP/14105-000000b2", "0?limit") in new stack
-- Executing [s#macro-user-callerid:13] ExecIf("SIP/14105-000000b2", "1?Set(GROUP(concurrency_limit)=14105)") in new stack
-- Executing [s#macro-user-callerid:14] ExecIf("SIP/14105-000000b2", "0?Set(CHANNEL(language)=)") in new stack
-- Executing [s#macro-user-callerid:15] GotoIf("SIP/14105-000000b2", "1?continue") in new stack
-- Goto (macro-user-callerid,s,28)
-- Executing [s#macro-user-callerid:28] Set("SIP/14105-000000b2", "CALLERID(number)=14105") in new stack
-- Executing [s#macro-user-callerid:29] Set("SIP/14105-000000b2", "CALLERID(name)=HERE'S_EXTENSION") in new stack
-- Executing [s#macro-user-callerid:30] Set("SIP/14105-000000b2", "CDR(cnum)=14105") in new stack
-- Executing [s#macro-user-callerid:31] Set("SIP/14105-000000b2", "CDR(cnam)=HERE'S_EXTENSION") in new stack
-- Executing [s#macro-user-callerid:32] Set("SIP/14105-000000b2", "CHANNEL(language)=es") in new stack
-- Executing [XXXXXXXXXX#from-internal:2] Set("SIP/14105-000000b2", "EMERGENCYROUTE=YES") in new stack
-- Executing [XXXXXXXXXX#from-internal:3] Set("SIP/14105-000000b2", "INTRACOMPANYROUTE=YES") in new stack
-- Executing [XXXXXXXXXX#from-internal:4] Set("SIP/14105-000000b2", "MOHCLASS=music-rony") in new stack
-- Executing [XXXXXXXXXX#from-internal:5] Set("SIP/14105-000000b2", "_NODEST=") in new stack
-- Executing [XXXXXXXXXX#from-internal:6] Gosub("SIP/14105-000000b2", "sub-record-check,s,1(out,XXXXXXXXXX,)") in new stack
-- Executing [s#sub-record-check:1] Set("SIP/14105-000000b2", "REC_POLICY_MODE_SAVE=") in new stack
-- Executing [s#sub-record-check:2] GotoIf("SIP/14105-000000b2", "1?check") in new stack
-- Goto (sub-record-check,s,7)
-- Executing [s#sub-record-check:7] Set("SIP/14105-000000b2", "__MON_FMT=wav") in new stack
-- Executing [s#sub-record-check:8] GotoIf("SIP/14105-000000b2", "1?next") in new stack
-- Goto (sub-record-check,s,11)
-- Executing [s#sub-record-check:11] ExecIf("SIP/14105-000000b2", "0?Return()") in new stack
-- Executing [s#sub-record-check:12] ExecIf("SIP/14105-000000b2", "0?Set(__REC_POLICY_MODE=)") in new stack
-- Executing [s#sub-record-check:13] GotoIf("SIP/14105-000000b2", "0?out,1") in new stack
-- Executing [s#sub-record-check:14] Set("SIP/14105-000000b2", "__REC_STATUS=INITIALIZED") in new stack
-- Executing [s#sub-record-check:15] Set("SIP/14105-000000b2", "NOW=1526653901") in new stack
-- Executing [s#sub-record-check:16] Set("SIP/14105-000000b2", "__DAY=18") in new stack
-- Executing [s#sub-record-check:17] Set("SIP/14105-000000b2", "__MONTH=05") in new stack
-- Executing [s#sub-record-check:18] Set("SIP/14105-000000b2", "__YEAR=2018") in new stack
-- Executing [s#sub-record-check:19] Set("SIP/14105-000000b2", "__TIMESTR=20180518-093141") in new stack
-- Executing [s#sub-record-check:20] Set("SIP/14105-000000b2", "__FROMEXTEN=14105") in new stack
-- Executing [s#sub-record-check:21] Set("SIP/14105-000000b2", "__CALLFILENAME=out-XXXXXXXXXX-14105-20180518-093141-1526653901.192") in new stack
-- Executing [s#sub-record-check:22] Goto("SIP/14105-000000b2", "out,1") in new stack
-- Goto (sub-record-check,out,1)
-- Executing [out#sub-record-check:1] ExecIf("SIP/14105-000000b2", "1?Set(__REC_POLICY_MODE=dontcare)") in new stack
-- Executing [out#sub-record-check:2] GosubIf("SIP/14105-000000b2", "0?record,1(exten,XXXXXXXXXX,14105)") in new stack
-- Executing [out#sub-record-check:3] Return("SIP/14105-000000b2", "") in new stack
-- Executing [XXXXXXXXXX#from-internal:7] Macro("SIP/14105-000000b2", "dialout-trunk,2,926984292,,off") in new stack
-- Executing [s#macro-dialout-trunk:1] Set("SIP/14105-000000b2", "DIAL_TRUNK=2") in new stack
-- Executing [s#macro-dialout-trunk:2] GosubIf("SIP/14105-000000b2", "0?sub-pincheck,s,1()") in new stack
-- Executing [s#macro-dialout-trunk:3] GotoIf("SIP/14105-000000b2", "0?disabletrunk,1") in new stack
-- Executing [s#macro-dialout-trunk:4] Set("SIP/14105-000000b2", "DIAL_NUMBER=926984292") in new stack
-- Executing [s#macro-dialout-trunk:5] Set("SIP/14105-000000b2", "DIAL_TRUNK_OPTIONS=tr") in new stack
-- Executing [s#macro-dialout-trunk:6] Set("SIP/14105-000000b2", "OUTBOUND_GROUP=OUT_2") in new stack
-- Executing [s#macro-dialout-trunk:7] GotoIf("SIP/14105-000000b2", "1?nomax") in new stack
-- Goto (macro-dialout-trunk,s,9)
-- Executing [s#macro-dialout-trunk:9] GotoIf("SIP/14105-000000b2", "1?skipoutcid") in new stack
-- Goto (macro-dialout-trunk,s,12)
-- Executing [s#macro-dialout-trunk:12] GosubIf("SIP/14105-000000b2", "1?sub-flp-2,s,1()") in new stack
-- Executing [s#sub-flp-2:1] ExecIf("SIP/14105-000000b2", "1?Set(TARGET_FLP_2=01151926984292)") in new stack
-- Executing [s#sub-flp-2:2] GotoIf("SIP/14105-000000b2", "1?match") in new stack
-- Goto (sub-flp-2,s,6)
-- Executing [s#sub-flp-2:6] Set("SIP/14105-000000b2", "DIAL_NUMBER=01151926984292") in new stack
-- Executing [s#sub-flp-2:7] Return("SIP/14105-000000b2", "") in new stack
-- Executing [s#macro-dialout-trunk:13] Set("SIP/14105-000000b2", "OUTNUM=01151926984292") in new stack
-- Executing [s#macro-dialout-trunk:14] Set("SIP/14105-000000b2", "custom=SIP/IDT") in new stack
-- Executing [s#macro-dialout-trunk:15] ExecIf("SIP/14105-000000b2", "1?Set(DIAL_TRUNK_OPTIONS=M(setmusic^music-rony)tr)") in new stack
-- Executing [s#macro-dialout-trunk:16] ExecIf("SIP/14105-000000b2", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^music-rony)trM(confirm))") in new stack
-- Executing [s#macro-dialout-trunk:17] Macro("SIP/14105-000000b2", "dialout-trunk-predial-hook,") in new stack
-- Executing [s#macro-dialout-trunk-predial-hook:1] MacroExit("SIP/14105-000000b2", "") in new stack
-- Executing [s#macro-dialout-trunk:18] GotoIf("SIP/14105-000000b2", "0?bypass,1") in new stack
-- Executing [s#macro-dialout-trunk:19] ExecIf("SIP/14105-000000b2", "1?Set(CONNECTEDLINE(num,i)=01151926984292)") in new stack
-- Executing [s#macro-dialout-trunk:20] ExecIf("SIP/14105-000000b2", "1?Set(CONNECTEDLINE(name,i)=CID:14105)") in new stack
-- Executing [s#macro-dialout-trunk:21] GotoIf("SIP/14105-000000b2", "0?customtrunk") in new stack
-- Executing [s#macro-dialout-trunk:22] Dial("SIP/14105-000000b2", "SIP/IDT/01151926984292,300,M(setmusic^music-rony)tr") in new stack
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
-- Called SIP/IDT/01151926984292
-- SIP/IDT-000000b3 answered SIP/14105-000000b2
-- Executing [s#macro-setmusic:1] Set("SIP/IDT-000000b3", "CHANNEL(musicclass)=music-rony") in new stack
> 0x2752f70 -- Probation passed - setting RTP source address to XXX.XXX.XXX.XXX:21522
> 0x29fa6b0 -- Probation passed - setting RTP source address to XXX.XXX.XXX.XXX:36935
> 0x29fa6b0 -- Probation passed - setting RTP source address to XXX.XXX.XXX.XXX:36935
-- Executing [h#macro-dialout-trunk:1] Macro("SIP/14105-000000b2", "hangupcall,") in new stack
-- Executing [s#macro-hangupcall:1] GotoIf("SIP/14105-000000b2", "1?endmixmoncheck") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s#macro-hangupcall:9] NoOp("SIP/14105-000000b2", "End of MIXMON check") in new stack
-- Executing [s#macro-hangupcall:10] GotoIf("SIP/14105-000000b2", "1?nomeetmemon") in new stack
-- Goto (macro-hangupcall,s,28)
-- Executing [s#macro-hangupcall:28] NoOp("SIP/14105-000000b2", "End of MEETME check") in new stack
-- Executing [s#macro-hangupcall:29] GotoIf("SIP/14105-000000b2", "1?noautomon") in new stack
-- Goto (macro-hangupcall,s,34)
-- Executing [s#macro-hangupcall:34] NoOp("SIP/14105-000000b2", "TOUCH_MONITOR_OUTPUT=") in new stack
-- Executing [s#macro-hangupcall:35] GotoIf("SIP/14105-000000b2", "1?noautomon2") in new stack
-- Goto (macro-hangupcall,s,41)
-- Executing [s#macro-hangupcall:41] NoOp("SIP/14105-000000b2", "MONITOR_FILENAME=") in new stack
-- Executing [s#macro-hangupcall:42] GotoIf("SIP/14105-000000b2", "1?noautomon3") in new stack
-- Goto (macro-hangupcall,s,48)
-- Executing [s#macro-hangupcall:48] NoOp("SIP/14105-000000b2", "MIXMONITOR_FILENAME=") in new stack
-- Executing [s#macro-hangupcall:49] GotoIf("SIP/14105-000000b2", "1?noautomon4") in new stack
-- Goto (macro-hangupcall,s,51)
-- Executing [s#macro-hangupcall:51] NoOp("SIP/14105-000000b2", "ONETOUCH_RECFILE=") in new stack
-- Executing [s#macro-hangupcall:52] GotoIf("SIP/14105-000000b2", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,55)
-- Executing [s#macro-hangupcall:55] GotoIf("SIP/14105-000000b2", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,58)
-- Executing [s#macro-hangupcall:58] GotoIf("SIP/14105-000000b2", "1?theend") in new stack
-- Goto (macro-hangupcall,s,60)
-- Executing [s#macro-hangupcall:60] AGI("SIP/14105-000000b2", "hangup.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hangup.agi
-- <SIP/14105-000000b2>AGI Script hangup.agi completed, returning 0
-- Executing [s#macro-hangupcall:61] Hangup("SIP/14105-000000b2", "") in new stack
== Spawn extension (macro-hangupcall, s, 61) exited non-zero on 'SIP/14105-000000b2' in macro 'hangupcall'
== Spawn extension (macro-dialout-trunk, h, 1) exited non-zero on 'SIP/14105-000000b2'
== Spawn extension (macro-dialout-trunk, s, 22) exited non-zero on 'SIP/14105-000000b2' in macro 'dialout-trunk'
== Spawn extension (from-internal, XXXXXXXXXX, 7) exited non-zero on 'SIP/14105-000000b2'

Dump your traffic for sip port and analyse with wireshark than you can see your flow, you need to check all packets, if you give first 200 then ring so it is problem by your provider side.
Example command for dump
tcpdump -i eth0 -n -s 0 port 5060 -vvv -w capture_file_name.cap
After that, download file to your local directory with scp. Open with Wireshark.

Capture made
This is the capture that i have when a call is made.

Related

1602 LCD through I2C with an FT232h not working on Raspberry Pi

I have a Raspberry Pi trying to drive a 1602 Character LCD that's connected through the I2C pin outs on an FT232H breakout board (from adafruit). However, I am unable print anything to it. I can see the address of the LCD through running this python script
import board
import busio
import time
i2c = busio.I2C(board.SCL, board.SDA)
while not i2c.try_lock():
pass
while True:
print("I2C addresses found:", [hex(device_address)
for device_address in i2c.scan()])
time.sleep(2)
And see that it reports a I2C addresses found: ['0x20'].
When I run i2cdetect -y 1 though, I do not see any devices connected.
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
I figured this was just because the LCD screen was being driven from the ft232h so I didn't have much concerns. However I am still unable to write anything to it and when I run the following script it just flashes.
import board
import busio
from adafruit_character_lcd.character_lcd_i2c import Character_LCD_I2C
i2c = busio.I2C(board.SCL, board.SDA)
lcd = Character_LCD_I2C(i2c, 16, 2)
while True:
lcd.message = "test"
lcd.backlight = True

pytest failure with no traceback or showing code

i want to change the behavior of pytest failure. i don't want to see a code or any trace back in the failure summery. i just want it to show the assertion statement and that is all. how i can do that
for instance if i have
assert x==y , pytest.fail("fail message")
i want the test to fail with the "fail message" and with no traceback
i usually workaround unexpected exception with logging the errors and exit , but i am not sure how to handle the pytest assertion

Airflow: Celery task failure

I have airflow up and running but I have an issue where my task is failing in celery.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/airflow/executors/celery_executor.py", line 52, in execute_command
subprocess.check_call(command, shell=True)
File "/usr/local/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'airflow run airflow_tutorial_v01 print_hello 2017-06-01T15:00:00 --local -sd /usr/local/airflow/dags/hello_world.py' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 375, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 632, in __protected_call__
return self.run(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/airflow/executors/celery_executor.py", line 55, in execute_command
raise AirflowException('Celery command failed')
airflow.exceptions.AirflowException: Celery command failed
it is a very basic DAG (taken from the hello world tutorial: https://github.com/apache/incubator-airflow/blob/master/airflow/example_dags/tutorial.py).
Also I do not see any logs of my worker, I got this stack strace from the Flower web interface.
If I run manually on the worker node, the airflow run command mentionned in the stack trace it works.
How can I get more information to debug further?
The only log I get when starting `airflow work` is
root#ip-10-0-4-85:~# /usr/local/lib/python3.5/dist-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
[2018-07-25 17:49:43,430] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python3.5/lib2to3/Grammar.txt
[2018-07-25 17:49:43,469] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python3.5/lib2to3/PatternGrammar.txt
[2018-07-25 17:49:43,594] {__init__.py:45} INFO - Using executor CeleryExecutor
Starting flask
[2018-07-25 17:49:43,665] {_internal.py:88} INFO - * Running on http://0.0.0.0:8793/ (Press CTRL+C to quit)
^C
The config I use is the default one with a postgresql and redis backend for celery.
I see the worked online in Flower.
Thanks.
edit: edited for more informations

using celery in airflow

I am new to airflow, for now I find out airflow is using celery to schedule its tasks. To run airflow, I need to run command 'airflow worker' which will start celery. However, there is always a bug here. Since I have searched in Internet, most problem happen to celery.py which write by user themselves. I use celery just by start airflow. So it is a little bit different.
Anyone could help me? Below is the screenshot of the bug.
airflow#linux-test:~$ airflow worker
[2018-06-22 07:29:04,068] {__init__.py:57} INFO - Using executor CeleryExecutor
[2018-06-22 07:29:04,125] {driver.py:124} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2018-06-22 07:29:04,146] {driver.py:124} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
-------------- celery#linux-test v4.2.0 (windowlicker)
---- **** -----
--- * *** * -- Linux-4.15.0-22-generic-x86_64-with-Ubuntu-18.04-bionic 2018-06-22 07:29:04
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: airflow.executors.celery_executor:0x7f2267122310
- ** ---------- .> transport: amqp://airflow:**#localhost:5672/airflow
- ** ---------- .> results: postgresql://airflow:**#localhost:5432/airflow
- *** --- * --- .> concurrency: 16 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> default exchange=default(direct) key=default
[2018-06-22 07:29:04,630] {__init__.py:57} INFO - Using executor CeleryExecutor
[2018-06-22 07:29:04,689] {driver.py:124} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2018-06-22 07:29:04,715] {driver.py:124} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
Starting flask
[2018-06-22 07:29:04,858] {_internal.py:88} INFO - * Running on http://0.0.0.0:8793/ (Press CTRL+C to quit)
[2018-06-22 07:29:06,122: ERROR/ForkPoolWorker-1] Pool process <celery.concurrency.asynpool.Worker object at 0x7f22648c8e10> error: TypeError("Required argument 'object' (pos 1) not found",)
Traceback (most recent call last):
File "/home/airflow/.local/lib/python2.7/site-packages/billiard/pool.py", line 289, in __call__
sys.exit(self.workloop(pid=pid))
File "/home/airflow/.local/lib/python2.7/site-packages/billiard/pool.py", line 347, in workloop
req = wait_for_job()
File "/home/airflow/.local/lib/python2.7/site-packages/billiard/pool.py", line 447, in receive
ready, req = _receive(1.0)
File "/home/airflow/.local/lib/python2.7/site-packages/billiard/pool.py", line 419, in _recv
return True, loads(get_payload())
File "/home/airflow/.local/lib/python2.7/site-packages/billiard/common.py", line 107, in pickle_loads
return load(BytesIO(s))
TypeError: Required argument 'object' (pos 1) not found
[2018-06-22 07:29:06,127: ERROR/MainProcess] Process 'ForkPoolWorker-1' pid:18839 exited with 'exitcode 1'
Uninstalling librabbitmq worked for me : pip uninstall librabbitmq. I didn't understand very well why, but apparently, there's some optimization on that library that made the thing fail. Here's the answer I found on some website (I had to translate the page, thus my inability to understand well the solution)
Hope it helps

fabric: Stacktrace on error?

If a fabric command fails, we get the below output.
But it would be very good for debugging to get a stacktrace.
I looked at fab --help and could not find an answer.
Here is our current output:
[remote-host] out:
Fatal error: run() received nonzero return code 1 while executing!
Requested: ...
Executed: /bin/bash -l -c "source /localhome/foo_eins_dtg/bin/activate && ...
Aborting.
Disconnecting from foo_eins_dtg#remote-host... done.
Disconnecting from root#remote-host... done.
How to get a stacktrace if the fabric command failes?
Up to now it is not possible. I asked on the mailing list.
bitprophet (the author) opened a ticket for the feature request:
https://github.com/fabric/fabric/issues/1200