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

Add support to monitor energy inside virtual machines #73

Merged
merged 19 commits into from
Jul 2, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add methods to read VM properties
  • Loading branch information
adelnoureddine committed Jun 6, 2024
commit 24e3785f799d5b1b79c200bc3b955cd5f92cc1b4
5 changes: 5 additions & 0 deletions config.properties
Original file line number Diff line number Diff line change
@@ -75,6 +75,10 @@ application-server=false
# On Windows, please escape slashes twice
powermonitor-path=C:\\joularjx\\PowerMonitor.exe

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

# Path for power consumption of the virtual machine
# Inside a virtual machine, indicate the file containing power consumption of the VM
# File usually shared with host to propagate the power of the VM from the host
@@ -86,4 +90,5 @@ vm-power-path=/tmp/power.csv
# powerjoular: a csv file generated by PowerJoular in the host, containing
# 3 columns: timestamp, CPU utilization of the VM and CPU power of the VM
# watts: a file containing one float value which is the power consumption of the VM
# Values: powerjoular, watts
vm-power-format=powerjoular
27 changes: 27 additions & 0 deletions src/main/java/org/noureddine/joularjx/utils/AgentProperties.java
Original file line number Diff line number Diff line change
@@ -42,6 +42,9 @@ public class AgentProperties {
private static final String OVERWRITE_CT_RUNTIME_DATA_PROPERTY = "overwrite-call-trees-runtime-data";
private static final String STACK_MONITORING_SAMPLE_RATE_PROPERTY = "stack-monitoring-sample-rate";
private static final String APPLICATION_SERVER_PROPERTY = "application-server";
private static final String VM_MONITORING_PROPERTY = "vm-monitoring";
private static final String VM_POWER_PATH_PROPERTY = "vm-power-path";
private static final String VM_POWER_FORMAT_PROPERTY = "vm-power-format";

/**
* Loaded configuration properties
@@ -60,6 +63,9 @@ public class AgentProperties {
private final boolean overwriteCtRuntimeData;
private final int stackMonitoringSampleRate;
private final boolean applicationServer;
private final boolean vmMonitoring;
private final String vmPowerPath;
private final String vmPowerFormat;

/**
* Instantiate a new instance which will load the properties
@@ -79,6 +85,9 @@ public AgentProperties(FileSystem fileSystem) {
this.overwriteCtRuntimeData = loadOverwriteCallTreeRuntimeData();
this.stackMonitoringSampleRate = loadStackMonitoringSampleRate();
this.applicationServer = loadApplicationServer();
this.vmMonitoring = loadVMMonitoring();
this.vmPowerPath = loadVMPowerPath();
this.vmPowerFormat = loadVMPowerFormat();
}

public AgentProperties() {
@@ -132,6 +141,12 @@ public boolean saveCallTreesRuntimeData() {

public boolean isApplicationServer() { return this.applicationServer; }

public boolean isVirtualMachine() { return this.vmMonitoring; }

public String getVMPowerPath() { return this.vmPowerPath; }

public String getVMPowerFormat() { return this.vmPowerFormat; }

private Properties loadProperties(FileSystem fileSystem) {
Properties result = new Properties();

@@ -226,4 +241,16 @@ private Optional<Path> getPropertiesPathIfExists(FileSystem fileSystem) {

return Optional.of(path);
}

public boolean loadVMMonitoring() {
return Boolean.parseBoolean(properties.getProperty(VM_MONITORING_PROPERTY));
}

public String loadVMPowerPath() {
return properties.getProperty(VM_POWER_PATH_PROPERTY);
}

public String loadVMPowerFormat() {
return properties.getProperty(VM_POWER_FORMAT_PROPERTY);
}
}