From 784b4d1c58229453a154d429fc056d7046fb0bd1 Mon Sep 17 00:00:00 2001 From: Mirko Stocker Date: Tue, 6 Aug 2024 14:27:25 +0200 Subject: [PATCH] allow to set the config.properties through system property --- README.md | 2 +- .../java/org/noureddine/joularjx/utils/AgentProperties.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f665f8..ea55950 100755 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ JoularJX can be configured by modifying the ```config.properties``` files: - ```vm-power-format```: power format of the shared VM power file. We currently support two formats: ```watts``` (a file containing one float value which is the power consumption of the VM), and ```powerjoular``` (a csv file generated by [PowerJoular](https://github.com/joular/powerjoular) in the host, containing 3 columns: timestamp, CPU utilization of the VM and CPU power of the VM). You can install the jar package (and the PowerMonitor.exe on Windows) wherever you want, and call it in the ```javaagent``` with the full path. -However, ```config.properties``` must be copied to the same folder as where you run the Java command. +However, ```config.properties``` must either be copied to the same folder as where you run the Java command or its location must be set with the ```-Djoularjx.config=/path/to/config.properties``` property when running your program. In virtual machines, JoularJX requires two steps: - Installing a power monitoring tool in the host machine, which will monitor the virtual machine power consumption every second and writing it to a file (to be shared with the guest VM). diff --git a/src/main/java/org/noureddine/joularjx/utils/AgentProperties.java b/src/main/java/org/noureddine/joularjx/utils/AgentProperties.java index b2b276d..fba9628 100644 --- a/src/main/java/org/noureddine/joularjx/utils/AgentProperties.java +++ b/src/main/java/org/noureddine/joularjx/utils/AgentProperties.java @@ -232,7 +232,7 @@ public int loadStackMonitoringSampleRate() { } private Optional getPropertiesPathIfExists(FileSystem fileSystem) { - Path path = fileSystem.getPath("config.properties"); + Path path = fileSystem.getPath(System.getProperty("joularjx.config", "config.properties")); if (Files.notExists(path)) { logger.log(Level.INFO, "Could not locate config.properties, will use default values");