diff --git a/src/main/java/org/gcube/informationsystem/resource_checker/ResourceCheckerPlugin.java b/src/main/java/org/gcube/informationsystem/resource_checker/ResourceCheckerPlugin.java index 58333d8..b7aa69a 100644 --- a/src/main/java/org/gcube/informationsystem/resource_checker/ResourceCheckerPlugin.java +++ b/src/main/java/org/gcube/informationsystem/resource_checker/ResourceCheckerPlugin.java @@ -52,7 +52,11 @@ public class ResourceCheckerPlugin extends Plugin { private static final int SECONDS2WAIT = 2; // seconds to wait among IS requests private static final String INITIAL_ERRORS_STATEMENT = "Other errors: "; public static final String ROLE_TO_NOTIFY = "role"; + private static final String NAGIOS_PROPERTY_FILE = "/META-INF/plugin_resources/nagios-report-location.properties"; + + public final static String HOME_SYSTEM_PROPERTY = "user.home"; + private static final Logger logger = LoggerFactory.getLogger(ResourceCheckerPlugin.class); @SuppressWarnings("rawtypes") private static final DiscoveryClient client = ICFactory.client(); @@ -270,11 +274,25 @@ public class ResourceCheckerPlugin extends Plugin { try{ Properties prop = new Properties(); prop.load(getClass().getResourceAsStream(NAGIOS_PROPERTY_FILE)); - String location = prop.getProperty("location"); + String relativeLocation = prop.getProperty("location"); - logger.trace("File location for nagios is " + location); - - File f = new File(location); + if(relativeLocation.startsWith("/")) { + relativeLocation = relativeLocation.substring(1); + } + + logger.trace("File home relative location for nagios is " + relativeLocation); + + String homePath = System.getProperty(HOME_SYSTEM_PROPERTY); + File home = new File(homePath); + + String[] parts = relativeLocation.split("/"); + + File f = new File(home, parts[0]); + + for(int i=1; i