diff options
author | Holger Weiss <hweiss@users.sourceforge.net> | 2009-04-22 00:28:53 +0200 |
---|---|---|
committer | Holger Weiss <hweiss@users.sourceforge.net> | 2009-05-10 13:37:35 +0200 |
commit | 006597a12d28d9cd752b3eeb56dff3bc97049f4c (patch) | |
tree | 26e322d4b996b901e0d928e11bba46658646b30f /lib/utils_base.h | |
parent | dd52d7e5e7acfd42243bc1ce173a0bf5d62fe347 (diff) | |
download | monitoring-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.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/utils_base.h b/lib/utils_base.h index f40fdb0f..8d0b2124 100644 --- a/lib/utils_base.h +++ b/lib/utils_base.h | |||
@@ -37,6 +37,23 @@ int get_status(double, thresholds *); | |||
37 | 37 | ||
38 | char *np_escaped_string (const char *); | 38 | char *np_escaped_string (const char *); |
39 | 39 | ||
40 | void np_set_output(const char *, const char *, int, int); | ||
41 | int np_adjust_verbosity(int); | ||
42 | void np_debug(int, const char *, ...) | ||
43 | __attribute__((format(printf, 2, 3))); | ||
44 | void np_verbose(const char *, ...) | ||
45 | __attribute__((format(printf, 1, 2))); | ||
46 | void 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. */ | ||
40 | void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3))); | 57 | void 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. */ | ||
85 | const char *state_text(int); | ||
86 | |||
67 | #endif /* _UTILS_BASE_ */ | 87 | #endif /* _UTILS_BASE_ */ |