diff --git a/pom.xml b/pom.xml index 86697e74..43959bdb 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,6 @@ ${project.build.directory}/staging 1.5 22.3.5 - 2.12.7.1 ${project.build.directory}/compiler @@ -695,7 +694,7 @@ commons-io commons-io - 2.11.0 + 2.16.1 jar false @@ -709,7 +708,7 @@ commons-logging commons-logging - 1.2 + 1.3.4 com.thoughtworks.xstream @@ -721,7 +720,7 @@ org.slf4j slf4j-api - 2.0.9 + 2.0.16 jar false @@ -749,7 +748,7 @@ org.mozilla rhino - 1.7.14 + 1.7.15 jar false @@ -761,21 +760,21 @@ org.bouncycastle bcprov-jdk18on - 1.78 + 1.78.1 jar false commons-cli commons-cli - 1.5.0 + 1.9.0 jar false - org.samba.jcifs + jcifs jcifs - 1.3.3 + 1.3.17 jar false @@ -801,7 +800,7 @@ junit junit - 4.13.1 + 4.13.2 jar false @@ -813,7 +812,7 @@ com.google.guava guava - 32.0.0-jre + 33.3.0-jre javax.transaction @@ -829,19 +828,19 @@ jaxb 2.3.6 with maven-jaxb2-plugin 0.15.1 --> - javax.xml.bind - jaxb-api - 2.3.1 + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.3 org.glassfish.jaxb jaxb-core - 2.3.0.1 + 3.0.0 com.sun.xml.bind jaxb-impl - 2.3.6 + 4.0.5 net.java.xadisk @@ -849,9 +848,9 @@ 1.2.2 - javax.resource - connector-api - 1.5 + jakarta.resource + jakarta.resource-api + 2.1.0 org.codehaus.btm @@ -859,24 +858,25 @@ 2.1.4 - org.codehaus.groovy + org.apache.groovy groovy-all - 2.4.21 + 4.0.22 + pom org.apache.directory.api api-all - 2.1.3 + 2.1.7 xml-apis xml-apis - 1.4.01 + 2.0.2 com.fasterxml.jackson.core jackson-databind - ${jackson.version} + 2.17.2 diff --git a/src/install/check_lsc.sh b/src/install/check_lsc.sh deleted file mode 100755 index 7de8a9a7..00000000 --- a/src/install/check_lsc.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/bash - -#========================================================================== -# Summary -#========================================================================== -# Log file analyzer for LSC for Nagios -# -# This can read LSC logs to detect time since last succesful execution. -# An alert will be thrown if either of these durations exceeds a limit. -# -# -# Copyright (c) 2009 - 2011 LSC Project -# Copyright (C) 2008 Jonathan Clarke -# Copyright (C) 2008 LINAGORA -# -#========================================================================== -# Original license: GPLv2, -#========================================================================== -# Contributed by jclarke@linagora.com under LSC original BSD license -#========================================================================== - -#========================================================================== -# Changelog -#========================================================================== -# Version 1.0 (2008/02/28): -# - First version -# Author: Jonathan Clarke -#========================================================================== - -# -# Usage: ./check_lsc -F -w -c -# - -# Pattern to match in log file -SUCCESS_PATTERN="Starting LSC" - -# Paths to commands used in this script. These -# may have to be modified to match your system setup. - -PROGNAME=`basename $0` -PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 1.0 $' | sed -e 's/[^0-9.]//g'` - -. $PROGPATH/utils.sh - -print_usage() { - echo "Usage: $PROGNAME -F logfile -w warnlevel -c criticallevel" - echo "Usage: $PROGNAME --help" - echo "Usage: $PROGNAME --version" -} - -print_help() { - print_revision $PROGNAME $REVISION - echo "" - print_usage - echo "" - echo "Log file analyzer for LSC for Nagios" - echo "" - support -} - -# Make sure the correct number of command line -# arguments have been supplied - -if [ $# -lt 6 ]; then - print_usage - exit $STATE_UNKNOWN -fi - -# Grab the command line arguments - -exitstatus=$STATE_UNKNOWN #default -while test -n "$1"; do - case "$1" in - --help) - print_help - exit $STATE_OK - ;; - -h) - print_help - exit $STATE_OK - ;; - --version) - print_revision $PROGNAME $REVISION - exit $STATE_OK - ;; - -V) - print_revision $PROGNAME $REVISION - exit $STATE_OK - ;; - --filename) - logfile=$2 - shift - ;; - -F) - logfile=$2 - shift - ;; - -w) - warnlevel=$2 - shift - ;; - -c) - criticallevel=$2 - shift - ;; - *) - echo "Unknown argument: $1" - print_usage - exit $STATE_UNKNOWN - ;; - esac - shift -done - -# If the log file doesn't exist, exit - -if [ ! -e $logfile ]; then - echo "Log check error: Log file $logfile does not exist!\n" - exit $STATE_UNKNOWN -elif [ ! -r $logfile ] ; then - echo "Log check error: Log file $logfile is not readable!\n" - exit $STATE_UNKNOWN -fi - -# Get the last matching entry in the diff file -lastentry=`grep "$SUCCESS_PATTERN" $logfile | tail -1` - -timeLastEntry=`echo $lastentry | sed 's/\([0-9]\{4\}\/[0-9]\{2\}\/[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\).*/\1/'` -timestampLastEntry=`date -d "$timeLastEntry" +%s` -timestampNow=`date +%s` -age=$(( ($timestampNow - $timestampLastEntry) / 60)) - -if [[ $age -lt $warnlevel ]]; then # recent execution, exit with no error - echo "OK: Last successful execution $age minutes ago" - exitstatus=$STATE_OK -elif [[ $age -ge $warnlevel && $age -lt $criticallevel ]]; then - echo "WARN: Last successful execution $age minutes ago" - exitstatus=$STATE_WARNING -elif [[ $age -ge $criticallevel ]]; then - echo "CRITICAL: Last successful execution $age minutes ago" - exitstatus=$STATE_CRITICAL -fi - -exit $exitstatus diff --git a/src/install/check_lsc_status_file.pl b/src/install/check_lsc_status_file.pl index 5c64b42e..7c6a50cd 100755 --- a/src/install/check_lsc_status_file.pl +++ b/src/install/check_lsc_status_file.pl @@ -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 ); #========================================================================== @@ -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'}; } diff --git a/src/main/java/org/lsc/AbstractSynchronize.java b/src/main/java/org/lsc/AbstractSynchronize.java index ff553181..d8dd0517 100644 --- a/src/main/java/org/lsc/AbstractSynchronize.java +++ b/src/main/java/org/lsc/AbstractSynchronize.java @@ -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; } @@ -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; } @@ -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; } @@ -392,8 +392,8 @@ 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 { @@ -401,11 +401,15 @@ protected void logStatus(InfoCounter counter) { } } - 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 { diff --git a/src/main/java/org/lsc/utils/ScriptingEvaluator.java b/src/main/java/org/lsc/utils/ScriptingEvaluator.java index b3683e78..ebf3d3e4 100644 --- a/src/main/java/org/lsc/utils/ScriptingEvaluator.java +++ b/src/main/java/org/lsc/utils/ScriptingEvaluator.java @@ -3,6 +3,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.function.Predicate; import javax.script.*; @@ -31,7 +32,7 @@ public class ScriptingEvaluator { private Map instancesTypeCache; - private ScriptableEvaluator defaultImplementation; + private Optional defaultImplementation; static { implementetionsCache = new HashMap>(); @@ -87,10 +88,11 @@ else if ("graal.js".equals(name)) { bindings.put( "polyglot.js.nashorn-compat", true); JScriptEvaluator graaljsevaluator = new JScriptEvaluator(graaljsEngine); instancesTypeCache.put("gj", graaljsevaluator); - defaultImplementation = graaljsevaluator; + defaultImplementation = Optional.of(graaljsevaluator); } else { - defaultImplementation = instancesTypeCache.get("js"); + defaultImplementation = Optional.ofNullable(Optional.ofNullable(instancesTypeCache.get("js")) + .orElse(instancesTypeCache.get("rjs"))); } } @@ -111,13 +113,13 @@ public static void contribute(String implementationName, implementetionsCache.put(implementationName, implementationClass); } - private ScriptableEvaluator identifyScriptingEngine(String expression) { + private ScriptableEvaluator identifyScriptingEngine(String expression) throws LscServiceException { String[] parts = expression.split(":"); if (parts != null && parts.length > 0 && parts[0].length() < 10 && instancesTypeCache.containsKey(parts[0])) { return instancesTypeCache.get(parts[0]); } - return defaultImplementation; + return defaultImplementation.orElseThrow(() -> new LscServiceException("Missing Script evaluator")); } /**