Search in sources :

Example 6 with ColumnFormatter

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);
}
Also used : HashMap(java.util.HashMap) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) AMXConfiguration(fish.payara.admin.amx.config.AMXConfiguration) MonitoringService(com.sun.enterprise.config.serverbeans.MonitoringService) CommandRunner(org.glassfish.api.admin.CommandRunner) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 7 with ColumnFormatter

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);
}
Also used : AMXConfiguration(fish.payara.admin.amx.config.AMXConfiguration) HashMap(java.util.HashMap) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) MonitoringService(com.sun.enterprise.config.serverbeans.MonitoringService) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 8 with ColumnFormatter

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);
}
Also used : HashMap(java.util.HashMap) Config(com.sun.enterprise.config.serverbeans.Config) ArrayList(java.util.ArrayList) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) MonitoringService(com.sun.enterprise.config.serverbeans.MonitoringService) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 9 with ColumnFormatter

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;
}
Also used : HashMap(java.util.HashMap) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 10 with 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);
}
Also used : HashMap(java.util.HashMap) Config(com.sun.enterprise.config.serverbeans.Config) Properties(java.util.Properties) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Aggregations

ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)53 Properties (java.util.Properties)24 HashMap (java.util.HashMap)22 ActionReport (org.glassfish.api.ActionReport)22 Config (com.sun.enterprise.config.serverbeans.Config)21 ServiceHandle (org.glassfish.hk2.api.ServiceHandle)8 ArrayList (java.util.ArrayList)7 PayaraNotifier (fish.payara.internal.notification.PayaraNotifier)5 MonitoringService (com.sun.enterprise.config.serverbeans.MonitoringService)3 AMXConfiguration (fish.payara.admin.amx.config.AMXConfiguration)2 MonitoredAttribute (fish.payara.jmx.monitoring.configuration.MonitoredAttribute)2 MonitoringServiceConfiguration (fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration)2 BaseHealthCheck (fish.payara.nucleus.healthcheck.preliminary.BaseHealthCheck)2 NotifierConfigurationType (fish.payara.nucleus.notification.configuration.NotifierConfigurationType)2 LogNotifierConfiguration (fish.payara.nucleus.notification.log.LogNotifierConfiguration)2 BaseNotifierService (fish.payara.nucleus.notification.service.BaseNotifierService)2 File (java.io.File)2 TaggedJobExecution (com.ibm.jbatch.spi.TaggedJobExecution)1 DomainConfig (com.sun.enterprise.admin.servermgmt.DomainConfig)1 DomainException (com.sun.enterprise.admin.servermgmt.DomainException)1