Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Assumptions:

  • installed opCharts

Overview

opCharts has dashboards built into the heart of it's engine.  Dashboards have the ability to display components, components can load data from many different sources and display it as a graph/table/pie/chart/etc.  Right now only graphs are supported.

opCharts runs in 2 modes.  Standalone and not-standalone (NMIS attached).  

Operational mode (standalone or not)

Not-Standalone

...

Table of Contents

Assumptions:

  • installed opCharts

Overview

opCharts has dashboards built into the heart of it's engine.  Dashboards have the ability to display components, components can load data from many different sources and display it as a graph/table/pie/chart/etc.  Right now only graphs are supported.

opCharts runs in 2 modes.  Standalone and not-standalone (NMIS attached).  

Operational mode (standalone or not)

Not-Standalone

When opCharts is not in standalone mode 'opcharts_running_standalone' => 'false', opCharts will be linked to NMIS and the index page will show a node search and a default dashboard (if the user has chosen one).  In this mode there are no custom opcharts users or customers.  Although the menu will allow the user to create them they will not be used.  All users are loaded from the NMIS configuration as well as their privilege mode.

...

 In the shipping configuration, a dashboard is defined for "CiscoRouter", so this will display for all nodes that use the CiscoRouter model. 

Node Resource / indexed resource

The search for this is more complex but it works the same way:

 

"${model_name}_${resource_name}_${dataset_name}",
"node_${resource_name}_${dataset_name}",
"${model_name}_${resource_id}_default",
"node_${resource_name}_default",
"${model_name}_resource_default",
"node_resource_default"

...

Code Block
 {
               "parameters" : {
                  "query" : "select * from nodes",
                  "groupby" : [
                     "group_column"
                  ],
                  "aggregation_function" : 1,
                  "value_column" : "unused",
                  "lineType" : "column",
                  "axis" : "0",
               },
               "data_source" : "local_mysql",
               "options" : {
                  "datasetTitle" : "Groups"
               },
               "name" : "sqlquery_dataset",
               "type" : "sql_query"
}

Breaking this down:

From the data_source "local_mysql", run the "sql_query" that is "select * from nodes", group the result by "group_column" and COUNT the number or rows in each group.  Display the results in a column graph on the 0 axis.

query:

The SQL to run.  This SQL can contain almost anything you would like. 

query subsitutions

Currently supported subsitutions are:

query tokensubstituted value
user.customerThe customer name of the current user is assigned to, if the user does not have a customer the query can fail. Administrators have an option to set this value in the advanced menu.
time.startunix timestamp of the starting time selected from the advanced menu, default value is 15min before now
time.endunix timestamp of the ending time selected from the advanced menu, default value is now

For the timestamps the time column being queried may need to be converted into a unix timestamp to make a comparison valid.  MySQL's timestamp function is UNIX_TIMESTAMP( timecolumn )

Example: SELECT * FROM interface WHERE UNIX_TIMESTAMP(lastUpdate) >= time.start AND UNIX_TIMESTAMP(lastUpdate) < time.end AND customerName = user.customer

groupby:

If the data returned from the SQL statement needs to be grouped (for summing or counting, works much like SQL GROUP BY) use this field to specify the group, as an array, order matters.  This works in tandem with the aggregation function to produce results.  Just like in an SQL GROUP BY each column requires a function to aggregate it's result.

value_column:

The column in the dataset to run the aggregation function on.  If you are not sure what the column name will be, use SELECT column AS some_unique_name. "some_unique_name" can then be used as the value column

aggregation_function:

PASSTHROUGH => 0, COUNT => 1, SUM => 2, MAX => 3, MIN => 4, AVG => 5

This function should be run on each entry in the "group" to produce one row.  The value_column will be read and have this function run on it, unless PASSTHROUGH or COUNT are used. For PASSTHROUGH no grouping or aggregation are done.  For COUNT the number of rows in each group is tallied.  both PASSTHROUGH or COUNT ignore the value_column setting.

