forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started working on healthchecks candidates
- Loading branch information
Matus Kasak
committed
Dec 16, 2024
1 parent
56b4862
commit b1f0978
Showing
7 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
dspace-api/src/main/java/org/dspace/health/AdditionalInfoCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
dspace-api/src/main/java/org/dspace/health/OAIPMHCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ""; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
dspace-api/src/main/java/org/dspace/health/ShibbolethCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters