X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Futils_cmd_listval.c;fp=src%2Futils_cmd_listval.c;h=644a67ccc8ee55b688c368f90642426fdf38d2fd;hb=bf46dad7cb3402921a2fb96b5194783ab12b3dc6;hp=0000000000000000000000000000000000000000;hpb=4aefb22f96c9bf9f63a9fb8dd6e7f6c33bc2a0d5;p=collectd.git diff --git a/src/utils_cmd_listval.c b/src/utils_cmd_listval.c new file mode 100644 index 00000000..644a67cc --- /dev/null +++ b/src/utils_cmd_listval.c @@ -0,0 +1,64 @@ +/** + * collectd - src/utils_cms_listval.c + * Copyright (C) 2008 Florian octo Forster + * + * 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: + * Florian octo Forster + **/ + +#include "collectd.h" +#include "common.h" +#include "plugin.h" + +#include "utils_cmd_listval.h" +#include "utils_cache.h" + +int handle_listval (FILE *fh, char **fields, int fields_num) +{ + char **names = NULL; + time_t *times = NULL; + size_t number = 0; + size_t i; + int status; + + if (fields_num != 1) + { + DEBUG ("command listval: us_handle_listval: Wrong number of fields: %i", + fields_num); + fprintf (fh, "-1 Wrong number of fields: Got %i, expected 1.\n", + fields_num); + fflush (fh); + return (-1); + } + + status = uc_get_names (&names, ×, &number); + if (status != 0) + { + DEBUG ("command listval: uc_get_names failed with status %i", status); + fprintf (fh, "-1 uc_get_names failed.\n"); + fflush (fh); + return (-1); + } + + fprintf (fh, "%i Values found\n", (int) number); + for (i = 0; i < number; i++) + fprintf (fh, "%u %s\n", (unsigned int) times[i], names[i]); + fflush (fh); + + return (0); +} /* int handle_listval */ + +/* vim: set sw=2 sts=2 ts=8 : */