X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Futils_complain.c;h=6193614940e34570265cff661c9517f38b349318;hp=d5c099647bb84b484d7a7c89c3b2f8113f1be60d;hb=633c3966f770e4d46651a2fe219a18d8a9907a9f;hpb=ec404735b0676bb44fdba10f3760e1ba9632405a diff --git a/src/utils_complain.c b/src/utils_complain.c index d5c09964..61936149 100644 --- a/src/utils_complain.c +++ b/src/utils_complain.c @@ -1,23 +1,28 @@ /** * collectd - src/utils_complain.c - * Copyright (C) 2006-2007 Florian octo Forster - * Copyright (C) 2008 Sebastian tokkee Harl + * Copyright (C) 2006-2013 Florian octo Forster + * Copyright (C) 2008 Sebastian tokkee 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. + * 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 * Sebastian tokkee Harl **/ @@ -29,28 +34,28 @@ static int vcomplain (int level, c_complain_t *c, const char *format, va_list ap) { - time_t now; + cdtime_t now; char message[512]; - now = time (NULL); + now = cdtime (); if (c->last + c->interval > now) return 0; c->last = now; - if (c->interval < interval_g) - c->interval = interval_g; + if (c->interval < plugin_get_interval ()) + c->interval = plugin_get_interval (); else c->interval *= 2; - if (c->interval > 86400) - c->interval = 86400; + if (c->interval > TIME_T_TO_CDTIME_T (86400)) + c->interval = TIME_T_TO_CDTIME_T (86400); vsnprintf (message, sizeof (message), format, ap); message[sizeof (message) - 1] = '\0'; - plugin_log (level, message); + plugin_log (level, "%s", message); return 1; } /* vcomplain */ @@ -58,12 +63,9 @@ void c_complain (int level, c_complain_t *c, const char *format, ...) { va_list ap; - /* reset the old interval */ - if (c->interval < 0) - c->interval *= -1; - va_start (ap, format); - vcomplain (level, c, format, ap); + if (vcomplain (level, c, format, ap)) + c->complained_once = 1; va_end (ap); } /* c_complain */ @@ -71,12 +73,12 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...) { va_list ap; - if (c->interval < 0) + if (c->complained_once) return; va_start (ap, format); if (vcomplain (level, c, format, ap)) - c->interval *= -1; + c->complained_once = 1; va_end (ap); } /* c_complain_once */ @@ -89,13 +91,14 @@ void c_do_release (int level, c_complain_t *c, const char *format, ...) return; c->interval = 0; + c->complained_once = 0; va_start (ap, format); vsnprintf (message, sizeof (message), format, ap); message[sizeof (message) - 1] = '\0'; va_end (ap); - plugin_log (level, message); + plugin_log (level, "%s", message); } /* c_release */ /* vim: set sw=4 ts=4 tw=78 noexpandtab : */