2 * collectd - src/utils_complain.c
3 * Copyright (C) 2006-2007 Florian octo Forster
4 * Copyright (C) 2008 Sebastian tokkee Harl
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; only version 2 of the License is applicable.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Florian octo Forster <octo at verplant.org>
21 * Sebastian tokkee Harl <sh at tokkee.org>
25 #include "utils_complain.h"
28 /* vcomplain returns 0 if it did not report, 1 else */
29 static int vcomplain (int level, c_complain_t *c,
30 const char *format, va_list ap)
37 if (c->last + c->interval > now)
42 if (c->interval < interval_g)
43 c->interval = interval_g;
47 if (c->interval > 86400)
50 vsnprintf (message, sizeof (message), format, ap);
51 message[sizeof (message) - 1] = '\0';
53 plugin_log (level, "%s", message);
57 void c_complain (int level, c_complain_t *c, const char *format, ...)
61 /* reset the old interval */
65 va_start (ap, format);
66 vcomplain (level, c, format, ap);
70 void c_complain_once (int level, c_complain_t *c, const char *format, ...)
77 va_start (ap, format);
78 if (vcomplain (level, c, format, ap))
81 } /* c_complain_once */
83 void c_do_release (int level, c_complain_t *c, const char *format, ...)
93 va_start (ap, format);
94 vsnprintf (message, sizeof (message), format, ap);
95 message[sizeof (message) - 1] = '\0';
98 plugin_log (level, "%s", message);
101 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */