Skip to main content

Posts

Showing posts from June, 2021

How to reset the Mysql root password in case of password forget.

  How to reset the Mysql root password in case of password forget. ***************************** Step 1 : stop the mysql ***************************** /etc/init.d/mysql stop it will outputs  stopping MySQL database server : mysqld ***************************** Step 2 : starting the mysql in safemode ***************************** run the below command to start mysql in safe mode mysqld_safe --skip-grant-tables & the above command outputs as [1]5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started ***************************** Step 3 : logging to mysql ***************************** mysql -u root  output Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> ***************************** Step 4 : updating new password for mysql root ***************************** use mysql update user

Email alert when hard disk is full in linux

Email alert when hard disk is full in linux           ******************************* Step 1: Create a bash script file ******************************* nano /opt/diskspacealert.sh ******************************* Step 2 : paste the below script ******************************* #!/bin/sh # refered https://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html # enter your mailed below for email alert ADMIN="admin123@gmail.com" # set alert level 90% is default ALERT=90 df -HP | grep -vE '^Filesystem|tmpfs|cdrom' |   while read partition size used free perc mnt ;   do     usep=$(echo $perc | tr -d '%' )     if [ $usep -ge $ALERT ]; then       echo "Running out of space \"$partition ($usep%)\" on $(hostname) as   on $(date)" |        mail -s "Alert: Almost out of disk space - $usep%" $ADMIN     fi   done Note *** change the admin123@gmail.com  to your mail id to which you want email alert ******************************* Step

Mysql Database Autobackup

Create file called dbbackup.sh put below mention lines in it and save. nano /home/dbbackup/dbbackup.sh #!/bin/bash echo "Starting to backup database" mysqldump --opt -uroot asterisk > /home/dbbackup/asterisk_`date '+%Y-%m-%d'`.sql echo "backup done..." echo "Please wait, Compressing backup file..." /bin/gzip /home/dbbackup/asterisk_`date '+%Y-%m-%d'`.sql echo "gzip done..." echo "Deleting 3 Days old backups" find /home/dbbackup -iname '*.sql.gz' -type f -mtime +3 -print | xargs rm -f \{\} \; put below line in cron file 00 02 * * * /home/dbbackup/dbbackup.sh

Asterisk Random callerid setting

  Why Random callerid setting required             In call centers sometimes they need to show random callerids for each call, which are generated by autodiallers or predictive diallers ,so customers wont see that call is from same center. in this blog i will show two methods to set random callerid  in asterisk or vicidial or goautodial based diallers, pbx. Option 1 :   using  RAND function in asterisk         RAND Function can be used in a scenario , if you have a range of DID's  like  40004001 to 40004999 pick any one number randomly within this range and set it has callerid. Before entering the dialplan , let me explain little bit about RAND function Asterisk Function RAND Synopsis: Choose a random number within a range Description: RAND(min,max) choose a random number between min and max , min default to 0 if not specified,  while max may be upto 2147483647 Lets get in to dialplan For eg:  consider the DID range as 40004001

Centos Remove ReadOnly Mode

  https://www.centos.org/forums/ viewtopic.php?t=13798 It turns out that unmouting it, and remounting it, restored the situation to normal - it was no longer read-only after mounting. Results of the fsck root@server [/]# fsck / fsck 1.39 (29-May-2006) e2fsck 1.39 (29-May-2006) /home contains a file system with errors, check forced. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /home: 3525299/107905024 files (1.0% non-contiguous), 10106708/107874459 blocks

Connect Mysql Database Remotly

  add below mention lines in /etc/my.cnf file __________________________ port=3306 bind-address=0.0.0.0 # skip-networking _______________________ net references old_passwords=1 #bind-address=10.233.137.233 #can skip this line port=3306 # skip-networking _________________ Create user sync to linux pc CREATE USER 'sync'@'%' IDENTIFIED BY 'sync'; GRANT ALL PRIVILEGES ON *.* TO 'sync'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES; systemctl restart mariadb.service   restart mysql service and check with telnet port 3306 able to access

Goautodial 3.3/vicidial XLSX upload issue

  cpan -i String::CRC Tk::TableMatrix Net::Address::IP::Local Term::ReadLine::Gnu Spreadsheet::Read Net::Address::IPv4::Local RPM::Specfile Spreadsheet::XLSX Spreadsheet::ReadSXC perl -e'use CPAN; install "Spreadsheet::ParseExcel"' cpan -i Spreadsheet::ParseXLSX yum -y install perl-CPAN cpan -i cpan Spreadsheet::WriteExcel cpan -i Spreadsheet::WriteExcel; ls cd .. find -name Spreadsheet/Read.pm find ... -print0 | grep -FzZ ‘Spreadsheet/Read.pm’ find -name Read.pm mkdir -p /usr/lib64/perl5/Spreadsheet cp -R ./root/perl5/lib/perl5/ Spreadsheet/Read.pm /usr/lib64/perl5/Spreadsheet check speadsheer/Read.pm file exist in path and check /var/log/httpd/error_log file for more info.

