Monthly Archives: October 2012

PHPAGI2


[root@alfamart agi-bin]# vim /etc/asterisk/manager.conf

[mosesagi]
secret = mosesagi
read = all
write = all

[root@alfamart agi-bin]# vim /etc/asterisk/extensions.conf

[ecentrix-agents]
exten => _9XXXX,1,Dial(SIP/${EXTEN:1},,tT)
exten => _9XXXX,n,Noop(${CHANNEL})
exten => _9XXXX,n,Softhangup(${CHANNEL})

#!/usr/bin/php -q
<?php
set_time_limit(30);
require_once(“include/phpagi-asmanager.php”);
//$asm = new AGI_AsteriskManager();
$asm = new AGI_AsteriskManager(“/etc/asterisk/phpagi.conf”,””);
$asm->connect(“localhost”,”mosesagi”,”mosesagi”);
$asm->send_request(‘Originate’, array(‘Channel’=> “SIP/8801”, ‘Context’ => “ecentrix-agents”, ‘Priority’ => 1, ‘Async’ => true,’callerid’=>”8801″,’Exten’=>98802,’Callerid’=>8801));
$asm->disconnect();
?>

[root@alfamart agi-bin]# pwd originate.php
/var/lib/asterisk/agi-bin

[root@alfamart agi-bin]# php originate.php => DIAL 8801 then DIAL 8802

 

Advertisements

PHPAGI + HANDLE MULTIPLE DID NUMBER


extensions.conf

[ecentrix-agents]
exten => 3000,1,Ringing
exten => 3000,n,Answer
exten => 3000,n,AGI(inbound_flow_agi.php)

#!/usr/bin/php -q
<?php
/*simple ivr phpagi
by moses
*/
set_time_limit(0);
ob_implicit_flush(false);
require(‘include/phpagi.php’);
$agi = new AGI();

/*connection mysql*/
if (!$dbh = mysql_connect(‘localhost’, ‘root’, ‘root’)) {
$agi->verbose(‘mysql_connect() failed, exiting…’);
$agi->hangup();
exit;
}
mysql_select_db(‘voip’, $dbh);
$agi->verbose(‘mysql_connect() connected…’);
/*end connection mysql*/

$query = “SELECT * FROM acd WHERE number='{$agi->request[‘agi_callerid’]}'”;

if (!$res = mysql_query($query, $dbh)) {
$agi->verbose(‘mysql_query() failed: ‘ . mysql_error());
$agi->hangup();
exit;
}

if (mysql_num_rows($res) == 0) {
$agi->verbose(‘mysql_num_rows() returned zero’);
// $agi->stream_file(‘wrong_inbound_number’, ‘#’);
$agi->hangup();
exit;
}

$data = mysql_fetch_array($res);

$agi->verbose(“number : {$data[‘number’]} extension : {$data[‘extensions’]} type : {$data[‘type’]}”);

mysql_free_result($res);

//$agi->stream_file(‘igc_001′);
$ext_destination=””;
$loop=0;
while($ext_destination == “”){
//$result = $agi->fastpass_get_data($buffer,’igc_002′, 3000, 4);
$result = $agi->fastpass_get_data($buffer,’igc_002’, 5000, 4);
$ext_destination=$result[‘result’];
$loop++;
if($loop>2){
$agi->hangup();
$loop=0;
break;
}
}

$agi->verbose($agi->request[“agi_callerid”]);
//operator
if($ext_destination==0){
if ($data[‘type’] == ‘seq’) {
// Dial sequentially
$exts = split(‘,’, $data[‘extensions’]);
foreach ($exts as $ext) {
$agi->exec(‘Dial’, ‘SIP/’ . $ext . ‘,15’);
}
}else if ($data[‘type’] == ‘sim’) {
// Dial simultaneously
$exts = split(‘,’, $data[‘extensions’]);

$last = count($exts);
$i = 1;
// Build dial string
foreach ($exts as $ext) {
$args .= ‘SIP/’ . $ext;
if ($i != $last) {
$args .= ‘&’;
}
$i++;
}
$agi->exec(‘Dial’, $args . ‘,60′,’tT’);

}
}else{
//dial extension
$agi->exec(‘Dial’,’SIP/’ .$ext_destination. ‘,60′,’tT’);
$agi->verbose($agi->channel_status($agi->agi_channel));
}
mysql_close($dbh);
$agi->hangup();
?>

 

 

DRBD + HEARTBEAT CENTOS 6.3


