3 /* Header file for nagios plugins utils_base.c */
5 /* This file holds header information for thresholds - use this in preference to
6 individual plugin logic */
8 /* This has not been merged with utils.h because of problems with
9 timeout_interval when other utils_*.h files use utils.h */
11 /* Long term, add new functions to utils_base.h for common routines
12 and utils_*.h for specific to plugin routines. If routines are
13 placed in utils_*.h, then these can be tested with libtap */
18 typedef struct range_struct
{
20 int start_infinity
; /* FALSE (default) or TRUE */
23 int alert_on
; /* OUTSIDE (default) or INSIDE */
26 typedef struct thresholds_struct
{
31 range
*parse_range_string (char *);
32 int _set_thresholds(thresholds
**, char *, char *);
33 void set_thresholds(thresholds
**, char *, char *);
34 void print_thresholds(const char *, thresholds
*);
35 int check_range(double, range
*);
36 int get_status(double, thresholds
*);
38 /* All possible characters in a threshold range */
39 #define NP_THRESHOLDS_CHARS "0123456789.:@~"
41 char *np_escaped_string (const char *);
43 void die (int, const char *, ...) __attribute__((noreturn
,format(printf
, 2, 3)));
45 /* Return codes for _set_thresholds */
46 #define NP_RANGE_UNPARSEABLE 1
47 #define NP_WARN_WITHIN_CRIT 2
49 /* a simple check to see if we're running as root.
50 * returns zero on failure, nonzero on success */
51 int np_check_if_root(void);
52 /* and a helpful wrapper around that. it returns the same status
53 * code from the above function, in case it's helpful for testing */
54 int np_warn_if_not_root(void);
57 * Extract the value from key/value pairs, or return NULL. The value returned
59 * This function can be used to parse NTP control packet data and performance
62 char *np_extract_value(const char*, const char*, char);
65 * Same as np_extract_value with separator suitable for NTP control packet
68 #define np_extract_ntpvar(l, n) np_extract_value(l, n, ',')
70 #endif /* _UTILS_BASE_ */