X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftail.c;h=708cd2a32737e0a10678bc7d650c48c4c6029ba8;hb=d89829d22853ee0b7678b6e2ee7fdd359f3b7202;hp=20f2a9b47cdf380c4ff81100de2ae33cd3f72de6;hpb=639f00e946bb3182688661a99119aa5f5d6c81b6;p=collectd.git diff --git a/src/tail.c b/src/tail.c index 20f2a9b4..708cd2a3 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1,22 +1,27 @@ /** * collectd - src/tail.c - * Copyright (C) 2008 Florian octo Forster + * 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. + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: * - * 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. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. * * Authors: - * Florian octo Forster + * Florian octo Forster **/ #include "collectd.h" @@ -75,6 +80,10 @@ static int ctail_config_add_match_dstype (ctail_config_match_t *cm, cm->flags |= UTILS_MATCH_CF_GAUGE_MAX; else if (strcasecmp ("GaugeLast", ci->values[0].value.string) == 0) cm->flags |= UTILS_MATCH_CF_GAUGE_LAST; + else if (strcasecmp ("GaugeInc", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_GAUGE_INC; + else if (strcasecmp ("GaugeAdd", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_GAUGE_ADD; else cm->flags = 0; } @@ -215,7 +224,6 @@ static int ctail_config_add_file (oconfig_item_t *ci) cdtime_t interval = 0; char *plugin_instance = NULL; int num_matches = 0; - int status; int i; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) @@ -228,14 +236,14 @@ static int ctail_config_add_file (oconfig_item_t *ci) if (tm == NULL) { ERROR ("tail plugin: tail_match_create (%s) failed.", - ci->values[0].value.string); + ci->values[0].value.string); return (-1); } - status = 0; for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; + int status = 0; if (strcasecmp ("Instance", option->key) == 0) status = cf_util_get_string (option, &plugin_instance); @@ -245,7 +253,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) { status = ctail_config_add_match (tm, plugin_instance, option, interval); if (status == 0) - num_matches++; + num_matches++; /* Be mild with failed matches.. */ status = 0; } @@ -258,10 +266,12 @@ static int ctail_config_add_file (oconfig_item_t *ci) break; } /* for (i = 0; i < ci->children_num; i++) */ + sfree (plugin_instance); + if (num_matches == 0) { ERROR ("tail plugin: No (valid) matches found for file `%s'.", - ci->values[0].value.string); + ci->values[0].value.string); tail_match_destroy (tm); return (-1); } @@ -270,7 +280,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) cu_tail_match_t **temp; temp = (cu_tail_match_t **) realloc (tail_match_list, - sizeof (cu_tail_match_t *) * (tail_match_list_num + 1)); + sizeof (cu_tail_match_t *) * (tail_match_list_num + 1)); if (temp == NULL) { ERROR ("tail plugin: realloc failed."); @@ -333,6 +343,8 @@ static int ctail_init (void) return (-1); } + memset(&ud, '\0', sizeof(ud)); + for (i = 0; i < tail_match_list_num; i++) { ud.data = (void *)tail_match_list[i];