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

Version 3.0.1 #81

Merged
merged 6 commits into from
Nov 19, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ powermonitor-path=C:\\joularjx\\PowerMonitor.exe

# Monitoring inside virtual machines
# Values: true, false
vm-monitoring=true
vm-monitoring=false

# Path for power consumption of the virtual machine
# Inside a virtual machine, indicate the file containing power consumption of the VM
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<groupId>org.noureddine</groupId>
<artifactId>joularjx</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>

<packaging>jar</packaging>
<name>${project.artifactId}</name>
Expand Down Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>memoryfilesystem</artifactId>
<version>2.8.0</version>
<version>2.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -71,7 +71,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.2</version>
<version>5.11.3</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down Expand Up @@ -110,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
<version>3.5.2</version>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/noureddine/joularjx/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void premain(String args, Instrumentation inst) {
JoularJXLogging.updateLevel(properties.getLoggerLevel());

logger.info("+---------------------------------+");
logger.info("| JoularJX Agent Version 3.0.0 |");
logger.info("| JoularJX Agent Version 3.0.1 |");
logger.info("+---------------------------------+");

ThreadMXBean threadBean = createThreadBean();
Expand Down
61 changes: 35 additions & 26 deletions src/main/java/org/noureddine/joularjx/cpu/RaplLinux.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,51 @@ public void initialize() {
final Path psysFile = fileSystem.getPath(RAPL_PSYS);
final Path psysMaxFile = fileSystem.getPath(RAPL_PSYS_MAX);
if (Files.exists(psysFile)) {
checkFileReadable(psysFile);
checkFileReadable(psysMaxFile);
// psys exists, so use this for energy readings
raplFilesToRead.add(psysFile);
maxRaplFilesToRead.add(psysMaxFile);
if (Files.isReadable(psysFile)) {
raplFilesToRead.add(psysFile);
if (Files.isReadable(psysMaxFile)) {
maxRaplFilesToRead.add(psysMaxFile);
} else {
logger.log(Level.SEVERE, "Failed to get read" + psysMaxFile + " file. Exiting... Did you run JoularJX with elevated privileges (sudo)?");
System.exit(1);
}
} else {
logger.log(Level.SEVERE, "Failed to get RAPL energy readings from" + psysFile + " file. Exiting... Did you run JoularJX with elevated privileges (sudo)?");
System.exit(1);
}
} else {
// No psys supported, then check for pkg and dram
final Path pkgFile = fileSystem.getPath(RAPL_PKG);
final Path pkgMaxFile = fileSystem.getPath(RAPL_PKG_MAX);
if (Files.exists(pkgFile)) {
checkFileReadable(pkgFile);
checkFileReadable(pkgMaxFile);
// pkg exists, check also for dram
raplFilesToRead.add(pkgFile);
maxRaplFilesToRead.add(pkgMaxFile);
if (Files.isReadable(pkgFile)) {
raplFilesToRead.add(pkgFile);
if (Files.isReadable(pkgMaxFile)) {
maxRaplFilesToRead.add(pkgMaxFile);
} else {
logger.log(Level.SEVERE, "Failed to get read" + pkgMaxFile + " file. Exiting... Did you run JoularJX with elevated privileges (sudo)?");
System.exit(1);
}
} else {
logger.log(Level.SEVERE, "Failed to get RAPL energy readings from" + pkgFile + " file. Exiting... Did you run JoularJX with elevated privileges (sudo)?");
System.exit(1);
}

final Path dramFile = fileSystem.getPath(RAPL_DRAM);
final Path dramMaxFile = fileSystem.getPath(RAPL_DRAM_MAX);
if (Files.exists(dramFile)) {
checkFileReadable(dramFile);
checkFileReadable(dramMaxFile);
// dram and pkg exists, then get sum of both
raplFilesToRead.add(dramFile);
maxRaplFilesToRead.add(dramMaxFile);
if (Files.isReadable(dramFile)) {
raplFilesToRead.add(dramFile);
if (Files.isReadable(dramMaxFile)) {
maxRaplFilesToRead.add(dramMaxFile);
} else {
logger.log(Level.SEVERE, "Failed to get read" + dramMaxFile + " file. Exiting... Did you run JoularJX with elevated privileges (sudo)?");
System.exit(1);
}
} else {
logger.log(Level.WARNING, "Failed to get RAPL energy readings from" + dramFile + " file. Continuing without it.");
}
}
}
}
Expand All @@ -113,18 +134,6 @@ public void initialize() {
}
}

/**
* Check that the passed file can be read by the program. Log error message and exit if reading the file is not
* possible.
* @param file the file to check the read access
*/
private void checkFileReadable(final Path file) {
if (!Files.isReadable(file)) {
logger.log(Level.SEVERE, "Failed to get RAPL energy readings. Did you run JoularJX with elevated privileges (sudo)?");
System.exit(1);
}
}

/**
* Get energy readings from RAPL through powercap
* Calculates the best energy reading as supported by CPU (psys, or pkg+dram, or pkg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public int loadStackMonitoringSampleRate() {
}

private Optional<Path> 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");
Expand Down
Loading