@Test public void testGenerateMetricMappingCurrentTcpConnections() { System.out.println("metrics mapping for Tcp Connections"); String rawString = "--title='Current TCP Connections' --vertical-label='Current Connections' DEF:currEstab={rrd1}:tcpCurrEstab:AVERAGE DEF:minCurrEstab={rrd1}:tcpCurrEstab:MIN DEF:maxCurrEstab={rrd1}:tcpCurrEstab:MAX LINE2:currEstab#00ff00:'Current ' GPRINT:currEstab:AVERAGE:'Avg \n: %8.2lf %s' GPRINT:currEstab:MIN:'Min \n: %8.2lf %s' GPRINT:currEstab:MAX:'Max \n: %8.2lf %s\n'"; String expectedResult = "'.1.3.6.1.2.1.6.9.0': '{rrd1}:tcpCurrEstab'"; Map<String, String> rrdGraphAttributesToMetricIds = new LinkedHashMap<String, String>(); rrdGraphAttributesToMetricIds.put("tcpCurrEstab", ".1.3.6.1.2.1.6.9.0"); String mappingResult = nrtHelper.generateJsMappingObject(rawString, rrdGraphAttributesToMetricIds); System.err.println("mappingResult = " + mappingResult); assertTrue(mappingResult.contains(".1.3.6.1.2.1.6.9.0")); assertTrue(mappingResult.contains("tcpCurrEstab")); assertFalse(mappingResult.contains("\n")); assertEquals(expectedResult, mappingResult); }
public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); } }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }  }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }  String cleanUpRrdGraphStringForWebUi(final PrefabGraph prefabGraph, final Map<String,String> externalPropertyAttributes, final Map<String,String> stringPropertyAttributes); String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds); }
NrtHelper { public String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds) { final StringBuilder stringBuilder = new StringBuilder(); final String command = rrdCommand; final Pattern pattern = Pattern.compile("DEF:.*?=(\\{.*?\\}):(.*?):"); final Matcher matcher = pattern.matcher(command); final Map<String, String> rrdFileMapping = new HashMap<String, String>(); while (matcher.find()) { rrdFileMapping.put(matcher.group(2), matcher.group(1)); } for (final Map.Entry<String,String> entry : rrdGraphAttributesToMetricIds.entrySet()) { final String row = String.format("'%s': '%s:%s', \n", entry.getValue(), rrdFileMapping.get(entry.getKey()), entry.getKey()); stringBuilder.append(row); } return stringBuilder.toString().substring(0,stringBuilder.toString().length() - ", \n".length()); }  String cleanUpRrdGraphStringForWebUi(final PrefabGraph prefabGraph, final Map<String,String> externalPropertyAttributes, final Map<String,String> stringPropertyAttributes); String generateJsMappingObject(String rrdCommand, final Map<String, String> rrdGraphAttributesToMetricIds); final static List<String> RRD_KEYWORDS; }