Tag Archives: Asterisk

Asterisk monast

Monast https://github.com/dagmoller/monast.git

Іssue: monast.py lost connection to asterisk each 3-4 seconds, and make reconnection

Debian 7
Asterisk 13.5

Tested git commits

* a02a81b 2012-06-19 | added option to set custom peer status using UserEvent [Diego Aguirre]
    DONT WORK - Lost connection to server each 3-4 seconds.

* 777df26 2012-04-24 | changes [Diego Aguirre]
    WORK 

Selected version bbce290 2018-01-23
Commented lines in monast.py:

 server.pushTask(server.ami.command, "database show") \
       .addCallbacks(onCustomPeerStatus, self._onAmiCommandFailure, errbackArgs = (servername, "Error Requesting Custom Peer Status from ASTDB"))

Now connection to asterisk not lost.

Reason on issue: too much records in database, long time of executing request ‘database show’.

$ asterisk -rx 'database deltree q-answered'
156568 database entries removed.

Asterisk CDR setup

cdr_adaptive_odbc

Debian 9 Stretch
Asterisk 13.14.1 from debian repo.
MariaDB 10.3.7 from MariaaDB repo.

apt install unixodbc unixodbc-dev 

/etc/odbcinst.ini

[mariadb]
Description=MariaDB Connector/ODBC v.2.0
Driver=/usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage=1
UsageCount=2

Continue reading

Asterisk | Save queue log in MySQL database

Check for existing ODBC MySQL DSN

asterisk*CLI> odbc show 

ODBC DSN Settings
-----------------
  Name:   asterisk
  DSN:    asteriskcdr-odbc
    Last connection attempt: 2019-12-21 11:42:30
    Number of active connections: 1 (out of 1)

Add to /etc/asterisk/extconfig.conf

[settings]
; queue_log => odbc,{DSN-NAME},{TableName}
queue_log => odbc,asterisk,queue_log_test

Continue reading

Asterisk Waster настройка рабочего времени

No FreePBX, No TrixBox – only /etc/asterisk/ !
Инструмент для определения рабочее/нерабочее время в extentions Asterisk.
Порядок обработки правил: от Большего приоритета к меньшему.
Если текущее время удовлетворяет правилу – обработка закончена и комментарий равен ID – правила, которое его сформировало.
Если ни одно правило не подошло – последним будет НЕ рабочее время (value=0) и комментарий “default last rule”.
Формат возвращаемых данных – plain:

$ curl "http://waster.dev.local/api/isworktime?datetime=2017-12-22 17:00&case=callcenter"
status done
value 0
comment default last rule

Continue reading

Asterisk: мониторинг очереди в Zabbix

Исходная: Астериск, Call-центр, операторов до 10.

Задача: Найти звонки, не принятые операторами Call-центра.

Инструментарии уже какой-то есть, но цифрам не доверяют, потому что число прошущенных звонков по системе сбора статистики очень большое, а найти его в CDR-viewer-е и показать Call-центру, во время разбора полетов не смогли. Потому и засомневались.

Dialplan не формализирован, в настройках куча устаревших рудиментов.

Решили начать с мониторинга – А что же там реально происходит.

День начала сбора статистики:

Среднее число звонков ожидающих попадание в очередь: 2,54

Continue reading

Asterisk AmoCRM интеграция

На текущий момент работает:
– Входящие через Asterisk виден Менеджеру в AmoCRM (всплывает окно, видно в карточке клиента)
– Исходящий со страницы AmoCRM выполняется. (см. amocrm.php п.5)
– Записанные звонки проигрываются.
– CDR-загружаются в AmoCRM. (Загадочное место, не нашел внятных объяснений поставщика)
Continue reading

Asterisk абонент Cisco 7911G

Заставить телефон обновить прошивку:
1. Выключаем питание телефона.
2. Зажимаем #
3. Включаем питание, не отпуская #
4. После того как индикатор на трубке начнёт мигать, отпускаем #
5. Вводим код: 349167285*0# или 123456789*0#
Continue reading

Asterisk chan_dongle

# Качаем
cd /usr/src
wget https://github.com/oleg-krv/asterisk-chan-dongle/archive/asterisk13.zip
# В пакете вложена инструкция по установке!
$ cd asterisk-chan-dongle-asterisk13
#
$ aclocal 
$ autoconf
$ automake -a
#
$ ./configure
#
$ make
$ make install
....
cpvt.o dc_config.o pdu.o mixbuffer.o pdiscovery.o
strip chan_dongle.so
/usr/bin/install -c -m 755 chan_dongle.so /usr/lib/asterisk/modules

Continue reading

Asterisk и шлюзы Goip

Goip 4 : Firmware Version: GS-4.01-98 Module Version: M35FAR02A01_RSIM

Goip16: Firmware Version: GST1610-1.01-61 Module Version: G610_V0C.58.0D_T1B

Goip32: Firmware Version: GST1610-1.01-61 Module Version: M35FAR02A01_RSIM

GoIP User Manual

Проблемs: Модели 16 и 32 не умеют Save/Restore  configuration. Функцинал есть, и файл формируется (текстовый, читаемый) но восстановление из него ничего не изменяет. На модели 4 – не тестировалось

Continue reading

Asterisk script for change externip

If gateway in lan is Mikrotik, and SIP ALG was enabled on it, this script is useless.

