56e74eabac3400d729df19d80ed7636157ede56b
1 /**
2 * collectd - src/utils_complain.h
3 * Copyright (C) 2006-2007 Florian octo Forster
4 * Copyright (C) 2008 Sebastian tokkee Harl
5 *
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.
9 *
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.
14 *
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
18 *
19 * Authors:
20 * Florian octo Forster <octo at verplant.org>
21 * Sebastian tokkee Harl <sh at tokkee.org>
22 **/
24 #ifndef UTILS_COMPLAIN_H
25 #define UTILS_COMPLAIN_H 1
27 #include <time.h>
29 typedef struct
30 {
31 /* time of the last report */
32 time_t last;
34 /* how long to wait until reporting again
35 * 0 indicates that the complaint is no longer valid
36 * < 0 indicates that the complaint has been reported once
37 * => c_complain_once will not report again
38 * => c_complain uses the absolute value to reset the old value */
39 int interval;
40 } c_complain_t;
42 #define C_COMPLAIN_INIT { 0, 0 }
44 /*
45 * NAME
46 * c_complain
47 *
48 * DESCRIPTION
49 * Complain about something. This function will report a message (usually
50 * indicating some error condition) using the collectd logging mechanism.
51 * When this function is called again, reporting the message again will be
52 * deferred by an increasing interval (up to one day) to prevent flooding
53 * the logs. A call to `c_release' resets the counter.
54 *
55 * PARAMETERS
56 * `level' The log level passed to `plugin_log'.
57 * `c' Identifier for the complaint.
58 * `format' Message format - see the documentation of printf(3).
59 */
60 void c_complain (int level, c_complain_t *c, const char *format, ...);
62 /*
63 * NAME
64 * c_complain_once
65 *
66 * DESCRIPTION
67 * Complain about something once. This function will not report anything
68 * again, unless `c_release' has been called in between. If used after some
69 * calls to `c_complain', it will report again on the next interval and stop
70 * after that.
71 *
72 * See `c_complain' for further details and a description of the parameters.
73 */
74 void c_complain_once (int level, c_complain_t *c, const char *format, ...);
76 /*
77 * NAME
78 * c_release
79 *
80 * DESCRIPTION
81 * Release a complaint. This will report a message once, marking the
82 * complaint as released.
83 *
84 * See `c_complain' for a description of the parameters.
85 */
86 void c_release (int level, c_complain_t *c, const char *format, ...);
88 #endif /* UTILS_COMPLAIN_H */
90 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */