%! % PS WEB SITE LOG ANALYZER AND REPORTER % ============================================== % Copyright c 2003 by Don Lancaster and Synergetics, Box 809, Thatcher, AZ, 85552 % (428) 428-4073 don@tinaja.com http://www.tinaja.com % Consulting services available per http://www.tinaja.com/info01.html % This dayproc.psl module is run by logrpt.psl to add trailing month % capabilities to the log report. % The last 30 entries are saved. If a day is missed, it is not included in the data. % ========= % This file requires the previous download of gonzo.psl % available from https://www.tinaja.com/pssamp1.shtml % Make sure the following line agrees with your own gonzo.psl location (C:/Users/don/Desktop/gonzo/gonzo.psl) run % use internal gonzo % ========== /trailsourcefilename (C:\\WINDOWS\\Desktop\\log_play\\trailing_stats\\trail30.psl) def % the name of the trailing 30 data file % Monthly info is saved and resaved in a trail30.psl data base file. % This is a PostScript array of arrays proc of form % /t30data [ [oldest day] ..... [newest day]] % The trail130.psl data builds till it is 30 entries long. Each % oldest entry then gets dropped as a new one is added. % The format of a day array is currently... % [ [date value] [pageview value] [popfiles array] % [errors array] [referrals array] ] % max limits get multiplied by 30, so file size may be an issue... /maxpopfiles 60 store % size limit on maximum popular files /maxerrors 60 store % size limit on maximum errors. /maxreferrals 60 store % size limit on maximum referrals. % /loadolddata loads the trailing data off disk and truncates it /loadolddata { trailsourcefilename run } store % /updatedata adds the current day to the trailing data /updatedata { % does not yet trap reports more than one day longer. t30data dup length 29 gt { 1 29 getinterval}if % lop off oldest entry dup length (\n\nt30 length is ) print == mark exch aload pop % place open array on stack mark % add last element getdate getpageviews getbannersdelivered getpopfiles geterrors getreferrals ] ] /t30data exch store % and save internally } store % service routines to get and format new data % /getdate extracts the current date from the shortsourcefilename. % currently specific to a XX123456.log logfile format. /getdate {mark shortsourcefilename 2 6 getinterval ]} store % /getpageviews gets the pageviews integer and converts to a string /getpageviews {mark pageviews 20 string cvs ]} store % /getbannersdelivered gets the banners delivered integer and converts to a string.. /getbannersdelivered { mark bannersdelivered 20 string cvs ] } store % /getpopfiles gets the fhlist array and shortens it for sane total storage... /getpopfiles {fhlist dup length maxpopfiles gt {0 maxpopfiles getinterval} if} store % /geterrors gets the e404hl array and shortens it for sane total storage... /geterrors { e404hl dup length maxerrors gt {0 maxerrors getinterval} if} store % /getreferrals gets the refhlist array and shortens it for sane total storage... /getreferrals {refhlist dup length maxreferrals gt {0 maxreferrals getinterval} if} store % /savenewdata saves the trailing data onto disk. /savenewdata { trailsourcefilename (w) file /workfile1 exch def workfile1 (/t30data [ \n\n) writestring t30data { /curday exch store workfile1 (\n[)writestring curday 0 get writestringonly % date workfile1 ( ) writestring curday 1 get writestringonly % page views workfile1 ( ) writestring curday 2 get writestringonly % banners workfile1 ( [\n) writestring curday 3 get {writestringandvalue} forall workfile1 ( ]\n) writestring workfile1 ( [\n) writestring curday 4 get {writestringandvalue} forall workfile1 ( ]\n) writestring workfile1 ( [\n) writestring curday 5 get {writestringandvalue} forall workfile1 ( ]\n ) writestring workfile1 (]\n\n) writestring } forall workfile1 (\n\n ] store ) writestring workfile1 closefile % close file } store /writestringonly { 0 get workfile1 ([\() writestring workfile1 exch writestring workfile1 (\)]\n) writestring } store /writestringandvalue { /curpair exch store workfile1 ( [\() writestring workfile1 curpair 0 get writestring workfile1 (\) ) writestring workfile1 curpair 1 get 6 string cvs writestring workfile1 (]\n) writestring } store (\n\n\n) print flush %%%%%%%%%% reporter below %%%%%%%% % /reportstats30 reports the new data to the output log file. /reportstats30 { (\n\n%%%%%%%%%%%%%%%%%%%%%%\n\nBeginning trailing 30 day report...\n\n) print %%%%%% REPORT PAGE VIEWS VERSUS DAYS %%%%%%% (Page views per day...\n\n) print 0 1 t30data length 1 sub {/curday1 exch store t30data curday1 get 0 get 0 get /cryptedday exch store cryptedday 2 2 getinterval cvr 1 sub cvi [(Jan )(Feb )(Mar ) (Apr )(May )(Jun )(Jul ) (Aug )(Sep ) (Oct ) (Nov )(Dec ) ] exch get ( ) exch mergestr cryptedday 4 2 getinterval mergestr ( - ) mergestr t30data curday1 get 1 get 0 get 10 string cvs mergestr (\n) mergestr print } for %%%%%% REPORT BANNER ADS VERSUS DAYS %%%%%%% (\nBanner ads delivered per day...\n\n) print 0 1 t30data length 1 sub {/curday1 exch store t30data curday1 get 0 get 0 get /cryptedday exch store cryptedday 2 2 getinterval cvr 1 sub cvi [(Jan )(Feb )(Mar ) (Apr )(May )(Jun )(Jul ) (Aug )(Sep ) (Oct ) (Nov )(Dec ) ] exch get ( ) exch mergestr cryptedday 4 2 getinterval mergestr ( - ) mergestr t30data curday1 get 2 get 0 get 10 string cvs mergestr (\n) mergestr print } for %%%%%% REPORT MOST POPULAR DOWNLOADS %%%%%%% (\nMost popular downloads...\n\n) print /mostpop [ ] store % create popular download sum array /stuffmostpop {/curarray2 exch store curarray2 0 get /curname2 exch store /newentry true store 0 1 mostpop length 1 sub {/curpos6 exch store % scan the existing hit list mostpop curpos6 get 0 get curname2 eq % already present? { mostpop dup curpos6 get dup dup 1 get % yes -- increase count curarray2 1 get add 1 exch put curpos6 exch put /newentry false store } if } for newentry {mark mostpop aload pop curarray2 ] /mostpop exch store } if % create new entry ? } store t30data {3 get { stuffmostpop } forall } forall % create combined array mostpop bubblesort mostpop {( ) print == } forall %%%%%% REPORT MOST FREQUENT ERRORS %%%%%%% (\nMost frequent errors...\n\n) print /mosterr [ ] store % create popular download sum array /stuffmosterr {/curarray3 exch store curarray3 0 get /curname3 exch store /newentry true store 0 1 mosterr length 1 sub {/curpos7 exch store % scan the existing hit list mosterr curpos7 get 0 get curname3 eq % already present? { mosterr dup curpos7 get dup dup 1 get % yes -- increase count curarray3 1 get add 1 exch put curpos7 exch put /newentry false store } if } for newentry {mark mosterr aload pop curarray3 ] /mosterr exch store } if % create new entry ? } store t30data {4 get { stuffmosterr } forall } forall % create combined array mosterr bubblesort mosterr {( ) print == } forall %%%%%% REPORT MOST POPULAR REFERRALS %%%%%%% (\nMost popular referrals...\n\n) print /mostref [ ] store % create popular download sum array /stuffmostref {/curarray4 exch store curarray4 0 get /curname4 exch store /newentry true store 0 1 mostref length 1 sub {/curpos8 exch store % scan the existing hit list mostref curpos8 get 0 get curname4 eq % already present? { mostref dup curpos8 get dup dup 1 get % yes -- increase count curarray4 1 get add 1 exch put curpos8 exch put /newentry false store } if } for newentry {mark mostref aload pop curarray4 ] /mostref exch store } if % create new entry ? } store t30data {5 get { stuffmostref } forall } forall % create combined array mostref bubblesort mostref {==} forall (\n\n\n\n) print flush } store % ////// actual code starts here ////// loadolddata % get old t30 data and shorten updatedata % remove old, add new % (\n\n t30 data ----> ) print t30data == % (\n\n) print flush (\n\nbeginning data replacement\n\n) print flush savenewdata % replace new t30 data (\n\ncompleted data replacement\n\n) print flush (\n\nbeginning report sequence\n\n) print flush reportstats30 % report results % EOF