Monday, October 27, 2014

Tables to support the GoIP incoming for both line is either non-busy or busy

When the GSM line is non-busy, GOIP allows user to configure the "Forward to VOIP number", For this case, I have set the VOIP number to 991 (call group in asterisk). And in the asterisk, I customised the 991 in the "/etc/asterisk" extensions_custom.conf with the following code

[ext-group-custom]
; here we start goip call handling
exten => 991,1,Macro(user-callerid,)
exten => 991,n,GotoIf($["foo${BLKVM_OVERRIDE}" = "foo"]?skipdb)
exten => 991,n,GotoIf($["${DB(${BLKVM_OVERRIDE})}" = "TRUE"]?skipov)
exten => 991,n(skipdb),Set(__NODEST=)
exten => 991,n,Set(__BLKVM_OVERRIDE=BLKVM/${EXTEN}/${CHANNEL})
exten => 991,n,Set(__BLKVM_BASE=${EXTEN})
exten => 991,n,Set(DB(${BLKVM_OVERRIDE})=TRUE)
exten => 991,n(skipov),Set(RRNODEST=${NODEST})
exten => 991,n(skipvmblk),Set(__NODEST=${EXTEN})
exten => 991,n,GosubIf($[${DB_EXISTS(RINGGROUP/991/changecid)} = 1 & "${DB(RINGGROUP/991/changecid)}" != "default" & "${DB(RINGGROUP/991/changecid)}" != ""]?sub-rgsetcid,s,1)
exten => 991,n,AGI(callgroup_mapping.agi)
exten => 991,n,NoOP("NewCallGroup=${callgrp}")
exten => 991,n,NoOP("NewCallType=${calltype}")
exten => 991,n,Set(RecordMethod=Group)
exten => 991,n,Macro(record-enable,${callgrp},${RecordMethod})
exten => 991,n,Set(RingGroupMethod=${calltype})
exten => 991,n(DIALGRP),Macro(dial,20,${DIAL_OPTIONS},${callgrp})
exten => 991,n,Set(RingGroupMethod=)
exten => 991,n,GotoIf($["foo${RRNODEST}" != "foo"]?nodest)
exten => 991,n,Set(__NODEST=)
exten => 991,n,Noop(Deleting: ${BLKVM_OVERRIDE} ${DB_DELETE(${BLKVM_OVERRIDE})})
exten => 991,n,Goto(app-blackhole,hangup,1)
exten => 991,n(nodest),Noop(SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST})



as you can see the above, it calls the "callgroup_mapping.agi".

Refer to the /var/lib/asterisk/agi-bin/callgroup_mapping.agi
it search in the cdr table for the last extension call make out to the caller id .
Base on this ext., it searches for goip_callgroup table for the call routing numbers.
The routing number has to be in the format of the call group e.g
7109-60123836313# or 8109-8110-8111

The above is for the non-busy.. as for busy.. the GOIP's SIM FORWARD
to a special number - "0321069278" and for this number, it has customised as "incoming route" for below "extensions_custom.conf"

to call the 991
[ext-did-0002-custom]
exten => 60321069278,1,Set(__FROM_DID=${EXTEN})
exten => 60321069278,n,Gosub(app-blacklist-check,s,1)
exten => 60321069278,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 60321069278,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 60321069278,n,Set(CALLERPRES()=allowed_not_screened)
exten => 60321069278,n(dest-ext),Goto(ext-group,991,1)

So the above try to loop back to the 991. 






Sunday, October 19, 2014

Open trunk or extension for MyPBX to connect to

You can either define new trunk with the following information on the
User Context =
User Details
type=friend
secret=1234Goip
qualify=yes
host=dynamic
dtmfmode=rfc2833
context=from-internal
canreinvite=no

However this option, it will not able to pass thru the a2billing since the accountcode is not defined.

To enable this, you need to define the account in the user context.

The other method is to define a new extension but for this option, you unable to pass thru the CLI as it will always follow the CLI defined at the extension level.

Monday, October 6, 2014

GOIP - handling incoming for multiple tenants

The GOIP single server mode will help in supporting the multiple tenants. The call within the GOIP  trunk will be randomly assigned to the any of the available channel. However, as for the incoming, we will have to configure the PSTN to VOIP forwarding. The good thing is that the GOIP allows you to specify the call group ext number. hence, I defined a generic call group no. 991 for all the SIM.

