Trunc for Subdomains

Jesus Calle, Ext 1081 (jesus@coms.indra-ssi.es)
Tue, 10 Dec 1996 14:26:17 -0800


First: Sorry for my English.

I think it is useful to have a trunc for the section "Transfers by Reversed
Subdomain" that would work in the same way that -trunc for the archive URL 
section. See the manual.

I have do it (almost copying the code of Roy) See CHANGES down.

It should run in the following way:
Now -trunc is dependant on the context, is "a section display option".
although for only two sections, archive and subdomain.
Then if you want trunc the path/filename in the archive section you have to
put "wwwstat -archive -trunc 3"
To truncate also the subdomain section to second level you have to do
"wwwstat -archive -trunc 3 -subdomain -trunc 2"
If you don't specify section -trunc will aply to both.

example:
a report with:
                Req
es.upm.etsit    10
es.upm.euitt    21
es.upm.dit      15

with "wwwstat -subdomain -trunc 2" for reversed subdomains will make:

es.upm          46

---------------------------------------------------------------------------
The CHANGES you have to do to work this way are the following:

erase line 54 where put:
-trunc   Truncate archive URL after Nth hierarchy level.

and put in Section Options:
  -trunc N              Truncate the entries (in archive and subdomain)
                        after Nth hierarchy level.
---------------------------------------------------------------------------
add after line 191 :
    $TruncSubdomain    = 0;    # Truncate the reverse subdomain to the Nth
level
---------------------------------------------------------------------------- 
   In line 420 substitute the elsif (/^trunc(.*)/) {...}
by:
 elsif (/^trunc(.*)/)                       # Truncate Archive URL
        {                                          #   after Nth level
            unless ($_ = $1) {
                shift @ARGV;
                &badarg('-trunc requires value') unless ($_ = $ARGV[0]);
            }
            &badarg('-trunc', $_) unless (/^\d+$/);
 
            if    ($scope == 5) { $TruncateLevel        = $_;}
            elsif ($scope == 4) { $TruncSubdomain       = $_;}
 
            else { $TruncateLevel = $TruncSubdomain = $_}
        }
-----------------------------------------------------------------------------in Line 1287 put:
$subdomain=&trunc_subdomain($subdomain);

just before the:
 #
 # Now that we have categorized it, add it to the corresponding counters
 #
-----------------------------------------------------------------------------add the following subroutine:

# ==========================================================================
# Truncate the subdomain
#
sub trunc_subdomain
{
local($_) = @_;
local($truncated);
local(@levels);
if ($_ =~ "$NoIdentificado") {$truncated = "$NoIdentificado";}
else
{
 if ($TruncSubdomain > 0)
    {
        @levels = split(/\./,$_);
        if ($#levels >= $TruncSubdomain)
        {
            $_ = join('.', @levels[0 .. $TruncSubdomain-1], '');
            chop ($_);# To trough away the last dot.
        }
    }
$truncated = $_;
}
}
--------------------------------------------------------------------------
add a Line in wwwstat.rc:
  $TruncSubdomain    = 0;    # Truncate the reverse subdomain to the Nth
                               level
---------------------------------------------------------------------------
Note:
I have proved it in my own wwwstat, but it have been modified a lot and may 
be I have a bug or forget something in the code above.
Do not doubt in tell me the problems you find. Here you have my address.

-- 
Saludos,
--------------------------------------------------
 Jesus Calle Vaquero   
 Dpto. Comunicaciones             
 INDRA SSI  c/Velazquez 132, Planta 2, Madrid                           
 Tfno: (+34) 1 3481258            
 e-mail: jesus@coms.indra-ssi.es  
--------------------------------------------------