Exemple #1
0
  private void showAlarms(Long minDuration, int minutes) {
    final DateTime now = new DateTime();
    final DateTime start = now.minusMinutes(minutes);
    final List<PollResult> alarms =
        pollService.listAlarms(start.toDate(), now.toDate(), minDuration);
    final List<PollResult> problems = pollService.listProblems(start.toDate(), now.toDate());

    System.out.println("\nListing events over last " + minutes + " minutes");
    System.out.println(" ALARMS (duration > " + minDuration + ")");
    TextTable table =
        new TextTable(
            "  ",
            TextTable.ALIGN.LEFT,
            TextTable.ALIGN.LEFT,
            TextTable.ALIGN.LEFT,
            TextTable.ALIGN.RIGHT,
            TextTable.ALIGN.CENTER);
    if (!alarms.isEmpty()) {
      for (PollResult pollResult : alarms) {
        table.add(format2(pollResult));
      }
      System.out.println(table.toString());
    } else {
      System.out.println("  No alarms");
    }
    table.clear();
    System.out.println(" PROBLEMS (non-successful events)");
    if (!problems.isEmpty()) {
      for (PollResult pollResult : problems) {
        table.add(format2(pollResult));
      }
      System.out.println(table.toString());
    } else {
      System.out.println("  No problems");
    }
  }