[root@node1 drbd.d]# rpm -aq | egrep -i “heartbeat|drbd|kmod”
heartbeat-libs-3.0.4-1.el6.x86_64
kmod-drbd83-8.3.13-2.el6_3.elrepo.x86_64
drbd83-utils-8.3.13-1.el6.elrepo.x86_64
heartbeat-3.0.4-1.el6.x86_64
[root@node1 drbd.d]#

[root@node1 drbd.d]# cat global_common.conf
global {
usage-count yes;
dialog-refresh 1;
minor-count 5;
# minor-count dialog-refresh disable-ip-verification
}

common {
protocol C;

handlers {
pri-on-incon-degr “/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f”;
pri-lost-after-sb “/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f”;
local-io-error “/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f”;
# fence-peer “/usr/lib/drbd/crm-fence-peer.sh”;
# split-brain “/usr/lib/drbd/notify-split-brain.sh root”;
# out-of-sync “/usr/lib/drbd/notify-out-of-sync.sh root”;
# before-resync-target “/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 — -c 16k”;
# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;
}

startup {
# wfc-timeout degr-wfc-timeout outdated-wfc-timeout wait-after-sb
wfc-timeout 20;
degr-wfc-timeout 30;
}

disk {
# on-io-error fencing use-bmbv no-disk-barrier no-disk-flushes
# no-disk-drain no-md-flushes max-bio-bvecs
on-io-error detach;
}

net {
# sndbuf-size rcvbuf-size timeout connect-int ping-int ping-timeout max-buffers
# max-epoch-size ko-count allow-two-primaries cram-hmac-alg shared-secret
# after-sb-0pri after-sb-1pri after-sb-2pri data-integrity-alg no-tcp-cork
timeout 20;
connect-int 20;
ping-int 20;
max-buffers 2048;
max-epoch-size 2048;
ko-count 30;
cram-hmac-alg “sha1”;
shared-secret “drbdtestingIntelix”;
}

syncer {
# rate after al-extents use-rle cpu-mask verify-alg csums-alg
rate 10M;
al-extents 257;
}
}

 

MRTG ON CENTOS 6.3 + MONITORING MULTIPLE HOST


Monitoring Multiple Host Using MRTG

[root@REMASTER63]# yum install mrtg net-snmp net-snmp-utils

[root@REMASTER63 mrtg]# vim /etc/snmp/snmpd.conf

rocommunity ipbx
syslocation intelix-cc
syscontact moses <mustafa@intelix.co.id>
## sec.name source community
## ======== ====== =========
com2sec local localhost ipbx
com2sec network_2 192.168.0.0/24 ipbx

## Access.group.name sec.model sec.name
## ================= ========= ========
group MyROGroup_1 v1 local
group MyROGroup_1 v1 network_1
group MyROGroup_2 v2c network_2

## MIB.view.name incl/excl MIB.subtree mask
## ============== ========= =========== ====
view all-mibs included .1 80

## MIB
## group.name context sec.model sec.level prefix read write notif
## ========== ======= ========= ========= ====== ==== ===== =====
access MyROGroup_1 “” v1 noauth exact all-mibs none none
access MyROGroup_2 “” v2c noauth exact all-mibs none none
[root@REMASTER63 mrtg]# /etc/init.d/snmpd restart
Stopping snmpd: [ OK ]
Starting snmpd: [ OK ]

[root@REMASTER63 etc]# vim /etc/mrtg/mrtg.cfg
HtmlDir: /var/www/html/mrtg
ImageDir: /var/www/html/mrtg
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg

#Agar uptodate setiap 5 menit
Interval:5
#Agar auto resfresh pada browser
Refresh:300

[root@REMASTER63 mrtg]# snmpwalk -v 1 -c ipbx 192.168.0.121 IP-MIB::ipAdEntIfIndex
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
IP-MIB::ipAdEntIfIndex.192.168.0.121 = INTEGER: 2

[root@REMASTER63]# mkdir -p /var/www/html/mrtg && chown -R apache.apache /var/www/html/mrtg

[root@REMASTER63]# cfgmaker –global ‘WorkDir: /var/www/html/mrtg’ –output /etc/mrtg/mrtg-192.168.0.121.cfg ipbx@192.168.0.121

[root@REMASTER63]# cfgmaker –global ‘WorkDir: /var/www/html/mrtg’ –output /etc/mrtg/mrtg-192.168.0.198.cfg ipbx@192.168.0.198

[root@REMASTER63]# cfgmaker –global ‘WorkDir: /var/www/html/mrtg’ –output /etc/mrtg/mrtg-192.168.0.240.cfg ipbx@192.168.0.240

[root@REMASTER63]# crontab -l
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg-localhost.cfg
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg-192.168.0.198.cfg
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg-192.168.0.240.cfg

