This blog moved to new address

September 7, 2008

Please, visit new place at: http://rutmandal.info/eng/

Home page: http://rutmandal.info/


Network tiering

August 21, 2008

Tier 4:
– most datacenters
– owns internal network
– pay other networks for IP transit outside the facility

Tier 3:
– regional providers
– build redundancy thru’ redundant POPs (points of presence) outside facility
– pay for IP transit past the POPs

Tier 2:
– national or international footprint
– still pay IP transit to reach some portions of Internet

Tier 1:
– do not pay IP transit
– global presence
– don’t pay other providers for any portion of connectivity


Datacenter tiering

August 21, 2008

Tier 1:
– 99.671% uptime
– annual 28.8 hrs downtime
– full shutdown for preventive maintenance

Tier 2:
– 99.741% uptime
– annual downtime of 22 hrs
– some redundancy with single path for power, requiring shutdown for preventive maintenance

Tier 3:
– 99.982% uptime
– annual 1.6 hrs downtime
– sufficient redundancy to allow planned maintenance
– at least 13.2 KV power

Tier 4:
– 99.995% uptime
– annual downtime of 0.4 hrs
– multiple paths to power and AC and designed to handle worst case scenario with no critical impact
– at least 26.2 KV power


C++ coding tips

August 8, 2008

Some C++ coding tips:

– Do not turn off warning level(s) from compilation. This will save you trouble later. Use as much stricter settings as possible.

– Do not ignore warning(s) in your build process.

– Stick to ANSI C++ coding as much as possible.
All header file code must be contained within:

#ifndef __file_h
#define __file_h 1

… (code)

#endif
Use “#pragma once” as first line of header file if using Visual C++ compiler 2003 and later.

 – Do not use “goto” if possible.

– Always perform clean build before code submission and/or merge.

– Use “const” modifier as much as possible.

– Define “enum” with assigned values. Do not let it go for assumption. This improves readability. Say,

enum MyEnum {

SUNDAY = 0,

MONDAY = 1,

}; // enum for days

– Use brackets in pre-processor director. Say,

#define BIT(n)  (1 << n) // not preferred

#define BIT(n) (1 << (n)) // preferred

– Prefer library functions that take size or count argument over to functions without such argument for string manipulation. Say,

strncpy is preferred over strcpy.

– One include file should not contain more than one class definitions.

– Using “const” or “enum” is preferred over using “define” for contants. Say,

#define LOOP_COUNT  100 // non preferred

const int LOOP_COUNT = 100; // preferred

enum { LOOP_COUNT = 100, }; // or preferred

– A member function that does not modify class state must be declared as “const”.

– A class must have a default constructor with all data members initialized in it.

– A class must have copy constructor and assignment operator defined to avoid surprises.

– Assignment operator function must take care of destructive operation e.g. assigning to self (a = a).

– Avoid functions having more than five arguments.

– Do not mix malloc/free and new/delete.

– If array is allocated using “new”, use “delete []” for deallocating it.

– Avoid type conversions if possible.

– Re-initialize pointer when deallocated. Say,

delete p;

p = NULL;

– It is good to have a carriage return in the end of a code file.

– Use inclusive lower limit and exclusive upper limit in “for” loop. Say,

for ( int idx = 0; idx < MAX; ++idx ) // exclusive upper limit

for ( int idx = MAX; idx >= 1; –idx ) // inclusive lower limit

– Do not use “static” variable in “inline” function in header file.

I hope that this article is helpful and will avoid some silly bugs creeping over your code :-)


Asterisk real-time DB with Trixbox

July 30, 2008
mysql> show columns in extensions in asteriskrealtime;

+———-+————–+——+—–+———+—————-+

| Field | Type | Null | Key | Default | Extra |

+———-+————–+——+—–+———+—————-+

| id | int(11) | NO | MUL | NULL | auto_increment |

| context | varchar(20) | NO | PRI | NULL | |

| exten | varchar(20) | NO | PRI | NULL | |

| priority | tinyint(4) | NO | PRI | 0 | |

| app | varchar(20) | NO | | NULL | |

| appdata | varchar(128) | NO | | NULL | |

+———-+————–+——+—–+———+—————-+

mysql> show columns in iax_buddies in asteriskrealtime;

+————-+————–+——+—–+———+——-+

| Field | Type | Null | Key | Default | Extra |

+————-+————–+——+—–+———+——-+

| name | varchar(30) | NO | PRI | NULL | |

| username | varchar(30) | YES | UNI | NULL | |

| type | varchar(6) | NO | | NULL | |

| secret | varchar(50) | YES | | NULL | |

| md5secret | varchar(32) | YES | | NULL | |

| dbsecret | varchar(100) | YES | | NULL | |

| notransfer | varchar(10) | YES | | NULL | |

| inkeys | varchar(100) | YES | | NULL | |

| auth | varchar(100) | YES | | NULL | |

| accountcode | varchar(100) | YES | | NULL | |

| amaflags | varchar(100) | YES | | NULL | |

| callerid | varchar(100) | YES | | NULL | |

| context | varchar(100) | YES | | NULL | |

| defaultip | varchar(15) | YES | | NULL | |

| host | varchar(31) | NO | | dynamic | |

| language | varchar(5) | YES | | NULL | |

| mailbox | varchar(50) | YES | | NULL | |

| deny | varchar(95) | YES | | NULL | |

| permit | varchar(95) | YES | | NULL | |

| qualify | varchar(4) | YES | | NULL | |

