summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ef3517d)
raw | patch | inline | side by side (parent: ef3517d)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 8 Aug 2010 21:23:40 +0000 (23:23 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 8 Aug 2010 21:23:40 +0000 (23:23 +0200) |
src/collectdctl.c | patch | blob | history |
diff --git a/src/collectdctl.c b/src/collectdctl.c
index 6e53ddc12a7585f9c9ca4ce28ed36cd9b5176a7c..85ad198dc63435ff87a6885795063c1a638a1208 100644 (file)
--- a/src/collectdctl.c
+++ b/src/collectdctl.c
" * getval <identifier>\n"
" * flush [timeout=<seconds>] [plugin=<name>] [identifier=<id>]\n"
+ " * listval\n"
"\nIdentifiers:\n\n"
}
return 0;
+#undef BAIL_OUT
} /* flush */
+static int listval (lcc_connection_t *c, int argc, char **argv)
+{
+ lcc_identifier_t *ret_ident = NULL;
+ size_t ret_ident_num = 0;
+
+ int status;
+ size_t i;
+
+ assert (strcasecmp (argv[0], "listval") == 0);
+
+ if (argc != 1) {
+ fprintf (stderr, "ERROR: listval: Does not accept any arguments.\n");
+ return (-1);
+ }
+
+#define BAIL_OUT(s) \
+ do { \
+ if (ret_ident != NULL) \
+ free (ret_ident); \
+ ret_ident_num = 0; \
+ return (s); \
+ } while (0)
+
+ status = lcc_listval (c, &ret_ident, &ret_ident_num);
+ if (status != 0)
+ BAIL_OUT (status);
+
+ for (i = 0; i < ret_ident_num; ++i) {
+ char id[1024];
+
+ status = lcc_identifier_to_string (c, id, sizeof (id), ret_ident + i);
+ if (status != 0) {
+ fprintf (stderr, "ERROR: listval: Failed to convert returned "
+ "identifier to a string.\n");
+ continue;
+ }
+
+ printf ("%s\n", id);
+ }
+ BAIL_OUT (0);
+#undef BAIL_OUT
+} /* listval */
+
int main (int argc, char **argv) {
char address[1024] = "unix:"DEFAULT_SOCK;
status = getval (c, argc - optind, argv + optind);
else if (strcasecmp (argv[optind], "flush") == 0)
status = flush (c, argc - optind, argv + optind);
+ else if (strcasecmp (argv[optind], "listval") == 0)
+ status = listval (c, argc - optind, argv + optind);
else {
fprintf (stderr, "%s: invalid command: %s\n", argv[0], argv[optind]);
return (1);