Chart-configuration.xml

From OpenNMS
Jump to: navigation, search

JFreeChart support

As of 1.3.0, OpenNMS supports the use of JFreeChart to display bar graphs on the front page of the OpenNMS webUI.

Example of how to create a custom chart

  1. Find a similar chart in the charts-configuration.xml
  2. Copy that chart
  3. Modify the name, domain-axis-label, and title value to match the new information being presented.
  4. For each series-def -
    1. Rename the series-name and domain-axis-label to an appropriate name
    2. modify the sql to return a row with two columns, the first column is the label, the second the numeric value. In most cases the first column will be a string in single quotes, the second will be a count(*).
  5. Test! I found I needed to restart the webapp after the first test to get this going. Right now the only way I know how to restart jetty is to restart all of OpenNMS.
  <tns:bar-chart name="Physical interfaces by type"
        variation="2d"
        domain-axis-label="Ethernet/PPP/Frame Relay"
        show-legend="true"
        plot-orientation="vertical"
        draw-bar-outline="true"
        range-axis-label="Count"
        show-urls="false"
    show-tool-tips="false">

    <tns:title font="SansSerif" style="" value="Physical Interface Inventory" pitch="12" />
    <tns:image-size>
      <tns:hz-size>
        <tns:pixels>450</tns:pixels>
      </tns:hz-size>
      <tns:vt-size>
        <tns:pixels>300</tns:pixels>
      </tns:vt-size>
    </tns:image-size>
    <tns:grid-lines visible="true">
        <tns:rgb>
            <tns:red>
                <tns:rgb-color>255</tns:rgb-color>
            </tns:red>
            <tns:green>
                <tns:rgb-color>255</tns:rgb-color>
            </tns:green>
            <tns:blue>
                <tns:rgb-color>255</tns:rgb-color>
            </tns:blue>
        </tns:rgb>
    </tns:grid-lines>
    <tns:series-def number="1" series-name="Ethernet" use-labels="true" >
          <tns:jdbc-data-set db-name="opennms" sql="select 'Eth', count(*) as Count from snmpinterface where snmpiftype=6;" />
      <tns:rgb>
        <tns:red>
          <tns:rgb-color>255</tns:rgb-color>
        </tns:red>
        <tns:green>
          <tns:rgb-color>0</tns:rgb-color>
        </tns:green>
        <tns:blue>
          <tns:rgb-color>0</tns:rgb-color>
        </tns:blue>
      </tns:rgb>
    </tns:series-def>
    <tns:series-def number="2" series-name="PPP" use-labels="true" >
          <tns:jdbc-data-set db-name="opennms" sql="select 'PPP', count(*) as Count from snmpinterface where snmpiftype=23;" />
      <tns:rgb>
        <tns:red>
          <tns:rgb-color>0</tns:rgb-color>
        </tns:red>
        <tns:green>
          <tns:rgb-color>255</tns:rgb-color>
        </tns:green>
        <tns:blue>
          <tns:rgb-color>0</tns:rgb-color>
        </tns:blue>
      </tns:rgb>
    </tns:series-def>
    <tns:series-def number="3" series-name="Frame Relay" use-labels="true" >
          <tns:jdbc-data-set db-name="opennms" sql="select 'FR', count(*) as Count from snmpinterface where snmpiftype=32;" />
      <tns:rgb>
        <tns:red>
          <tns:rgb-color>0</tns:rgb-color>
        </tns:red>
        <tns:green>
          <tns:rgb-color>0</tns:rgb-color>
        </tns:green>
        <tns:blue>
          <tns:rgb-color>255</tns:rgb-color>
        </tns:blue>
      </tns:rgb>
    </tns:series-def>
  </tns:bar-chart>