diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/CreateStatReport.java b/dspace-api/src/main/java/org/dspace/app/statistics/CreateStatReport.java new file mode 100644 index 0000000000..f87ddba0f1 --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/app/statistics/CreateStatReport.java @@ -0,0 +1,394 @@ +/* + * CreateStatReport.java + * + * Date: $Date: 2008-01-08 + * + * Copyright (c) 2002-2008, Hewlett-Packard Company and Massachusetts + * Institute of Technology. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Hewlett-Packard Company nor the name of the + * Massachusetts Institute of Technology nor the names of their + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + */ + +package org.dspace.app.statistics; + +import java.io.File; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.PosixParser; + +import org.dspace.core.Context; +import org.dspace.core.ConfigurationManager; + +/** + * This class allows the running of the DSpace statistic tools + * + * Usage: java CreateStatReport -r + * Available: + * + * + * @author Chris Yates + * + */ + +public class CreateStatReport { + + /**Current date and time*/ + private static Calendar calendar = null; + + /**Reporting start date and time*/ + private static Calendar reportStartDate = null; + + /**Path of log directory*/ + private static String outputLogDirectory = null; + + /**Path of reporting directory*/ + private static String outputReportDirectory = null; + + /**File suffix for log files*/ + private static String outputSuffix = ".dat"; + + /**User context*/ + private static Context context; + + + /* + * Main method to be run from the command line executes individual statistic methods + * + * Usage: java CreateStatReport -r + */ + public static void main(String[] argv) throws Exception { + + calendar = new GregorianCalendar(); + reportStartDate = new GregorianCalendar(2007, 0, 1); //Date to begin initial reports from + + // create context as super user + context = new Context(); + context.setIgnoreAuthorization(true); + + //get paths to directories + outputLogDirectory = ConfigurationManager.getProperty("log.dir") + File.separator; + outputReportDirectory = ConfigurationManager.getProperty("report.dir") + File.separator; + + //read in command line variable to determine which statistic to run + CommandLineParser parser = new PosixParser(); + Options options = new Options(); + options.addOption("r", "report", true, "report"); + CommandLine line = parser.parse(options, argv); + + String statAction = null; + + if(line.hasOption('r')) + { + statAction = line.getOptionValue('r'); + } + + if (statAction == null) { + usage(); + System.exit(0); + } + + //call appropriate statistics method + if(statAction.equals("stat-monthly")) { + statMonthly(); + } + + if(statAction.equals("stat-general")) { + statGeneral(); + } + + if(statAction.equals("stat-initial")) { + statInitial(); + } + + if(statAction.equals("stat-report-general")) { + statReportGeneral(); + } + + if(statAction.equals("stat-report-initial")) { + statReportInitial(); + } + + if(statAction.equals("stat-report-monthly")) { + statReportMonthly(); + } + } + + /** + * This method generates a report from the first of the current month to the end of the current month. + * + * @throws Exception + */ + private static void statMonthly() throws Exception { + + //Output Prefix + String outputPrefix = "dspace-log-monthly-"; + + // set up our command line variables + String myLogDir = null; + String myFileTemplate = null; + String myConfigFile = null; + StringBuffer myOutFile = null; + Date myStartDate = null; + Date myEndDate = null; + boolean myLookUp = false; + + Calendar start = new GregorianCalendar( calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH), + calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); + myStartDate = start.getTime(); + + Calendar end = new GregorianCalendar( calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH), + calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); + myEndDate = end.getTime(); + + myOutFile = new StringBuffer(outputLogDirectory); + myOutFile.append(outputPrefix); + myOutFile.append(calendar.get(Calendar.YEAR)); + myOutFile.append("-"); + myOutFile.append(calendar.get(Calendar.MONTH)+1); + myOutFile.append(outputSuffix); + + LogAnalyser.processLogs(context, myLogDir, myFileTemplate, myConfigFile, myOutFile.toString(), myStartDate, myEndDate, myLookUp); + } + + /** + * This method generates a full report based on the full log period + * + * @throws Exception + */ + private static void statGeneral() throws Exception { + + //Output Prefix + String outputPrefix = "dspace-log-general-"; + + // set up our command line variables + String myLogDir = null; + String myFileTemplate = null; + String myConfigFile = null; + StringBuffer myOutFile = null; + Date myStartDate = null; + Date myEndDate = null; + boolean myLookUp = false; + + myOutFile = new StringBuffer(outputLogDirectory); + myOutFile.append(outputPrefix); + myOutFile.append(calendar.get(Calendar.YEAR)); + myOutFile.append("-"); + myOutFile.append(calendar.get(Calendar.MONTH)+1); + myOutFile.append("-"); + myOutFile.append(calendar.get(Calendar.DAY_OF_MONTH)); + myOutFile.append(outputSuffix); + + LogAnalyser.processLogs(context, myLogDir, myFileTemplate, myConfigFile, myOutFile.toString(), myStartDate, myEndDate, myLookUp); + } + + /** + * This script starts from the year and month specified below and loops each month until the current month + * generating a monthly aggregation files for the DStat system. + * + * @throws Exception + */ + private static void statInitial() throws Exception { + + //Output Prefix + String outputPrefix = "dspace-log-monthly-"; + + // set up our command line variables + String myLogDir = null; + String myFileTemplate = null; + String myConfigFile = null; + StringBuffer myOutFile = null; + Date myStartDate = null; + Date myEndDate = null; + boolean myLookUp = false; + + Calendar reportEndDate = new GregorianCalendar( calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH), + calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); + + while(reportStartDate.before(reportEndDate)) { + + Calendar start = new GregorianCalendar( reportStartDate.get(Calendar.YEAR), + reportStartDate.get(Calendar.MONTH), + reportStartDate.getActualMinimum(Calendar.DAY_OF_MONTH)); + myStartDate = start.getTime(); + + Calendar end = new GregorianCalendar( reportStartDate.get(Calendar.YEAR), + reportStartDate.get(Calendar.MONTH), + reportStartDate.getActualMaximum(Calendar.DAY_OF_MONTH)); + myEndDate = end.getTime(); + + myOutFile = new StringBuffer(outputLogDirectory); + myOutFile.append(outputPrefix); + myOutFile.append(reportStartDate.get(Calendar.YEAR)); + myOutFile.append("-"); + myOutFile.append(reportStartDate.get(Calendar.MONTH)+1); + myOutFile.append(outputSuffix); + + LogAnalyser.processLogs(context, myLogDir, myFileTemplate, myConfigFile, myOutFile.toString(), myStartDate, myEndDate, myLookUp); + + reportStartDate.add(Calendar.MONTH, 1); + } + } + + /** + * This method generates a full report based on the full log period + * + * @throws Exception + */ + private static void statReportGeneral() throws Exception { + + //Prefix + String inputPrefix = "dspace-log-general-"; + String outputPrefix = "report-general-"; + + String myFormat = "html"; + StringBuffer myInput = null; + StringBuffer myOutput = null; + String myMap = null; + + myInput = new StringBuffer(outputLogDirectory); + myInput.append(inputPrefix); + myInput.append(calendar.get(Calendar.YEAR)); + myInput.append("-"); + myInput.append(calendar.get(Calendar.MONTH)+1); + myInput.append("-"); + myInput.append(calendar.get(Calendar.DAY_OF_MONTH)); + myInput.append(outputSuffix); + + myOutput = new StringBuffer(outputReportDirectory); + myOutput.append(outputPrefix); + myOutput.append(calendar.get(Calendar.YEAR)); + myOutput.append("-"); + myOutput.append(calendar.get(Calendar.MONTH)+1); + myOutput.append("-"); + myOutput.append(calendar.get(Calendar.DAY_OF_MONTH)); + myOutput.append("."); + myOutput.append(myFormat); + + ReportGenerator.processReport(context, myFormat, myInput.toString(), myOutput.toString(), myMap); + } + + /** + * This script starts from the year and month specified below and loops each month until the current month + * generating monthly reports from the DStat aggregation files + * + * @throws Exception + */ + private static void statReportInitial() throws Exception { + + //Prefix + String inputPrefix = "dspace-log-monthly-"; + String outputPrefix = "report-"; + + String myFormat = "html"; + StringBuffer myInput = null; + StringBuffer myOutput = null; + String myMap = null; + + Calendar reportEndDate = new GregorianCalendar( calendar.get(Calendar.YEAR), + calendar.get(Calendar.MONTH), + calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); + + while(reportStartDate.before(reportEndDate)) { + + myInput = new StringBuffer(outputLogDirectory); + myInput.append(inputPrefix); + myInput.append(reportStartDate.get(Calendar.YEAR)); + myInput.append("-"); + myInput.append(reportStartDate.get(Calendar.MONTH)+1); + myInput.append(outputSuffix); + + myOutput = new StringBuffer(outputReportDirectory); + myOutput.append(outputPrefix); + myOutput.append(reportStartDate.get(Calendar.YEAR)); + myOutput.append("-"); + myOutput.append(reportStartDate.get(Calendar.MONTH)+1); + myOutput.append("."); + myOutput.append(myFormat); + + ReportGenerator.processReport(context, myFormat, myInput.toString(), myOutput.toString(), myMap); + + reportStartDate.add(Calendar.MONTH, 1); + } + } + + /** + * This method generates a report from the aggregation files which have been run for the most recent month + * + * @throws Exception + */ + private static void statReportMonthly() throws Exception + { + //Prefix + String inputPrefix = "dspace-log-monthly-"; + String outputPrefix = "report-"; + + String myFormat = "html"; + StringBuffer myInput = null; + StringBuffer myOutput = null; + String myMap = null; + + myInput = new StringBuffer(outputLogDirectory); + myInput.append(inputPrefix); + myInput.append(calendar.get(Calendar.YEAR)); + myInput.append("-"); + myInput.append(calendar.get(Calendar.MONTH)+1); + myInput.append(outputSuffix); + + myOutput = new StringBuffer(outputReportDirectory); + myOutput.append(outputPrefix); + myOutput.append(calendar.get(Calendar.YEAR)); + myOutput.append("-"); + myOutput.append(calendar.get(Calendar.MONTH)+1); + myOutput.append("."); + myOutput.append(myFormat); + + ReportGenerator.processReport(context, myFormat, myInput.toString(), myOutput.toString(), myMap); + } + + /* + * Output the usage information + */ + private static void usage() throws Exception { + + System.out.println("Usage: java CreateStatReport -r "); + System.out.println("Available: "); + return; + } +} diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java b/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java index fb642ccfa4..75bad9db28 100644 --- a/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java +++ b/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java @@ -100,19 +100,19 @@ public class LogAnalyser ///////////////// /** aggregator for all actions performed in the system */ - private static Map actionAggregator = new HashMap(); + private static Map actionAggregator; /** aggregator for all searches performed */ - private static Map searchAggregator = new HashMap(); + private static Map searchAggregator; /** aggregator for user logins */ - private static Map userAggregator = new HashMap(); + private static Map userAggregator; /** aggregator for item views */ - private static Map itemAggregator = new HashMap(); + private static Map itemAggregator; /** aggregator for current archive state statistics */ - private static Map archiveStats = new HashMap(); + private static Map archiveStats; /** warning counter */ private static int warnCount = 0; @@ -125,19 +125,19 @@ public class LogAnalyser ////////////////// /** list of actions to be included in the general summary */ - private static List generalSummary = new ArrayList(); + private static List generalSummary; /** list of words not to be aggregated */ - private static List excludeWords = new ArrayList(); + private static List excludeWords; /** list of search types to be ignored, such as "author:" */ - private static List excludeTypes = new ArrayList(); + private static List excludeTypes; /** list of characters to be excluded */ - private static List excludeChars = new ArrayList(); + private static List excludeChars; /** list of item types to be reported on in the current state */ - private static List itemTypes = new ArrayList(); + private static List itemTypes; /** bottom limit to output for search word analysis */ private static int searchFloor; @@ -350,11 +350,22 @@ public class LogAnalyser // together in a single aggregating object // if the timer has not yet been started, then start it - if (startTime != null) - { - startTime = new GregorianCalendar(); - } + startTime = new GregorianCalendar(); + + //instantiate aggregators + actionAggregator = new HashMap(); + searchAggregator = new HashMap(); + userAggregator = new HashMap(); + itemAggregator = new HashMap(); + archiveStats = new HashMap(); + //instantiate lists + generalSummary = new ArrayList(); + excludeWords = new ArrayList(); + excludeTypes = new ArrayList(); + excludeChars = new ArrayList(); + itemTypes = new ArrayList(); + // set the parameters for this analysis setParameters(myLogDir, myFileTemplate, myConfigFile, myOutFile, myStartDate, myEndDate, myLookUp); @@ -767,6 +778,7 @@ public class LogAnalyser { BufferedWriter out = new BufferedWriter(new FileWriter(outFile)); out.write(summary.toString()); + out.flush(); out.close(); } catch (IOException e) diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java b/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java index 1e8320888e..54743ea8ee 100644 --- a/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java +++ b/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java @@ -88,19 +88,19 @@ public class ReportGenerator ///////////////// /** aggregator for all actions performed in the system */ - private static Map actionAggregator = new HashMap(); + private static Map actionAggregator; /** aggregator for all searches performed */ - private static Map searchAggregator = new HashMap(); + private static Map searchAggregator; /** aggregator for user logins */ - private static Map userAggregator = new HashMap(); + private static Map userAggregator; /** aggregator for item views */ - private static Map itemAggregator = new HashMap(); + private static Map itemAggregator; /** aggregator for current archive state statistics */ - private static Map archiveStats = new HashMap(); + private static Map archiveStats; ////////////////// @@ -147,7 +147,7 @@ public class ReportGenerator private static int warnings; /** the list of results to be displayed in the general summary */ - private static List generalSummary = new ArrayList(); + private static List generalSummary; ////////////////// // regular expressions @@ -164,7 +164,7 @@ public class ReportGenerator private static Calendar startTime = null; /** a map from log file action to human readable action */ - private static Map actionMap = new HashMap(); + private static Map actionMap = null; ///////////////// // report generator config data @@ -250,7 +250,18 @@ public class ReportGenerator throws Exception, SQLException { startTime = new GregorianCalendar(); + + /** instantiate aggregators */ + actionAggregator = new HashMap(); + searchAggregator = new HashMap(); + userAggregator = new HashMap(); + itemAggregator = new HashMap(); + archiveStats = new HashMap(); + actionMap = new HashMap(); + /** instantite lists */ + generalSummary = new ArrayList(); + // set the parameters for this analysis setParameters(myFormat, myInput, myOutput, myMap); diff --git a/dspace/CHANGES b/dspace/CHANGES index f050ae43ee..c5dc2aa6c7 100644 --- a/dspace/CHANGES +++ b/dspace/CHANGES @@ -73,10 +73,11 @@ SF Patch 1794700 Bug fix for stat-monthly and stat-report-monthly - SF Patch #1799575 New EPersonConsumer event consumer - SF Patch #1642563 bin/update-handle-prefix rewritten in Java -(Chris yates) +(Chris Yates) - SF Patch #1724330 Removes "null" being displayed in community-home.jsp - SF Patch #1763535 Alert DSpace administrator of new user registration - SF Patch #1759438 Multilingualism Language Switch - DSpace Header +- SF Patch #1888652 Statistics Rewritten In Java (Robert Tansley / Stuart Lewis) - SF Patch #1587225 Google and html sitemap generator diff --git a/dspace/bin/stat-general b/dspace/bin/stat-general index 3a10698644..84764d2fc0 100644 --- a/dspace/bin/stat-general +++ b/dspace/bin/stat-general @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/bin/sh ########################################################################### # @@ -42,45 +42,9 @@ ########################################################################### # This script generates a full report based on the full log period -# -# To customise for your own use change the $out_prefix, $out_suffix, -# $dsrun and $out_directory variables below. -# -# If you wish to futher configure this script, you will need to edit the -# command being executed, which is below under $general -# -# For more information on using the LogAnalyser, use: -# -# [dspace]/bin/dsrun org.dspace.app.statistics.LogAnalyser -help ########################################################################### -my $second; -my $minute; -my $hour; -my $day; -my $month; -my $year; -my $week_day; -my $day_of_year; -my $is_dst; +# Get the DSPACE/bin directory +BINDIR=`dirname $0` -# Get the all the values for current time -($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); - -my $this_year = $year + 1900; -my $this_month = $month + 1; - -# Details used -###################################################### -$out_prefix = "dspace-log-general-"; -$out_suffix = ".dat"; -$dsrun = "/dspace/bin/dsrun"; -$out_directory = "/dspace/log/"; - -###################################################### - -$execute = "$dsrun org.dspace.app.statistics.LogAnalyser -out $out_directory$out_prefix$this_year-$this_month-$day$out_suffix"; - -$status = system($execute); - -exit($status); +$BINDIR/dsrun org.dspace.app.statistics.CreateStatReport -r stat-general \ No newline at end of file diff --git a/dspace/bin/stat-initial b/dspace/bin/stat-initial index 346c853c36..22e09ba2e8 100644 --- a/dspace/bin/stat-initial +++ b/dspace/bin/stat-initial @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/bin/sh ########################################################################### # @@ -44,113 +44,9 @@ # This script starts from the year and month specified below and works # forward until the end of the current month, generating monthly aggregation # files for the DStat system. -# -# To customise for your own use change the $out_prefix, $out_suffix, -# $start_year, $start_month, $dsrun and $out_directory variables below. -# -# If you wish to futher configure this script, you will need to edit the -# command being executed, which appears near the bottom of the page, and is -# commented with "# The command to generate the report" -# -# For more information on using the LogAnalyser, use: -# -# [dspace]/bin/dsrun org.dspace.app.statistics.LogAnalyser -help ########################################################################### -use POSIX qw(floor); +# Get the DSPACE/bin directory +BINDIR=`dirname $0` -my $start; -my $end; -my $out; -my $i; -my $no_months; -my $second; -my $minute; -my $hour; -my $day; -my $month; -my $year; -my $week_day; -my $day_of_year; -my $is_dst; -my $out_prefix; -my $out_suffix; - -# Details used -################################################ - -$out_prefix = "dspace-log-monthly-"; -$out_suffix = ".dat"; -$start_year = "2005"; -$start_month = "1"; -$dsrun = "/dspace/bin/dsrun"; -$out_directory = "/dspace/log/"; - -################################################ - -# Get the all the values for current time -($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); - -# set up the variables to use in the loop - -# number of years after the current year (will mostly be negative) -# = ( + 1900) -# = - -$year_offset = $start_year - ($year + 1900); - -# total number of months between now and the start date (negated to be positive in general) -# = || * 12 -# = ( + 1) - -# = + -# we use -1 to make positive since it should always be negative -$no_months = (-1 * ($year_offset * 12)) + (($month + 1) - $start_month); - -# start day of every month -$start_day = "01"; - -# for every month ... -for ($i = 0; $i < $no_months; $i++) -{ - # the month of the year (horrid modular maths) - $this_month = (($start_month + $i - 1) % 12) + 1; - - # number of years gone through since we started the loop - $year_count = floor(($i + $start_month - 1) / 12); - - # the year of the current analysis period - $this_year = $year + $year_offset + $year_count + 1900; - - # set the end day for the processing - if ($this_month == 1 || $this_month == 3 || $this_month == 5 || $this_month == 7 || $this_month == 8 || $this_month == 10 || $this_month == 12) - { - $end_day = "31"; - } - elsif ($this_month == 4 || $this_month == 6 || $this_month == 9 || $this_month == 11) - { - $end_day = "30"; - } - else - { - if (($year % 4) != 0) - { - $end_day = "28"; - } - else - { - $end_day = "29"; - } - } - - # generate the date string - $start = $this_year . "-" . $this_month . "-" . $start_day; - $end = $this_year . "-" . $this_month . "-" . $end_day; - - $out = $out_directory . $out_prefix . $this_year . "-" . $this_month . $out_suffix; - - # The command to generate the report - $execute = "$dsrun org.dspace.app.statistics.LogAnalyser -start $start -end $end -out $out"; - - system($execute); -} - -exit(1); \ No newline at end of file +$BINDIR/dsrun org.dspace.app.statistics.CreateStatReport -r stat-initial \ No newline at end of file diff --git a/dspace/bin/stat-monthly b/dspace/bin/stat-monthly index 4e5a2fcce8..51ab31bc63 100644 --- a/dspace/bin/stat-monthly +++ b/dspace/bin/stat-monthly @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/bin/sh ########################################################################### # @@ -43,83 +43,9 @@ ########################################################################### # This script generates a report from the first of the current month to the end # of the current month. This is not great, and will be superceded soon -# -# To customise for your own use change the $out_prefix, $out_suffix, -# $dsrun and $out_directory variables below. -# -# If you wish to futher configure this script, you will need to edit the -# command being executed, which appears near the bottom of the page, and is -# commented with "# The command to generate the report" -# -# For more information on using the LogAnalyser, use: -# -# [dspace]/bin/dsrun org.dspace.app.statistics.LogAnalyser -help ########################################################################### -use POSIX qw(floor); +# Get the DSPACE/bin directory +BINDIR=`dirname $0` -my $start; -my $end; -my $out; -my $i; -my $no_months; -my $second; -my $minute; -my $hour; -my $day; -my $month; -my $year; -my $week_day; -my $day_of_year; -my $is_dst; -my $out_prefix; -my $out_suffix; - -# Get the all the values for current time -($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); - -# Details used -################################################ - -$out_prefix = "dspace-log-monthly-"; -$out_suffix = ".dat"; -$dsrun = "/dspace/bin/dsrun"; -$out_directory = "/dspace/log/"; - -################################################ - -$start_day = "01"; -$this_year = $year + 1900; -$this_month = $month + 1; - -if ($this_month == 1 || $this_month == 3 || $this_month == 5 || $this_month == 7 || $this_month == 8 || $this_month == 10 || $this_month == 12) -{ - $end_day = "31"; -} -elsif ($this_month == 4 || $this_month == 6 || $this_month == 9 || $this_month == 11) -{ - $end_day = "30"; -} -else -{ - if (($year % 4) != 0) - { - $end_day = "28"; - } - else - { - $end_day = "29"; - } -} - -$start = $this_year . "-" . $this_month . "-" . $start_day; -$end = $this_year . "-" . $this_month . "-" . $end_day; - -$out = $out_directory . $out_prefix . $this_year . "-" . $this_month . $out_suffix; - -# The command to generate the report -$execute = "$dsrun org.dspace.app.statistics.LogAnalyser -start $start -end $end -out $out"; - -$status = system($execute); - -exit($status); +$BINDIR/dsrun org.dspace.app.statistics.CreateStatReport -r stat-monthly \ No newline at end of file diff --git a/dspace/bin/stat-report-general b/dspace/bin/stat-report-general index e7786704a5..17ef8ea6ab 100644 --- a/dspace/bin/stat-report-general +++ b/dspace/bin/stat-report-general @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/bin/sh ########################################################################### # @@ -42,52 +42,9 @@ ########################################################################### # This script generates a full report based on the full log period -# -# To customise for your own use change the $out_prefix, $out_suffix, -# $dsrun and $out_directory variables below. -# -# If you wish to futher configure this script, you will need to edit the -# command being executed, which is below under $general -# -# For more information on using the LogAnalyser, use: -# -# [dspace]/bin/dsrun org.dspace.app.statistics.LogAnalyser -help ########################################################################### -my $second; -my $minute; -my $hour; -my $day; -my $month; -my $year; -my $week_day; -my $day_of_year; -my $is_dst; +# Get the DSPACE/bin directory +BINDIR=`dirname $0` -# Get the all the values for current time -($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); - -my $this_year = $year + 1900; -my $this_month = $month + 1; - -# Details used -###################################################### - -$in_prefix = "dspace-log-general-"; -$in_suffix = ".dat"; -$out_prefix = "report-general-"; -$out_suffix = ".html"; -$dsrun = "/dspace/bin/dsrun"; -$in_directory = "/dspace/log/"; -$out_directory = "/dspace/reports/"; - -###################################################### - -$in = $in_directory . $in_prefix . $this_year . "-" . $this_month . "-" . $day . $in_suffix; -$out = $out_directory . $out_prefix . $this_year . "-" . $this_month . "-" . $day . $out_suffix; - -$execute = "$dsrun org.dspace.app.statistics.ReportGenerator -format html -in $in -out $out"; - -$status = system($execute); - -exit($status); +$BINDIR/dsrun org.dspace.app.statistics.CreateStatReport -r stat-report-general \ No newline at end of file diff --git a/dspace/bin/stat-report-initial b/dspace/bin/stat-report-initial index 2919e9a48f..8f204c209d 100644 --- a/dspace/bin/stat-report-initial +++ b/dspace/bin/stat-report-initial @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/bin/sh ########################################################################### # @@ -44,94 +44,9 @@ # This script starts from the year and month specified below and works # forward until the end of the current month, generating monthly reports # from the dstat aggregation files. -# -# To customise for your own use change the $in_prefix, $in_suffix, $out_prefix, -# $out_suffix, $start_year, $start_month, $dsrun and $out_directory variables -# below. -# -# If you wish to futher configure this script, you will need to edit the -# command being executed, which appears near the bottom of the page, and is -# commented with "# The command to generate the report" -# -# For more information on using the ReportGenerator, use: -# -# [dspace]/bin/dsrun org.dspace.app.statistics.ReportGenerator -help ########################################################################### -use POSIX qw(floor); +# Get the DSPACE/bin directory +BINDIR=`dirname $0` -my $start; -my $end; -my $out; -my $i; -my $no_months; -my $second; -my $minute; -my $hour; -my $day; -my $month; -my $year; -my $week_day; -my $day_of_year; -my $is_dst; -my $out_prefix; -my $out_suffix; - -# Details used -################################################ - -$in_prefix = "dspace-log-monthly-"; -$in_suffix = ".dat"; -$out_prefix = "report-"; -$out_suffix = ".html"; -$start_year = "2004"; -$start_month = "5"; -$dsrun = "/dspace/bin/dsrun"; -$in_directory = "/dspace/log/"; -$out_directory = "/dspace/reports/"; - -################################################ - -# Get the all the values for current time -($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); - -# set up the variables to use in the loop - -# number of years after the current year (will mostly be negative) -# = ( + 1900) -# = - -$year_offset = $start_year - ($year + 1900); - -# total number of months between now and the start date (negated to be positive in general) -# = || * 12 -# = ( + 1) - -# = + -# we use -1 to make positive since it should always be negative -$no_months = (-1 * ($year_offset * 12)) + (($month + 1) - $start_month); - -# start day of every month -$start_day = "01"; - -# for every month ... -for ($i = 0; $i < $no_months; $i++) -{ - # the month of the year (horrid modular maths) - $this_month = (($start_month + $i - 1) % 12) + 1; - - # number of years gone through since we started the loop - $year_count = floor(($i + $start_month - 1) / 12); - - # the year of the current analysis period - $this_year = $year + $year_offset + $year_count + 1900; - - # input and output file paths - $in = $in_directory . $in_prefix . $this_year . "-" . $this_month . $in_suffix; - $out = $out_directory . $out_prefix . $this_year . "-" . $this_month . $out_suffix; - - # The command to generate the report - $execute = "$dsrun org.dspace.app.statistics.ReportGenerator -format html -in $in -out $out"; - - system($execute); -} - -exit(1); \ No newline at end of file +$BINDIR/dsrun org.dspace.app.statistics.CreateStatReport -r stat-report-initial \ No newline at end of file diff --git a/dspace/bin/stat-report-monthly b/dspace/bin/stat-report-monthly index a76ecbebf5..fd00be7b57 100644 --- a/dspace/bin/stat-report-monthly +++ b/dspace/bin/stat-report-monthly @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/bin/sh ########################################################################### # @@ -43,63 +43,9 @@ ########################################################################### # This script generates a report from the aggregation file which has been # run for the most recent month -# -# To customise for your own use change the $out_prefix, $out_suffix, -# $dsrun and $out_directory variables below. -# -# If you wish to futher configure this script, you will need to edit the -# command being executed, which appears near the bottom of the page, and is -# commented with "# The command to generate the report" -# -# For more information on using the LogAnalyser, use: -# -# [dspace]/bin/dsrun org.dspace.app.statistics.LogAnalyser -help ########################################################################### -use POSIX qw(floor); +# Get the DSPACE/bin directory +BINDIR=`dirname $0` -my $start; -my $end; -my $out; -my $i; -my $no_months; -my $second; -my $minute; -my $hour; -my $day; -my $month; -my $year; -my $week_day; -my $day_of_year; -my $is_dst; -my $out_prefix; -my $out_suffix; - -# Get the all the values for current time -($second, $minute, $hour, $day, $month, $year, $week_day, $day_of_year, $is_dst) = localtime(time); - -# Details used -################################################ - -$in_prefix = "dspace-log-monthly-"; -$in_suffix = ".dat"; -$out_prefix = "report-"; -$out_suffix = ".html"; -$dsrun = "/dspace/bin/dsrun"; -$in_directory = "/dspace/log/"; -$out_directory = "/dspace/reports/"; - -################################################ - -$this_year = $year + 1900; -$this_month = $month + 1; - -$in = $in_directory . $in_prefix . $this_year . "-" . $this_month . $in_suffix; -$out = $out_directory . $out_prefix . $this_year . "-" . $this_month . $out_suffix; - -# The command to generate the report -$execute = "$dsrun org.dspace.app.statistics.ReportGenerator -format html -in $in -out $out"; - -$status = system($execute); - -exit($status); +$BINDIR/dsrun org.dspace.app.statistics.CreateStatReport -r stat-report-monthly \ No newline at end of file