VHDL, verilog, design, verification, scripts, ...
Email: bknpk@hotmail.com Phone: +972-54-7649119



 

ASIC/FPGA Design and Verification Out Source Services

This page presents a script, which is used by this site, to extract, what pages have been accessed (from apache2 access log).

  1. To view the main page of this work.
    This page explains the basics parts of the PERL script.

  2. In the first part of the script, I build the date in the very same format used by the apache2 web server.
    While the day and year are simple, the month is taken from an array:
    ...
    1. my @a_month = ();
    2. push(@a_month, "Jan");
    3. push(@a_month, "Feb");
    4. ...
    5. my $date_tmp=`date +%m`; chomp($date_tmp);
    6. my $date=$a_month[$date_tmp-1];
    7. $date_tmp=`date +%d`; chomp($date_tmp);
    8. $date=$date_tmp . "/" . $date;
    9. $date_tmp=`date +%y`; chomp($date_tmp);
    10. if( length($date_tmp) == 2 ) {$date_tmp="20" . $date_tmp;}
    11. $date=$date . "/" . $date_tmp;
    ...

  3. The next part is the hash. The hash key is the HTML file and its content is the number of times the page was visited today. ...
    1. my %hash_cnt = ();
    2. my $fp_val="";
    3. ...
    4.     if( $line =~ /[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*.*(my_web\/.*\.html).*/ ) {
    5.       $t1=$1;
    6.       #filter two html entries
    7.       $search_ix=index($t1, "html ");
    8.       if( $search_ix >= 0 ) {
    9.         $t1=substr($t1, 0, $search_ix+4);
    10.       }
    11.       #filter non my page
    12.       $search_ix=index($t1, "www\.google");
    13.       if( $search_ix < 0 ) {
    14.         $fp_cnt=$t1;

    15.         $hash_cnt{ $fp_cnt }++;
    ...

  4. The data is finally written out the hash to create an HTML file HTML report, using a reverse (b <=> a and not a <=>b) sort to show the largest value first :
    for my $key ( sort {$hash_cnt{$b} <=> $hash_cnt{$a}} keys %hash_cnt ) {

  5. Note: that in many case I use the PERL function index to find a string in a string. This is faster than the regular expression syntax:
    if( $line =~ //) ...

  6. The script is also capable to filter out based on an IP list. For instance entries, which start with my router's IP at home or work.
    ...
    my $filter_ip_1="192.168.2.1";
    my $entry_ip="";
    ...
    1. my @filter_ip_a = ();
    2. push(@filter_ip_a, "192.168.2.1"); #home
    3. push(@filter_ip_a, "82.166.32.218"); #broadcom
    4. ...
    5.     #filter my views, which come from my router
    6.     FILT_L : foreach $searchAix (@filter_ip_a) {
    7.       $search_ix=index($entry_ip, $searchAix);
    8.       last FILT_L if ($search_ix >= 0);
    9.     }
    10.     if( $search_ix < 0 ) {
    ...

  7. The script also print a IP report. Only the most popular are printed (above 30 percent of the total). The most popular ones are printed with a darker color than others:
    IP report
    180.149.52.44.. 100% 50
    46.117.65.202.. 088% 44
    192.109.150.105 086% 43

Home

An extension to the example from cadance of producer consumer.






Search This Site


Feedback This Site




new pages on this site