X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Ftable.c;h=d798820763f96335a204bcc2afb7a6d3536e508d;hp=eb18660cb82a7732a8c52af58d9a6b40f63b3a39;hb=1159cb5d383c55a80a0db100b8f7aadcf44740a5;hpb=6d63f6e9834c838e0a6469d9eaf17feffa3b2959 diff --git a/src/table.c b/src/table.c index eb18660c..d7988207 100644 --- a/src/table.c +++ b/src/table.c @@ -55,6 +55,7 @@ typedef struct { typedef struct { char *file; char *sep; + char *plugin_name; char *instance; tbl_result_t *results; @@ -96,6 +97,7 @@ static void tbl_result_clear(tbl_result_t *res) { static void tbl_setup(tbl_t *tbl, char *file) { tbl->file = sstrdup(file); tbl->sep = NULL; + tbl->plugin_name = NULL; tbl->instance = NULL; tbl->results = NULL; @@ -111,6 +113,7 @@ static void tbl_clear(tbl_t *tbl) { sfree(tbl->file); sfree(tbl->sep); + sfree(tbl->plugin_name); sfree(tbl->instance); /* (tbl->results == NULL) -> (tbl->results_num == 0) */ @@ -257,6 +260,8 @@ static int tbl_config_table(oconfig_item_t *ci) { if (0 == strcasecmp(c->key, "Separator")) tbl_config_set_s(c->key, &tbl->sep, c); + else if (0 == strcasecmp(c->key, "Plugin")) + tbl_config_set_s(c->key, &tbl->plugin_name, c); else if (0 == strcasecmp(c->key, "Instance")) tbl_config_set_s(c->key, &tbl->instance, c); else if (0 == strcasecmp(c->key, "Result")) @@ -371,7 +376,8 @@ static int tbl_result_dispatch(tbl_t *tbl, tbl_result_t *res, char **fields, vl.values = values; vl.values_len = STATIC_ARRAY_SIZE(values); - sstrncpy(vl.plugin, "table", sizeof(vl.plugin)); + sstrncpy(vl.plugin, (tbl->plugin_name != NULL) ? tbl->plugin_name : "table", + sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, tbl->instance, sizeof(vl.plugin_instance)); sstrncpy(vl.type, res->type, sizeof(vl.type)); @@ -524,5 +530,3 @@ void module_register(void) { plugin_register_complex_config("table", tbl_config); plugin_register_init("table", tbl_init); } /* module_register */ - -/* vim: set sw=4 ts=4 tw=78 noexpandtab : */