Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create health check for size of the log files #35 #36

Draft
wants to merge 85 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
6078db0
Create the pom structure of the application #1
ChiuchiuSorin Aug 7, 2023
6939275
Create the pom structure of the application #1
ChiuchiuSorin Aug 9, 2023
04a62b8
Create the pom structure of the application #1
ChiuchiuSorin Aug 11, 2023
046cb6d
Display App server info #3
ChiuchiuSorin Aug 11, 2023
5b62df5
Display App server info #3
ChiuchiuSorin Aug 11, 2023
00ad0f6
Display App server info #3
ChiuchiuSorin Aug 11, 2023
5794faf
Display App server info #3
ChiuchiuSorin Aug 11, 2023
08afe11
try resolve merge issue
ChiuchiuSorin Aug 11, 2023
d3aab58
Display App server info #3
ChiuchiuSorin Aug 22, 2023
63b0fb8
Display App server info #3
ChiuchiuSorin Aug 24, 2023
ccaf7c7
Merge branch 'main' into config-info
ChiuchiuSorin Aug 24, 2023
853d8c5
isplay App server info #3 - debug
ChiuchiuSorin Aug 25, 2023
2d3de9e
Display App server info #3
ChiuchiuSorin Aug 25, 2023
9345101
Display App server info #3
ChiuchiuSorin Aug 28, 2023
e9bc0f4
Display App server info #3
ChiuchiuSorin Aug 30, 2023
7439f99
Download important files #8 - DRAFT
ChiuchiuSorin Aug 31, 2023
fa91965
Display App server info #3
ChiuchiuSorin Aug 31, 2023
82ad541
Merge branch 'config-info' into files-logs-download
ChiuchiuSorin Sep 4, 2023
57cebb5
Display App server info #3
ChiuchiuSorin Sep 5, 2023
a1096b3
Download important files #8
ChiuchiuSorin Sep 5, 2023
a2a79ba
Download important files #8
ChiuchiuSorin Sep 5, 2023
1d56ff4
Download important files #8
ChiuchiuSorin Sep 6, 2023
f2e164a
Display App server info #3
ChiuchiuSorin Sep 8, 2023
6f5aff4
Download important files #8
ChiuchiuSorin Sep 8, 2023
ed557e0
Download important files #8
ChiuchiuSorin Sep 8, 2023
8cc8c1d
Download important files #8 - DRAFT
ChiuchiuSorin Sep 12, 2023
0e4c97f
Display App server info #3
ChiuchiuSorin Sep 13, 2023
2476cb1
Display App server info #3
ChiuchiuSorin Sep 15, 2023
00c1c25
Display App server info #3
ChiuchiuSorin Sep 15, 2023
c8d3208
Display App server info #3
ChiuchiuSorin Sep 15, 2023
924923c
Display App server info #3 - Test issues
ChiuchiuSorin Sep 21, 2023
84a3481
Display App server info #3
ChiuchiuSorin Sep 25, 2023
5aa3405
Create health check #13
ChiuchiuSorin Sep 28, 2023
f5ad74e
Create health check #13
ChiuchiuSorin Sep 28, 2023
f7fb823
Health check job status cast issue
ChiuchiuSorin Sep 29, 2023
568d754
Health check job status class cast fix
ChiuchiuSorin Oct 2, 2023
fd1a19f
Merge branch 'main' into files-logs-download
ChiuchiuSorin Oct 4, 2023
b67fc67
Download important files #8
ChiuchiuSorin Oct 4, 2023
d10e04c
Download important files #8
ChiuchiuSorin Oct 5, 2023
e49e1a8
Download important files #8
ChiuchiuSorin Oct 5, 2023
873b88e
Download important files #8
ChiuchiuSorin Oct 5, 2023
238f9e4
Add support for downloading important files #8 - misc
ChiuchiuSorin Oct 6, 2023
562de33
Add support for downloading important files #8
ChiuchiuSorin Oct 6, 2023
f8acc5f
Add support for downloading important files #8
ChiuchiuSorin Oct 6, 2023
f7cae01
Add support for downloading important files #8
ChiuchiuSorin Oct 9, 2023
f315a3a
Add support for downloading important files #8
ChiuchiuSorin Oct 9, 2023
0376549
Add support for downloading important files #8
ChiuchiuSorin Oct 10, 2023
b5499b7
Add support for downloading important files #8
ChiuchiuSorin Oct 11, 2023
07628bf
Add support for downloading important files #8
ChiuchiuSorin Oct 12, 2023
34d2f03
Add support for downloading important files #8
ChiuchiuSorin Oct 17, 2023
e2db098
Merge remote-tracking branch 'origin/main' into health-check
ChiuchiuSorin Oct 17, 2023
9d2804e
Add support for downloading important files #8
ChiuchiuSorin Oct 20, 2023
bfb1e08
Add support for downloading important files #8
ChiuchiuSorin Oct 24, 2023
90a2b4c
Add support for downloading important files #8
ChiuchiuSorin Oct 24, 2023
3eb3f11
Create a health check dashboard section #13 misc
ChiuchiuSorin Oct 25, 2023
eac09c1
Merge remote-tracking branch 'origin/files-logs-download' into health…
ChiuchiuSorin Oct 25, 2023
6436d00
Add support for downloading important files #8
ChiuchiuSorin Oct 25, 2023
2e6b908
Create a health check dashboard section #13
ChiuchiuSorin Oct 25, 2023
23d6906
Add support for downloading important files #8
ChiuchiuSorin Oct 25, 2023
0eec0f8
Add support for downloading important files #8
ChiuchiuSorin Oct 27, 2023
65dd92c
Create a health check dashboard section #13 draft
ChiuchiuSorin Oct 30, 2023
05ef0b5
Create a health check dashboard section #13 draft
ChiuchiuSorin Oct 30, 2023
16e4914
Add support for downloading important files #8
ChiuchiuSorin Oct 31, 2023
f732720
Add support for downloading important files #8
ChiuchiuSorin Oct 31, 2023
c264f93
Add support for downloading important files #8
ChiuchiuSorin Nov 1, 2023
b20d087
Merge remote-tracking branch 'origin/main' into files-logs-download
ChiuchiuSorin Nov 1, 2023
e10c232
Add support for downloading important files #8
ChiuchiuSorin Nov 1, 2023
1ca23e2
Create a health check dashboard section #13
ChiuchiuSorin Nov 1, 2023
b1f9a5d
Merge remote-tracking branch 'origin/files-logs-download' into health…
ChiuchiuSorin Nov 1, 2023
376a467
Create a health check dashboard section #13
ChiuchiuSorin Nov 1, 2023
5022e3e
Create a health check dashboard section #13
ChiuchiuSorin Nov 2, 2023
2e160b3
Merge remote-tracking branch 'origin/main' into health-check
ChiuchiuSorin Nov 2, 2023
382126c
Create a health check dashboard section #13
ChiuchiuSorin Nov 2, 2023
0579d60
Create a health check dashboard section #13
ChiuchiuSorin Nov 3, 2023
f3148cb
Create a health check dashboard section #13
ChiuchiuSorin Nov 7, 2023
52704fa
Merge remote-tracking branch 'origin/main' into health-check
ChiuchiuSorin Nov 7, 2023
163e3cd
Create a health check dashboard section #13
ChiuchiuSorin Nov 9, 2023
ce52ac2
Merge remote-tracking branch 'origin/main' into health-check
ChiuchiuSorin Nov 10, 2023
d56a333
Create a health check dashboard section #13 - backup
ChiuchiuSorin Nov 16, 2023
aec872e
Create a health check dashboard section #13
ChiuchiuSorin Nov 16, 2023
0cb5093
Create a health check dashboard section #13
ChiuchiuSorin Nov 17, 2023
18d6765
Create a health check dashboard section #13
ChiuchiuSorin Nov 17, 2023
dbe6f45
Merge remote-tracking branch 'origin/main' into health-check
ChiuchiuSorin Nov 21, 2023
1d53e87
Create a health check dashboard section #13
ChiuchiuSorin Nov 24, 2023
c8b8a8e
Create health check for size of the log files #35 - draft
ChiuchiuSorin Dec 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions application-admintools-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@
<name>Admin Tools (Pro) - API</name>
<description>Provides the Java APIs needed by the Admin tools Application.</description>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-component-api</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-job-api</artifactId>
<version>${platform.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-rest-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package com.xwiki.admintools.health;

import org.xwiki.component.annotation.Role;
import org.xwiki.stability.Unstable;

/**
* Check for issues in the current wiki.
*
* @since 1.0
* @version $Id$
*/
@Role
@Unstable
public interface HealthCheck
{
/**
* Execute the health check on the wiki instance.
*
* @return a {@link HealthCheckResult} with {@code null} values if no issue was found, or with initialized values
* otherwise.
*/
HealthCheckResult check();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package com.xwiki.admintools.health;

import org.xwiki.stability.Unstable;

/**
* Result of a health check. May store the error message, severity level, recommendation and the current value of the
* checked resource. The severity level is used as "info", for informative result, "warn" for warnings and "error"
* for critical issues.
*
* @version $Id$
* @since 1.0
*/
@Unstable
public class HealthCheckResult
{
private String message;

private String recommendation;

private String level;

private String currentValue;

/**
* Used for registering a result.
*
* @param message error message representing the summary of the found issue.
* @param recommendation suggestion in context of the message.
* @param level severity level of a result.
* @param currentValue Current value of the checked resource.
*/
public HealthCheckResult(String message, String recommendation, String level, String currentValue)
{
this.message = message;
this.recommendation = recommendation;
this.level = level;
this.currentValue = currentValue;
}

/**
* Partial result definition.
*
* @param message error message representing the summary of the found issue.
* @param recommendation suggestion in context of the message.
* @param level severity level of a result.
*/
public HealthCheckResult(String message, String recommendation, String level)
{
this(message, recommendation, level, null);
}

/**
* Simple result definition.
*
* @param message error message representing the summary of the found issue.
* @param level severity level of a result.
*/
public HealthCheckResult(String message, String level)
{
this(message, null, level);
}

/**
* Get the error body.
*
* @return a summary of the error.
*/
public String getMessage()
{
return message;
}

/**
* Get the recommendation for the set error.
*
* @return a suggestion for fixing the error.
*/
public String getRecommendation()
{
return recommendation;
}

/**
* Get the severity level a detected error.
*
* @return the severity level of an error.
*/
public String getLevel()
{
return level;
}

/**
* Get the value of a checked resource.
*
* @return the value of a checked resource.
*/
public String getCurrentValue()
{
return currentValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package com.xwiki.admintools.jobs;

import java.util.List;

import org.xwiki.job.AbstractRequest;
import org.xwiki.stability.Unstable;

/**
* Represents a request to start a health check on current wiki.
*
* @version $Id$
* @since 1.0
*/
@Unstable
public class HealthCheckJobRequest extends AbstractRequest
{
/**
* Default constructor.
*/
public HealthCheckJobRequest()
{
setDefaultId();
}

/**
* Creates a request specific to the wiki from which the call was made.
*
* @param requestId the ID for the request.
*/
public HealthCheckJobRequest(List<String> requestId)
{
setId(requestId);
}

private void setDefaultId()
{
List<String> id = List.of("adminTools", "healthCheck");
setId(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package com.xwiki.admintools.jobs;

import java.util.LinkedList;
import java.util.List;

import org.xwiki.job.DefaultJobStatus;
import org.xwiki.logging.LoggerManager;
import org.xwiki.observation.ObservationManager;
import org.xwiki.stability.Unstable;

import com.xwiki.admintools.health.HealthCheckResult;

/**
* The status of the health check job.
*
* @version $Id$
* @since 1.0
*/
@Unstable
public class HealthCheckJobStatus extends DefaultJobStatus<HealthCheckJobRequest>
{
private final List<HealthCheckResult> healthCheckResults = new LinkedList<>();

/**
* Create a new health check job status.
*
* @param jobType the job type
* @param request the request provided when the job was started
* @param observationManager the observation manager
* @param loggerManager the logger manager
*/
public HealthCheckJobStatus(String jobType, HealthCheckJobRequest request, ObservationManager observationManager,
LoggerManager loggerManager)
{
super(jobType, request, null, observationManager, loggerManager);
setCancelable(true);
}

/**
* Get the list issues list from the job.
*
* @return list with {@link HealthCheckResult} containing errors.
*/
public List<HealthCheckResult> getHealthCheckResults()
{
return healthCheckResults;
}

/**
* Get the list issues list from the job.
* @param level the logger manager
*
* @return boolean with {@link HealthCheckResult} containing errors.
*/
public boolean hasErrorLevel(String level)
{
for (HealthCheckResult checkResult : healthCheckResults) {
if (checkResult.getLevel().equals(level)) {
return true;
}
}
return false;
}
}
13 changes: 12 additions & 1 deletion application-admintools-default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<artifactId>xwiki-platform-oldcore</artifactId>
<version>${platform.version}</version>
</dependency>
<!-- Access CPU info to be used by the health check. -->
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>5.8.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand All @@ -66,8 +72,13 @@
<version>${commons.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-cache-api</artifactId>
<version>${commons.version}</version>
</dependency>
</dependencies>
<properties>
<xwiki.jacoco.instructionRatio>0.79</xwiki.jacoco.instructionRatio>
<xwiki.jacoco.instructionRatio>0.76</xwiki.jacoco.instructionRatio>
</properties>
</project>
Loading