[root@REMASTER63 mrtg]# indexmaker –output=/var/www/html/mrtg/index.html \
/etc/mrtg/mrtg-192.168.0.198.cfg \
/etc/mrtg/mrtg.cfg \
/etc/mrtg/mrtg-localhost.cfg \

/etc/mrtg/mrtg-192.168.0.240.cfg

Issue + Physical to Virtual (P2V) LVM CENTOS 6.3


[root@alfamart yum.repos.d]# uname -a

Linux localhost.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@alfamart yum.repos.d]# rpm -aq | grep lvm
lvm2-2.02.95-10.el6.x86_64
lvm2-libs-2.02.95-10.el6.x86_64

Solution : DOWNGRADE LVM VERSION (Package on Centos 6.2)

[root@alfamart yum.repos.d]# yum downgrade lvm2* 
Loaded plugins: downloadonly, fastestmirror, presto
Setting up Downgrade Process
Determining fastest mirrors
addons-local | 1.3 kB 00:00
addons-local/primary | 574 kB 00:00
addons-local 1121/1121
Resolving Dependencies
–> Running transaction check
—> Package lvm2.x86_64 0:2.02.87-6.el6 will be a downgrade
—> Package lvm2.x86_64 0:2.02.95-10.el6 will be erased
—> Package lvm2-libs.x86_64 0:2.02.87-6.el6 will be a downgrade
—> Package lvm2-libs.x86_64 0:2.02.95-10.el6 will be erased
–> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================
Downgrading:
lvm2 x86_64 2.02.87-6.el6 addons-local 548 k
lvm2-libs x86_64 2.02.87-6.el6 addons-local 614 k

Transaction Summary
======================================================================================================================================
Downgrade 2 Package(s)

Total download size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 1.1 M
(1/2): lvm2-2.02.87-6.el6.x86_64.rpm | 548 kB 00:00
(2/2): lvm2-libs-2.02.87-6.el6.x86_64.rpm | 614 kB 00:00
————————————————————————————————————————————–
Total 7.2 MB/s | 1.1 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lvm2-libs-2.02.87-6.el6.x86_64 1/4
Installing : lvm2-2.02.87-6.el6.x86_64 2/4
Cleanup : lvm2-2.02.95-10.el6.x86_64 3/4
Cleanup : lvm2-libs-2.02.95-10.el6.x86_64 4/4
Verifying : lvm2-2.02.87-6.el6.x86_64 1/4
Verifying : lvm2-libs-2.02.87-6.el6.x86_64 2/4
Verifying : lvm2-libs-2.02.95-10.el6.x86_64 3/4
Verifying : lvm2-2.02.95-10.el6.x86_64 4/4

Removed:
lvm2.x86_64 0:2.02.95-10.el6 lvm2-libs.x86_64 0:2.02.95-10.el6

Installed:
lvm2.x86_64 0:2.02.87-6.el6 lvm2-libs.x86_64 0:2.02.87-6.el6

Complete!

Migrate using “VMware vCenter Converter Standalone Client”  5.0.0 

Thank You

#vmkfstools + CLI clode VMK EXSI 5.0


~ # ls -l /vmfs/volumes/lts_medan/ipbx_lts_medan/
-rw-r–r– 1 root root 23 Oct 18 04:42 ipbx_medan-4adab0e2.hlog
-rw——- 1 root root 214748364800 Oct 18 05:53 ipbx_medan-flat.vmdk
-rw——- 1 root root 8684 Oct 18 05:53 ipbx_medan.nvram
-rw——- 1 root root 506 Oct 18 05:35 ipbx_medan.vmdk
-rw-r–r– 1 root root 0 Oct 17 04:25 ipbx_medan.vmsd
-rwxr-xr-x 1 root root 3541 Oct 18 05:53 ipbx_medan.vmx
-rw-r–r– 1 root root 272 Oct 18 04:45 ipbx_medan.vmxf
-rw-r–r– 1 root root 85480 Oct 17 04:26 vmware-1.log
-rw-r–r– 1 root root 168037 Oct 17 05:07 vmware-2.log
-rw-r–r– 1 root root 108120 Oct 17 08:38 vmware-3.log
-rw-r–r– 1 root root 107348 Oct 17 08:59 vmware-4.log
-rw-r–r– 1 root root 112161 Oct 18 04:42 vmware-5.log
-rw-r–r– 1 root root 144158 Oct 18 05:09 vmware-6.log
-rw-r–r– 1 root root 111144 Oct 18 05:53 vmware.log