| disallow | varchar(100) | YES | | NULL | |

| allow | varchar(100) | YES | | NULL | |

| ipaddr | varchar(15) | YES | | NULL | |

| port | int(11) | YES | | 0 | |

| regseconds | int(11) | YES | | 0 | |

+————-+————–+——+—–+———+——-+

mysql> show columns in queue_member_table in asteriskrealtime;

+————+————–+——+—–+———+——-+

| Field | Type | Null | Key | Default | Extra |

+————+————–+——+—–+———+——-+

| queue_name | varchar(128) | NO | PRI | NULL | |

| interface | varchar(128) | NO | PRI | NULL | |

| penalty | int(11) | YES | | NULL | |

+————+————–+——+—–+———+——-+

mysql> show columns in queue_table in asteriskrealtime;

+————————+————–+——+—–+———+——-+

| Field | Type | Null | Key | Default | Extra |

+————————+————–+——+—–+———+——-+

| name | varchar(128) | NO | PRI | NULL | |

| musiconhold | varchar(128) | YES | | NULL | |

| announce | varchar(128) | YES | | NULL | |

| context | varchar(128) | YES | | NULL | |

| timeout | int(11) | YES | | NULL | |

| monitor_join | tinyint(1) | YES | | NULL | |

| monitor_format | varchar(128) | YES | | NULL | |

| queue_youarenext | varchar(128) | YES | | NULL | |

| queue_thereare | varchar(128) | YES | | NULL | |

| queue_callswaiting | varchar(128) | YES | | NULL | |

| queue_holdtime | varchar(128) | YES | | NULL | |

| queue_minutes | varchar(128) | YES | | NULL | |

| queue_seconds | varchar(128) | YES | | NULL | |

| queue_lessthan | varchar(128) | YES | | NULL | |

| queue_thankyou | varchar(128) | YES | | NULL | |

| queue_reporthold | varchar(128) | YES | | NULL | |

| announce_frequency | int(11) | YES | | NULL | |

| announce_round_seconds | int(11) | YES | | NULL | |

| announce_holdtime | varchar(128) | YES | | NULL | |

| retry | int(11) | YES | | NULL | |

| wrapuptime | int(11) | YES | | NULL | |

| maxlen | int(11) | YES | | NULL | |

| servicelevel | int(11) | YES | | NULL | |

| strategy | varchar(128) | YES | | NULL | |

| joinempty | varchar(128) | YES | | NULL | |

| leavewhenempty | varchar(128) | YES | | NULL | |

| eventmemberstatus | tinyint(1) | YES | | NULL | |

| eventwhencalled | tinyint(1) | YES | | NULL | |

| reportholdtime | tinyint(1) | YES | | NULL | |

| memberdelay | int(11) | YES | | NULL | |

| weight | int(11) | YES | | NULL | |

| timeoutrestart | tinyint(1) | YES | | NULL | |

+————————+————–+——+—–+———+——-+

mysql> show columns in sip_buddies in asteriskrealtime;

+—————-+————–+——+—–+————————-+—————-+

| Field | Type | Null | Key | Default | Extra |

+—————-+————–+——+—–+————————-+—————-+

| id | int(11) | NO | PRI | NULL | auto_increment |

| name | varchar(80) | NO | UNI | NULL | |

| accountcode | varchar(20) | YES | | NULL | |

| amaflags | varchar(7) | YES | | NULL | |

| callgroup | varchar(10) | YES | | NULL | |

| callerid | varchar(80) | YES | | NULL | |

| canreinvite | char(3) | YES | | yes | |

| context | varchar(80) | YES | | NULL | |

| defaultip | varchar(15) | YES | | NULL | |

| dtmfmode | varchar(7) | YES | | NULL | |

| fromuser | varchar(80) | YES | | NULL | |

| fromdomain | varchar(80) | YES | | NULL | |

| fullcontact | varchar(80) | YES | | NULL | |

| host | varchar(31) | NO | | NULL | |

| insecure | varchar(4) | YES | | NULL | |

| language | char(2) | YES | | NULL | |

| mailbox | varchar(50) | YES | | NULL | |

| md5secret | varchar(80) | YES | | NULL | |

| nat | varchar(5) | NO | | no | |

| deny | varchar(95) | YES | | NULL | |

| permit | varchar(95) | YES | | NULL | |

| mask | varchar(95) | YES | | NULL | |

| pickupgroup | varchar(10) | YES | | NULL | |

| port | varchar(5) | NO | | NULL | |

| qualify | char(3) | YES | | NULL | |

| restrictcid | char(1) | YES | | NULL | |

| rtptimeout | char(3) | YES | | NULL | |

| rtpholdtimeout | char(3) | YES | | NULL | |

| secret | varchar(80) | YES | | NULL | |

| type | varchar(6) | NO | | friend | |

| username | varchar(80) | NO | | NULL | |

| disallow | varchar(100) | YES | | all | |

| allow | varchar(100) | YES | | g729;ilbc;gsm;ulaw;alaw | |

| musiconhold | varchar(100) | YES | | NULL | |

| regseconds | int(11) | NO | | 0 | |

| ipaddr | varchar(15) | NO | | NULL | |

| regexten | varchar(80) | NO | | NULL | |

| cancallforward | char(3) | YES | | yes | |

+—————-+————–+——+—–+————————-+—————-+

mysql> show columns in voicemail_users in asteriskrealtime;

+————-+————-+——+—–+——————-+—————-+

| Field | Type | Null | Key | Default | Extra |

