X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fexamples%2Fmyplugin.c;h=f68cc1ac85c090792efa1bfe9433272327b378fa;hb=abfe65ffb5239060c0c9558d916bbeddee0bc86c;hp=cdd537a755327e94959a2808750f665a84d1bdc8;hpb=94105804a59bf3e2a5d4b1320550f8aad1a0c288;p=collectd.git diff --git a/contrib/examples/myplugin.c b/contrib/examples/myplugin.c index cdd537a7..f68cc1ac 100644 --- a/contrib/examples/myplugin.c +++ b/contrib/examples/myplugin.c @@ -59,6 +59,12 @@ static data_source_t dsrc[1] = * - name of the data set * - number of data sources * - list of data sources + * + * NOTE: If you're defining a custom data-set, you have to make that known to + * any servers as well. Else, the server is not able to store values using the + * type defined by that data-set. + * It is strongly recommended to use one of the types and data-sets + * pre-defined in the types.db file. */ static data_set_t ds = { @@ -92,14 +98,15 @@ static int my_read (void) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "myplugin"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "myplugin", sizeof (vl.plugin)); /* optionally set vl.plugin_instance and vl.type_instance to reasonable * values (default: "") */ /* 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 */ + * definition (it is strongly recommended to use a type defined in the + * types.db file) */ plugin_dispatch_values ("myplugin", &vl); /* A return value != 0 indicates an error and the plugin will be skipped