@Override public void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception { String udpContentString = packet.content().toString(CharsetUtil.UTF_8); long currentTimestampInMilliseconds = System.currentTimeMillis(); List<GraphiteMetric> graphiteMetrics = GraphiteMetric.parseGraphiteMetrics( udpContentString, GlobalVariables.graphiteAggregatedPrefix, currentTimestampInMilliseconds); for (GraphiteMetric graphiteMetric : graphiteMetrics) { long hashKey = GlobalVariables.metricHashKeyGenerator.incrementAndGet(); graphiteMetric.setHashKey(hashKey); if (graphiteMetric.getMetricPath() != null) graphiteMetric.getMetricPath().hashCode(); GlobalVariables.graphiteAggregatorMetrics.put(graphiteMetric.getHashKey(), graphiteMetric); GlobalVariables.incomingMetricsCount.incrementAndGet(); } if (ApplicationConfiguration.isDebugModeEnabled()) { logger.info("UDP_Graphite_Aggregator_Received_Metrics=" + graphiteMetrics.size()); logger.info("UDP_Graphite_Aggregator_String=\"" + udpContentString + "\""); } }
public void testNotificationGroup(String notificationGroupName) { if (notificationGroupName == null) { logger.info("Failed to send email alert to notification group. Name cannot be null"); return; } NotificationGroupsDao notificationGroupsDao = new NotificationGroupsDao(); NotificationGroup notificationGroup = notificationGroupsDao.getNotificationGroupByName(notificationGroupName); if ((notificationGroup == null) || (notificationGroup.getName() == null) || (notificationGroup.getId() == null)) { String cleanNotificationGroupName = StringUtilities.removeNewlinesFromString(notificationGroupName, ' '); logger.warn( "Failed to send email alert to notification group '" + cleanNotificationGroupName + "'. Notification group does not exist."); return; } String testAlertName = "Notification test - alert"; Alert testAlert = new Alert( 99999, testAlertName, testAlertName.toUpperCase(), "This is a fake alert to test sending email alerts to the notification group named '" + notificationGroup.getName() + "'", 88888, true, true, true, Alert.TYPE_THRESHOLD, false, false, 60l, DatabaseObjectCommon.TIME_UNIT_MINUTES, 77777, 77777, Alert.OPERATOR_GREATER, Alert.COMBINATION_ALL, null, new BigDecimal("100"), 9900L, DatabaseObjectCommon.TIME_UNIT_SECONDS, null, DatabaseObjectCommon.TIME_UNIT_SECONDS, 1, true, new Timestamp(System.currentTimeMillis()), false, null, null, 77777, 77777, Alert.OPERATOR_GREATER, Alert.COMBINATION_ALL, null, new BigDecimal("200"), 91000L, DatabaseObjectCommon.TIME_UNIT_SECONDS, null, DatabaseObjectCommon.TIME_UNIT_SECONDS, 2, true, new Timestamp(System.currentTimeMillis()), false, null, null); String testMetricGroupName = "Notification test - metric group"; MetricGroup metricGroup = new MetricGroup( 88888, testMetricGroupName, testMetricGroupName.toUpperCase(), "This is a fake metric group to test sending email alerts to the notification group named '" + notificationGroup.getName() + "'"); List<String> metricKeys = new ArrayList<>(); metricKeys.add("emailtest.metric2"); metricKeys.add("emailtest.metric1"); metricKeys.add("emailtest.metric3"); metricKeys.add("emailtest.metric4"); metricKeys.add("emailtest.metric5"); Map<String, BigDecimal> alertMetricValues = new HashMap<>(); alertMetricValues.put("emailtest.metric1-99999", new BigDecimal(101)); alertMetricValues.put("emailtest.metric2-99999", new BigDecimal(102)); alertMetricValues.put("emailtest.metric3-99999", new BigDecimal(103)); alertMetricValues.put("emailtest.metric4-99999", new BigDecimal(104)); EmailThread emailThread = new EmailThread( testAlert, EmailThread.WARNING_LEVEL_CAUTION, metricKeys, alertMetricValues, new ConcurrentHashMap<String, String>(), false, false, ApplicationConfiguration.getAlertStatsAggLocation()); emailThread.buildAlertEmail(3, metricGroup); List<String> emailsAddresses = EmailThread.getToEmailsAddressesForAlert(notificationGroup.getId()); emailThread.sendEmail(emailsAddresses, emailThread.getSubject(), emailThread.getBody()); String cleanNotificationGroupName = StringUtilities.removeNewlinesFromString(notificationGroup.getName(), ' '); logger.info("Sent test email alert to notification group '" + cleanNotificationGroupName + "'"); }