#!/bin/bash
#
log() {
    echo `date +"%Y-%m-%d %H:%M:%S"` $@ >>$Log
}
Log=/var/log/asterisk/change_externalip.log
#
getIPUrl="http://smart-ip.net/myip"
configFile=/etc/asterisk/sip.conf
configIP=`grep externip /etc/asterisk/sip.conf | sed 's/;.*//' | grep -v ^$ | sed s/.*=\ *//`
#
#echo "ConfigIP =" $configIP
extIP=`curl -s $getIPUrl`
#echo "ExtIP =" $extIP
if [ "$configIP" != "$extIP" ]
then
        log "Updating IP in /etc/asterisk/sip.conf from $configIP to $extIP"
        sed -i "s/externip=$configIP/externip=$extIP/" $configFile
        sed -i "s/externaddr=$configIP/externaddr=$extIP/" $configFile
        log "Running asterisk sip reload"
        /usr/sbin/asterisk asterisk -rx "sip reload"
fi
# end of file

Asterisk iptables firewall

-A INPUT -p udp -m udp --dport 5060 -m string --string "sipcli" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "sip-scan" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "iWar" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "sipvicious" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "sipsak" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "sundayddr" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "VaxSIPUserAgent" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "friendly-scanner" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m udp --dport 5060 -m string --string "kamailio4friendly" --algo bm --to 65535 -j DROP

Asterisk SMS уведомления при неответе

CentOS 6.5
Asterisk 12
GSM шлюз 2N VoiceBlue Lite, 4 GSM канала, две исходящих группы 8881 и 8882
SMS сервер https://github.com/ttobi/2n-sms-server

SIP/gsm-gate = GSG шлюз
SIP/cityoperator = Оператор IP-телефонии

officemobilephones – база Астериска в которую добавляем телефоны сотрудников вручную, т.е. СМС-ки шлем только своим сотрудниками, а не всем мобильным номерам.
Continue reading

Asterisk notes

Команды консоли Астериска

SIP

# просмотр всех
$ sip show peers 
# просмотр одного пира
$ sip show peer [TAB] 
# просмотр текущих SIP регистраций
$ sip show registry 
# ...
sip reload 
# просмотр каналов
sip show channels 
# 
sip show settings 

Continue reading

Zabbix Шаблон для Asterisk

Проверно на Zabbix: 1.8, 2.4, 3.0.2
Asterisk v.12

Версия 2.

Изменения:
– список имен SIP-пов провайдеров в отдельном файле, а не жестко в шаблоне.
– правило обнаружения для SIP-ов провайдеров.
zabbix_agentd.conf:

UserParameter=get_users,/usr/local/sbin/zabbix-get-users
UserParameter=get_sipproviders,/usr/local/sbin/zabbix-get-sipproviders
UserParameter=check_peer[*],/usr/local/sbin/zabbix-check-peer $1
UserParameter=calls,/usr/local/sbin/zabbix-check calls

Continue reading

Asterisk logs logrotate

Logrotate config

cat /etc/logrotate.d/asterisk
/var/log/asterisk/full
/var/log/asterisk/security
/var/log/asterisk/messages
/var/log/asterisk/queue_log
{
    weekly
    dateext
    missingok
    compress
    delaycompress
    rotate 12
    sharedscripts
    postrotate
        asterisk -rx "logger rotate" > /dev/null 2>/dev/null
    endscript
}

Asterisk абоненты Linksys SPA922, Cisco SPA502G

Конфиги для Provisioning

Linksys SPA922

#
# spa922.cfg
#

tftp://10.7.7.1/spa922-$MA.cfg
Yes
3600
3600
MASTER_PASSWORD
 
DHCP
10.7.7.1
10.7.7.1
10.7.7.1
yes
7
sip.domain
G711a
<2nd_Preferred_Codec_1_ ua="na">G729a
<3rd_Preferred_Codec_1_ ua="na">G729a
Info
GMT+02:00
0
3/-1/7/03:0:0;end=10/-1/7/04:0:0;save=1
24hr
day/month
(9x*xxx.|99*xx*xxx.|1xxx|3xxx|xxx|76xxxx|65xxxx|[2345]xxxxxx|0900xxxxx.|0xxxxxxxxx|82xxxxxxx.|380xxxxxxxx.|00xxxxxxxx.|
/up922/spa942-6-1-5a.bin
Yes
serv=tftp://10.7.7.1/lang922/;d0=English;x0=enS_US_v615.xml;d1=Russian;x1=ruS_v615.xml
Russian
Yes

#
#
# Индивидуальный spa922-.cfg
#

1001
P.Petrov
P.Petrov
p.petrov
secret_user_password

Про Daylight_Saving_Time_Rule

Supports auto adjustment for daylight saving time. Configuration is defined by 3 fields. Each field is separated by semicolon ( ; ) as shown
below. Optional values inside [ ] are assumed to be 0 if they are not specified. Midnight means 0:0:0 of the given date
Start = ; end=; save =
and are of the form: / / [/HH:[mm[:ss]]]
is of form: [/[+|-]HH:[mm[:ss]]]
= 1,2,3,…,12 (for Jan, Feb, …, Dec)
= [+|-]1,2,3,…,31
= 1, 2, 3, …, 7 (for Mon, Tue, …,Sun), or 0 which has special meaning
• HH = hour (0-23)
• mm = minute (0-59)
• ss = second (0-59)
and specify the start and end-time date of daylight saving time.
is the amount of hour/min/sec to add to the current time during daylight saving period.
The value can be preceded by a negative (-) sign if subtraction is desired instead of addition.
If is 0, it means the date to start or end daylight saving is at exactly the given date. In that case, the value must not be negative.
If is not zero, then the daylight saving starts or ends on the on or after the given date
if is positive, or on or before the given date if is negative. If is 1, it means the on or
before the end-of-the-month (in other words the last occurrence of < weekday> in that month).

An example for certain European countries :
start=3/-1/7/2:0:0;end=10/-1/7/3:0:0;save=1
The DST starts at last Sunday of March at 2am
The DST ends the last Sunday of October at 3am
The DST shift is +1 hour

Удаленная перезагрузка телефона

http://10.7.7.43/admin/reboot