As for the 991, I customised the "extensions_custom.conf" and the 991 will call the agi in the "callgroup_mapping.agi" /var/lib/asterisk/agi-bin/

within this agi, it will select the last extension e.g 7109 which calls the caller id. the script will then check on the "goip_callgroup" table. in this table, you shall define which call group that the call shall route to for incoming. e.g if any of the caller calling 7109, it will route to the same ext. or you have an option to divert the call to another ext or even to a group of ext e.g 7109-6012xxxxx#-2701

With the above, I can upsell the sim base trunk to customer with more attractive rate.

Friday, September 26, 2014

Steps to handling the call forwarding (from call group)

The current a2billing doesn't support the call forwarding and incoming call rating. Hence, we will have to write our own rating engine and also update the a2billing tables according.
Based on the following SQL, we shall able to identify all the call fowarding traffic but then it has to be match to the individual calling number to determine the account no.

mysql> select calldate, dst, dcontext, dst, billsec, (billsec/60) into outfile "/tmp/DS20141005_04" FIELDS TERMINATED BY '|' from cdr where channel like '%from-internal%' and dcontext = "from-internal" and dst = "60182258257" and calldate > "2014-09-01 00:00:00" and calldate <= "2014-09-30 23:59:59" order by calldate;

Steps to generate new bill for customer (Jinercel)

Login to Jinercel Server

 mysql --user=root --password=xxxxxx

use mya2billing;

search for the account id for the customer - refer to the elastix, "Extras", "Calling Cards",

SELECT a.starttime, a.src, a.sessionid, a.calledstation, a.sessiontime, a.sessionbill into outfile "/tmp/VENUS20140926_01" FIELDS TERMINATED BY '|' from cc_call a, cc_card b where b.id = a.card_id and a.starttime >= "2014-08-01 00:00:00" and  a.starttime <= "2014-08-31 23:59:59" and b.username = '1483798503' and a.sessionbill > 0 order by a.starttime;

scp the outfile to the local PC

start up the "wkhtmltopdf TRIAL" instance

login to the instance and cd "/var/tmp/perldev/jinercel/v01"

scp the outfile into this instance


Tuesday, September 16, 2014

twilio - aggregated sms gateway

found the twilio when looking for freelancer.
initially, I thought that they provide attractive sms rate of 0.027 but only later found out that this is in US currency which converted to RM is close to 9sen / sms. Much higher than local content provider rate. Hence, the short code option is not viable through twilio.
Nevertheless,  please find the following method to test the twilio with their published REST API

Go to 54.254.53.88 (wkhtmltopdf server)
go to /var/tmp/twilio/twilio-php-master
edit test.php

install the twilio-php-master.zip
unzip in the PC and download (winscp) into the server (/var/tmp/twilio/twilio-php-master)
follow the sample code on the twilio website. 



require "/var/tmp/twilio/twilio-php-master/Services/Twilio.php";

// set your AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "AC637853e1e1201472b91684dbcc88bd87";
$AuthToken = "a080c7872a6a0fe5dccd4784813ec34e";

$client = new Services_Twilio($AccountSid, $AuthToken);

//$message = $client->account->messages->create(array(
//    "From" => "66001",
//    "To" => "60123836313",
//    "Body" => "Test message!",
//));

// Display a confirmation message on the screen
//echo "Sent message {$message->sid}";