Multiple trunk failover / random order dialing Asterisk vicidial

  exten => _7X.,1,AGI( agi://127.0.0.1:4577/call_log ) exten => _7X.,n,Dial(${ABC}/${EXTEN:1},10000,To) exten => _7X.,n,Hangup in ABC exten => _8X.,1,AGI( agi://127.0.0.1:4577/call_log ) exten => _8X.,n,Dial(${XYZ}/${EXTEN:1},10000,To) exten => _8X.,n,Hangup and in same XYZ exten => _9X.,1,AGI( agi://127.0.0.1:4577/call_log ) exten => _9X.,n,Dial(${ABC}/${EXTEN:1},10000,To) exten => _9X.,n,Dial(${XYZ}/${EXTEN:1},10000,To) exten => _9X.,n,Hangup or exten => _6X.,1,AGI( agi://127.0.0.1:4577/call_log ) exten => _6X.,n,Set(Trunk=${RAND(1|2)}) exten => _6X.,n,GoToIf($[${Trunk} = 1]?trunkA) exten => _6X.,n,GoToIf($[${Trunk} = 2]?trunkB) exten => _6X.,n(trunkA),Dial(${ABC}/${EXTEN:1},,tToR) exten => _6X.,n(trunkB),Dial(${XYZ}/${EXTEN:1},,tToR) exten => _6X.,n,Hangup then in campaing set the PREFIX as per ur requirement 7 to dial via ABC 8 to dial via XYZ 9 to dial via the failover dialplan 6 to dial via the random dialp

Restoring corrupted InnoDB MySQL databases

  There are three ways to restore corrupted InnoDB databases (you should decide which one to choose, sometimes You will need to use not only one): manually importing files to newly created database using Percona InnoDB recovery tools using innodb_force_recovery For above methods You will need to have files from Your datadir (for example: /var/lib/mysql), so copy it somwhere. Manually importing files For this method You need to have ibd files from MySQL’s datadir and You need to know how was the table created (whole create command). First step is to create new database, so login to MySQL and create it: create database corrupted; Now create table: use corrupted; CREATE TABLE ` maintenances ` ( ` maintenanceid ` bigint unsigned NOT NULL, ` name ` varchar ( 128 ) DEFAULT '' NOT NULL, ` maintenance_type ` integer DEFAULT '0' NOT NULL, ` descriptio

Adding-listen-whisper-and-barge-to-freepbx-or-asterisk

  This should be placed in /etc/asterisk/extensions_ custom.conf for FreePBX [ext-local-custom] ;listen exten => _*222x.#,1,Macro(user- callerid,) exten => _*222x.#,n,Answer exten => _*222x.#,n,NoCDR exten => _*222x.#,n,Wait(1) exten => _*222x.#,n,ChanSpy(sip/${ EXTEN:4},q) exten => _*222x.#,n,Hangup ;whisper exten => _*223x.#,1,Macro(user- callerid,) exten => _*223x.#,n,Answer exten => _*223x.#,n,NoCDR exten => _*223x.#,n,Wait(1) exten => _*223x.#,n,ChanSpy(sip/${ EXTEN:4},qw) exten => _*223x.#,n,Hangup ;barge exten => _*224x.#,1,Macro(user- callerid,) exten => _*224x.#,n,Answer exten => _*224x.#,n,NoCDR exten => _*224x.#,n,Wait(1) exten => _*224x.#,n,ChanSpy(SIP/${ EXTEN:4},qB) exten => _*224x.#,n,Hangup

TATA SIP WITH ISSBEL PBX

  add route file in /etc/sysconfig/network-script/ route-em2 or name of network card 10.51.134.2 via 10.51.135.53 dev em2 serverip             gateway            device name add SipAddHeader(P-Preferred- Identity: to extensions.conf [macro-dialout-trunk-predial- hook] exten => s,1,SipAddHeader(P-Preferred- Identity:< sip:68176XX@10.51. 140.18 >) exten => s,n,MacroExit() save and dialplan reload leave system and asterisk setting as it is eg sendpid and trustedpid as it is. ass for incoming in extensions.conf in from-pstn context [tata] exten => _X.,1,Goto(s,1) exten => s,1,Noop(Let us look deeper into the soul of the invite) exten => s,n,Set(pseudodid=${SIP_ HEADER(To)}) exten => s,n,Set(pseudodid=${CUT( pseudodid,@,1)}) exten => s,n,Set(pseudodid=${CUT( pseudodid,:,2)}) exten => s,n,Goto(trunkinbound,${ pseudodid},1) SIP settings disallow=all allow=gsm&ulaw&alaw type=friend dtmfmode=rfc2833 context=tata qualify=yes insecure=invite,port nat=yes host

Connecting two issabel server together via SIP trunk

[SERVER1] dtmfmode=rfc2833 type=friend qualify=yes host=192.168.0.106 ;IP of server2 context=from-internal EXT:-1001-1015 ______________________________ __________ [SERVER2] dtmfmode=rfc2833 type=friend qualify=yes host=192.168.0.107 ;IP of server1 context=from-internal EXT-2001-2015 ______________________________ ____________

Allow recording link/filename on web with full name

  To enable web browsing of Recordings on Asterisk server, add the below line  at last line of httpd.conf Alias /RECORDINGS/ “/var/spool/asterisk/ monitorDONE/” <Directory “/var/spool/asterisk/ monitorDONE”> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all <files *.mp3> Forcetype application/forcedownload </files> </Directory> Restart the Apache web server to apply the changes service httpd restart chkconfig httpd on

How to delete old call logs and other logs in vicidial or goautodial.

Step 1 : SSH to the server using the Putty Step 2:   login to mysql by typing   mysql -p                    (if you dont know password try below command )               mysql -ucron -p1234 Step 3 : select the asterisk database by typing               use asterisk step 4: Run the below command to check total disk occupied by asterisk database                SELECT table_schema AS "asterisk", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema; Step 5 : Run the below command to check disk space consumed by each table in asterisk database SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "asterisk" ORDER BY (data_length + index_length) DESC; Step 6 : as per the above output, i will be deleting the data for first top 10 tables which consumes more space vicidial_url_log

Goautodial dahdi-tool avoid dahdi-tools package conflict

  Enable EPEL repository yum install -y epel-release yum install perl-Crypt-Eksblowfish perl-Sys-RunAlone Edit /etc/yum.conf: nano /etc/yum.conf Append to the bottom: exclude=dahdi-tools* Note: there's an asterisk (*) at the end of the line above. It's not a typo error. This will avoid dahdi-tools package conflict with the EPEL repo.

How to record calls dialed from IP Phone or softphone in vicidial or goautodial

  Introduction : By default Vicidial  have the option to record all the calls made via Agent Panel / Campaign. But Sometimes you need to record the calls which are dialed from  phones / extensions directly Solution: There are two methods to enable recording 1. Either Change the Phone Context of the Phones to defaultlog  as shown below screenshot     Goto  ADMIN -- Phones -- modify the phone 2. Or Add the Below dialplan in your extensions.conf exten => _99X.,1,AGI(agi-NVA_recording. agi,BOTH------Y---Y---Y) exten => _99X.,n,Dial(SIP/trunkname/${ EXTEN:2}) exten => _99X.,n,Hangup where 99 is the prefix Note: If you want a report and download the recording,  then create a userid (users-add a new user) with the same extension number then go to that userid , click user stats were you can find the Recordings RECORDINGS FOR THIS TIME PERIOD: (10000 record limit)     [DOWNLOAD] # LEAD DATE/TIME SECONDS   RECID FILENAME LOCATION check default log bel

Secure Issabel and Elastix PBX (asterisk)

  Change default sip port from 5060 to something else for example 11333. cd /etc/asterisk nano sip_general_custom.conf 1 2 cd / etc / asterisk nano sip_general_custom . conf add the following to the file: bindport=5060 1 bindport = 5060 (Change 5060 to your new port). amportal stop amportal start 1 2 amportal stop amportal start Don’t forget to add the new port into Fail2Ban. cd /etc/fail2ban nano jail.local 1 2 cd / etc / fail2ban nano jail . local Define the new port on firewall Disable unused rules and add a one with the new port Reduce failed attempts Set “alwaysauthreject=yes” in your sip

Missed calls Notification on Email (Issabel, FreePBX, Elastix, Asterisk)

This is a simple cronJob to send automatic a custom CDR email every 10 minutes that will include all missed calls of this period. Create a php file named missed_calls.php PHP <?php //error_reporting(0); /*------------------------------------------------------------------------ # copyright Copyright (C) 2018 sbzsystems.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: https://www.sbzsystems.com -------------------------------------------------------------------------*/ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header('Content-Type: text/html; charset=UTF-8'); //error_reporting(0); $host = 'localhost'; $user = 'root'; $password = 'XXXXXXXX'; $db = 'asteriskcdrdb'; $logfile='/usr/local/issabel/missed_calls.log'; // Connects to your Database $link=mysqli_connect("$host", $user, $password) or die(