use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetMonitoringConfiguration method execute.
@Override
public void execute(AdminCommandContext context) {
ActionReport actionReport = context.getActionReport();
ActionReport monitoringServiceReport = actionReport.addSubActionsReport();
Config config = targetUtil.getConfig(target);
if (config == null) {
actionReport.setMessage("No such config named: " + target);
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
MonitoringService monitoringService = config.getMonitoringService();
AMXConfiguration amxConfiguration = config.getExtensionByType(AMXConfiguration.class);
CommandRunner.CommandInvocation commandInvocation = commandRunner.getCommandInvocation("get-rest-monitoring-configuration", actionReport, context.getSubject());
commandInvocation.execute();
commandInvocation = commandRunner.getCommandInvocation("get-jmx-monitoring-configuration", actionReport, context.getSubject());
commandInvocation.execute();
final String[] headers = { "Monitoring Enabled", "AMX Enabled", "MBeans Enabled", "DTrace Enabled" };
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
columnFormatter.addRow(new Object[] { monitoringService.getMonitoringEnabled(), amxConfiguration.getEnabled(), monitoringService.getMbeanEnabled(), monitoringService.getDtraceEnabled() });
Map<String, Object> extraPropertiesMap = new HashMap<>();
extraPropertiesMap.put("monitoringEnabled", monitoringService.getMonitoringEnabled());
extraPropertiesMap.put("mbeanEnabled", monitoringService.getMbeanEnabled());
extraPropertiesMap.put("dtraceEnabled", monitoringService.getDtraceEnabled());
extraPropertiesMap.put("amxEnabled", amxConfiguration.getEnabled());
Properties extraProperties = new Properties();
extraProperties.put("getMonitoringConfiguration", extraPropertiesMap);
actionReport.setExtraProperties(extraProperties);
monitoringServiceReport.setMessage(columnFormatter.toString());
monitoringServiceReport.appendMessage(StringUtils.EOL);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetMonitoringServiceConfiguration method execute.
@Override
public void execute(AdminCommandContext context) {
Config config = targetUtil.getConfig(target);
if (config == null) {
context.getActionReport().setMessage("No such config named: " + target);
context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
MonitoringService monitoringService = config.getMonitoringService();
AMXConfiguration amxConfiguration = config.getExtensionByType(AMXConfiguration.class);
final ActionReport actionReport = context.getActionReport();
final String[] headers = { "Monitoring Enabled", "AMX Enabled", "MBeans Enabled", "DTrace Enabled" };
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
columnFormatter.addRow(new Object[] { monitoringService.getMonitoringEnabled(), amxConfiguration.getEnabled(), monitoringService.getMbeanEnabled(), monitoringService.getDtraceEnabled() });
actionReport.appendMessage(columnFormatter.toString());
Map<String, Object> extraPropertiesMap = new HashMap<>();
extraPropertiesMap.put("monitoringEnabled", monitoringService.getMonitoringEnabled());
extraPropertiesMap.put("amxEnabled", amxConfiguration.getEnabled());
extraPropertiesMap.put("mbeanEnabled", monitoringService.getMbeanEnabled());
extraPropertiesMap.put("dtraceEnabled", monitoringService.getDtraceEnabled());
Properties extraProperties = new Properties();
extraProperties.put("getMonitoringServiceConfiguration", extraPropertiesMap);
actionReport.setExtraProperties(extraProperties);
actionReport.setMessage(columnFormatter.toString());
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetMonitoringLevel method execute.
@Override
public void execute(AdminCommandContext context) {
Config config = targetUtil.getConfig(target);
if (config == null) {
context.getActionReport().setMessage("No such config named: " + target);
context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
MonitoringService monitoringService = config.getMonitoringService();
final ActionReport actionReport = context.getActionReport();
final String[] headers = { "Module", "Monitoring Level" };
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Map<String, Object> extraPropertiesMap = new HashMap<>();
List<String> validModuleList = new ArrayList<>(Arrays.asList(Constants.validModuleNames));
// their monitoring levels
if (moduleName == null) {
for (String validModule : validModuleList) {
columnFormatter.addRow(new Object[] { validModule, monitoringService.getMonitoringLevel(validModule) });
extraPropertiesMap.put(validModule, monitoringService.getMonitoringLevel(validModule));
}
}
if (moduleName != null) {
List<String> moduleNameList = Arrays.asList(moduleName.split(","));
for (String module : moduleNameList) {
boolean isValidMoudle = false;
String selectedModule = module.trim().toLowerCase();
for (String validModule : validModuleList) {
if (validModule.trim().equals(selectedModule)) {
columnFormatter.addRow(new Object[] { selectedModule, monitoringService.getMonitoringLevel(selectedModule) });
extraPropertiesMap.put(selectedModule, monitoringService.getMonitoringLevel(selectedModule));
isValidMoudle = true;
break;
}
}
if (!isValidMoudle) {
actionReport.setMessage(selectedModule + " isn't a valid Module name");
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
}
Properties extraProperties = new Properties();
extraProperties.put("getMonitoringLevel", extraPropertiesMap);
actionReport.setExtraProperties(extraProperties);
actionReport.setMessage(columnFormatter.toString());
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class RestartMonitoring method getFormattedColumns.
private ColumnFormatter getFormattedColumns(Map<String, String> enabledModules) {
final String[] headers = { "Module", "Monitoring Level" };
ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Map<String, Object> extraPropertiesMap = new HashMap<>();
if (!enabledModules.isEmpty()) {
for (String module : enabledModules.keySet()) {
columnFormatter.addRow(new Object[] { module, monitoringService.getMonitoringLevel(module) });
extraPropertiesMap.put(module, monitoringService.getMonitoringLevel(module));
}
}
return columnFormatter;
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class GetMetricsConfigurationCommand method execute.
@Override
public void execute(AdminCommandContext adminCommandContext) {
Config targetConfig = targetUtil.getConfig(target);
if (targetConfig == null) {
adminCommandContext.getActionReport().setMessage("No such config name: " + targetUtil);
adminCommandContext.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
MetricsServiceConfiguration metricsConfiguration = targetConfig.getExtensionByType(MetricsServiceConfiguration.class);
ColumnFormatter columnFormatter = new ColumnFormatter(OUTPUT_HEADERS);
Object[] outputValues = { metricsConfiguration.getEnabled(), metricsConfiguration.getDynamic(), metricsConfiguration.getEndpoint(), metricsConfiguration.getVirtualServers(), metricsConfiguration.getSecurityEnabled(), metricsConfiguration.getRoles() };
columnFormatter.addRow(outputValues);
adminCommandContext.getActionReport().appendMessage(columnFormatter.toString());
Map<String, Object> extraPropertiesMap = new HashMap<>();
extraPropertiesMap.put("enabled", metricsConfiguration.getEnabled());
extraPropertiesMap.put("dynamic", metricsConfiguration.getDynamic());
extraPropertiesMap.put("endpoint", metricsConfiguration.getEndpoint());
extraPropertiesMap.put("virtualServers", metricsConfiguration.getVirtualServers());
extraPropertiesMap.put("securityenabled", metricsConfiguration.getSecurityEnabled());
extraPropertiesMap.put("roles", metricsConfiguration.getRoles());
Properties extraProperties = new Properties();
extraProperties.put("metricsConfiguration", extraPropertiesMap);
adminCommandContext.getActionReport().setExtraProperties(extraProperties);
}
Aggregations