+ Responder ao Tópico



  1. #1
    c4f0f0
    Seguinte Galera,

    Ai instalei o squid tudo rodando bunitinho, agora quero gerenciar ele, fiquei sabendo do SARG, alguém já usou??, é Bom??, e quais são os passos pra gerenciar legal o squid.

    AH e o log do squid é o tal do access.log, certo? eu tenho que apagar ele as vezes?? ele fica muito grande, o squid faz isso sozinho??


    Um Grande Abraço
    C4f0f0

  2. #2
    beastie

    Eu já implementei alguns sarg´s por ai, eu particularmente achei muito útil, ele gera retórios bons, pelo menos os necessários como banda utilizada por user, sites bloqueados (para saber o que ele andou acessando indevidamente) e sites mais visitados (pra vc poder dar uma sacaneada no pessoal e bloqueá-los ;-) )....

    é verdade, aqui eu fiquei sabendo que o log do squid fica absurdo e as vezes tem que apagá-lo, e com sarg tambem é fogo, porque ele demora muito para gerar o relatorio...

    qq coisa posta ai!



  3. #3
    Gnuser
    vc pode utilizar tbm o proxy-report

    Este programa tem a extensão .pl (PERL) no entanto
    você tem que ter o perl instalado em seu computador.

    Ex.:
    Para executar digite:
    perl proxy-report 10.0.0.1 /var/log/squid

    Em seguida o proxy-report irá gerar o arquivo
    proxy-report.txt contendo a listagem dos sites
    que foram visitados e quantas vezes foram acessados.

  4. #4
    Gnuser
    O script perl do prox report e este aqui:

    #!/usr/bin/perl

    # Changelog:
    # 14-Aug-2001 v1.6
    # + Complete logic rewrite.
    # + (!!! NOTE !!!) IP is now a part of the command line
    # 14-Aug-2001 v1.4
    # * Use glob() instead of external ls and grep.
    # * Incorrect filename in logfile when decompressing.
    # + Total requests, total urls
    # + Comments (after I tried to understand WTF am I doing <IMG SRC="images/forum/icons/icon_smile.gif">)
    # + Changelog (for the same reason)
    # 11-May-2001 v1.2
    # + Optimization
    # + Code clean-up
    # + Ignore URL

    use POSIX qw(strftime);

    $version="proxy-report.pl v1.6 (Leonid Mamtchenkov <leonid\@leonid.maks.net&gt<IMG SRC="images/forum/icons/icon_wink.gif">";
    $workdir=".";
    $tempfile="$workdir/proxy-report.tmp";
    $resultfile="$workdir/proxy-report.txt"; # Actual report file.
    $mylogfile="$workdir/proxy-report.log"; # Script log file.
    $ip2find=shift; # IP address to find in log file.
    $ignoreurl=""; # Dismiss all references to URL.
    $logdir=shift; # Squid logs from command line.
    $logfilenamepattern="access"; # $logdir/access*
    ###############################################################################
    line2log("-"x50); # Separate script log entries.

    # Check the command line arguments to be correct.
    if (!(-d $logdir)) {
    line2log("ERROR: $logdir does not seem to be a directory&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    print "\n";
    print "Usage: $0 IPaddr DIRname\n";
    print "IPaddr - IP address to find in the log. Put 127.0.0.1 to be on the safe side.\n";
    print "DIRname- directory where to find squid logs. /var/log/squid/ is a good start.\n";
    print "\n";
    exit(1);
    }

    $logdir=~s/\/$//; # Get rid of the trailing slash in dir name.
    line2log("Searching for &acute;$logfilenamepattern*&acute;-files in directory $logdir&quot<IMG SRC="images/forum/icons/icon_wink.gif">;


    foreach $foundlogfile (glob("$logdir/$logfilenamepattern*&quot<IMG SRC="images/forum/icons/icon_wink.gif">) {
    chomp($foundlogfile); # Just in case.
    line2log("Found $foundlogfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    ($logfile,$compressed)=decompresslogfile("$foundlogfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    line2log("Processing $logfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;

    open (IN, $logfile) or die "ERROR: Could not read from input file ($!)\n";
    while (chomp($line=<IN&gt<IMG SRC="images/forum/icons/icon_wink.gif">) {
    @fields = split (/\s+/, $line);
    $reqtime = $fields[0]; # Time or the request
    $reqip = $fields[2]; # IP address from which request came.
    $requrl = $fields[6]; # URL requested

    # IP matches and URL not matches ignore
    if (($reqip =~ m/$ip2find/) && (!($requrl=~ m/$ignoreurl/))) {
    if ($requrl =~ /:\/\//) {
    ($proto,$server)=split(/:\/\//, $requrl);
    }
    else {
    $proto="http"; $server=$requrl;
    }
    ($fqdn,) = split (/\//, $server);
    $requrl="$proto://$fqdn";
    $currentdate=strftime "%Y-%m-%d (%a)", localtime($reqtime);
    $requests{$currentdate}{$requrl}++; # hash of hashes

    }
    }
    close (IN);
    if ($compressed eq 1) {
    line2log("Compressing $logfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    system("gzip $logfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    }
    }
    line2log("Generating report to file $resultfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    $reportdate=strftime "%d %b %Y (%a)", localtime(time);
    $reporttime=strftime "%H:%M:%S", localtime(time);

    open (OUT, ">$resultfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;

    print OUT "Proxy server statistics report\n";
    print OUT "------------------------------\n";
    print OUT "Date: $reportdate\t$reporttime\n";
    print OUT "Monitored IP address: $ip2find\n\n";

    foreach $date (reverse sort keys %requests) {
    print OUT "\n$date\n";
    print OUT "# Requests\tURL\n";
    # If there is better way to sort out the hash, let me know <IMG SRC="images/forum/icons/icon_smile.gif">
    open (TMP,">$tempfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    $reqcounter=$urlcounter=0;
    foreach $url (sort keys %{ $requests{$date} }) {
    print TMP "$requests{$date}{$url}\t\t$url\n";
    $reqcounter+=$requests{$date}{$url};
    $urlcounter++;
    }
    close (TMP);
    # I don&acute;t like this, but who cares <IMG SRC="images/forum/icons/icon_smile.gif">
    system ("sort -n -r $tempfile -o $tempfile.tmp ; mv -f $tempfile.tmp $tempfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    open (TMP, "$tempfile&quot<IMG SRC="images/forum/icons/icon_wink.gif"> || die "ERROR: $!\n";
    while ($inline=<TMP&gt<IMG SRC="images/forum/icons/icon_wink.gif"> {
    print OUT $inline;
    }
    close (TMP);
    print OUT "-"x60,"\n";
    print OUT "$reqcounter\t\tTotal requests\n";
    print OUT "$urlcounter\t\tTotal URLs\n";
    print OUT "-"x60,"\n";
    print OUT "\n";
    }
    print OUT "Generated by $version\n";

    close (OUT);

    unlink ($tempfile);
    ###############################################################################
    sub decompresslogfile{
    $file2check=shift;
    if ($file2check=~/\.gz/) {
    line2log("Decompressing $file2check&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    system ("gzip -d $file2check&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    $file2check=~s/\.gz//;
    $compressed=1;
    }
    else {
    line2log("File $file2check is not compressed&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    $compressed=0;
    }
    return $file2check,$compressed;
    }
    ###############################################################################
    sub line2log {
    $logline=shift;
    $now=strftime "%Y-%b-%d %H:%M:%S", localtime(time);
    open (LOG, ">>$mylogfile&quot<IMG SRC="images/forum/icons/icon_wink.gif">;
    print LOG "$now\t$logline\n";
    close (LOG);
    }

    <IMG SRC="images/forum/icons/icon_biggrin.gif"> Blz espero que isto te ajude:
    LEMBRE-SE o interpretador da linguagem perl deve estar instalado.



  5. #5
    c4f0f0
    Valeu galera,

    Vou usar o Sarg mesmo

    Um Abraço
    Felipe Machado






Tópicos Similares

  1. Inicialização do Squid
    Por ATNunes no fórum Servidores de Rede
    Respostas: 4
    Último Post: 11-12-2002, 10:30
  2. Duvidas sobre Log access.log do SQUID !!!
    Por Danielvb no fórum Servidores de Rede
    Respostas: 2
    Último Post: 23-11-2002, 15:46
  3. Log do Squid?
    Por no fórum Servidores de Rede
    Respostas: 2
    Último Post: 15-10-2002, 19:50
  4. figura na pagina de erro do squid
    Por roggy no fórum Servidores de Rede
    Respostas: 1
    Último Post: 25-09-2002, 16:40
  5. como limpar o cache do squid?
    Por no fórum Servidores de Rede
    Respostas: 3
    Último Post: 17-08-2002, 11:13

Visite: BR-Linux ·  VivaOLinux ·  Dicas-L