remote agents script question....

All installation and configuration problems and questions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

remote agents script question....

Postby brainstorm » Fri Jun 27, 2008 9:45 am

I am using vicidial-2.0.3
In "AST_VDremote_agents.pl" script, line number 383 there is a mysql query which counts number of rows based on user number, server_ip, campaign, conf_exten, & closer_campaign.

So each time it gets one row and after tht, that perticular row is updated by new random_id.

So I am not getting tht wy it is updating the random number each time for a selected user ?

Next thing is related to this script also. In line number 609 u will find one update query. and under tht query there is one another update query (line no 613).

One by one both these queries are updating 2 diff columns of a same row. We can do this thing by writing a single query. So wy it is there in 2 sepret queries ??
Software and cathedrals are much the same - first we build them, then we pray.
brainstorm
 
Posts: 33
Joined: Thu Nov 29, 2007 2:50 am
Location: India-Gujarat-Ahmedabad

Postby mflorell » Fri Jun 27, 2008 7:35 pm

The first one is to update the timestamp and allow for routing of calls to agents randomly.

The second one I am not sure of since it has been about a year since I worked on 2.0.3, could you post the actual queries?
mflorell
Site Admin
 
Posts: 18339
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Postby brainstorm » Mon Jun 30, 2008 12:29 am

Dear mflorel,

I am using vicidial-2.0.3. :D

The query wt I am asking for is given below. Below there are two queries.(line number 383 and 398 in AST_VDremote_agents.pl)

Code: Select all
      ###############################################################################
        ###### third traverse array of remote agents to be active and insert or update
        ###### in vicidial_live_agents table
        ###############################################################################
                $h=0;
                foreach(@DBremote_user)
                        {
                        if (length($DBremote_user[$h])>1)
                                {

                                ### check to see if the record exists and only needs random number update

                              $stmtA = "SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]';";

                                $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
                                $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
                                $sthArows=$sthA->rows;
                                $rec_count=0;
                                while ($sthArows > $rec_count)
                                        {
                                        @aryA = $sthA->fetchrow_array;
                                        $loginexistsRANDOM[$h] =        "$aryA[0]";
                                        $rec_count++;
                                        }
                                $sthA->finish();

                                if ($loginexistsRANDOM[$h] > 0)
                                        {

                                        $stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]' where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]';";

                                        $affected_rows = $dbhA->do($stmtA);
                                        if ($DBX) {print STDERR "$DBremote_user[$h] $DBremote_campaign[$h] ONLY RANDOM ID UPDATE: $affected_rows\n";}
                                        }
     


First one is "Select count(*)....." query which gives total no of records by user number. Most of times it gives me 1. So the next query "Update vicidial_live_agents...." will be executed. Now, here in update query we are only updating the "random_id", not updating the timestamp.

And main question is tht "Wt is actual use of "random_id" ??? And wy we r updating only random_id here ??? :? :? :?
As per ur ans we should update timestamp also, isn't it ??? :? :? :?

==================================================================================================================================================================

Next thing is, the following 2 queries(line number 609 and 613 in AST_VDremote_agents.pl)

Code: Select all
                                        }
                                else
                                        {

                                        $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',last_call_finish='$SQLdate',lead_id='',uniqueid='',callerid='',channel='' where user='$VD_user[$z]' and server_ip='$server_ip';";

                                        $affected_rows = $dbhA->do($stmtA);
                                        if ($DB) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|READY|$VD_uniqueid[$z]|$VD_user[$z]|\n";}

                                        $stmtA = "UPDATE vicidial_live_agents set status='READY' where user='$VD_user[$z]' and server_ip='$server_ip';";

                                        $affected_rows = $dbhA->do($stmtA);
                                        if ($DB) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|READY|$VD_uniqueid[$z]|$VD_user[$z]|\n";}



Here in first query we r updating random_id, last_call_finish, lead_id, uniqueid, callerid, channel based on user & server_ip, and in next query we are only updating the status based on user & server_ip.

We can do this by single query only like the following

Code: Select all
"UPDATE vicidial_live_agents set random_id='$VD_random[$z]', status='READY', last_call_finish='$SQLdate', lead_id='', uniqueid='', callerid='', channel=''  where user='$VD_user[$z]' and server_ip='$server_ip';";


So my question is , "Is it necessary to use two seprate quries here ??" :roll: :roll: :roll:
Software and cathedrals are much the same - first we build them, then we pray.
brainstorm
 
Posts: 33
Joined: Thu Nov 29, 2007 2:50 am
Location: India-Gujarat-Ahmedabad

Postby mflorell » Mon Jun 30, 2008 9:24 am

The random ID is used when doing call routing to agents using the random method. The update of the timestamp is also used to determine whether the agent is still active.

As for the other queries, I had them seaprated when fixing a specific bug and it is still usefull in some debugging of a specific configuration error. The processor cost of doing two queries on the vicidial_live_agents table is pretty much nothing even on a system with 250 agents so i was not worried about optimizing it.
mflorell
Site Admin
 
Posts: 18339
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Postby brainstorm » Mon Jun 30, 2008 11:26 pm

yeps :) thnx mflorel, thnx for ur help and support.

:lol: :lol: :lol:
Software and cathedrals are much the same - first we build them, then we pray.
brainstorm
 
Posts: 33
Joined: Thu Nov 29, 2007 2:50 am
Location: India-Gujarat-Ahmedabad

Postby brainstorm » Tue Jul 01, 2008 2:58 am

Currently I am getting strange problem.

When I am logging in 300 remote agents. and placing calls in sipp then i m getting the following error in asterisk. :(

Code: Select all
DBI connect('asterisk:192.168.1.28:3306','cron',...) failed: Too many connections at /var/lib/asterisk/agi-bin/agi-VDADtransfer.agi line 97
Couldn't connect to database: Too many connections at /var/lib/asterisk/agi-bin/agi-VDADtransfer.agi line 97.



All agents can successfuly logged in but wen agents tries to place calls, then after placing 282 no of calls, I m getting the above error in asterisk console and asterisk got crashing.

:cry: :cry: :cry:
Software and cathedrals are much the same - first we build them, then we pray.
brainstorm
 
Posts: 33
Joined: Thu Nov 29, 2007 2:50 am
Location: India-Gujarat-Ahmedabad

Postby mflorell » Tue Jul 01, 2008 7:16 am

What do you have your max connections set to in your /etc/my.cnf file?

What is your loadavg when this happens?
mflorell
Site Admin
 
Posts: 18339
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida


Return to Support

Who is online

Users browsing this forum: Bing [Bot] and 270 guests