+————-+————-+——+—–+——————-+—————-+

| uniqueid | int(11) | NO | MUL | NULL | auto_increment |

| customer_id | int(11) | NO | | 0 | |

| context | varchar(50) | NO | | NULL | |

| mailbox | int(5) | NO | PRI | 0 | |

| password | varchar(4) | NO | | 0 | |

| fullname | varchar(50) | NO | | NULL | |

| email | varchar(50) | NO | | NULL | |

| pager | varchar(50) | NO | | NULL | |

| stamp | timestamp | YES | | CURRENT_TIMESTAMP | |

| attach | char(3) | NO | | no | |

| saycid | char(3) | NO | | yes | |

| hidefromdir | char(3) | NO | | no | |

+————-+————-+——+—–+——————-+—————-+

 


Install Asterisk on Centos

July 19, 2008
http://www.voipuser.org/forum_topic_9971.html – click to call

http://www.jeremy-mcnamara.com/2007/02/26/how-to-configure-asterisk-your-first-installation/

http://www.asteriskguru.com/tutorials/asterisk_voip_ipphone.html

——————————–

yum -y update

yum -y install gcc gcc-c++ libtermcap-devel kernel-devel bison openssl-devel mysql mysql-server mysql-devel

OR if ‘uname -a’ says SMP

 yum -y install gcc gcc-c++ libtermcap-devel kernel-smp-devel bison openssl-devel mysql mysql-server mysql-devel

reboot

cd /usr/src

wget http://downloads.digium.com/pub/asterisk/asterisk-1.6.0-beta7.1.tar.gz

tar -zxvf asterisk-1.6.0-beta7.1.tar.gz

ln -s asterisk-1.6.0-beta7.1 asterisk

wget http://downloads.digium.com/pub/asterisk/asterisk-addons-1.6.0-beta3.tar.gz

tar -zxvf asterisk-addons-1.6.0-beta3.tar.gz

ln -s asterisk-addons-1.6.0-beta3 asterisk-addons

cd /usr/src/asterisk

./configure

make

make install

make samples

make config

cd /usr/src/asterisk-addons

./configure

make install

————————-

trixbox installed

mysql -p

passw0rd

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘passw0rd’;

 


Asterisk database on MySql

July 19, 2008

 

 

 

 

Core System :

Network Manager :

This would take care of system IP configuration in a DHCP network . This could be made static from gui , so that end users dont have to connect everytime they want to login . Share Sense :

The system advertises to the gui software to connect to the pbx box which could be authenticated with a standard password. Also option to change the password Call Routing Trunks Incoming :PSTN

Welcome Window navigated to connect the PSTN jack to connect to the PORT 1 of the PBX and ask for callerid . This would repeat , the wizard for other ports and stop if we need to . These PORT 1 … n will have standard configuration.

VOIP :

Followed by the pstn , Voip trunk wizard runs to configure the incoming trunks and outbound .

Extensions and Groups :

Wizard for creating the extensions specific to a person and also added to group in case need. This would have VM enabled with the user defined email id .

Call Routing \ Dial plan

 

 

Based on the VOIP & PSTN , we will have the outbound dial rules like 1XXXXXXXXX is routed thru PSTN and [2-9]X. is routed thry voip trunk.

Call Attendant :

Here the incoming trunks are handled based on the trunks (PSTN & voip) created ..

Endpoint Manager:

 

 

This will configure the GXP phones with the settings once added in the network.

 

 

Description of the CDR table in asteriskcdr :
`calldate` datetime NOT NULL default ‘0000-00-00 00:00:00’,
`clid` varchar(80) NOT NULL default ”,
`src` varchar(80) NOT NULL default ”,
`dst` varchar(80) NOT NULL default ”,
`dcontext` varchar(80) NOT NULL default ”,
`channel` varchar(80) NOT NULL default ”,
`dstchannel` varchar(80) NOT NULL default ”,
`lastapp` varchar(80) NOT NULL default ”,
`lastdata` varchar(80) NOT NULL default ”,
`duration` int(11) NOT NULL default ‘0’,
`billsec` int(11) NOT NULL default ‘0’,
`disposition` varchar(45) NOT NULL default ”,
`amaflags` int(11) NOT NULL default ‘0’,
`accountcode` varchar(20) NOT NULL default ”,
`userfield` varchar(255) NOT NULL default ”

1. what is the difference between clid and src?
if my ext is 601 which is the src , my clid could be < Kias> or <601>

2. what is dcontext?
Destination context: every incoming call has a context like IVR , Ring groups , Call forwarding

3. possible values of lastapp and lastdata?
lastapp could be VM for eg , lastdata could be some DTMF recd from the callee (1,2 …)

4. what is the difference between duration and billsec?
Duration is with ring time and billsec is actual conversation period

5. significance of disposition/amaflags/accountcode/userfield?

dispostion could be Answered , No -Answer , hangup , Busy , Rejected etc
Accountcode , Amaflags,userfield are related to A2billing

RealTime support is currently available for the following families:

sippeers

sipusers

iaxpeers

iaxusers

voicemail

queues and queue_members (used together for the Queue application).

extensions

 

tables sip_buddies & extensions_table are created in asterisk db — ???

1. User id should mention Tehcnology ( SIP /IAX )
2. Zap trunks and Incoming preferences
3. Separate tab for Inbound Trunks ( SIp, Iax ) with host name , username , secret ,codecs and context . Preferences will take the incoming parameters

