utils_base.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. void print_thresholds(const char *, thresholds *);
  28. int check_range(double, range *);
  29. int get_status(double, thresholds *);
  30. char *np_escaped_string (const char *);
  31. void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
  32. /* Return codes for _set_thresholds */
  33. #define NP_RANGE_UNPARSEABLE 1
  34. #define NP_WARN_WITHIN_CRIT 2
  35. #endif /* _UTILS_BASE_ */