summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 91ccfb6)
raw | patch | inline | side by side (parent: 91ccfb6)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 27 Feb 2008 20:57:37 +0000 (21:57 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 27 Feb 2008 21:48:18 +0000 (22:48 +0100) |
This command flushes all cached data using plugin_flush_all(). An optional
timeout may be specified as an argument.
A new module "utils_cmd_flush" has been added for this purpose.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
timeout may be specified as an argument.
A new module "utils_cmd_flush" has been added for this purpose.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/Makefile.am | patch | blob | history | |
src/collectd-unixsock.pod | patch | blob | history | |
src/unixsock.c | patch | blob | history | |
src/utils_cmd_flush.c | [new file with mode: 0644] | patch | blob |
src/utils_cmd_flush.h | [new file with mode: 0644] | patch | blob |
diff --git a/src/Makefile.am b/src/Makefile.am
index 48a201367802a17919fb5b785d0d84366f42e97c..194e118a7bccd168a4a25ebf7acd8ddcef3e1d02 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
if BUILD_PLUGIN_UNIXSOCK
pkglib_LTLIBRARIES += unixsock.la
unixsock_la_SOURCES = unixsock.c \
+ utils_cmd_flush.h utils_cmd_flush.c \
utils_cmd_getval.h utils_cmd_getval.c \
utils_cmd_putval.h utils_cmd_putval.c \
utils_cmd_putnotif.h utils_cmd_putnotif.c
index d17852a79affe9d7f943c38069b2669fe1a39c50..a08a75da0ae9ed5f4d3c41c5dcde67309d103c86 100644 (file)
-> | PUTNOTIF type=temperature severity=warning time=1201094702 message=The roof is on fire!
<- | 0 Success
+=item B<FLUSH> [I<Timeout>]
+
+Flushes all cached data older than I<Timeout> seconds. If no timeout has been
+specified, it defaults to -1 which causes all data to be flushed.
+
+Example:
+ -> | FLUSH
+ <- | 0 Done
+
=back
=head2 Identifiers
diff --git a/src/unixsock.c b/src/unixsock.c
index 5f859b3fc8bdb3035b5d86b28df2ea0028446216..a7618c0f9a4a2d5366bb1548e931804a938a6147 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
#include "plugin.h"
#include "configfile.h"
+#include "utils_cmd_flush.h"
#include "utils_cmd_getval.h"
#include "utils_cmd_putval.h"
#include "utils_cmd_putnotif.h"
{
handle_putnotif (fh, fields, fields_num);
}
+ else if (strcasecmp (fields[0], "flush") == 0)
+ {
+ handle_flush (fh, fields, fields_num);
+ }
else
{
fprintf (fh, "-1 Unknown command: %s\n", fields[0]);
diff --git a/src/utils_cmd_flush.c b/src/utils_cmd_flush.c
--- /dev/null
+++ b/src/utils_cmd_flush.c
@@ -0,0 +1,52 @@
+/**
+ * collectd - src/utils_cmd_flush.c
+ * Copyright (C) 2008 Sebastian Harl
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Sebastian "tokkee" Harl <sh at tokkee.org>
+ **/
+
+#include "collectd.h"
+#include "plugin.h"
+
+int handle_flush (FILE *fh, char **fields, int fields_num)
+{
+ int timeout = -1;
+
+ if ((fields_num != 1) && (fields_num != 2))
+ {
+ DEBUG ("unixsock plugin: us_handle_flush: "
+ "Wrong number of fields: %i", fields_num);
+ fprintf (fh, "-1 Wrong number of fields: Got %i, expected 1 or 2.\n",
+ fields_num);
+ fflush (fh);
+ return (-1);
+ }
+
+ if (fields_num == 2)
+ timeout = atoi (fields[1]);
+
+ INFO ("unixsock plugin: flushing all data");
+ plugin_flush_all (timeout);
+ INFO ("unixsock plugin: finished flushing all data");
+
+ fprintf (fh, "0 Done\n");
+ fflush (fh);
+ return (0);
+} /* int handle_flush */
+
+/* vim: set sw=4 ts=4 tw=78 noexpandtab : */
+
diff --git a/src/utils_cmd_flush.h b/src/utils_cmd_flush.h
--- /dev/null
+++ b/src/utils_cmd_flush.h
@@ -0,0 +1,30 @@
+/**
+ * collectd - src/utils_cmd_flush.h
+ * Copyright (C) 2008 Sebastian Harl
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Sebastian "tokkee" Harl <sh at tokkee.org>
+ **/
+
+#ifndef UTILS_CMD_FLUSH_H
+#define UTILS_CMD_FLUSH_H 1
+
+int handle_flush (FILE *fh, char **fields, int fields_num);
+
+#endif /* UTILS_CMD_FLUSH_H */
+
+/* vim: set sw=4 ts=4 tw=78 noexpandtab : */
+