~ #mkdir -p ls -l /vmfs/volumes/lts_medan/backup_ipbx_medan/

~ #vmkfstools -i “/vmfs/volumes/lts_medan/ipbx_medan/ipbx_medan.vmdk” -d thin “/vmfs/volumes/lts_medan/backup_ipbx_medan/backup_ipbx_medan.vmdk”

 

This slideshow requires JavaScript.

 

Percona Streaming Backup


SERVER B (192.168.0.140)

[root@alfamart ~]# rpm -aq | grep Percona
Percona-Server-shared-55-5.5.27-rel28.1.296.rhel6.x86_64
Percona-Server-55-debuginfo-5.5.27-rel28.1.296.rhel6.x86_64
Percona-Server-client-55-5.5.27-rel28.1.296.rhel6.x86_64
Percona-Server-server-55-5.5.27-rel28.1.296.rhel6.x86_64
Percona-Server-devel-55-5.5.27-rel28.1.296.rhel6.x86_64
Percona-Server-test-55-5.5.27-rel28.1.296.rhel6.x86_64
Percona-Server-shared-compat-5.5.27-rel28.1.296.rhel6.x86_64

[root@alfamart ~]# innobackupex -v
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Inc 2009-2012. All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
[root@alfamart ~]# mysql –version
mysql Ver 14.14 Distrib 5.5.27, for Linux (x86_64) using readline 5.1
[root@alfamart ~]# ls -l /var/lib/mysql
total 28864
-rw-rw—- 1 mysql mysql 5 Oct 17 22:43 alfamart.pid
drwx—— 2 mysql mysql 4096 Oct 13 13:18 percona
drwx—— 2 mysql mysql 4096 Oct 11 01:01 percona_addons
drwx—— 2 mysql mysql 4096 Oct 11 01:01 percona_report
-rwx—— 1 mysql mysql 18874368 Oct 17 22:43 ibdata1
-rw-rw—- 1 mysql mysql 5242880 Oct 17 22:43 ib_logfile0
-rw-rw—- 1 mysql mysql 5242880 Oct 11 01:01 ib_logfile1
drwx—— 2 mysql mysql 4096 Oct 11 01:01 mysql
srwxrwxrwx 1 mysql mysql 0 Oct 17 22:43 mysql.sock
drwx—— 2 mysql mysql 4096 Oct 12 13:50 oshop_gc
drwx—— 2 mysql mysql 4096 Oct 11 01:01 performance_schema
-rwx—— 1 mysql mysql 21 Oct 11 01:01 xtrabackup_binlog_pos_innodb
[root@alfamart ~]# innobackupex –host=localhost –user=myuser –password=mypassword –stream=tar ./ | ssh -q root@192.168.0.121 “cat – > /tmp/test/backup.tar”

SERVER A ( 192.168.0.121)
[root@REMASTER63 test]# ls -l /tmp/test/backup.tar

[root@REMASTER63 test]# tar -ixvf backup.tar

[root@REMASTER63 test]# ls -l
total 64868
-rw-r–r– 1 root root 260 Oct 17 22:59 backup-my.cnf
drwxr-xr-x 2 root root 4096 Oct 17 23:18 percona
drwxr-xr-x 2 root root 4096 Oct 17 23:18 percona_addons
drwxr-xr-x 2 root root 4096 Oct 17 23:18 percona_report
-rw-rw—- 1 root root 18874368 Oct 17 22:43 ibdata1
drwxr-xr-x 2 root root 4096 Oct 17 23:18 mysql
drwxr-xr-x 2 root root 4096 Oct 17 23:18 oshop_gc
drwxr-xr-x 2 root root 4096 Oct 17 23:18 performance_schema
-rw-r–r– 1 root root 13 Oct 17 22:59 xtrabackup_binary
-rw-r–r– 1 root root 23 Oct 17 22:59 xtrabackup_binlog_info
-rw-rw—- 1 root root 79 Oct 17 22:59 xtrabackup_checkpoints
-rw-rw—- 1 root root 2560 Oct 17 22:59 xtrabackup_logfile

[root@alfamart mysql]# /etc/init.d/mysql stop

[root@alfamart lib]# mv mysql mysql-percona

[root@alfamart lib]# mkdir mysql

[root@REMASTER63 test]# rsync -avz -e ‘ssh -p 22’ /tmp/test/* root@192.168.0.140:/var/lib/mysql/

[root@alfamart mysql]# chown -R mysql.mysql /var/lib/mysql

[root@alfamart mysql]# /etc/init.d/mysql start
Starting MySQL (Percona Server)…. SUCCESS!

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: