View Source Crow.Plugin behaviour (crow v0.1.4)

The behaviour all configured plugins should implement.

overview

Overview

Writing Munin plugins is rather simple. A trivial plugin with the default Munin node setup is a script with two main behaviours:

  • When invoked with the command line argument config, print out configuration of the plugin, such as graph setup (title, category, labels), field information and more. A full description of all options can be found at the Plugin reference documentation.

  • When not invoked with any command line argument, print out the values for fields declared in the config command.

This is the foundation from which plugins are developed. Since our node runs in the BEAM, we've taken a different approach here. Instead of being executable shell scripts, crow plugins are modules which provide two main functions:

  • config/0, which returns the configuration of the plugin, corresponding to the first invocation form described above.

  • values/0, which returns the values of the plugin, corresponding to the second invocation form described above.

Instead of printing to standard output, these return a list of charlists which is then sent to the peer via TCP.

An additional callback, name/0, specifies the name of the plugin shown to Munin. This must be unique amongst all plugins configured on the node.

community-plugins

Community plugins

Plugins for the crow node can be found in the crow_plugins repository.

Link to this section Summary

Callbacks

Display the configuration for this plugin.

Return the name of the plugin displayed to peers.

Display values for this plugin.

Link to this section Callbacks

@callback config() :: [charlist()]

Display the configuration for this plugin.

Each element in the output represents a single line in the output. Adding newlines to each line is done by the worker.

For reference, see Munin plugin config command from the official documentation.

example

Example

def config do
  [
    'graph_title Total processes',
    'graph_category BEAM',
    'graph_vlabel processes',
    'processes.label processes'
  ]
end
@callback name() :: charlist()

Return the name of the plugin displayed to peers.

example

Example

def name do
  'my_plugin'
end
@callback values() :: [charlist()]

Display values for this plugin.

example

Example

def values do
  [
    'processes.value #{length(:erlang.processes())}'
  ]
end