4. Outbound trunks : Dial plan specific wherein like 00 prefix will take SIP trunk1
& pattern NXXXXXXXX will take Zap 1

e.g. INSERT INTO `extensions` (`id`, `context`, `exten`, `priority`, `app`, `appdata`)
VALUES (5, ‘cytel’, ‘8322008630’, ‘1’, ‘Dial’, ‘SIP/3044,30’);

INSERT into sip_buddies (id, name, callerid, context, canreinvite, insecure, type, host, secret, allow, nat) VALUES (”,’1001′,’JD’,’incoming’,’no’,’port,invite’,’friend’,’dynamic’,’bob123′,’all’,’yes’);

Below is the structure for sip ext , iax ext & extension rules table

 

 

 

 

 

 

Table structure for table `sip_buddies`

CREATE TABLE `sip_buddies` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(80) NOT NULL default ”,
`host` varchar(31) NOT NULL default ”,
`nat` varchar(5) NOT NULL default ‘no’,
`type` enum(‘user’,’peer’,’friend’) NOT NULL default ‘friend’,
`accountcode` varchar(20) default NULL,
`amaflags` varchar(13) default NULL,
`call-limit` smallint(5) unsigned default NULL,
`callgroup` varchar(10) default NULL,
`callerid` varchar(80) default NULL,
`cancallforward` char(3) default ‘yes’,
`canreinvite` char(3) default ‘yes’,
`context` varchar(80) default NULL,
`defaultip` varchar(15) default NULL,
`dtmfmode` varchar(7) default NULL,
`fromuser` varchar(80) default NULL,
`fromdomain` varchar(80) default NULL,
`insecure` varchar(4) default NULL,
`language` char(2) default NULL,
`mailbox` varchar(50) default NULL,
`md5secret` varchar(80) default NULL,
`deny` varchar(95) default NULL,
`permit` varchar(95) default NULL,
`mask` varchar(95) default NULL,
`musiconhold` varchar(100) default NULL,
`pickupgroup` varchar(10) default NULL,
`qualify` char(3) default NULL,
`regexten` varchar(80) default NULL,
`restrictcid` char(3) default NULL,
`rtptimeout` char(3) default NULL,
`rtpholdtimeout` char(3) default NULL,
`secret` varchar(80) default NULL,
`setvar` varchar(100) default NULL,
`disallow` varchar(100) default ‘all’,
`allow` varchar(100) default ‘g729;ilbc;gsm;ulaw;alaw’,
`fullcontact` varchar(80) NOT NULL default ”,
`ipaddr` varchar(15) NOT NULL default ”,
`port` smallint(5) unsigned NOT NULL default ‘0’,
`regserver` varchar(100) default NULL,
`regseconds` int(11) NOT NULL default ‘0’,
`username` varchar(80) NOT NULL default ”,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `name_2` (`name`)
) ENGINE=MyISAM ROW_FORMAT=DYNAMIC;

Table structure for table `iax_buddies`

CREATE TABLE iax_buddies (
name varchar(30) primary key NOT NULL,
username varchar(30),
type varchar(6) NOT NULL,
secret varchar(50),
md5secret varchar(32),
dbsecret varchar(100),
notransfer varchar(10),
inkeys varchar(100),
outkey varchar(100),
auth varchar(100),
accountcode varchar(100),
amaflags varchar(100),
callerid varchar(100),
context varchar(100),
defaultip varchar(15),
host varchar(31) NOT NULL default ‘dynamic’,
language char(5),
mailbox varchar(50),
deny varchar(95),
permit varchar(95),
equalify varchar(4),
disallow varchar(100),
allow varchar(100),
ipaddr varchar(15),
port integer default 0,
regseconds integer default 0
);
CREATE UNIQUE INDEX iax_buddies_username_idx ON iax_buddies(username); Table structure for table `extensions_table`

CREATE TABLE `extensions_table` (
`id` int(11) NOT NULL auto_increment,
`context` varchar(20) NOT NULL default ”,
`exten` varchar(20) NOT NULL default ”,
`priority` tinyint(4) NOT NULL default ‘0’,
`app` varchar(20) NOT NULL default ”,
`appdata` varchar(128) NOT NULL default ”,
PRIMARY KEY (`context`,`exten`,`priority`),
KEY `id` (`id`)
) TYPE=MyISAM;

Asterisk:

 

There are 2 Databases 
1. Asteriskcdr
Tables : cdr , will handle the reports part of call handling and other call details

2. Asterisk
Tables: sip_buddies,extensions_table,voicemail_users

For eg we have a scenario like this , we need to add sip extensions and sip peers
Sip extensions are those which will be registered to the box as an extension and sip peer are those which are trunk to any providers like varphonex, call centric ,voxbone etc.
Peers can give Inbound/ outbound functionalities , some outbound alone . In case of incoming , we get DID from the providers which are added to our box as extensions.

Now I add an user – sip extension the possible values
`id` int(11) NOT NULL auto_increment,   – Auto increment

`name` varchar(80) NOT NULL default ”, – It could be the person name eg Kias or Chirag … or any number too 1001 or 1002

`host` varchar(31) NOT NULL default ”, – Host will be dynamic , as we will be in a DHCP environment . This is for user extension alone ,in case of peer will have provider IP address or domain name

`nat` varchar(5) NOT NULL default ‘no’, – We will have nat as yes since we are in NAT environment

`type` enum(‘user’,’peer’,’friend’) NOT NULL default ‘friend’, – default value for user is friend & for peer is peer ,in our case here is friend

`accountcode` varchar(20) default NULL, – NULL

