summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.h
diff options
context:
space:
mode:
authorHolger Weiss <hweiss@users.sourceforge.net>2009-04-21 22:28:53 (GMT)
committerHolger Weiss <hweiss@users.sourceforge.net>2009-05-10 11:37:35 (GMT)
commit006597a12d28d9cd752b3eeb56dff3bc97049f4c (patch)
tree26e322d4b996b901e0d928e11bba46658646b30f /lib/utils_base.h
parentdd52d7e5e7acfd42243bc1ce173a0bf5d62fe347 (diff)
downloadmonitoring-plugins-006597a12d28d9cd752b3eeb56dff3bc97049f4c.tar.gz
Make C plugin output format configurablehw/output/functions
The development guidelines¹ currently state that the plugin output should be in the format "SERVICE STATUS: Information text". However, the SERVICE and STATUS information is redundant, as the plugin caller (e.g., Nagios) should know which SERVICE is checked and the STATUS is returned via the plugin's exit code. After discussing² this issue on the development list, we decided to make the plugin output configurable at compile time (separately for "normal" and "verbose" output). ¹ http://nagiosplug.sf.net/developer-guidelines.html ² http://thread.gmane.org/gmane.network.nagios.plugins.devel/5155 Signed-off-by: Holger Weiss <hweiss@users.sourceforge.net>
Diffstat (limited to 'lib/utils_base.h')
-rw-r--r--lib/utils_base.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/utils_base.h b/lib/utils_base.h
index f40fdb0..8d0b212 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -37,6 +37,23 @@ int get_status(double, thresholds *);
37 37
38char *np_escaped_string (const char *); 38char *np_escaped_string (const char *);
39 39
40void np_set_output(const char *, const char *, int, int);
41int np_adjust_verbosity(int);
42void np_debug(int, const char *, ...)
43 __attribute__((format(printf, 2, 3)));
44void np_verbose(const char *, ...)
45 __attribute__((format(printf, 1, 2)));
46void np_die(int, const char *, ...)
47 __attribute__((noreturn, format(printf, 2, 3)));
48
49#define np_verbatim(s) np_verbose("%s", s)
50#define np_increase_verbosity(i) np_adjust_verbosity(i)
51#define np_decrease_verbosity(i) np_adjust_verbosity(-i)
52#define np_get_verbosity() np_adjust_verbosity(0)
53#define np_set_verbosity(v) np_set_output(NULL, NULL, v, 0)
54#define np_set_mynames(p, s) np_set_output(p, s, -2, 0)
55
56/* TODO: die() can be removed as soon as all plugins use np_die() instead. */
40void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3))); 57void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
41 58
42/* Return codes for _set_thresholds */ 59/* Return codes for _set_thresholds */
@@ -64,4 +81,7 @@ char *np_extract_value(const char*, const char*, char);
64 */ 81 */
65#define np_extract_ntpvar(l, n) np_extract_value(l, n, ',') 82#define np_extract_ntpvar(l, n) np_extract_value(l, n, ',')
66 83
84/* Given a numerical status, return a pointer to the according string. */
85const char *state_text(int);
86
67#endif /* _UTILS_BASE_ */ 87#endif /* _UTILS_BASE_ */