summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils_base.h')
-rw-r--r--lib/utils_base.h69
1 files changed, 31 insertions, 38 deletions
diff --git a/lib/utils_base.h b/lib/utils_base.h
index 9d4dffed..123066f8 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -2,8 +2,15 @@
2#define _UTILS_BASE_ 2#define _UTILS_BASE_
3/* Header file for Monitoring Plugins utils_base.c */ 3/* Header file for Monitoring Plugins utils_base.c */
4 4
5#include "../config.h"
6#include <time.h>
7
8#include "./perfdata.h"
9#include "./thresholds.h"
10
11
5#ifndef USE_OPENSSL 12#ifndef USE_OPENSSL
6# include "sha256.h" 13# include "sha256.h"
7#endif 14#endif
8 15
9/* This file holds header information for thresholds - use this in preference to 16/* This file holds header information for thresholds - use this in preference to
@@ -19,49 +26,35 @@
19#define OUTSIDE 0 26#define OUTSIDE 0
20#define INSIDE 1 27#define INSIDE 1
21 28
22typedef struct range_struct {
23 double start;
24 bool start_infinity;
25 double end;
26 int end_infinity;
27 int alert_on; /* OUTSIDE (default) or INSIDE */
28 char* text; /* original unparsed text input */
29 } range;
30
31typedef struct thresholds_struct {
32 range *warning;
33 range *critical;
34 } thresholds;
35
36#define NP_STATE_FORMAT_VERSION 1 29#define NP_STATE_FORMAT_VERSION 1
37 30
38typedef struct state_data_struct { 31typedef struct state_data_struct {
39 time_t time; 32 time_t time;
40 void *data; 33 void *data;
41 int length; /* Of binary data */ 34 int length; /* Of binary data */
42 } state_data; 35} state_data;
43
44 36
45typedef struct state_key_struct { 37typedef struct state_key_struct {
46 char *name; 38 char *name;
47 char *plugin_name; 39 char *plugin_name;
48 int data_version; 40 int data_version;
49 char *_filename; 41 char *_filename;
50 state_data *state_data; 42 state_data *state_data;
51 } state_key; 43} state_key;
52 44
53typedef struct np_struct { 45typedef struct np_struct {
54 char *plugin_name; 46 char *plugin_name;
55 state_key *state; 47 state_key *state;
56 int argc; 48 int argc;
57 char **argv; 49 char **argv;
58 } monitoring_plugin; 50} monitoring_plugin;
59 51
60range *parse_range_string (char *); 52range *parse_range_string(char *);
61int _set_thresholds(thresholds **, char *, char *); 53int _set_thresholds(thresholds **, char *, char *);
62void set_thresholds(thresholds **, char *, char *); 54void set_thresholds(thresholds **, char *, char *);
63void print_thresholds(const char *, thresholds *); 55void print_thresholds(const char *, thresholds *);
64bool check_range(double, range *); 56bool check_range(double, range *);
57bool mp_check_range(mp_perfdata_value, mp_range);
65int get_status(double, thresholds *); 58int get_status(double, thresholds *);
66 59
67/* Handle timeouts */ 60/* Handle timeouts */
@@ -71,13 +64,13 @@ extern unsigned int timeout_interval;
71/* All possible characters in a threshold range */ 64/* All possible characters in a threshold range */
72#define NP_THRESHOLDS_CHARS "-0123456789.:@~" 65#define NP_THRESHOLDS_CHARS "-0123456789.:@~"
73 66
74char *np_escaped_string (const char *); 67char *np_escaped_string(const char *);
75 68
76void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3))); 69void die(int, const char *, ...) __attribute__((noreturn, format(printf, 2, 3)));
77 70
78/* Return codes for _set_thresholds */ 71/* Return codes for _set_thresholds */
79#define NP_RANGE_UNPARSEABLE 1 72#define NP_RANGE_UNPARSEABLE 1
80#define NP_WARN_WITHIN_CRIT 2 73#define NP_WARN_WITHIN_CRIT 2
81 74
82/* a simple check to see if we're running as root. 75/* a simple check to see if we're running as root.
83 * returns zero on failure, nonzero on success */ 76 * returns zero on failure, nonzero on success */
@@ -93,7 +86,7 @@ int np_check_if_root(void);
93 * This function can be used to parse NTP control packet data and performance 86 * This function can be used to parse NTP control packet data and performance
94 * data strings. 87 * data strings.
95 */ 88 */
96char *np_extract_value(const char*, const char*, char); 89char *np_extract_value(const char *, const char *, char);
97 90
98/* 91/*
99 * Same as np_extract_value with separator suitable for NTP control packet 92 * Same as np_extract_value with separator suitable for NTP control packet
@@ -105,15 +98,15 @@ char *np_extract_value(const char*, const char*, char);
105 * Read a string representing a state (ok, warning... or numeric: 0, 1) and 98 * Read a string representing a state (ok, warning... or numeric: 0, 1) and
106 * return the corresponding NP_STATE or ERROR) 99 * return the corresponding NP_STATE or ERROR)
107 */ 100 */
108int mp_translate_state (char *); 101int mp_translate_state(char *);
109 102
110void np_enable_state(char *, int); 103void np_enable_state(char *, int);
111state_data *np_state_read(); 104state_data *np_state_read(void);
112void np_state_write_string(time_t, char *); 105void np_state_write_string(time_t, char *);
113 106
114void np_init(char *, int argc, char **argv); 107void np_init(char *, int argc, char **argv);
115void np_set_args(int argc, char **argv); 108void np_set_args(int argc, char **argv);
116void np_cleanup(); 109void np_cleanup(void);
117const char *state_text (int); 110const char *state_text(int);
118 111
119#endif /* _UTILS_BASE_ */ 112#endif /* _UTILS_BASE_ */