mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
(Stuart Lewis) Updates to the stats scripts. (1) Better error reporting. (2) Adding the ability to enter start dates - these had been removed with the Java replacements for the previous Perl scripts. (3) Added upgrade instructions. (4) Tidied up dstat.cfg. (5) Hostname and service name now taken from dspace.cfg rather than dstat.cfg.
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2680 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -39,11 +39,13 @@
|
||||
package org.dspace.app.statistics;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
@@ -83,19 +85,45 @@ public class CreateStatReport {
|
||||
|
||||
/**User context*/
|
||||
private static Context context;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
/** the config file from which to configure the analyser */
|
||||
private static String configFile = ConfigurationManager.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator +
|
||||
"dstat.cfg";
|
||||
|
||||
/*
|
||||
* Main method to be run from the command line executes individual statistic methods
|
||||
*
|
||||
* Usage: java CreateStatReport -r <statistic to run>
|
||||
*/
|
||||
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
|
||||
|
||||
// Open the statistics config file
|
||||
FileInputStream fis = new java.io.FileInputStream(new File(configFile));
|
||||
Properties config = new Properties();
|
||||
config.load(fis);
|
||||
int startMonth = 0;
|
||||
int startYear = 2005;
|
||||
try
|
||||
{
|
||||
startYear = Integer.parseInt(config.getProperty("start.year", "1").trim());
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
System.err.println("start.year is incorrectly set in dstat.cfg. Must be a number (e.g. 2005).");
|
||||
System.exit(0);
|
||||
}
|
||||
try
|
||||
{
|
||||
startMonth = Integer.parseInt(config.getProperty("start.month", "2005").trim());
|
||||
} catch (NumberFormatException nfe)
|
||||
{
|
||||
System.err.println("start.month is incorrectly set in dstat.cfg. Must be a number between 1 and 12.");
|
||||
System.exit(0);
|
||||
}
|
||||
reportStartDate = new GregorianCalendar(startYear, startMonth - 1, 1);
|
||||
calendar = new GregorianCalendar();
|
||||
|
||||
// create context as super user
|
||||
context = new Context();
|
||||
context.setIgnoreAuthorization(true);
|
||||
|
||||
|
@@ -546,15 +546,13 @@ public class LogAnalyser
|
||||
archiveStats.put(itemTypes.get(i), getNumItems(context, (String) itemTypes.get(i)));
|
||||
}
|
||||
|
||||
// now do the host lookup
|
||||
try
|
||||
// now do the host name and url lookup
|
||||
hostName = ConfigurationManager.getProperty("dspace.hostname").trim();
|
||||
name = ConfigurationManager.getProperty("dspace.name").trim();
|
||||
url = ConfigurationManager.getProperties("dspace.url").trim();
|
||||
if ((url != null) && (!url.endsWith("/")))
|
||||
{
|
||||
InetAddress addr = InetAddress.getLocalHost();
|
||||
hostName = addr.getHostName();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
hostName = "unknown host";
|
||||
url = url + "/";
|
||||
}
|
||||
|
||||
// do the average views analysis
|
||||
@@ -922,7 +920,7 @@ public class LogAnalyser
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.out.println("Failed to read config file");
|
||||
System.out.println("Failed to read config file: " + configFile);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -987,16 +985,6 @@ public class LogAnalyser
|
||||
{
|
||||
userEmail = value;
|
||||
}
|
||||
|
||||
if (key.equals("host.url"))
|
||||
{
|
||||
url = value;
|
||||
}
|
||||
|
||||
if (key.equals("host.name"))
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -230,7 +230,7 @@ public class ReportGenerator
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processReport(context, myFormat, myInput, myOutput, myMap);
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ public class ReportGenerator
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.out.println("Failed to read input file");
|
||||
System.out.println("Failed to read input file: " + input);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -749,7 +749,7 @@ public class ReportGenerator
|
||||
{
|
||||
url = value;
|
||||
}
|
||||
|
||||
|
||||
if (section.equals("item_lookup"))
|
||||
{
|
||||
itemLookup = Integer.parseInt(value);
|
||||
|
@@ -1,7 +1,10 @@
|
||||
# DSpace information
|
||||
|
||||
# the log directory to be analysed
|
||||
dspace.log=${log.dir}
|
||||
# the year and month to start creating reports from
|
||||
# - year as four digits (e.g. 2005)
|
||||
# - month as a number (e.g. January is 1, December is 12)
|
||||
start.year = 2005
|
||||
start.month = 1
|
||||
|
||||
# actions to place in the general summary
|
||||
general.summary=archive_item
|
||||
@@ -72,8 +75,4 @@ item.lookup=10
|
||||
# individual users without disclosing email addresses. Note: later we may
|
||||
# support an "id" option, which replaces the address with the db id of the
|
||||
# eperson account.
|
||||
user.email=alias
|
||||
|
||||
# the name and url of the service being reported on
|
||||
host.name=Edinburgh Research Archive
|
||||
host.url=http://www.era.lib.ed.ac.uk/
|
||||
user.email=alias
|
@@ -30,6 +30,7 @@
|
||||
<li>A snapshot of the database</li>
|
||||
<li>The asset store (<code>[dspace]/assetstore</code> by default)</li>
|
||||
<li>Your configuration files and customizations to DSpace</li>
|
||||
<li>Your statistics scripts (<code>[dspace]/bin/stat*</code>) which contain customizable dates</li>
|
||||
</ul><br/></li>
|
||||
|
||||
|
||||
@@ -186,8 +187,27 @@ ant -Dconfig=[dspace]/config/dspace.cfg update
|
||||
[dspace]/bin/index-init
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li><b>Update statistics scripts</b>
|
||||
<p>The statistics scripts have been rewritten for DSpace 1.5. Prior to 1.5 they were written in Perl, but have been rewritten in Java to avoid having to install Perl. First, make a note of the dates you have specified in your statistics scripts for the statistics to run from. You will find these in <code>[dspace]/bin/stat-initial</code>, as <code>$start_year</code> and <code>$start_month</code>. Note down these values.</p>
|
||||
<p>Copy the new stats scripts:</p>
|
||||
<pre>
|
||||
cp [dspace-source]/dspace/target/dspace-1.5-build.dir/bin/stat* [dspace]/bin/
|
||||
</pre>
|
||||
<p>Then edit your statistics configuration file with the start details. Add the follwing to <code>[dspace]/conf/dstat.cfg</code></p>
|
||||
<p>
|
||||
<code># the year and month to start creating reports from</code><br />
|
||||
<code># - year as four digits (e.g. 2005)</code><br />
|
||||
<code># - month as a number (e.g. January is 1, December is 12)</code><br />
|
||||
<code>start.year = 2005</code><br />
|
||||
<code>start.month = 1</code><br />
|
||||
Replace '2005' and '1' as with the values you noted down.
|
||||
</p>
|
||||
<p><code>dstat.cfg</code> also used to contain the hostname and service name as displayed at the top of the statistics. These values are now taken from <code>dspace.cfg</code> so you can remove <code>host.name</code> and <code>host.url</code> from <code>dstat.cfg</code> if you wish. The values now used are <code>dspace.hostname</code> and <code>dspace.name</code> from <code>dspace.cfg</code></p>
|
||||
</li>
|
||||
|
||||
|
||||
<li><b>Deploy webapplications</b>
|
||||
<p>Copy the webapplications files from your [dspace]/webapps directory to the subdirectory of your servlet container (e.g. Tomcat):</p>
|
||||
<pre>
|
||||
|
Reference in New Issue
Block a user