From: Pierre-Yves Ritschard Date: Tue, 29 Jul 2014 20:05:40 +0000 (+0200) Subject: Merge pull request #673 from deferraz/master X-Git-Tag: collectd-5.5.0~249 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=de21923bcdbd01827f445eb1f573778b7bfa5202;hp=-c Merge pull request #673 from deferraz/master Including DStypes GaugeInc and GaugeAdd for tail plugin --- de21923bcdbd01827f445eb1f573778b7bfa5202 diff --combined src/tail.c index d5166b2a,b2d52268..ab063389 --- a/src/tail.c +++ b/src/tail.c @@@ -1,27 -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" @@@ -80,6 -75,10 +80,10 @@@ static int ctail_config_add_match_dstyp 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; } diff --combined src/utils_match.c index 8e9b32c3,44eaece2..b024c69b --- a/src/utils_match.c +++ b/src/utils_match.c @@@ -1,27 -1,23 +1,27 @@@ /** * collectd - src/utils_match.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; either version 2 of the License, or (at your - * option) any later version. + * 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" @@@ -84,6 -80,13 +84,13 @@@ static int default_callback (const cha gauge_t value; char *endptr = NULL; + if (data->ds_type & UTILS_MATCH_CF_GAUGE_INC) + { + data->value.gauge = isnan (data->value.gauge) ? 1 : data->value.gauge + 1; + data->values_num++; + return(0); + } + if (matches_num < 2) return (-1); @@@ -112,6 -115,10 +119,10 @@@ if (data->value.gauge < value) data->value.gauge = value; } + else if (data->ds_type & UTILS_MATCH_CF_GAUGE_ADD) + { + data->value.gauge += value; + } else { ERROR ("utils_match: default_callback: obj->ds_type is invalid!"); diff --combined src/utils_match.h index 6ffd9574,a30eb447..705a609e --- a/src/utils_match.h +++ b/src/utils_match.h @@@ -1,27 -1,23 +1,27 @@@ /** * collectd - src/utils_match.h - * 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; either version 2 of the License, or (at your - * option) any later version. + * 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 **/ #ifndef UTILS_MATCH_H @@@ -30,17 -26,22 +30,22 @@@ #include "plugin.h" /* - * Defines + * Each type may have 12 sub-types + * 0x1000 = 1000000000000 + * ^ <- Type bit + * ^^^^^^^^^^^^ <- Subtype bits */ - #define UTILS_MATCH_DS_TYPE_GAUGE 0x10 - #define UTILS_MATCH_DS_TYPE_COUNTER 0x20 - #define UTILS_MATCH_DS_TYPE_DERIVE 0x40 - #define UTILS_MATCH_DS_TYPE_ABSOLUTE 0x80 + #define UTILS_MATCH_DS_TYPE_GAUGE 0x1000 + #define UTILS_MATCH_DS_TYPE_COUNTER 0x2000 + #define UTILS_MATCH_DS_TYPE_DERIVE 0x4000 + #define UTILS_MATCH_DS_TYPE_ABSOLUTE 0x8000 #define UTILS_MATCH_CF_GAUGE_AVERAGE 0x01 #define UTILS_MATCH_CF_GAUGE_MIN 0x02 #define UTILS_MATCH_CF_GAUGE_MAX 0x04 #define UTILS_MATCH_CF_GAUGE_LAST 0x08 + #define UTILS_MATCH_CF_GAUGE_INC 0x10 + #define UTILS_MATCH_CF_GAUGE_ADD 0x20 #define UTILS_MATCH_CF_COUNTER_SET 0x01 #define UTILS_MATCH_CF_COUNTER_ADD 0x02