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;
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)
status = parse_identifier (str_copy, &host,
&plugin, &plugin_instance,
- &type, &type_instance);
+ &type, &type_instance,
+ /* default_host = */ NULL);
if (status != 0)
return (status);
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);
int parse_identifier_vl (const char *str, value_list_t *vl);
int parse_value (const char *value, value_t *ret_value, int ds_type);
int parse_values (char *buffer, value_list_t *vl, const data_set_t *ds);
ret_flush->identifiers_num++;
if (parse_identifier (opt_value,
&id->host, &id->plugin, &id->plugin_instance,
- &id->type, &id->type_instance) != 0)
+ &id->type, &id->type_instance,
+ NULL) != 0)
{
cmd_error (CMD_PARSE_ERROR, err,
"Invalid identifier `%s'.", opt_value);
status = parse_identifier (identifier_copy, &host,
&plugin, &plugin_instance,
- &type, &type_instance);
+ &type, &type_instance,
+ /* default_host = */ NULL);
if (status != 0)
{
DEBUG ("handle_getthreshold: Cannot parse identifier `%s'.", identifier);
status = parse_identifier (argv[0], &ret_getval->identifier.host,
&ret_getval->identifier.plugin, &ret_getval->identifier.plugin_instance,
- &ret_getval->identifier.type, &ret_getval->identifier.type_instance);
+ &ret_getval->identifier.type, &ret_getval->identifier.type_instance,
+ NULL);
if (status != 0)
{
DEBUG ("cmd_parse_getval: Cannot parse identifier `%s'.", identifier_copy);
status = parse_identifier (identifier, &hostname,
&plugin, &plugin_instance,
- &type, &type_instance);
+ &type, &type_instance,
+ NULL);
if (status != 0)
{
DEBUG ("cmd_handle_putval: Cannot parse identifier `%s'.",