summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d82efb9)
raw | patch | inline | side by side (parent: d82efb9)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 23 Nov 2009 20:45:33 +0000 (21:45 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 23 Nov 2009 20:46:36 +0000 (21:46 +0100) |
contrib/examples/MyPlugin.pm | patch | blob | history |
index 13806ee91157fc1592b220b5191b192907ab264c..b1a8a6d8ff3cb2487a1bd5c29de6f0c29336a6ee 100644 (file)
# This code is executed after loading the plugin to register it with collectd.
plugin_register (TYPE_LOG, 'myplugin', 'my_log');
plugin_register (TYPE_NOTIF, 'myplugin', 'my_notify');
-plugin_register (TYPE_DATASET, 'myplugin', $dataset);
+plugin_register (TYPE_DATASET, 'mytype', $dataset);
plugin_register (TYPE_INIT, 'myplugin', 'my_init');
plugin_register (TYPE_READ, 'myplugin', 'my_read');
plugin_register (TYPE_WRITE, 'myplugin', 'my_write');
# do the magic to read the data:
# the number of values has to match the number of data sources defined in
- # the registered data set
+ # the registered data set. The type used here (in this example:
+ # "mytype") must be defined in the types.db, see types.db(5) for
+ # details, or registered as "TYPE_DATASET".
$vl->{'values'} = [ rand(65535) ];
$vl->{'plugin'} = 'myplugin';
+ $vl->{'type'} = 'mytype';
# any other elements are optional
# dispatch the values to collectd which passes them on to all registered
- # write functions - the first argument is used to lookup the data set
- # definition (it is strongly recommended to use a type defined in the
- # types.db file)
- plugin_dispatch_values ('myplugin', $vl);
+ # write functions
+ plugin_dispatch_values ($vl);
# A false return value indicates an error and the plugin will be skipped
# for an increasing amount of time.