projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-4.3'
[collectd.git]
/
src
/
utils_cmd_getval.c
diff --git
a/src/utils_cmd_getval.c
b/src/utils_cmd_getval.c
index
a4edf4f
..
f110196
100644
(file)
--- a/
src/utils_cmd_getval.c
+++ b/
src/utils_cmd_getval.c
@@
-35,6
+35,8
@@
int handle_getval (FILE *fh, char **fields, int fields_num)
gauge_t *values;
size_t values_num;
gauge_t *values;
size_t values_num;
+ char *identifier_copy;
+
const data_set_t *ds;
int status;
const data_set_t *ds;
int status;
@@
-52,12
+54,16
@@
int handle_getval (FILE *fh, char **fields, int fields_num)
if (strlen (fields[1]) < strlen ("h/p/t"))
{
if (strlen (fields[1]) < strlen ("h/p/t"))
{
- fprintf (fh, "-1 Invalied identifier, %s", fields[1]);
+ fprintf (fh, "-1 Invalied identifier, %s
\n
", fields[1]);
fflush (fh);
return (-1);
}
fflush (fh);
return (-1);
}
- status = parse_identifier (fields[1], &hostname,
+ /* parse_identifier() modifies its first argument,
+ * returning pointers into it */
+ identifier_copy = sstrdup (fields[1]);
+
+ status = parse_identifier (identifier_copy, &hostname,
&plugin, &plugin_instance,
&type, &type_instance);
if (status != 0)
&plugin, &plugin_instance,
&type, &type_instance);
if (status != 0)
@@
-65,6
+71,7
@@
int handle_getval (FILE *fh, char **fields, int fields_num)
DEBUG ("unixsock plugin: Cannot parse `%s'", fields[1]);
fprintf (fh, "-1 Cannot parse identifier.\n");
fflush (fh);
DEBUG ("unixsock plugin: Cannot parse `%s'", fields[1]);
fprintf (fh, "-1 Cannot parse identifier.\n");
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
return (-1);
}
@@
-74,6
+81,7
@@
int handle_getval (FILE *fh, char **fields, int fields_num)
DEBUG ("unixsock plugin: plugin_get_ds (%s) == NULL;", type);
fprintf (fh, "-1 Type `%s' is unknown.\n", type);
fflush (fh);
DEBUG ("unixsock plugin: plugin_get_ds (%s) == NULL;", type);
fprintf (fh, "-1 Type `%s' is unknown.\n", type);
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
return (-1);
}
@@
-82,8
+90,9
@@
int handle_getval (FILE *fh, char **fields, int fields_num)
status = uc_get_rate_by_name (fields[1], &values, &values_num);
if (status != 0)
{
status = uc_get_rate_by_name (fields[1], &values, &values_num);
if (status != 0)
{
- fprintf (fh, "-1 No such value");
+ fprintf (fh, "-1 No such value
\n
");
fflush (fh);
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
return (-1);
}
@@
-95,23
+104,24
@@
int handle_getval (FILE *fh, char **fields, int fields_num)
fprintf (fh, "-1 Error reading value from cache.\n");
fflush (fh);
sfree (values);
fprintf (fh, "-1 Error reading value from cache.\n");
fflush (fh);
sfree (values);
+ sfree (identifier_copy);
return (-1);
}
return (-1);
}
- fprintf (fh, "%u", (unsigned int) values_num);
+ fprintf (fh, "%u Value%s found\n", (unsigned int) values_num,
+ (values_num == 1) ? "" : "s");
for (i = 0; i < values_num; i++)
{
for (i = 0; i < values_num; i++)
{
- fprintf (fh, "
%s=", ds->ds[i].name);
+ fprintf (fh, "%s=", ds->ds[i].name);
if (isnan (values[i]))
if (isnan (values[i]))
- fprintf (fh, "NaN");
+ fprintf (fh, "NaN
\n
");
else
else
- fprintf (fh, "%12e", values[i]);
+ fprintf (fh, "%12e
\n
", values[i]);
}
}
-
- fprintf (fh, "\n");
fflush (fh);
sfree (values);
fflush (fh);
sfree (values);
+ sfree (identifier_copy);
return (0);
} /* int handle_getval */
return (0);
} /* int handle_getval */