`amaflags` varchar(13) default NULL, – NULL

`call-limit` smallint(5) unsigned default NULL, – we can make it as 10 default

`callgroup` varchar(10) default NULL, – suppose we have a group of users for hunting , we need to update the group number . We can standardize 500 … 600 as group numbers, it can be NULL by default

`callerid` varchar(80) default NULL, – any value eg 1001 or Kias

`cancallforward` char(3) default ‘yes’, default will be yes

`canreinvite` char(3) default ‘yes’, default will be yes

`context` varchar(80) default NULL, we can group all sip extension as sip-internal context , possible value is sip-internal

`defaultip` varchar(15) default NULL, – could be NULL

`dtmfmode` varchar(7) default NULL, rfc2833 will be default, we can include inband as choice

`fromuser` varchar(80) default NULL, will be NULL

`fromdomain` varchar(80) default NULL , will be NULL

`insecure` varchar(4) default NULL, NULL

`language` char(2) default NULL, , NULL

`mailbox` varchar(50) default NULL, suppose 1001 is the extension we will have 1001@default

`md5secret` varchar(80) default NULL, NULL

`deny` varchar(95) default NULL, NULL

`permit` varchar(95) default NULL, NULL

`mask` varchar(95) default NULL, NULL

`musiconhold` varchar(100) default NULL, NULL or default

`pickupgroup` varchar(10) default NULL, 1

`qualify` char(3) default NULL, yes

`regexten` varchar(80) default NULL,eg 1001 or the preferred extenion number

`restrictcid` char(3) default NULL, NULL

`rtptimeout` char(3) default NULL, NULL ( we define those directly )

`rtpholdtimeout` char(3) default NULL, NULL ( we define those directly )

`secret` varchar(80) default NULL, password for the softphone or IP phone eg 1234!#$

`setvar` varchar(100) default NULL, NULL

`disallow` varchar(100) default ‘all’, all

`allow` varchar(100) default ‘g729;ilbc;gsm;ulaw;alaw’, ulaw;g729

`fullcontact` varchar(80) NOT NULL default ”, ”

`ipaddr` varchar(15) NOT NULL default ”, ”

`port` smallint(5) unsigned NOT NULL default ‘0’, 5060

`regserver` varchar(100) default NULL, IP address of our linux box

`regseconds` int(11) NOT NULL default ‘0’, ”

`username` varchar(80) NOT NULL default ”, 1001

 

SIP:

host – dynamic 99% time

advance option: md5secret, account code, default, ip address, call group, pickup group, from domain, reg. server, qualify : yes/no

remove: RTP hold timeout, rtp timeout, nat: (must be yes), AMA flags, restrict callerid, set var, deny, permit, mask

allow: ulaw first

disallow: ‘ ‘ (SPACE) / all : if SPACE, select allow codecs, otherwise all

full contact: only readable field

music on hold: no / default

insecure: no / port,invite

port: default value 5060 (SIP), 4569 (IAX)

context: (readable) Kias will provide values

from user : same as user name, advance option

language: two char, ‘en’ etc

dtmf mode: rfc2833, inband, info, auto (drop down)

reg. extens: same as user (1001 e.g.)

reg. second: 3000ms

IAX:

same as sip

md5secret: regular screen required

allow, disallow, reg.seconds

port: 4569 (default)

remove: in keys, out keys

advance: – auth: plain/md5, no xfer : yes/no

exten:

id: auto-generate

exten: same as user name (sip/iax) e.g. 101

priority: 1

application: dial, playback, forward

application data: /101

call report:

filter: disposition, source, dest, bill sec,

move port and regseconds in the SIP user template to advanced options

I add a sip user 101 . in the preferences like settings he can choose different templates like

1. Plain

when someone dials 101 , it will ring his extension alone in this case

values in extension_table for id , exten, priority,app,app_data ( “”,101,1,Dial,SIP/101)

this would simply ring his /her extension

2. Voicemail

then we add 2 rules

(“”,101,1,Dial,SIP/101|30)

(“”,101,2.Voicemail,u101@default)

this rules would dial for 30 secs then take the caller to voicemail

3. Simulataneous ring 2 or more extens

(“”,101,1,Dial,SIP/101&SIP/102 )

This will ring 2 more extensions .

Pl advise if we could create template like this which will update with the database directly.

———————————

This could be a standard IVR for the system .,pl check attached csv

the context explains

the call lands

Play the greetings . The Eapen15 file could be custom wav file saved thru tftp and we could have standard message also/

It waits for the exten to be dialed by the caller

if 1001 is pressed it dial the sip phone 1001
or if timeouts it goes to the extension 1001 – which needs user confirmation in our template

. Like which would be receptionist etc ..

if invalid dial repeats the message 2 times , else hangs up

——————————————————–

