diff --git a/dspace-api/src/main/java/org/dspace/health/AdditionalInfoCheck.java b/dspace-api/src/main/java/org/dspace/health/AdditionalInfoCheck.java new file mode 100644 index 000000000000..8b2a7567af35 --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/health/AdditionalInfoCheck.java @@ -0,0 +1,27 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.health; + +public class AdditionalInfoCheck extends Check { + + @Override + protected String run(ReportInfo ri) { + String output = ""; + + output += String.format( + "JVM uptime: %s\n", Info.get_jvm_uptime()); + output += String.format( + "Testing build time: %s\n", Info.get_build_time()); + + output += "\n\n"; + + output += "Example url 1: https://dev-5.pc:8443/repository/home\n"; + output += "Example url 2: https://dev-5.pc:85/repository/home\n"; + return output; + } +} diff --git a/dspace-api/src/main/java/org/dspace/health/Info.java b/dspace-api/src/main/java/org/dspace/health/Info.java new file mode 100644 index 000000000000..898f1f3d464b --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/health/Info.java @@ -0,0 +1,67 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.health; + +import org.dspace.services.ConfigurationService; +import org.dspace.services.factory.DSpaceServicesFactory; +//import src.main.java.org.dspace.xoai.services.impl.config.DSpaceConfigurationService; + + +import java.io.FileInputStream; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.Scanner; + +public class Info { + + protected static final ConfigurationService configurationService + = DSpaceServicesFactory.getInstance().getConfigurationService(); + + final static public String get_proc_uptime() { + String uptime = "unknown"; + try { + //works only on linux + uptime = new Scanner(new FileInputStream("/proc/uptime")).next(); + System.out.println("\nUPTIME " + uptime); + float fuptime = Float.parseFloat( uptime ); + int seconds = (int) (fuptime % 60); + int minutes = (int) ((fuptime / 60) % 60); + int hours = (int) ((fuptime / (60 * 60)) % 24); + int days = (int) ((fuptime / (60 * 60 * 24)) ); + return Integer.toString( days ) + "d " + + Integer.toString( hours ) + "h:" + + Integer.toString( minutes ) + "m." + + Integer.toString( seconds ); + } catch (Exception e) { + return uptime; + } + } + + final static public String get_jvm_uptime() { + RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean(); + long milliseconds = mxBean.getUptime(); + int seconds = (int) (milliseconds / 1000) % 60 ; + int minutes = (int) ((milliseconds / (1000 * 60)) % 60); + int hours = (int) ((milliseconds / (1000 * 60 * 60)) % 24); + int days = (int) ((milliseconds / (1000 * 60 * 60 * 24))); + + return Integer.toString( days ) + "d " + + Integer.toString( hours ) + "h:" + + Integer.toString( minutes ) + "m." + + Integer.toString( seconds ); + } + + final static public String get_build_time() { + //springacka do nespring triedy, chceme autowired, component + String buildTime = configurationService.getProperty("testing-config"); + if (buildTime != null && !buildTime.equals("")) { + return buildTime; + } + return "unknown"; + } +} diff --git a/dspace-api/src/main/java/org/dspace/health/OAIPMHCheck.java b/dspace-api/src/main/java/org/dspace/health/OAIPMHCheck.java new file mode 100644 index 000000000000..576261de9fca --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/health/OAIPMHCheck.java @@ -0,0 +1,31 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.health; + +import org.dspace.services.ConfigurationService; +import org.dspace.services.factory.DSpaceServicesFactory; + +public class OAIPMHCheck extends Check { + protected static final ConfigurationService configurationService + = DSpaceServicesFactory.getInstance().getConfigurationService(); + + @Override + protected String run(ReportInfo ri) { + String output = ""; + String dspace_dir = configurationService.getProperty("dspace.dir"); + System.out.println("Dspace dir " + dspace_dir); + String dspace_url = configurationService.getProperty("dspace.server.url"); + System.out.println("Dspace url " + dspace_url); + String oaiurl = dspace_url + "/oai/request"; + System.out.println("Dspace oai " + oaiurl); + output += String.format("Trying [%s]\n", oaiurl); + //output += IOUtils.run(new File(dspace_dir + "/bin/"), new String[]{ + // "python", "./validators/oai_pmh/validate.py", oaiurl}); + return output; + } +} diff --git a/dspace-api/src/main/java/org/dspace/health/PIDCheck.java b/dspace-api/src/main/java/org/dspace/health/PIDCheck.java new file mode 100644 index 000000000000..6a2566b1b64b --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/health/PIDCheck.java @@ -0,0 +1,15 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.health; + +public class PIDCheck extends Check { + @Override + protected String run(ReportInfo ri) { + return ""; + } +} diff --git a/dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java b/dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java new file mode 100644 index 000000000000..8a437e6bda93 --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java @@ -0,0 +1,15 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.health; + +public class ShibbolethCheck extends Check { + @Override + protected String run(ReportInfo ri) { + return ""; + } +} diff --git a/dspace/config/clarin-dspace.cfg b/dspace/config/clarin-dspace.cfg index f27d6830c213..df3d81271ae3 100644 --- a/dspace/config/clarin-dspace.cfg +++ b/dspace/config/clarin-dspace.cfg @@ -301,3 +301,5 @@ autocomplete.custom.separator.solr-dataProvider_ac = \\|\\|\\| autocomplete.custom.separator.solr-dctype_ac = \\|\\|\\| autocomplete.custom.separator.solr-author_ac = \\|\\|\\| autocomplete.custom.allowed = solr-author_ac,solr-publisher_ac,solr-dataProvider_ac,solr-dctype_ac,solr-subject_ac,solr-handle_title_ac,json_static-iso_langs.json + +testing-config = TESTINGCONFIG \ No newline at end of file diff --git a/dspace/config/modules/healthcheck.cfg b/dspace/config/modules/healthcheck.cfg index e45407abdfb1..4835574c519b 100644 --- a/dspace/config/modules/healthcheck.cfg +++ b/dspace/config/modules/healthcheck.cfg @@ -8,7 +8,11 @@ healthcheck.checks = General Information,\ Checksum,\ Item summary,\ User summary,\ - Log Analyser Check + Log Analyser Check,\ + Additional Information,\ + OAI-PMH validation,\ + PID check,\ + Shibboleth Check plugin.named.org.dspace.health.Check = \ org.dspace.health.InfoCheck = General Information,\ @@ -16,7 +20,11 @@ plugin.named.org.dspace.health.Check = \ org.dspace.health.EmbargoCheck = Embargo items (Pre-3.0),\ org.dspace.health.ItemCheck = Item summary,\ org.dspace.health.UserCheck = User summary,\ - org.dspace.health.LogAnalyserCheck = Log Analyser Check + org.dspace.health.LogAnalyserCheck = Log Analyser Check,\ + org.dspace.health.AdditionalInfoCheck = Additional Information,\ + org.dspace.health.OAIPMHCheck = OAI-PMH validation,\ + org.dspace.health.PIDCheck = PID Check,\ + org.dspace.health.ShibbolethCheck = Shibboleth Check # report from the last N days (where dates are applicable) healthcheck.last_n_days = 7