@rem = '-*- Perl -*-'; @rem = ' @echo off perl -S %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl '; # musage4.prl script derived from musage.txt (see below) # I have radically altered Nick Phillips script (he asserts # copyright and I have no wish to deny him that and just hope # he doesn't mind my having done this and making this hacked # version publically available. If I knew how to contact him # to discuss this I would. If he, or someone who knows his # whereabouts comes across this I hope they will let me know # how to contact him # # Chris Evans 21.ii.96 # # (Last update of Nick Phillips script: 1st May 1995) # # musage.txt --- script to calculate monthly usage statistics from # log files generate by the EMWAC Windows NT World # Wide Web and gopher servers (https and gophers). # # Copyright (c) 1995 Nick Phillips (N.R.Phillips@lse.ac.uk) # # Configuration variables are hard-coded in # (see the section "CONFIGURE THESE VARIABLES"). # # File and path names should be absolute (e.g. C:/LOGS/) # or relative to current directory (e.g. ./LOGS/) # Directory names must always end with trailing backslash # (e.g. ./ for current directory - don't just leave blank) # In Perl for Windows NT use forward slash (not backslash) # in pathnames (e.g. C:/LOGS/) # # Uses the gethostbyaddr() function to look up the DNS name # corresponding to the IP addresses of users recorded in the logs - # this will only work if your version of Perl supports this function. # It is best to run this at a time when the Internet is quiet as it # could end up doing lots of DNS lookups. # # If you rename the script to MUSAGE.CMD then on an NT system you will # be able to run it from the command line (i.e. you will be able to just # type MUSAGE, rather than PERL MUSAGE.TXT) - note that MUSAGE.CMD is # a batch file (with Perl script embedded in it), so if you invoke it # from another batch file you will have to do CALL MUSAGE in order for # control to return to the original batch file. # # === all other subroutines are in musage.prl for consistency sub config { # -------------------------------------------------------------------------- # CONFIGURE THESE VARIABLES # # File and path names should be absolute (e.g. C:/LOGS/) # or relative to current directory (e.g. ./LOGS/) # In Perl for Windows NT use forward slash (not backslash) # in pathnames (e.g. C:/LOGS/) # Directory names must always end with trailing slash # (e.g. ./ for current directory - don't just leave blank) # # Lists of items consist of a list surrounded by brackets, with # each item in the list separated by commas # e.g. @ignoreip = ('158.143.104.174', '158.143.104.209'); # Lists of IP addresses can also include DNS names # e.g. @homeip = ('158.143', 'lse.ac.uk'); # # Flags can be set to 1 (meaning 'true' or 'enabled') or # set to 0 or not defined (meaning 'false' or 'disabled') # @homeip -- list of ip addresses of local users (e.g. ('158.143.') ) # $homedomain -- domain of local users (e.g. lse.ac.uk) # # $homename -- name of home site (e.g. LSE, London School of Economics) # $servername -- name of server (not always the same as the name of # the home site - may be name of PART of overall server # e.g. Law Department) # # $topfiles -- present statistics for this many most popular files (e.g. 20) # $topips -- present statistics for this many most attentive ip addresses # # $dnsnames -- file containing DNS names (e.g. ./dnsnames.lst) # # $inputdir -- directory containing https & gophers log files (e.g. /logs/) # $outputdir -- directory to write usage statistics reports (e.g. ./) # # @ignoreip -- list of IP addresses to ignore (e.g. ('158.143.104.174') ) # @myownip -- list of IP addresses which are administrative accesses # $i_ipcomment -- comment about excluded IP addresses for reports # @ignorepath -- list of paths/files to ignore (e.g. () ) # @ignoreext -- list of file extensions to ignore (e.g. ('.gif') # @focusonip -- list of IP addresses to focus on (e.g. () ) # @focusonpath -- list of paths/files to focus on (e.g. () ) # $f_pathcomment -- comment abut path focus for reports # @focusonext -- list of file extensions to focus on (e.g. ('.htm') # # $verbosemode -- flag - disable if you don't want the detailed output # musage gives to indicate what it's doing # $lookupdnsnames -- flag - disable if you don't want to look up dnsname of # each ip address accessing your server # $commonlogformat -- flag - disable for use with EMWAC's free server, enable # to use MUSAGE with logs from an http server that uses # the common log format (e.g. the professional version # of EMWAC's server) # $filenamestolowercase # -- flag - enable to convert all filenames (URLs) to lower # case before processing them # $logfilepattern -- the pattern used to recognise log files (e.g. EMWAC's # server's log files match *.log - translate this into # a Perl regular expression and you get .+\.log) # # $do_not_log -- pattern identifying files _NOT_ to log (e.g. proxy-errors.log) # %servertype -- PERL associative array - MUSAGE looks at the # first letter of the log file to deduce what kind # of server it comes from (e.g. EMWAC gopher, WWW # & WAIS logs start with g, h & w respectively; # CERN3 httpd proxy, access & cache logs start # with p, a & c respectively) # $debug -- invokes a debugging run on a small file # $debuglog -- name of a debugging file $debug = 1; $debuglog = "/usr1/www/pages/mhs/psychotherapy/wwwstats/debug.log"; $dnsnames = "/usr1/www/pages/mhs/psychotherapy/wwwstats/dnsnames.lst"; @homeip = ("192.153", "sghms.ac.uk"); $homedomain = ("sghms.ac.uk"); $homename = "SGHMS"; $servername = "SGHMS Psychotherapy"; @ignorepath = (); @ignoreext = (); @focusonip = (); @myownip = ("194.80.201.27","cevanpc.sghms.ac.uk"); @focusonext = (); $verbosemode = 0; $lookupdnsnames = 1; $commonlogformat = 1; $filenamestolowercase = 0; $logdir = "/usr1/www/log/"; $logfilepattern = ".*log.*"; # all log files in that dir are logs $do_not_log = "errors"; # except those containing errors # now define a file that will contain all the log results you want $newlog = "/usr1/www/pages/mhs/psychotherapy/wwwstats/pnewlog.log"; # this block are default settings usually overridden by musage.set data $topfiles = 50; $topips = 30; $inputdir = "/usr1/www/pages/psychotherapy/wwwstats/"; $outputdir = "/dev/null/"; @focusonpath = ("/mhs/psychotherapy/"); $f_pathcomment = "files in any Psychotherapy Section directories considered"; @ignoreip = ("194.80.201.27","cevanpc.sghms.ac.uk","infoserv.sghms.ac.uk","192.153.12.1","192.153.12.30"); $i_ipcomment = "does not include my own accesses as administrator"; $servertype{"g"} = "Gopher"; $servertype{"h"} = "WWW"; $servertype{"w"} = "WAIS"; $servertype{"p"} = "Proxy"; $servertype{"a"} = "Access"; $servertype{"c"} = "Cache"; $psylog = "psylog.log"; $errlog = "errlog.log"; # *** added by CE to get date of statistics run into the output $dated = 1; # relates to getting file size data $outputdir = "/usr1/www/pages/mhs/psychotherapy/dir/"; $startdir = "/mhs/psychotherapy"; $www_offset = "/usr1/www/pages"; @filemask = ("*.*"); # sort out the location that the server will show for files $http_rep_dir = $outputdir; $http_rep_dir =~ s|$www_offset||o; # o switch as the value of $www_offset is fixed # *** the next three variables contain text to go at the end of the menu, summary and error files # *** respectively $btm_m = < File created using Perl script: musage3.prl adapted by Chris Evans C.Evans@sghms.ac.uk from MUSAGE.TXT by Nick Philips END $btm_s = < A complete usage is also available.
File created using Perl script: musage3.prl adapted by Chris Evans C.Evans@sghms.ac.uk from MUSAGE.TXT by Nick Philips END $btm_e = < An error log is available.
File created using Perl script: musage3.prl adapted by Chris Evans C.Evans@sghms.ac.uk from MUSAGE.TXT by Nick Philips END } # sub config # ====== end of subroutines =================== require "musage.prl"; # contains all other subroutines print "\n\n\n\n\n\nMUSAGE4.PRL adapted by Chris Evans from the following:\n\n"; print " MUSAGE --- script to calculate monthly usage statistics from\n"; print " v1.4 log files generated by the EMWAC Windows NT World\n"; print " Wide Web and gopher servers (https and gophers).\n"; print " Copyright (c) 1995 Nick Phillips\n"; &config; # run subroutine above to get all variables &error_lab; # provide labels to classify errors if ($dated) { # provide date info. &uptonow; } &getdata; # gets information on all files in WWW published directories # &getlogs; # gets all information from the files in the log directory # and places it in one output file $newlog &do_each_dir; # takes info. from that log and puts pertinent bits in each subdir # then crunches information from each directory log __END__ :endofperl