Exemplo n.º 1
0
  private String buildEmailAlarmContent(ThresholdAlarmMeta meta) {
    Map<Object, Object> root = new HashMap<Object, Object>();
    StringWriter sw = new StringWriter(5000);

    root.put("rule", buildRuleMeta(meta.getDuration()));
    root.put("count", meta.getRealCount());
    root.put("domain", meta.getDomain());
    root.put("date", meta.getDate());
    root.put("url", buildProblemUrl(meta.getBaseShowUrl(), meta.getDomain(), meta.getDate()));

    try {
      String type = meta.getType();

      if (type.equalsIgnoreCase(AlertInfo.EXCEPTION)) {
        Template t = m_configuration.getTemplate("exceptionAlarm.ftl");

        t.process(root, sw);
      } else if (type.equalsIgnoreCase(AlertInfo.SERVICE)) {
        Template t = m_configuration.getTemplate("serviceAlarm.ftl");

        t.process(root, sw);
      }
    } catch (Exception e) {
      Cat.logError(e);
    }
    return sw.toString();
  }