Skip to content

Commit

Permalink
Add task name and task mode in status (#302)
Browse files Browse the repository at this point in the history
* Log task name+mode as well (#300)

* log task name and task mode as well

* reverted BUILD.txt

* Fix wrong task mode name

---------

Co-authored-by: Bram Daams <[email protected]>
Co-authored-by: Clément "KPTN" OUDOT <[email protected]>

* Get task name and task mode in status, and use them in monitoring script output

* Remove deprecated monitoring script

---------

Co-authored-by: brammeleman <[email protected]>
Co-authored-by: Bram Daams <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 1e42009 commit 5470810
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 160 deletions.
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

0 comments on commit 5470810

Please sign in to comment.