Code

check_disk: rerpopulate the mount list after doing a stat() on paths specified with...
[nagiosplug.git] / lib / utils_base.h
1 #ifndef _UTILS_BASE_
2 #define _UTILS_BASE_
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 */
15 #define OUTSIDE 0
16 #define INSIDE  1
18 typedef struct range_struct {
19         double  start;
20         int     start_infinity;         /* FALSE (default) or TRUE */
21         double  end;
22         int     end_infinity;
23         int     alert_on;               /* OUTSIDE (default) or INSIDE */
24         } range;
26 typedef struct thresholds_struct {
27         range   *warning;
28         range   *critical;
29         } thresholds;
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 char *np_escaped_string (const char *);
40 void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
42 /* Return codes for _set_thresholds */
43 #define NP_RANGE_UNPARSEABLE 1
44 #define NP_WARN_WITHIN_CRIT 2
46 /* a simple check to see if we're running as root.  
47  * returns zero on failure, nonzero on success */
48 int np_check_if_root(void);
49 /* and a helpful wrapper around that.  it returns the same status
50  * code from the above function, in case it's helpful for testing */
51 int np_warn_if_not_root(void);
53 #endif /* _UTILS_BASE_ */