summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 47faf00)
raw | patch | inline | side by side (parent: 47faf00)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 13 May 2008 12:28:58 +0000 (14:28 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 13 May 2008 12:28:58 +0000 (14:28 +0200) |
Using something like
FLUSH plugin=rrdtool identifier=localhost/cpu-0/cpu-idle
will now only flush the local cpu-0/cpu-idle value, only using the rrdtool
plugin.
This is meant to be used in frontends which want to display up-to-date graphs
but there are too many hosts/rrd files to update them ``live'', i. e. without
caching.
FLUSH plugin=rrdtool identifier=localhost/cpu-0/cpu-idle
will now only flush the local cpu-0/cpu-idle value, only using the rrdtool
plugin.
This is meant to be used in frontends which want to display up-to-date graphs
but there are too many hosts/rrd files to update them ``live'', i. e. without
caching.
src/utils_cmd_flush.c | patch | blob | history |
diff --git a/src/utils_cmd_flush.c b/src/utils_cmd_flush.c
index 6fa8b7bf00b5d0b68979b4e828e1f7093e32f5dc..7feaac28c556b6a74b10af845082c7342926722f 100644 (file)
--- a/src/utils_cmd_flush.c
+++ b/src/utils_cmd_flush.c
return -1; \
}
+static int add_to_array (char ***array, int *array_num, char *value)
+{
+ char **temp;
+
+ temp = (char **) realloc (*array, sizeof (char *) * (*array_num + 1));
+ if (temp == NULL)
+ return (-1);
+
+ *array = temp;
+ (*array)[*array_num] = value;
+ (*array_num)++;
+
+ return (0);
+} /* int add_to_array */
+
int handle_flush (FILE *fh, char **fields, int fields_num)
{
int success = 0;
int error = 0;
int timeout = -1;
+ char **plugins = NULL;
+ int plugins_num = 0;
+ char **identifiers = NULL;
+ int identifiers_num = 0;
int i;
if (strncasecmp ("plugin=", option, strlen ("plugin=")) == 0)
{
- char *plugin = option + strlen ("plugin=");
+ char *plugin;
+
+ plugin = option + strlen ("plugin=");
+ add_to_array (&plugins, &plugins_num, plugin);
+ }
+ else if (strncasecmp ("identifier=", option, strlen ("identifier=")) == 0)
+ {
+ char *identifier;
- if (0 == plugin_flush_one (timeout, plugin))
- ++success;
- else
- ++error;
+ identifier = option + strlen ("identifier=");
+ add_to_array (&identifiers, &identifiers_num, identifier);
}
else if (strncasecmp ("timeout=", option, strlen ("timeout=")) == 0)
{
}
}
+ /* Add NULL entries for `any plugin' and/or `any value' if nothing was
+ * specified. */
+ if (plugins_num == 0)
+ add_to_array (&plugins, &plugins_num, NULL);
+
+ if (identifiers_num == 0)
+ add_to_array (&identifiers, &identifiers_num, NULL);
+
+ for (i = 0; i < plugins_num; i++)
+ {
+ char *plugin;
+ int j;
+
+ plugin = plugins[i];
+
+ for (j = 0; j < identifiers_num; j++)
+ {
+ char *identifier;
+ int status;
+
+ identifier = identifiers[j];
+ status = plugin_flush (plugin, timeout, identifier);
+ if (status == 0)
+ success++;
+ else
+ error++;
+ }
+ }
+
if ((success + error) > 0)
{
print_to_socket (fh, "0 Done: %i successful, %i errors\n",