plugins.d is the Netdata internal plugin that collects metrics
from external processes, thus allowing Netdata to use external plugins.
Provided External Plugins
|apps.plugin||linux, freebsd||monitors the whole process tree on Linux and FreeBSD and breaks down system resource usage by process, user and user group.|
|charts.d.plugin||all||a plugin orchestrator for data collection modules written in |
|fping.plugin||all||measures network latency, jitter and packet loss between the monitored node and any number of remote network end points.|
|ioping.plugin||all||measures disk latency.|
|freeipmi.plugin||linux||collects metrics from enterprise hardware sensors, on Linux servers.|
|nfacct.plugin||linux||collects netfilter firewall, connection tracker and accounting metrics using |
|xenstat.plugin||linux||collects XenServer and XCP-ng metrics using |
|perf.plugin||linux||collects CPU performance metrics using performance monitoring units (PMU).|
|node.d.plugin||all||a plugin orchestrator for data collection modules written in |
|python.d.plugin||all||a plugin orchestrator for data collection modules written in |
|slabinfo.plugin||linux||collects kernel internal cache objects (SLAB) metrics.|
Plugin orchestrators may also be described as modular plugins. They are modular since they accept custom made modules to be included. Writing modules for these plugins is easier than accessing the native Netdata API directly. You will find modules already available for each orchestrator under the directory of the particular modular plugin (e.g. under python.d.plugin for the python orchestrator). Each of these modular plugins has each own methods for defining modules. Please check the examples and their documentation.
This plugin allows Netdata to use external plugins for data collection:
external data collection plugins may be written in any computer language.
external data collection plugins may use O/S capabilities or
setuidto run with escalated privileges (compared to the
netdatadaemon). The communication between the external plugin and Netdata is unidirectional (from the plugin to Netdata), so that Netdata cannot manipulate an external plugin running with escalated privileges.
Each of the external plugins is expected to run forever. Netdata will start it when it starts and stop it when it exits.
If the external plugin exits or crashes, Netdata will log an error. If the external plugin exits or crashes without pushing metrics to Netdata, Netdata will not start it again.
- Plugins that exit with any value other than zero, will be disabled. Plugins that exit with zero, will be restarted after some time.
- Plugins may also be disabled by Netdata if they output things that Netdata does not understand.
stdout of external plugins is connected to Netdata to receive metrics,
with the API defined below.
stderr of external plugins is connected to Netdata's
Plugins can create any number of charts with any number of dimensions each. Each chart can have its own characteristics independently of the others generated by the same plugin. For example, one chart may have an update frequency of 1 second, another may have 5 seconds and a third may have 10 seconds.
Netdata will supply the environment variables
NETDATA_USER_CONFIG_DIR (for user supplied) and
NETDATA_STOCK_CONFIG_DIR (for Netdata supplied) configuration files to identify the directory where configuration files are stored. It is up to the plugin to read the configuration it needs.
[plugins] section contains a list of all the plugins found at the system where Netdata runs, with a boolean setting to enable them or not.
enable running new plugins sets the default behavior for all external plugins. It can be
overriden for distinct plugins by modifying the appropriate plugin value configuration to either
check for new plugins every sets the interval between scans of the directory
/usr/libexec/netdata/plugins.d. New plugins can be added any time, and Netdata will detect them in a timely manner.
For each of the external plugins enabled, another
is created, in the form of
NAME is the name of the external plugin.
This section allows controlling the update frequency of the plugin and provide
additional command line arguments to it.
For example, for
apps.plugin the following section is available:
update everycontrols the granularity of the external plugin.
command optionsallows giving additional command line options to the plugin.
Netdata will provide to the external plugins the environment variable
NETDATA_UPDATE_EVERY, in seconds (the default is 1). This is the minimum update frequency for all charts. A plugin that is updating values more frequently than this, is just wasting resources.
Netdata will call the plugin with just one command line parameter: the number of seconds the user requested this plugin to update its data (by default is also 1).
Other than the above, the plugin configuration is up to the plugin.
Keep in mind, that the user may use Netdata configuration to overwrite chart and dimension parameters. This is transparent to the plugin.
Plugins should attempt to autoconfigure themselves when possible.
For example, if your plugin wants to monitor
squid, you can search for it on port
8080. If any succeeds, you can proceed. If it fails you can output an error (on stderr) saying that you cannot find
squid running and giving instructions about the plugin configuration. Then you can stop (exit with non-zero value), so that Netdata will not attempt to start the plugin again.
External Plugins API
Any program that can print a few values to its standard output can become a Netdata external plugin.
Netdata parses 7 lines starting with:
CHART- create or update a chart
DIMENSION- add or update a dimension to the chart just created
BEGIN- initialize data collection for a chart
SET- set the value of a dimension for the initialized chart
END- complete data collection for the initialized chart
FLUSH- ignore the last collected values
DISABLE- disable this plugin
a single program can produce any number of charts with any number of dimensions each.
Charts can be added any time (not just the beginning).
command line parameters
The plugin MUST accept just one parameter: the number of seconds it is expected to update the values for its charts. The value passed by Netdata to the plugin is controlled via its configuration file (so there is no need for the plugin to handle this configuration option).
The external plugin can overwrite the update frequency. For example, the server may request per second updates, but the plugin may ignore it and update its charts every 5 seconds.
There are a few environment variables that are set by
netdata and are
available for the plugin to use.
|The directory where all Netdata-related user configuration should be stored. If the plugin requires custom user configuration, this is the place the user has saved it (normally under |
|The directory where all Netdata -related stock configuration should be stored. If the plugin is shipped with configuration files, this is the place they can be found (normally under |
|The directory where all Netdata plugins are stored.|
|The directory where the web files of Netdata are saved.|
|The directory where the cache files of Netdata are stored. Use this directory if the plugin requires a place to store data. A new directory should be created for the plugin for this purpose, inside this directory.|
|The directory where the log files are stored. By default the |
|This is used in environments where system directories like |
|This is a number (probably in hex starting with |
|The minimum number of seconds between chart refreshes. This is like the internal clock of Netdata (it is user configurable, defaulting to |
The output of the plugin
The plugin should output instructions for Netdata to its output (
stdout). Since this uses pipes, please make sure you flush stdout after every iteration.
DISABLE will disable this plugin. This will prevent Netdata from restarting the plugin. You can also exit with the value
1 to have the same effect.
CHART defines a new chart.
the template is:
CHART type.id name title units [family [context [charttype [priority [update_every [options [plugin [module]]]]]]]]
uniquely identifies the chart, this is what will be needed to add values to the chart
typepart controls the menu the charts will appear in
is the name that will be presented to the user instead of
type.id. This means that only the
type.idis changed. When a name has been given, the chart is index (and can be referred) as both
type.name. You can set name to
(null)to disable it.
the text above the chart
the label of the vertical axis of the chart, all dimensions added to a chart should have the same units of measurement
is used to group charts together (for example all eth0 charts should say: eth0), if empty or missing, the
type.idwill be used
this controls the sub-menu on the dashboard
the context is giving the template of the chart. For example, if multiple charts present the same information for a different family, they should have the same
this is used for looking up rendering information for the chart (colors, sizes, informational texts) and also apply alarms to it
stacked, if empty or missing, the
linewill be used
is the relative priority of the charts as rendered on the web page, lower numbers make the charts appear before the ones with higher numbers, if empty or missing,
1000will be used
overwrite the update frequency set by the server, if empty or missing, the user configured value will be used
a space separated list of options, enclosed in quotes. 4 options are currently supported:
obsoleteto mark a chart as obsolete (Netdata will hide it and delete it after some time),
detailto mark a chart as insignificant (this may be used by dashboards to make the charts smaller, or somehow visualize properly a less important chart),
store_firstto make Netdata store the first collected value, assuming there was an invisible previous value set to zero (this is used by statsd charts - if the first data collected value of incremental dimensions is not zero based, unrealistic spikes will appear with this option set) and
hiddento perform all operations on a chart, but do not offer it on dashboards (the chart will be send to backends).
CHARToptions have been added in Netdata v1.7 and the
hiddenoption was added in 1.10.
both are just names that are used to let the user identify the plugin and the module that generated the chart. If
pluginis unset or empty, Netdata will automatically set the filename of the plugin that generated the chart.
modulehas not default.
DIMENSION defines a new dimension for the chart
the template is:
DIMENSION id [name [algorithm [multiplier [divisor [options]]]]]
idof this dimension (it is a text value, not numeric), this will be needed later to add values to the dimension
We suggest to avoid using
.in dimension ids. Backends expect metrics to be
.separated and people will get confused if a dimension id contains a dot.
the name of the dimension as it will appear at the legend of the chart, if empty or missing the
idwill be used
the value is to drawn as-is (interpolated to second boundary), if
algorithmis empty, invalid or missing,
the value increases over time, the difference from the last value is presented in the chart, the server interpolates the value and calculates a per second figure
the % of this value compared to the total of all dimensions
the % of this value compared to the incremental total of all dimensions
an integer value to multiply the collected value, if empty or missing,
an integer value to divide the collected value, if empty or missing,
a space separated list of options, enclosed in quotes. Options supported:
obsoleteto mark a dimension as obsolete (Netdata will delete it after some time) and
hiddento make this dimension hidden, it will take part in the calculations but will not be presented in the chart.
VARIABLE [SCOPE] name = value
VARIABLE defines a variable that can be used in alarms. This is to used for setting constants (like the max connections a server may accept).
Variables support 2 scopes:
HOSTto define the variable at the host level.
CHARTto define the variable at the chart level. Use chart-local variables when the same variable may exist for different charts (i.e. Netdata monitors 2 mysql servers, and you need to set the
max_connectionseach server accepts). Using chart-local variables is the ideal to build alarm templates.
The position of the
VARIABLE line, sets its default scope (in case you do not specify a scope). So, defining a
VARIABLE before any
CHART, or between
BEGIN (outside any chart), sets
GLOBAL scope, while defining a
VARIABLE just after a
CHART or a
DIMENSION, or within the
END block of a chart, sets
These variables can be set and updated at any point.
Variable names should use alphanumeric characters, the
. and the
value is floating point (Netdata used
Variables are transferred to upstream Netdata servers (streaming and database replication).
data collection is defined as a series of
BEGIN type.id [microseconds]
is the unique identification of the chart (as given in
is the number of microseconds since the last update of the chart. It is optional.
Under heavy system load, the system may have some latency transferring data from the plugins to Netdata via the pipe. This number improves accuracy significantly, since the plugin is able to calculate the duration between its iterations better than Netdata.
The first time the plugin is started, no microseconds should be given to Netdata.
SET id = value
is the unique identification of the dimension (of the chart just began)
is the collected value, only integer values are collected. If you want to push fractional values, multiply this value by 100 or 1000 and set the
DIMENSIONdivider to 1000.
END does not take any parameters, it commits the collected values for all dimensions to the chart. If a dimensions was not
SET, its value will be empty for this commit.
SET lines may appear to update all the dimensions of the chart.
All of them in one
SET lines within a single
END block have to refer to the
If more charts need to be updated, each chart should have its own
If, for any reason, a plugin has issued a
BEGIN but wants to cancel it,
it can issue a
FLUSH command will instruct Netdata to ignore
all the values collected since the last
If a plugin does not behave properly (outputs invalid lines, or does not follow these guidelines), will be disabled by Netdata.
Netdata will collect any signed value in the 64bit range:
If a value is not collected, leave it empty, like this:
SET id =
or do not output the line at all.
python.d.plugin, there are many examples in the python.d directory
python is ideal for Netdata plugins. It is a simple, yet powerful way to collect data, it has a very small memory footprint, although it is not the most CPU efficient way to do it.
node.d.plugin, there are a few examples in the node.d directory
node.js is the fastest scripting language for collecting data. If your plugin needs to do a lot of work, compute values, etc, node.js is probably the best choice before moving to compiled code. Keep in mind though that node.js is not memory efficient; it will probably need more RAM compared to python.
charts.d.plugin, there are many examples in the charts.d directory
BASH is the simplest scripting language for collecting values. It is the less efficient though in terms of CPU resources. You can use it to collect data quickly, but extensive use of it might use a lot of system resources.
Of course, C is the most efficient way of collecting data. This is why Netdata itself is written in C.
Writing Plugins Properly
There are a few rules for writing plugins properly:
Respect system resources
Pay special attention to efficiency:
- Initialize everything once, at the beginning. Initialization is not an expensive operation. Your plugin will most probably be started once and run forever. So, do whatever heavy operation is needed at the beginning, just once.
- Do the absolutely minimum while iterating to collect values repeatedly.
- If you need to connect to another server to collect values, avoid re-connects if possible. Connect just once, with keep-alive (for HTTP) enabled and collect values using the same connection.
- Avoid any CPU or memory heavy operation while collecting data. If you control memory allocation, avoid any memory allocation while iterating to collect values.
- Avoid running external commands when possible. If you are writing shell scripts avoid especially pipes (each pipe is another fork, a very expensive operation).
The best way to iterate at a constant pace is this pseudo code:
Using the above procedure, your plugin will be synchronized to start data collection on steps of
update_every. There will be no need to keep track of latencies in data collection.
Netdata interpolates values to second boundaries, so even if your plugin is not perfectly aligned it does not matter. Netdata will find out. When your plugin works in increments of
update_every, there will be no gaps in the charts due to the possible cumulative micro-delays in data collection. Gaps will only appear if the data collection is really delayed.
If you are not sure of memory leaks, exit every one hour. Netdata will re-start your process.
If possible, try to autodetect if your plugin should be enabled, without any configuration.