Re: [squid-users] adding a parameter to a URL / Problem in the url_redirect program

From: Shaine <gsm_linux_at_yahoo.co.uk>
Date: Tue, 8 Jul 2008 23:12:23 -0700 (PDT)

Hi Henrik,

Thanks for all valuable informations. Those are really help full for me.
Actually in my squid.conf i got enabled url_rewrite_concurrency. As u said
that is why it shifted another step ahead. Now its disabled , took its own
place. second position. I wrote a perl script to handle a sqlite db and
capture some value according to STDIN.

Its working fine in command line, i tested and it works as i expected. But
when i placed in url_rewrite_program in squid, unfortunately squid get PANIC
and its crashed.

2008/07/09 17:14:34| WARNING: redirector #3 (FD 8) exited
2008/07/09 17:14:34| WARNING: redirector #2 (FD 7) exited
2008/07/09 17:14:34| WARNING: redirector #5 (FD 10) exited
2008/07/09 17:14:34| WARNING: redirector #1 (FD 6) exited
2008/07/09 17:14:34| WARNING: redirector #6 (FD 11) exited
2008/07/09 17:14:34| WARNING: redirector #4 (FD 9) exited
2008/07/09 17:14:34| Too few redirector processes are running
FATAL: The redirector helpers are crashing too rapidly, need help!

Here with i have attached my Perl code also .

#!/usr/bin/perl
use DBI;
use strict;
use warnings;
#
## no buffered output, auto flush
$|=1;

my ($dbh,$sth,$dbargs,$IntValue,$query,$url);

$dbargs = {AutoCommit => 0, PrintError => 1};
$dbh = DBI->connect("dbi:SQLite:dbname=List","","",$dbargs);

if ($dbh->err()) {
   print;
   exit;
}

while (<STDIN>) {
   chomp;
   my ($url, $ip) = split(/ /);
   $query = "SELECT * from ACCOUNTING where IPAddress = '". $ip ."' order by
DATETIME desc";
   $sth = $dbh->prepare($query);
   $sth->execute();

   if (my $ref = $sth->fetchrow_hashref()) {
       $IntValue = $ref->{'CalliId'};
       #if ($IntValue == undef) {
        # $IntValue = "NA";
      # }
   }else{
       $IntValue = "NA";
   }

   if (!($url =~ m#VALUE#)) {
       if ($url =~ m#\?#) {
          $url .= ("&VALUE=" . $IntValue);
       } else {
          $url .= ("?VALUE=" . $IntValue);
       }
       print $url."\n";
   } else {
       print "\n";
   }
}
   $sth->finish();
   undef $sth;
   $dbh->commit();
   $dbh->disconnect();

Why , its getting FALAL error when placed in squid? what is wrong with the
script ? Can you help me please ?

Many Thanks
Shaine.

 

Henrik Nordstrom-5 wrote:
>
> On mån, 2008-07-07 at 05:49 -0700, Shaine wrote:
>> I did same way . but client ip doesn't comes in the second possition. Its
>> in
>> third.
>
> It's the second..
>
> http://www.squid-cache.org/ 127.0.0.1/localhost.localdomain - GET -
> myip=127.0.0.1 myport=3128
>
> unless you have enabled url_rewrite_concurrency in which case all
> parameters is shifted one step due to the added request identifier
> infront... but then url is the second..
>
> 0 http://www.squid-cache.org/ 127.0.0.1/localhost.localdomain - GET -
> myip=127.0.0.1 myport=3128
>
> Regards
> Henrik
>
>
>

-- 
View this message in context: http://www.nabble.com/adding-a-parameter-to-a-URL-tp17776816p18355096.html
Sent from the Squid - Users mailing list archive at Nabble.com.
Received on Wed Jul 09 2008 - 06:12:29 MDT

This archive was generated by hypermail 2.2.0 : Wed Jul 09 2008 - 12:00:03 MDT