11 дек. 2019 г.

Скопировать первую страницу со всех pdf to png

find ./*.pdf -exec pdftocairo -png -r 300 -f 1 -l 1 '{}' \; 

29 окт. 2019 г.

Zabbix notifications to Telegram

Send notification from Zabbix to Telegram messenger

18 окт. 2019 г.

OpenVPN Microtik to IPFire net-to-net

Connect Microtik router as openVPN client of IPFire security appliance - OpenVPN connection.

25 июл. 2019 г.

Asterisk - Loud alert (Громкое оповещение)

Проверено на телефонах Yealink.

exten => 330,1,Set(TIMEOUT(absolute)=60)
 same => n,SIPAddHeader(Call-info: answer-after=0)
 same => n,Page(SIP/101&SIP/102&SIP/107&SIP/126&SIP/133&SIP/134&SIP/143&
SIP/148&SIP/155&SIP/156&SIP/165&SIP/166&SIP/173&SIP/210&SIP/223)
 same => n,Hangup

В настройках телефона должен быть разрешен автоответ. По умолчанию разрешен, но мало ли.

24 июл. 2019 г.

Asterisk - Zabbix

Мониторим - количество подключенных аппаратов, задержка до городского транка, количество ожидающих в очереди, количество обслуживающих в очереди.

Ставим агент (debian - прямо из репозитария), разрешаем ему выполнять 'asterisk -x'
(sudoers, groups и.т.п.)

В параметрах агента  (/etc/zabbix/zabbix_agent.conf) добавляем

UserParameter=asterisk.trunkdelay,sudo /usr/sbin/asterisk  -x 'sip show peers'| awk '$0~/^trunkname/ {print substr($8,2,3)}'
UserParameter=asterisk.trunkstatus,sudo /usr/sbin/asterisk -x 'sip show peers'| awk '$0~/^trunkname/ {print $7}'|grep OK|wc -l
UserParameter=asterisk.activepeers,sudo /usr/sbin/asterisk -x 'sip show peers'| awk '$8~/OK/ {print $0}' |wc -l
UserParameter=asterisk.queuecalls,sudo /usr/sbin/asterisk -x 'queue show callcenter'| grep 'in call'  |wc -l
UserParameter=asterisk.queuequeue,sudo /usr/sbin/asterisk -x 'queue show callcenter'| grep 'callcenter has' |awk '{ print $3 }'



Шаблон:

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>

8 июл. 2019 г.

Set outbound CallerID Asterisk

Before Dial() command call the macro
You can use REGEX for extensions list or just compare one number.
[macro-SetOutCID]
exten => s,1,Verbose("External Caller ID setting for internal ${CALLERID(num)}...")
 same => n,ExecIf($[${REGEX("^(1011|1012|1013|1014)" ${CALLERID(num)})}]?Set(CALLERID(num)=4953229131))
 same => n,ExecIf($["${CALLERID(num)}" = "1040"]?Set(CALLERID(num)=4953229146))
 same => n,ExecIf($["${CALLERID(num)}" = "1041"]?Set(CALLERID(num)=4953229141))
 same => n,ExecIf($[${REGEX("^(1042|1043)" ${CALLERID(num)})}]?Set(CALLERID(num)=4953229156))
 same => n,ExecIf($["${CALLERID(num)}" = "1050"]?Set(CALLERID(num)=4953229151))
 same => n,ExecIf($["${CALLERID(num)}" = "2002"]?Set(CALLERID(num)=4953229120))
; and so on 
 same => n,ExecIf($["${CALLERID(num)}" = "5014"]?Set(CALLERID(num)=4953229198))
; last chance -  if no other options, set 4953229141 !!!
 same => n,ExecIf($[${LEN(${CALLERID(num)})} = 4]?Set(CALLERID(num)=4953229141))
 same => n,ExecIf($[${LEN(${CALLERID(num)})} = 0]?Set(CALLERID(num)=4953229141))
 same => n,Verbose("Outbound CallerID Set to ${CALLERID(num)}")



5 июл. 2019 г.

Asterisk - nightmode (ночной режим)

Если ночной режим включается и выключается автоматически, то используем функцию GotoIfTime:

exten => 3000,1,Answer
 same => n,GotoIfTime(8:00-19:00,mon-fri,*,*?open)
 same => n,Playback(announce/weekend)
 same => n,Hangup()
 same => n(open),Playback(announce/hello)
 same => n,Queue(callcenter,t,,,300)

Если ночной режим включаем вручную, то делаем так:

; toggle night mode variable 
=================================================
exten => 999,1,Answer()
 same => n,Verbose(1,"NIGHT=${GLOBAL(NIGHT)}")
 same => n,GotoIf(${GLOBAL(NIGHT)}?no)
 same => n,Set(GLOBAL(NIGHT)=1)
 same => n,Playback(announce/nighton)
 same => n,Hangup()
 same => n(no),Set(GLOBAL(NIGHT)=0)
 same => n,Playback(announce/nightoff)

 same => n,Hangup()

А потом проверяем значение переменной:

exten => _X.,1,Answer
 same => n,GotoIf(${GLOBAL(NIGHT)}?night)
 same => n,Background(announce/hello)
 same => n,Queue(callcenter,t,,,300)
 same => n,Hangup()
 same => n(night),Background(announce/weekend)
 same => n,Hangup()

13 июн. 2019 г.

Asterisk - отправить звонок в разные очереди, в зависимости от номера звонящего

How to send incoming call to certain queue, depending on CallerID?
Use mysql table with clients phones - filter clients and advertisement calls.

; main callcenter queue entry from outside
exten => 4100,1,Answer
 same => n,Playback(announce/announce)
; Check - is it special user?
; get target queue name by callerID - for certain callers
 same => n,Macro(MySQLConnect,${connid})
 same => n,MySQL(Query resultid ${connid} SELECT ID,NUMBER,INCOMING_ID,QUEUE_NAME,COMMENT from queue_target where NUMBER=${CALLERID(num)})
 same => n,MYSQL(Fetch foundRow ${resultid} id number incoming_id queue_name comment) ; fetch row
 same => n,MYSQL(Disconnect ${connid})
 same => n,Verbose("Skilltagging checking number  - ${id} ${number} ${incoming_id} ${queue_name} ${comment}")
 same => n,GotoIf($[${foundRow}]?:qcallc)
 same => n,Verbose(1,"Caller ${CALLERID(num)} ${foundRow} was found as ${comment} and sent to queue ${queue_name} ")
 same => n,GotoIf($[${foundRow}&$[${queue_name}=insurance]]?qins:)
 same => n,GotoIf($[${foundRow}&$[${queue_name}=advertisement]]?qadvert:)
; usual call
 same => n(qcallc),Queue(callcenter,t,,,60)
 same => n,Hangup()
; insurance company
 same => n(qins),Queue(insurance,t,,,120)
; not serviced (no members or not answered)- goto common queue
 same => n,Goto(qcallc)
 same => n,Hangup()

 same => n(qadvert),Queue(advertisement,t,,,120)
; not serviced (no members or not answered)- goto common queue
 same => n,Goto(qcallc)
 same => n,Hangup()

Asterisk - поставить звонок в начало очереди

All animals are equal, but some animals are more equal than others.


exten => n,GotoIf($["${CALLERID(num)}" = "2666"]?bigdick:others)
; Вызовы от важных клиентов
same => n(bigdick),Playback(welcome)
same => n,SetVar(QUEUE_PRIO=10)
same => n,Queue(support)

; Вызовы от менее важных клиентов
same => n(others),Playback(welcome)
same => n,SetVar(QUEUE_PRIO=5)
same => n,Queue(support)