Monitoring Data Producers
This chapter covers how to add a new metrics and health checks scripts with cmsh.
Five different types of Monitoring Data Producers can be added:
-
metric: a script which produces a single value. -
health check: a script which produces aPASS,FAIL,UNKNOWN, orno datavalue. -
collection: a script that produces zero or more metrics, health checks, or a combination of both. -
perpetuala script that is started once over the lifetime of the BCMcmdprocess. The script produces zero or more metrics, health checks, or a combination of both on its own timing mechanism. -
prometheusone or more URLs to Prometheus metric exporters.
A monitoring data producer cannot be plotted in cmsh or Base View, because it contains no data. A producer defines measurables: metrics and/or health checks. It also generates data for these measurables, which can be plotted.
2.1 Measurables
There are three types of measurable:
-
metric: a numeric value, orno data. -
health check:PASS/FAIL/UNKNOWN/no data. -
enum metric: one of a set of user-defined string based values, orno data.
2.2 Measurables Classes
All measurables are grouped into classes. A class is a user-defined free string field, with / as delimiters. Base View uses this class to build a tree for easy search and access.
2.3 Metric Monitoring Data Producers
A metric data producer script generates one data point.
For example, as in the following script:
Example
The script can be defined as a metric script via the monitoring setup mode of cmsh:
Example
All nodes then execute the script every minute, and produce a random number.
2.4 Health Check Monitoring Data Producers
A health check data producer script generates one data point. The data point can be one of four possible values expected of it: PASS, FAIL, UNKNOWN, or no data. Other file descriptors can be used to provide extra information.
For example, as in the following script:
Example
The script can be defined as a health check script via the monitoring setup mode of cmsh:
Example
All nodes then execute the script every minute, and produce data values with roughly 75% PASS and 25% FAIL.
2.5 Collection Monitoring Data Producers
A collection data producer script can generate multiple data points in one run. Data points can be a combination of metrics and health checks. Collection scripts are also allowed to produce no data.
A collection script has two modes: initialize mode and sample mode.
-
initialize: defines the measurables that data values are generated for. -
sample: returns the data values for all the measurables defined in initialize mode.
During normal cluster operation the initialize mode is called only once, during boot. Afterwards, the script is called in sample mode at the desired interval.
The following example combines both of the metric and health check examples from earlier on. However, this time it is written as a single script, using JSON as the output format:
Example
The script can be defined as a collection script via the monitoring setup mode of cmsh:
Example
All nodes then execute the script every minute and produce two data points upon each execution. That is, one metric and one health check per execution.
2.6 Perpetual Monitoring Data Producers
A perpetual data producer script is a special case of a collection data producer script. It is intended to be used if the script needs permanent memory storage.
Example
The my_sampler_module is the part which does the important work.
Example
The script can be defined as a perpetual script via the monitoring setup mode of cmsh:
Example
2.7 Prometheus Monitoring Data Producers
Prometheus is a monitoring and alerting toolkit (https://prometheus.io). A Prometheus monitoring data producer script parses data from a Prometheus exporter (https://prometheus.io/docs/instrumenting/exporters/)
The script can be defined as a Prometheus script via the monitoring setup mode of cmsh:
Example
If multiple URLs are defined, then only the data values from the first successful HTTP GET are used.
2.8 Node Execution Filters
By default a monitoring data producer script is executed on every node. When this is not desirable, a node execution filter should be created. A node execution filter defines the nodes on which the producer script should be executed.
For example, a filter to execute the script only on cloud nodes can be configured as follows:
Example
It is also possible to filter based on the specific resources associated with a node:
Example
Because of high availability, a special resource, active, is defined for the active head node.
Example
2.9 Execution Multiplexers
By default a monitoring data producer script is executed once: the node executes the script only for itself.
However, some scripts, such as BMC samplers, must be sampled from the active head node for all nodes.
In the following example a BMC script is run on each node that has the ipmi or drac resource:
Example
If an execution multiplexer <multiplexer> is defined, then there should also be a node execution filter <filter> associated with it to restrict the number of nodes on which the script runs.
This is because having the script run on many nodes for many other nodes is unlikely to be a desired configuration.
The combination of the execution filter and the multiplexer should be read as:
for every node that matches filter, run script, for each node that matches multiplexer.
A more specific example, using two of the preceding examples, with a filter based on the resource IB, and multiplexers based on the IPMI/Drac resources, the combination should be read as:
for every node that matches IB, run script, for each node that matches ipmi or drac.
2.10 Monitoring Resources
Every device in BCM has one or more resources. These resources are automatically calculated from:
-
Roles
-
Hardware
-
Settings
Resources for a specific node can be viewed as follows:
Example
It is possible to add one or more custom resources to a device:
Example
Any of these resources can be used to filter and multiplex monitoring data producers.
If a resources changes because of a settings change, then monitoring automatically stops or starts sampling.
2.11 Collection Monitoring Data Producers With Filter And Multiplexer
If a script has an execution multiplexer set, then it needs to determine for which nodes the script runs:
Example
It can be defined with a filter to run on the active head for all nodes in the GPU category:
Example
The script is then executed on the head, once for each node in the category of GPU.
2.12 Collection Monitoring Data Producers For Standalone Entities
Sometimes monitoring data does not belong to a BCM entity.
For this reason the standalone monitored entity was added in NVIDIA Base Command Manager 8.0.
This entity can be anything with a name and custom type.
BCM does nothing with this kind of entity, except allow it to store monitoring data.
Each standalone entity which needs to be monitored should be added:
Example
A script can be created that produces data for all MSD entities:
Example
It can be defined to run on only the active head node:
Example
The script is then executed on the active head every 5 minutes and collects one data point for each MSD.
Data for a standalone script can be viewed with the same commands as for regular BCM nodes.
Example
2.13 Debugging Standalone Scripts
Here describes how debugging information can be obtained when running samplenow with the --debug option with the ntp healthcheck script.
Many scripts under /cm/local/apps/cmd/scripts/ can have their debug output inspected with samplenow --debug.
A recursive grep on the head node, similar to the following, should show which scripts have a settable debug environment:
The debug output in the script can be specified along the lines of the following code snippet:
Example