lineType:

column is most likely, other options are available, open the chart creator (go to charts and click new chart), there is a drop down with the options.

name:

this is of little consequence, functionally not used at all right now but a way for you to name the dataset for later recognition.

type:

must be sql_query for the above parameters to work.

Back to the chart

The name is the unique name that identifies this chart when using it elsewhere (like creating a dashboard).  What is type for?

type

         "type" : "non-time-chart"
         "type" : "graph"

2 options exist for this.  "non-time-chart" means the data will not be an "over time" graph, but a snapshot of the data at a specific time.  This is the most likely candidate for an SQL chart.  "graph" is a data over time view, the time base is in unix epoc, the SQL query must return the time column in this format and "time_column" must be specified in the dataset telling it what the column is that holds the time value.

Customising the opCharts GUI

Changing the Blue Login Message

To change the text when logging in from the default of "Authentication required: default credentials are nmis/nm188", change the configuration option in opCommon.nmis, "auth_login_motd" to the required text.

To hide the "view in nmis" button, change the configuration option in opCommon.nmis, "opcharts_gui_display_view_in_nmis" to false, by default this is true.

Hiding Modules List in Menu Bar

...

}

Breaking this down:

From the data_source "local_mysql", run the "sql_query" that is "select * from nodes", group the result by "group_column" and COUNT the number or rows in each group.  Display the results in a column graph on the 0 axis.

query:

The SQL to run.  This SQL can contain almost anything you would like. 

query subsitutions

Currently supported subsitutions are:

query tokensubstituted value
user.customerThe customer name of the current user is assigned to, if the user does not have a customer the query can fail. Administrators have an option to set this value in the advanced menu.
time.startunix timestamp of the starting time selected from the advanced menu, default value is 15min before now
time.endunix timestamp of the ending time selected from the advanced menu, default value is now

For the timestamps the time column being queried may need to be converted into a unix timestamp to make a comparison valid.  MySQL's timestamp function is UNIX_TIMESTAMP( timecolumn )

Example: SELECT * FROM interface WHERE UNIX_TIMESTAMP(lastUpdate) >= time.start AND UNIX_TIMESTAMP(lastUpdate) < time.end AND customerName = user.customer

groupby:

If the data returned from the SQL statement needs to be grouped (for summing or counting, works much like SQL GROUP BY) use this field to specify the group, as an array, order matters.  This works in tandem with the aggregation function to produce results.  Just like in an SQL GROUP BY each column requires a function to aggregate it's result.

value_column:

The column in the dataset to run the aggregation function on.  If you are not sure what the column name will be, use SELECT column AS some_unique_name. "some_unique_name" can then be used as the value column

aggregation_function:

PASSTHROUGH => 0, COUNT => 1, SUM => 2, MAX => 3, MIN => 4, AVG => 5

This function should be run on each entry in the "group" to produce one row.  The value_column will be read and have this function run on it, unless PASSTHROUGH or COUNT are used. For PASSTHROUGH no grouping or aggregation are done.  For COUNT the number of rows in each group is tallied.  both PASSTHROUGH or COUNT ignore the value_column setting.

lineType:

column is most likely, other options are available, open the chart creator (go to charts and click new chart), there is a drop down with the options.

name:

this is of little consequence, functionally not used at all right now but a way for you to name the dataset for later recognition.

type:

must be sql_query for the above parameters to work.

Back to the chart

The name is the unique name that identifies this chart when using it elsewhere (like creating a dashboard).  What is type for?

type

         "type" : "non-time-chart"
         "type" : "graph"

2 options exist for this.  "non-time-chart" means the data will not be an "over time" graph, but a snapshot of the data at a specific time.  This is the most likely candidate for an SQL chart.  "graph" is a data over time view, the time base is in unix epoc, the SQL query must return the time column in this format and "time_column" must be specified in the dataset telling it what the column is that holds the time value.