utils_base.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _UTILS_BASE_
  2. #define _UTILS_BASE_
  3. /* Header file for nagios plugins utils_base.c */
  4. /* This file holds header information for thresholds - use this in preference to
  5. individual plugin logic */
  6. /* This has not been merged with utils.h because of problems with
  7. timeout_interval when other utils_*.h files use utils.h */
  8. /* Long term, add new functions to utils_base.h for common routines
  9. and utils_*.h for specific to plugin routines. If routines are
  10. placed in utils_*.h, then these can be tested with libtap */
  11. #define OUTSIDE 0
  12. #define INSIDE 1
  13. typedef struct range_struct {
  14. double start;
  15. int start_infinity; /* FALSE (default) or TRUE */
  16. double end;
  17. int end_infinity;
  18. int alert_on; /* OUTSIDE (default) or INSIDE */
  19. } range;
  20. typedef struct thresholds_struct {
  21. range *warning;
  22. range *critical;
  23. } thresholds;
  24. range *parse_range_string (char *);
  25. int _set_thresholds(thresholds **, char *, char *);
  26. void set_thresholds(thresholds **, char *, char *);
  27. int check_range(double, range *);
  28. int get_status(double, thresholds *);
  29. char *np_escaped_string (const char *);
  30. void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
  31. /* Return codes for _set_thresholds */
  32. #define NP_RANGE_UNPARSEABLE 1
  33. #define NP_WARN_WITHIN_CRIT 2
  34. #endif /* _UTILS_BASE_ */