Skip to content

Commit

Permalink
Improving the auto-generated graphs created by the MIB Compiler
Browse files Browse the repository at this point in the history
- Adding a new system-wide property to control the default color used
  for the template:

  org.opennms.snmp.mib-compiler.default-graph-template.color

  If the property doesn't exist on opennms.properties, the default value
  is: #00ccff

- Fixing the graph title to be more concise, including the MIB name, the
  table name, and the metric name (instead of using the description,
  which can be extremely long in some cases).
  • Loading branch information
agalue committed Mar 17, 2015
1 parent 41d9ccb commit a406b3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -279,6 +279,7 @@ public List<PrefabGraph> getPrefabGraphs() {
if (module == null) {
return null;
}
final String color = System.getProperty("org.opennms.snmp.mib-compiler.default-graph-template.color", "#00ccff");
List<PrefabGraph> graphs = new ArrayList<PrefabGraph>();
LOG.info("Generating graph templates for {}", module.getId());
NameCutter cutter = new NameCutter();
Expand All @@ -295,17 +296,18 @@ public List<PrefabGraph> getPrefabGraphs() {
int order = 1;
if (typeName != null && !typeName.toLowerCase().contains("string")) {
String name = groupName + '.' + v.getId();
String title = getMibName() + "::" + groupName + "::" + v.getId();
String alias = cutter.trimByCamelCase(v.getId(), 19); // RRDtool/JRobin DS size restriction.
String descr = v.getDescription().replaceAll("[\n\r]", "").replaceAll("\\s+", " ");
StringBuffer sb = new StringBuffer();
sb.append("--title=\"").append(v.getId()).append("\" \\\n");
sb.append("--title=\"").append(title).append("\" \\\n");
sb.append(" DEF:var={rrd1}:").append(alias).append(":AVERAGE \\\n");
sb.append(" LINE1:var#0000ff:\"").append(v.getId()).append("\" \\\n");
sb.append(" LINE1:var").append(color).append(":\"").append(v.getId()).append("\" \\\n");
sb.append(" GPRINT:var:AVERAGE:\"Avg\\\\: %8.2lf %s\" \\\n");
sb.append(" GPRINT:var:MIN:\"Min\\\\: %8.2lf %s\" \\\n");
sb.append(" GPRINT:var:MAX:\"Max\\\\: %8.2lf %s\\\\n\"");
sb.append("\n\n");
PrefabGraph graph = new PrefabGraph(name, descr, new String[] { alias }, sb.toString(), new String[0], new String[0], order++, new String[] { resourceType }, descr, null, null, new String[0]);
PrefabGraph graph = new PrefabGraph(name, title, new String[] { alias }, sb.toString(), new String[0], new String[0], order++, new String[] { resourceType }, descr, null, null, new String[0]);
graphs.add(graph);
}
}
Expand Down
Expand Up @@ -281,7 +281,7 @@ public void testGenerateGraphTemplates() throws Exception {
PrefabGraphDumper dumper = new PrefabGraphDumper();
dumper.dump(graphs, writer);
System.out.println(writer.getBuffer().toString());
Assert.assertEquals(99344, writer.getBuffer().toString().length());
Assert.assertEquals(102533, writer.getBuffer().toString().length()); // FIXME we should implement a more comprehensive check here.

PropertiesGraphDao dao = new PropertiesGraphDao();
StringBuffer sb = new StringBuffer();
Expand Down

0 comments on commit a406b3a

Please sign in to comment.