private void dumpStacksToFile(Set<DistributedMember> targetMembers, String fileName)
      throws Exception {
    Map<String, byte[]> dumps = new HashMap<>();

    ResultCollector<?, ?> rc =
        ManagementUtils.executeFunction(new GetStackTracesFunction(), null, targetMembers);
    ArrayList<Object> resultList = (ArrayList<Object>) rc.getResult();
    assertEquals(targetMembers.size(), resultList.size());

    for (Object resultObj : resultList) {
      if (resultObj instanceof StackTracesPerMember) {
        StackTracesPerMember stackTracePerMember = (StackTracesPerMember) resultObj;
        dumps.put(stackTracePerMember.getMemberNameOrId(),
            stackTracePerMember.getStackTraces());
      } else {
        fail("expected a stack trace but found " + resultObj);
      }
    }
    assertEquals(targetMembers.size(), dumps.size());

    new ExportStackTraceCommand().writeStacksToFile(dumps, fileName);
  }
Gfsh has an "export stack-traces" command that PluckStacks should be able to parse
geode-core/src/distributedTest/java/org/apache/geode/internal/util/PluckStacksDUnitTest.java