Version

This relates to opCharts version 3

Introduction

New opCharts TopN tables can be created by following a few steps.  Each TopN table is really just a component in a dashboard, by default opCharts ships it's components in omk/lib/json/opCharts/components.d/.  User defined components are also loaded from omk/conf/components.d, and are loaded last so that default components can be overridden if desired.

opCharts takes several steps generate TopN data and display it, understanding these steps will make the process of adding a new TopN table make more sense.

  1. nmis_topn_export.pl is run as a plugin by NMIS
  2. nmis_topn_export.pl looks for opcharts_topn_properties in opCommon.nmis,
    1. For each node it attempts to get values for each topn_property
    2. After gathering all TopN data it outputs the topn data as json to <omk_topn>
  3. When a user views the TopN page, opCharts loads all components tagged with topn, and puts them into a dashboard which is dynamically created and presented
    1. If a TopN component is added to a user defined dashboard the specific components is searched for and included in the dashboard

In order to make a new TopN table steps 2 and 3 need to process new data for the new TopN table.

Add a new opcharts_topn_properties entry

The nmis_topn_export.pl script runs through each node and attempts to find a value for each entry in the opcharts_topn_properties config array, adding a new entry will generate new data.  

The first step in adding a new opcharts_topn_properties entry is to find the data the that you would like to add and either make sure the NMIS threshold system is outputting it or make sure the opCharts Resource Model is modelling it.

After that is done, a new entry can be added which describes the data, that process (and more) is described in another wiki article

To debug, run the nmis_topn_export.pl script with force=1 (and possibly debug=1) and look for a new file in the <omk_topn> directory with new data

Add a new component file

The easiest way to get started is to copy an existing topn component file from omk/lib/json/opCharts/components.d/topn_* into omk/conf/components.d (and rename the file).

Next open the new file and modify it to suite your new TopN data, the changes required are fairly straight forward and are outlined below: 

{
  "name": "TopN NEW THING", # set a new name here
  "tags": [ "topn" ], # leave this
  "ep_template_file": "charts/topn/topn_table_component", #leave this
  "ep_configuration_file" : "charts/topn/topn_table_component_configuration", # leave this
  "options": {
    "titleText": "TopN NEW THING", # set the component title here
    "limit" : 10, # set how many to show here
    "show_element": 0, 
    "show_sparkline": 1 , # 0 for no sparkline, 1 for sparkline
    "show_value": 1, # 0 to not show the value, 1 to show the value
  },
  "order": 1, # order the new TopN table will appear in the TopN list, see the others to get a total ordering
  "parameters": {
    "topn_id": "cpuLoad" # the field the TopN is using, this will be the same as the filename outputted by nmis_topn_export, and also the same as the "data" attribute in the opcharts_topn_properties that was added
  },
  "type": "ep_template" # leave this
}

The new TopN table should now appear in opCharts TopN page and also as an option when adding a component to a dashboard under the opCharts data source.

Last Step

After the previous steps have been completed, make sure the nmis_topn_export.pl script has run, then check the TopN page for the new data.  If there is none, verify the data is being created by checking <omkd_topn> directory for the new json file.  Verify the file has contents, if it does not run the nmis_topn_export.pl in debug and search the output for the new entry field/data.