$sms = $client->account->messages->sendMessage(

        // Step 6: Change the 'From' number below to be a valid Twilio number
        // that you've purchased, or the (deprecated) Sandbox number
            "+1 717-454-2049",


            // the number we are sending to - Any phone number

.....

Monday, September 1, 2014

Sample code to send and retrieve Whatsapp

Go to http://blog.philippheckel.com/2013/07/07/send-whatsapp-messages-via-php-script-using-whatsapi/
Login to "wkhtmltopdf TRIAL" amazon server
as root
cd /var/whatsapp/WhatsAPI
change the whatsapp_whatsapi_config.php

How to get whatapps encryption keys

uninstall whatsapp
install whatsapp with new sim details
use titanium backup to backup the whatsapp
uninstall whatsapp again
install with the cracked one - storage/download/folder bla bla/.apk
restore only DATA from titanimum backup
start the whatsapp
check catlog
search for WhatsPwd
Use the http://tomeko.net/online_tools/hex_to_base64.php?lang=en to convert the password

That is !!

Saturday, August 16, 2014

Migrating tuitionads from iwebhosting to ipserverone

Due to slow and security concern, I have decided to migrate the tuitionads to ipserverone.
Firstly, I need to get the migration code from iwebhosting - easy, there is a way from their menu itself
then, I share with ipserverone support and they trigger the migration process
Within 3-5 days, the domain is migrated but I need to move the wordpress over

backup the entire public_html directory and ftp to the ipserverone
backup the database and restore onto the new ipserverone xxxxwp5
but there are few more changes required... wp_config,
change the domain from tuitionads.com www.tuitionads.com
change all the pages with db connection - to using new databse, user and password.
surprisingly, ip serverone doesn't allow to change the db name or even create new user

Friday, August 8, 2014

How to identify the AMI (for the instance) and also the creation date

As we creating more and more instances, it's important to know that the instance was created based on which AMI. First, there is a relationship between the snapshots and AMI in the snapshot's description. based on that, you shall be able to tell the creation date of those AMI.
E.g

The jinercel instance was created based on the ami-6cce9c3e
Refer to snapshot this ami is created on the May 14 2014
So in order to determine the earlier AMI which was without the A2Billing,
It shall be the AMI created for the alwaysblue instance (ami-b096dce2)
which was created on Oct 14 2013

Tuesday, July 29, 2014

Table involved for the recording tracking

mysql> describe recording_track;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| primary_ext | varchar(20)  | YES  |     | NULL    |                |
| httplink    | varchar(100) | YES  |     | NULL    |                |
| filesize    | int(20)      | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> insert into recording_track values ("","3101","https://drive.google.com/folderview?id=0Bzw96Nl15-yLQlZYR0h2V1dxWmc&usp=sharing&invite=CKjF-ssJ",1250,"201406TnL");
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from recording_track;
+----+-------------+--------------------------------------------------------------------------------------------------+----------+-----------+
| id | primary_ext | httplink                                                                                         | filesize | name      |
+----+-------------+--------------------------------------------------------------------------------------------------+----------+-----------+
|  1 | 2801        |
https://drive.google.com/folderview?id=0Bzw96Nl15-yLbnJFd2Q1UkhtY1k&usp=sharing&invite=CPWiouII |      948 | 201406LS  |
|  2 | 2801        | https://drive.google.com/folderview?id=0Bzw96Nl15-yLbmh5THoxa1RNU0k&usp=sharing&invite=CImO6sYN  |      225 | 201405LS  |
|  3 | 3101        | https://drive.google.com/folderview?id=0Bzw96Nl15-yLQlZYR0h2V1dxWmc&usp=sharing&invite=CKjF-ssJ  |     1250 | 201406TnL |
+----+-------------+--------------------------------------------------------------------------------------------------+----------+-----------+



Monday, July 28, 2014

Activities on the early of the month

Besides generating bill for all customer by early of the month, the other important activity is to backup the recording .wav files, compress them and transfer them to the google drive. Set the http link for customer to access and also develop a GUI interface to access those download links.

cd /var/www/html
Modify the content of keeplogger.php and change the start - end date/time and master ext for the customer
Run the following command
php keeplogger.php > /mnt/ebs002/keeplogger/TnLJune2014/TnLJune2014.csv

cd /mnt/ebs002/keeplogger/TnLJune2014/
cat TnLJune2014.csv| awk -F'|' '{ print $7 }' > move
vi move

Copy all the .wav belong to this specific customer to the ebs002 directory
:1,$s/^/mv \/mnt\/ebs001\/asterisk\/monitor\//
:1,$s/$/ \./

sh move

tar cvf LSMay14.tar *.wav

gzip LSMay14.tar

scp the .tar.gz to the local PC directory

and then copy to the google drive directory.

Create the link and set to the GUI


Struggling with registration issue

This was the major issue that the client SIP Phone unable to register with the server intermittently. This is particular sensitive to the unifi original DIR-615 modem. From the server's messages log, you can see that the registration attempt was replied with "ChallengeSent" but some how, the client was not receiving this reply.

Trying out many methods including replacing the router with Asus 12HP and the latter seems to make the reoccurring lesser but still didn't fully resolve the problem. Even replacing the Asus router for TMS at Kota Damansara but still out of 6 ip phones (GXP1405), it's always one or two of them unable to register. It seems that the router was blocking the ip phone MAC addresses for some reasons.

The workaround is to replace those problematic ip phone and for Asus 12HP router, once it's connected, there is no issue so far for GSS amd TMS. But it is a hassle to replace the router as most customers prefer to retain the existing unifi router.

The worth to try possible solution was to set the outbound proxy server to the SIP server domain or IP address. So far, I have set this setting onto both TnL and LoanStreet (except the CS 2807 or 2804). Those ip phones still under close monitoring. If still not working, will have to figure out alternate solution

8.8.2014 - based on the last status, the registration fail doesn't happen to those phones with outbound proxy IP set. still under close monitoring

Thursday, May 15, 2014

Retransmission timeout error - SIP NAT issue

when you have this problem in the /var/log/asterisk/full as below .....

[May 15 15:29:09] WARNING[2376] chan_sip.c: Retransmission timeout reached on transmission ZTlmMDZlNjk1ODVkNWU5ZGRlNmI2ZWFhZGM5MDU5NGY. for seqno 2 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 6401ms with no response
[May 15 15:29:09] WARNING[2376] chan_sip.c: Hanging up call ZTlmMDZlNjk1ODVkNWU5ZGRlNmI2ZWFhZGM5MDU5NGY. - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
[May 15 15:29:09] VERBOSE[2420][C-00000000] res_agi.c:     -- AGI Script a2billing.php completed, returning 4
[May 15 15:29:09] VERBOSE[2420][C-00000000] pbx.c:   == Spawn extension (PSTNOutBound, 60383215500, 9) exited non-zero on 'SIP/5106-00000000'

It was due to /var/www/html/admin/modules/core/etc/sip.conf
externip= (MUST SET TO THE CORRECT EXTERNAL IP Address)

Tuesday, May 13, 2014

How to plan order for new domain on ip serverone

Login to https://portal.ipserverone.com/customer/account/login_owner
login - checkerbox88@gmail.com
password - XXXXXXX
Buy a new domain and picking back on the existing host - RM38
Paid thru maybank2u and now waiting for their sales to revert on the domain registration

How to setup eFax and problems encountered

Refer to the google internet information to setup efax
Problem and remain unresolved - license issue, codec incompatibility especially on unifi pstn line
It seems it's working ok on the P1 trunk.

Nevertheless, in order to support multitenant in elastix, we will have to make changes on the
faxviewer, fax queue and send fax.

faxviewer files modified

/var/www/html/modules/faxviewer/libs/paloSantoFaxVisor.class.php



Friday, January 17, 2014

how does mail works in asterisk / centos ?

1. setup the postfix

cd /etc/postfix

a)download ca-bundle.crt
b)enter the following into generic

