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

Add task name and task mode in status #302

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
145 changes: 0 additions & 145 deletions src/install/check_lsc.sh

This file was deleted.

10 changes: 5 additions & 5 deletions src/install/check_lsc_status_file.pl
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ sub check_critical_param {
}

# Get statistics
my ( $all, $modify, $modified, $errors ) =
my ( $taskname, $taskmode, $all, $modify, $modified, $errors ) =
( $last =~
/All entries: (\d+), to modify entries: (\d+), (?:successfully )?modified entries: (\d+), errors: (\d+)/mi
/(\w+) - (\w+) - All entries: (\d+), to modify entries: (\d+), (?:successfully )?modified entries: (\d+), errors: (\d+)/mi
);

#==========================================================================
Expand All @@ -224,17 +224,17 @@ sub check_critical_param {
# Test the errors and exit
if ( $errors == 0 or $errors < $warning ) {
print
"OK - LSC is running with $errors errors (W:$warning - C:$critical)$perfparse\n";
"OK - LSC task $taskname in mode $taskmode is running with $errors errors (W:$warning - C:$critical)$perfparse\n";
exit $ERRORS{'OK'};
}
elsif ( $errors >= $warning and $errors < $critical ) {
print
"WARNING - LSC is running with $errors errors (W:$warning - C:$critical)$perfparse\n";
"WARNING - LSC task $taskname in mode $taskmode is running with $errors errors (W:$warning - C:$critical)$perfparse\n";
exit $ERRORS{'WARNING'};
}
else {
print
"CRITICAL - LSC is running with $errors errors (W:$warning - C:$critical)$perfparse\n";
"CRITICAL - LSC task $taskname in mode $taskmode is running with $errors errors (W:$warning - C:$critical)$perfparse\n";
exit $ERRORS{'CRITICAL'};
}

Expand Down
24 changes: 14 additions & 10 deletions src/main/java/org/lsc/AbstractSynchronize.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected final boolean clean2Ldap(Task task) {
LOGGER.info("If you want to avoid this message, " + "increase the time limit by using dedicated parameter.");
}

logStatus(counter);
logStatus(task.getName(), Task.Mode.clean.toString(), counter);
return counter.getCountError() == 0;
}

Expand Down Expand Up @@ -231,7 +231,7 @@ protected final boolean synchronize2Ldap(final Task task) {
LOGGER.info("If you want to avoid this message, " + "increase the time limit by using dedicated parameter.");
}

logStatus(counter);
logStatus(task.getName(), Task.Mode.sync.toString(), counter);
return counter.getCountError() == 0;
}

Expand Down Expand Up @@ -298,7 +298,7 @@ public final String getTaskFullStatus(final String syncName) {
if(asyncThread != null && asyncThread.isAlive()) {
AsynchronousRunner asyncRunner = mapSTasks.get(syncName);
InfoCounter counter = asyncRunner.getCounter();
return getLogStatus(counter);
return getLogStatus(syncName, Task.Mode.async.toString(), counter);
} else {
return null;
}
Expand Down Expand Up @@ -392,20 +392,24 @@ public final void logShouldAction(final LscModifications lm, final String syncNa
LSCStructuralLogger.DESTINATION.debug("", lm);
}

protected void logStatus(InfoCounter counter) {
String totalsLogMessage = getLogStatus(counter);
protected void logStatus(String taskName, String taskMode, InfoCounter counter) {
String totalsLogMessage = getLogStatus(taskName, taskMode, counter);
if (counter.getCountError() > 0) {
LOGGER.error(totalsLogMessage);
} else {
LOGGER.info(totalsLogMessage);
}
}

protected String getLogStatus(InfoCounter counter) {
return "All entries: "+ counter.getCountAll() +
", to modify entries: "+ counter.getCountModifiable() +
", successfully modified entries: "+counter.getCountCompleted()+
", errors: "+counter.getCountError();
protected String getLogStatus(String taskName, String taskMode, InfoCounter counter) {

String totalsLogMessage =
taskName + " - " + taskMode +
" - All entries: "+ counter.getCountAll() +
", to modify entries: "+ counter.getCountModifiable() +
", successfully modified entries: "+counter.getCountCompleted()+
", errors: "+counter.getCountError();
return totalsLogMessage;
}

public IBean getBean(Task task, IService service, String pivotName, LscDatasets pivotAttributes, boolean fromSameService, boolean fromSource) throws LscServiceException {
Expand Down
Loading