CREATE TABLE `voicemail_users` (
`uniqueid` int(11) NOT NULL auto_increment,
`customer_id` varchar(11) NOT NULL default ‘0’,
`context` varchar(50) NOT NULL default ”,
`mailbox` varchar(11) NOT NULL default ‘0’,
`password` varchar(5) NOT NULL default ‘0’,
`fullname` varchar(150) NOT NULL default ”,
`email` varchar(50) NOT NULL default ”,
`pager` varchar(50) NOT NULL default ”,
`tz` varchar(10) NOT NULL default ‘central’,
`attach` varchar(4) NOT NULL default ‘yes’,
`saycid` varchar(4) NOT NULL default ‘yes’,
`dialout` varchar(10) NOT NULL default ”,
`callback` varchar(10) NOT NULL default ”,
`review` varchar(4) NOT NULL default ‘no’,
`operator` varchar(4) NOT NULL default ‘no’,
`envelope` varchar(4) NOT NULL default ‘no’,
`sayduration` varchar(4) NOT NULL default ‘no’,
`saydurationm` tinyint(4) NOT NULL default ‘1’,
`sendvoicemail` varchar(4) NOT NULL default ‘no’,
`delete` varchar(4) NOT NULL default ‘no’,
`nextaftercmd` varchar(4) NOT NULL default ‘yes’,
`forcename` varchar(4) NOT NULL default ‘no’,
`forcegreetings` varchar(4) NOT NULL default ‘no’,
`hidefromdir` varchar(4) NOT NULL default ‘yes’,
`stamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`uniqueid`),
KEY `mailbox_context` (`mailbox`,`context`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;

Insert into voicemail_users (context,mailbox,password,review) values (default,4051,4444,yes)

———————————————————————-

All custom recorded files are to be stored in
/var/lib/asterisk/sounds/custom as gsm files
for i in *.mp3; do lame –decode $i `basename $i .mp3`.wav; done
for i in *.wav; do sox $i -r 8000 -v 0.2 -c 1 $(basename $i .wav).gsm resample -ql; done

Before uploading any file it has to be resampled in the above format .

In case of Music on Hold , the wav fiels has to be converted to mp3 format as follows:
/var/lib/asterisk/mohmp3/

$LAME -S -V7 -B24 –tt $OUT –add-id3v2 $OUT.wav $OUT.mp3


Installing Centos 5 and Asterisk 1.4.6

July 19, 2008

Installing CentOS for Asterisk

Based on Centos 5 for i386 on AMD Duo-core 64bit machine ================>

Required packages
Minimal install
kernel-devel / kernel-smp-devel
bison
openssl-devel

for mysql support (Asterisk sip mysql peers, Asterisk voicemail database, Asterisk cdr mysql etc) add
mysql
mysq-server
mysql-devel

Installation process

Select minimal from the Package Group selector option (on Centos 4.1 this required just disk1 for my hardware – HP DL360 – G4)
When the installation completes, install the YUM GPG Key
rpm –import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-45

Now simply install the required packages using yum
yum -y install kernel-devel bison openssl-devel
or to include mysql:

yum -y install kernel-devel bison openssl-devel mysql mysql-server mysql-devel

If you run an SMP kernel, you need kernel-smp-devel instead of kernel-devel above.

Now go make yourself a cup of tea/coffee as this will take a while, depending on your connection speed (it will download and install all dependencies and packages required)

Then:

yum -y update
Another cup of coffee, and a reboot to ensure that you compile against the correct kernel.

Once installed, standard asterisk installation procedure applies.
Installing Asterisk on to CentOS 5.x
Quick and Easy Install Guide, continuing from above section.
>>> If you are running an SMP kernel, then instead of “kernel-devel” use “kernel-smp-devel”<<<

Install prereqs:
yum -y update
yum -y install gcc kernel-smp-devel bison openssl-devel mysql mysql-server mysql-devel

#installing/upgrading asterisk
#clean modules – just in case this is an upgrade.
rm -f /usr/lib/asterisk/modules/* 

 

Go fetch latest asterisk sources. If you get “404” errors, chances are that there
are newer versions. Please update this page. (Yes, I know about /releases ,
and I avoided using it to keep this page up-to-date)

===> check of freepbx supports asterisk-1.4.6
 If not, install asterisk-1.2.20

/usr/src 
rm asterisk 
wget http://ftp.digium.com/pub/asterisk/asterisk-1.4.6.tar.gz 
tar -zxvf asterisk-1.4.6.tar.gz 
ln -s asterisk-1.4.6 asterisk 

rm -f zaptel 
wget http://ftp.digium.com/pub/zaptel/zaptel-1.4.3.tar.gz 
tar -zxvf zaptel-1.4.3.tar.gz 
ln -s zaptel-1.4.3 zaptel 

rm -f libpri 
wget http://ftp.digium.com/pub/libpri/libpri-1.4.0.tar.gz 
tar -zxvf libpri-1.4.0.tar.gz 
mv libpri-1.4.0 libpri 

rm -f asterisk-addons 
wget http://ftp.digium.com/pub/asterisk/asterisk-addons-1.4.2.tar.gz 
tar -zxvf asterisk-addons-1.4.2.tar.gz 
mv asterisk-addons-1.4.2 asterisk-addons 
Should be run before building asterisk: ===================>
cd /usr/src/zaptel
./configure
# make menuselect
make install
make config

===> If you get kernel error in ‘make install’ for zaptel:
 # rpm -q | grep kernel
 — check if kernel mentoned in zaptel error appears.
 If not follow the procedure below:

 # ls /lib/modules/2.6.18-8.1.6.el5xen -l
 # cd /lib/modules/2.6.18-8.1.6.el5xen/
 # rm build (press ‘y’ when prompted)
 # ln -s /usr/src/kernels/2.6.18-8.1.6.el5-i686/ build
 # cd /usr/src/zaptel
 # make clean
 # make install
 # make config
Optional: If you have Zaptel digital cards:
cd ../libpri
make clean
make install

Must be installed after zaptel and (if you need it) libpri:
cd ../asterisk
./configure 
# make menuselect # for extra configuration
make
make install
make samples
make config
Optional. Should be run after installing Asterisk:
cd ../asterisk-addons
./configure
make
make install

===> If you get compilation error for ‘libchan_h323.so.1.0.1’:
 # ls -la asterisk-ooh323c/.libs
 (check if you have ‘libchan_h323.1.0.1’)
 # cp asterisk-ooh323c/.libs/libchan_h323.1.0.1 asterisk-ooh323c/.libs/libchan_h323.so.1.0.1
 # make install

Installing freepbx 2.2.2 ============================>

# yum install gcc libxml2-devel libtiff-devel mysql-server php-gd php-mysql kernel-devel kernel-smp-devel bison ncurses-devel audiofile-devel subversion libogg-devel openssl-devel mysql-devel

OR

Do ‘yum’ for all of these: (you might need ‘php-pear’ only)
 build-essential php5 php5-cli php5-mysql mysql-server php-pear php-db
 openssh-server curl sox apache2 subversion libncurses5-dev libssl-dev
 linux-headers-`uname -r` libmysqlclient15-dev
e.g. # yum install php5

OR

both:)

lame is not available through a yum repository; but it can be obtained and installed
from Dag Wieers’ RPM repository:

[root@dhcp1 ~]# rpm -ivh http://apt.sw.be/redhat/el4/en/i386/RPMS.dag/lame-3.96.1-2.2.el4.rf.i386.rpm

# cd /usr/src
# wget http://superb-east.dl.sourceforge.net/sourceforge/amportal/freepbx-2.2.2-withmodules.tar.gz
# tar -xvzf freepbx-2.2.2-withmodules.tar.gz

Setup users, groups, folders and permissions: ===>

[root@dhcp1 ~l]# useradd -c “Asterisk PBX” -d /var/lib/asterisk asterisk
[root@dhcp1 ~]# chown asterisk /var/lib/php/session/

Using nano (or your favourite editor, but nano is fine), you need to change User apache and Group apache to User asterisk and Group asterisk.

[root@dhcp1 ~]# nano +227 /etc/httpd/conf/httpd.conf (Push Control-X to save when you’ve finished)

You also want to change AllowOverride None to AllowOverride All

[root@dhcp1 ~]# nano +311 /etc/httpd/conf/httpd.conf (Push Control-X to save when you’ve finished)
Set up MySQL   ======>
Before you can do anything to MySQL, you need to make sure it’s running:

[root@dhcp1 ~]# /etc/init.d/mysqld start
Initializing MySQL database:                               [  OK  ]
Starting MySQL:                                            [  OK  ]
[root@dhcp1 ~]#

Now, to configure the databases for freePBX:

[root@dhcp1 ~]# cd /usr/src/freepbx-2.2.2
[root@dhcp1 freepbx-2.2.2]# mysqladmin create asterisk
[root@dhcp1 freepbx-2.2.2]# mysqladmin create asteriskcdrdb
[root@dhcp1 freepbx-2.2.2]# mysql asterisk < SQL/newinstall.sql
[root@dhcp1 freepbx-2.2.2]# mysql asteriskcdrdb < SQL/cdr_mysql_table.sql

They also need to be secured, so that not just anyone can access them. freePBX will prompt you for a database password when you do the install. You need to pick that now. We’ll assume that you’ve picked ‘asteriskuser’ and ‘amp109’ – you probably shouldn’t use these, as they are well known passwords for Asterisk@Home builds. If anyone’s trying to attack your machine, they will try this.

[root@dhcp1 freepbx-2.2.2]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 4.1.16

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO eapenuser@localhost IDENTIFIED BY ‘electron’;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON asterisk.* TO eapenuser@localhost IDENTIFIED BY ‘electron’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye
[root@dhcp1 freepbx-2.2.2]
Now, after all of this, you need to pick a root ‘mysql’ password. For this, we’ll pretend it’s ‘quark101’. If you need to do anything else with mysql, you’ll need to provide this password.

[root@dhcp1 freepbx-2.2.2]# mysqladmin -u root password ‘quark101’
Build the cdr_mysql module for Asterisk (Yep, more compiling!)
[root@dhcp1 freepbx-2.1.1]# cd /usr/src/asterisk-addons
[root@dhcp1 freepbx-2.1.1]# cp Makefile Makefile.orig
[root@dhcp1 freepbx-2.1.1]# sed -i ‘s/SOURCE/SOURCE -DMYSQL_LOGUNIQUEID/’ Makefile
[root@dhcp1 freepbx-2.1.1]# make && make install
Install freePBX at last!
You’re there – you’ve done the hard yards, and finally you can install freePBX!
WARNING! If you have an existing Asterisk installation, the script below will overwrite your Asterisk configuration files. Backup your
/etc/asterisk directory before running.
$cd /usr/src/freepbx-2.2.2
$./install_amp

===> If you get PEAR DB…FAILED
 # yum install php-gd
 # yum install php-mbstring
 # pear install DB

Checking for PEAR DB..OK
Checking for PEAR Console::Getopt..OK
Checking for libasteriskperl (perl bindings for asterisk)…Checking user..OK
Checking for /etc/amportal.conf../etc/amportal.conf does not exist, copying default
Creating new /etc/amportal.conf
Enter your USERNAME to connect to the ‘asterisk’ database: [eapenuser]
Enter your PASSWORD to connect to the ‘asterisk’ database: [electron]
Enter the hostname of the ‘asterisk’ database: [localhost]
Enter a USERNAME to connect to the Asterisk Manager interface: [admin]
Enter a PASSWORD to connect to the Asterisk Manager interface:[quark111]
Enter the path to use for your AMP web root:[/var/www/html]
Enter the path to use for your FOP web root:[/var/www/html/panel]
Created /var/www/html/panel
Enter the path to your Apache cgi-bin:[/var/www/cgi-bin]
Enter the IP ADDRESS or hostname used to access the AMP web-admin:[xx.xx.xx.xx] The IP Address of your Asterisk Machine [ElectronTest]
Enter a PASSWORD to perform call transfers with the Flash Operator Panel: [passw0rd]
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]? extensions
Enter directory in which to store AMP executable scripts: [/var/lib/asterisk/bin]
Created /var/lib/asterisk/bin
Enter directory in which to store super-user scripts: [/usr/sbin]
/etc/amportal.conf writtenOK
Reading /etc/amportal.conf..OK
Checking for /etc/asterisk/asterisk.conf../etc/asterisk/asterisk.conf does not exist, copying default
OK
Reading /etc/asterisk/asterisk.conf..OK
Connecting to database..OK
Checking current version of AMP..1.10.010beta1
Installing new AMP files..OK
Configuring install for your environment..OK
Setting permissions on files..OK
Checking for upgrades..5 found
Upgrading to 1.10.010..
Upgrading to 1.10.010..OK
Upgrading to 2.0beta1..
-> Running PHP script /usr/src/freepbx-2.0-beta4/upgrades/2.0beta1/emergencycid.php
-> Running SQL script /usr/src/freepbx-2.0-beta4/upgrades/2.0beta1/tables.sql
PHP Notice: Undefined variable: data in /usr/src/freepbx-2.0-beta4/install_amp on line 305
Upgrading to 2.0beta1..OK
Upgrading to 2.0beta2..
Upgrading to 2.0beta2..OK
Upgrading to 2.0beta3..
-> Running PHP script /usr/src/freepbx-2.0-beta4/upgrades/2.0beta3/fixgotovm.php
Updating existing voicemail destinations..
..OK
Upgrading to 2.0beta3..OK
Upgrading to 2.0beta4..
Upgrading to 2.0beta4..OK
Generating AMP configs..
Generating Configurations.conf..
Checking for PEAR DB..OK
Checking for PEAR Console::Getopt..OK
Checking for /etc/amportal.conf..OK
Reading /etc/amportal.conf..OK
Connecting to database..OK
Please Reload Asterisk by visiting http://XXX.XXX.XXX.XX/admin
Generating AMP configs..OK
Restarting Flash Operator Panel..-bash: /var/www/html/admin/bounce_op.sh: Permission denied
OK
Please Reload Asterisk by visiting http://XXX.XXX.XXX.XX/admin

If you get any warnings or errors in the last part of the output, they’re usually not traumatic, but please use the IRC Support tool to report a bug to the developers.
amportal control script

Starting with version 1.10.004, freePBX provided a new control script. The functionality of which is to start, stop or kill services in the freePBX environment, or to set permissions on directories/files in the freePBX environment:

$amportal
———-AMP Control Script———–
Usage: amportal start|stop|kill|chown

start: Starts Asterisk and Flash Operator Panel server
stop: Gracefully stops Asterisk and the FOP server
restart: Stop and Starts
kill: Kills Asterisk and the FOP server
chown: Sets appropriate permissions on files
The amportal script is the recommended way to stop and start asterisk:
$ /usr/sbin/amportal stop
$ /usr/sbin/amportal start

19.Automatic start-up

echo /usr/sbin/amportal start >> /etc/rc.local

 

Ensure services are starting at boot time and reboot

In order to access and use freePBX we will want both Apache (httpd) and MySQL (mysqld) to be started at boot. You can check to see if they are setup to start at boot by using chkconfig:

[root@dhcp1 freepbx-2.1.1]# chkconfig –list httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@dhcp1 freepbx-2.1.1]# chkconfig –list mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Here we see that both httpd and mysqld have off across the board (runlevels). chkconfig can also be used to turn on a particular service, which you would want to do in this case.
^[root@dhcp1 freepbx-2.1.1]# chkconfig httpd on
[root@dhcp1 freepbx-2.1.1]# chkconfig mysqld on
You can now access freePBX with your web browser.

The first time you click on the FreePBX Administration link you will be prompted for a username and password. Use admin and admin. CREATE A NEW ADMINISTRATIVE USER IMMEDIATELY AFTER LOGIN.


Network configuration

July 19, 2008

Usually, I ssh to my sand box and if it happens to be Red Hat flavor; I jump to /etc/sysconfig/network-scripts and/or /etc/sysconfig/networking and tweak NICs.

But, I love this one. On SuSE, I use YaSt! very very user friendly…


Change host-name for Trixbox shell

July 10, 2008

By default, Trixbox installation uses [trixbox1.localdomain] as HOSTNAME, which is also diplayed as shell prompt.

To change this:

[trixbox1.localdomain ~]# sysctl kernel.hostname

kernel.hostname = trixbox1.localdomain

[trixbox1.localdomain ~]# sysctl kernel.hostname=veejansh.ivr

kernel.hostname = veejansh.ivr

You also need to edit your network file to make this change permanent i.e. persistent across reboots.

[veejansh.ivr ~]# vi /etc/sysconfig/netowrk

Here, edit “HOSTNAME” to “veejansh.ivr”, and save the file.

Now, restart your shell and you will have new name for your shell prompt or HOSTNAME. This is applicable to trixbox installations or RedHat/Centos Linux installations.