c)postmap /etc/postfix/generic
d)edit main.cf  <-- in="" key="" name="" p="" router="" server="" smtp="" the="">e) postmap /etc/postfix/sasl_passwd
/etc/init.d/postfix restart

2. Test the mail

mail -s "Hello World" XXXXXX@yahoo.com -- -f"sender address" -F"sender name"

/usr/share/a2billing/Cronjobs/a2billing_batch_autodialer.php create a lot of dummy mail to vm@vioblue.com

what is the functions of a2billing_batch_autodialer ?

1. Check on the /etc/crontab
[root@ip-10-142-157-15 cron]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

5 * * * * /usr/bin/perl /var/monitortools/checkconf.pl


and there are also schedule jobs within each of those hourly, daily, weekly and monthly. 

Other than the above, you shall also check on the /var/spool/cron
in this directory, your will find those users who has cron job setup e.g asterisk 


How to login in as owner for the happy diary and post new blog ?

Although the blog was created back in 2009 but things had changed over the past few years. including the way how you can login in as owner of your own blog.

1. access to your own blog site http://khlee-happydiary.blogspot.com/
2. Click on the top right corner - Sign In
3. You will see one google, one account, change the manage account for this device
4. key in kwonghong@yahoo and password XXXXXXXX
5. then you can start posting new blog ... Great !!