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 controller properties for monitoring enable or not #1001

Merged
merged 1 commit into from
Feb 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package org.ngrinder.agent.controller;

import org.ngrinder.common.exception.NGrinderRuntimeException;
import org.ngrinder.common.util.AopUtils;
import org.ngrinder.infra.config.Config;
import org.ngrinder.monitor.controller.model.SystemDataModel;
Expand Down Expand Up @@ -53,6 +54,13 @@ public class MonitorManagerApiController {
*/
@GetMapping("/state")
public SystemDataModel getRealTimeMonitorData(@RequestParam final String ip) throws InterruptedException, ExecutionException, TimeoutException {
if (!config.isMonitorEnabled()) {
throw new NGrinderRuntimeException(
"Monitoring is disabled. If you want to enable monitoring feature," +
" modify system settings. but there is a risk of attack from the monitoring server."
);
}

int port = config.getMonitorPort();
Future<SystemInfo> systemInfoFuture = AopUtils.proxy(this).getAsyncSystemInfo(ip, port);
SystemInfo systemInfo = checkNotNull(systemInfoFuture.get(2, TimeUnit.SECONDS), "Monitoring data is not available.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public interface ControllerConstants {
String PROP_CONTROLLER_MAX_RUN_HOUR = "controller.max_run_hour";
String PROP_CONTROLLER_MAX_VUSER_PER_AGENT = "controller.max_vuser_per_agent";
String PROP_CONTROLLER_MONITOR_PORT = "controller.monitor_port";
String PROP_CONTROLLER_ENABLE_MONITOR = "controller.enable_monitor";
String PROP_CONTROLLER_PLUGIN_SUPPORT = "controller.plugin_support";
String PROP_CONTROLLER_SAFE_DIST = "controller.safe_dist";
String PROP_CONTROLLER_SAFE_DIST_THRESHOLD = "controller.safe_dist_threshold";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ public int getMonitorPort() {
return getControllerProperties().getPropertyInt(PROP_CONTROLLER_MONITOR_PORT);
}

public boolean isMonitorEnabled() {
return getControllerProperties().getPropertyBoolean(PROP_CONTROLLER_ENABLE_MONITOR);
}

/**
* Check if the periodic usage report is enabled.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ controller.max_run_count,10000,agent.max.runcount
controller.max_run_hour,8,agent.max.runhour
controller.max_concurrent_test,10,ngrinder.max.concurrenttest
controller.monitor_port,13243,monitor.listen.port
controller.enable_monitor,false,
controller.url,,ngrinder.http.url,http.url
controller.console_port_base,12000,ngrinder.console.portbase
controller.controller_port,16001,ngrinder.agent.control.port
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Set verbose to print the detailed log
# Set verbose to print the detailed log
#controller.verbose=true

# If dev_mode is true, the log goes to stdout and
Expand Down Expand Up @@ -32,7 +32,6 @@
# true if you want to controller uses high level password encoding(sha256).
#controller.user_password_sha256=false


# The maximum number of agents which can be attached per one test.
#controller.max_agent_per_test=10

Expand All @@ -52,6 +51,9 @@
# The monitor connecting port. The default value is 13243.
#controller.monitor_port=13243

# monitoring feature enable or not.
#controller.enable_monitor=false

# The base URL of the controller. If not set, the controller URL is automatically selected.
#controller.url=

Expand Down Expand Up @@ -135,7 +137,7 @@
# clustering configuration.
# This is not the option applied on the fly. You need to reboot to apply this.
######################################################################################
# These should be very carefully set.
# These should be very carefully set.
# You can refer http://www.cubrid.org/wiki_ngrinder/entry/controller-clustering-guide

# if you want to enable controller clustering. please enable below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
this.memory.queue.enQueue(res.data.totalMemory - res.data.freeMemory);
this.cpu.chart.load({ json: { 'cpu-usage': this.cpu.queue.getArray() } });
this.memory.chart.load({ json: { 'memory-usage': this.memory.queue.getArray() } });
});
}).catch(() => {}); // ignore error.
}

closeMonitorConnection() {
this.$http.get('/monitor/api/close', {
params: {
ip: this.ip
ip: this.ip,
},
});
}
Expand Down
Loading