private ResultModel getSystemWideMetrics(String export_to_report_to, String[] categoriesArr,
      StringBuilder csvBuilder) {
    final ManagementService managementService = getManagementService();
    DistributedSystemMXBean dsMxBean = managementService.getDistributedSystemMXBean();
    if (dsMxBean == null) {
      String errorMessage =
          CliStrings.format(CliStrings.SHOW_METRICS__ERROR, "Distributed System MBean not found");
      return ResultModel.createError(errorMessage);
    }

    ResultModel result = new ResultModel();
    TabularResultModel metricsTable = result.addTable("cluster-metrics");

    Set<Category> categoriesToDisplay = ArrayUtils.isNotEmpty(categoriesArr)
        ? getCategorySet(categoriesArr) : new HashSet<>(SYSTEM_METRIC_CATEGORIES);

    metricsTable.setHeader("Cluster-wide Metrics");

    writeSystemWideMetricValues(dsMxBean, csvBuilder, metricsTable, categoriesToDisplay);
    if (StringUtils.isNotEmpty(export_to_report_to)) {
      result.addFile(export_to_report_to, csvBuilder.toString());
    }

    return result;
  }
Gets the system wide metrics

@return ResultData with required System wide statistics or ErrorResultData if DS MBean is not
        found to gather metrics
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMetricsCommand.java