X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fcommon.c;h=3d1420d62da20c5d5b8f1b02ed1f1acfa719f529;hb=92860d61218a3da1e9b74a2fad37e9df88df8ce8;hp=c80abcbee65cb1e95a8ef14dc065d7082f83c4c2;hpb=1e5687027549c68ecb29f33822501f6976debd5f;p=collectd.git diff --git a/src/daemon/common.c b/src/daemon/common.c index c80abcbe..3d1420d6 100644 --- a/src/daemon/common.c +++ b/src/daemon/common.c @@ -1016,7 +1016,8 @@ int format_values (char *ret, size_t ret_len, /* {{{ */ int parse_identifier (char *str, char **ret_host, char **ret_plugin, char **ret_plugin_instance, - char **ret_type, char **ret_type_instance) + char **ret_type, char **ret_type_instance, + char *default_host) { char *hostname = NULL; char *plugin = NULL; @@ -1035,8 +1036,19 @@ int parse_identifier (char *str, char **ret_host, type = strchr (plugin, '/'); if (type == NULL) - return (-1); - *type = '\0'; type++; + { + if (default_host == NULL) + return (-1); + /* else: no host specified; use default */ + type = plugin; + plugin = hostname; + hostname = default_host; + } + else + { + *type = '\0'; + type++; + } plugin_instance = strchr (plugin, '-'); if (plugin_instance != NULL) @@ -1077,7 +1089,8 @@ int parse_identifier_vl (const char *str, value_list_t *vl) /* {{{ */ status = parse_identifier (str_copy, &host, &plugin, &plugin_instance, - &type, &type_instance); + &type, &type_instance, + /* default_host = */ NULL); if (status != 0) return (status);