root/src/noit_check.h

Revision 7a1324aa50711b4d7f5d81f7e901081a150cf9fe, 3.9 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

online editing of attributes

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  */
5
6 #ifndef _NOIT_POLLER_H
7 #define _NOIT_POLLER_H
8
9 #include "noit_defines.h"
10
11 #include <uuid/uuid.h>
12 #include <netinet/in.h>
13
14 #include "eventer/eventer.h"
15 #include "utils/noit_hash.h"
16 #include "noit_conf.h"
17 #include "noit_console.h"
18
19 /*
20  * Checks:
21  *  attrs:
22  *   UUID
23  *   host (target)
24  *   check (module)
25  *   name (identifying the check to the user if
26  *         multiple checks of the same module are specified)
27  *   config (params for the module)
28  *   period (ms)
29  *   timeout (ms)
30  *  transient:
31  *   eventer_t (fire)
32  *   stats_t [inprogress, last]
33  *   closure
34  */
35
36 #define NP_RUNNING  0x00000001
37 #define NP_KILLED   0x00000002
38 #define NP_DISABLED 0x00000004
39
40 #define NP_UNKNOWN 0               /* stats_t.{available,state} */
41 #define NP_AVAILABLE 1             /* stats_t.available */
42 #define NP_UNAVAILABLE -1          /* stats_t.available */
43 #define NP_BAD 1                   /* stats_t.state */
44 #define NP_GOOD 2                  /* stats_t.state */
45
46 typedef struct {
47   char *metric_name;
48   enum { METRIC_INT, METRIC_FLOAT, METRIC_STRING } metric_type;
49   union {
50     float *f;
51     int *i;
52     char *s;
53   } metric_value;
54 } metric_t;
55
56 typedef struct {
57   struct timeval whence;
58   int16_t available;
59   int16_t state;
60   u_int32_t duration;
61   char *status;
62   noit_hash_table metrics;
63 } stats_t;
64
65 typedef struct dep_list {
66   struct noit_check *check;
67   struct dep_list *next;
68 } dep_list_t;
69
70 typedef struct noit_check {
71   uuid_t checkid;
72   int8_t target_family;
73   union {
74     struct in_addr addr;
75     struct in6_addr addr6;
76   } target_addr;
77   char *target;
78   char *module;
79   char *name;
80   noit_hash_table *config;
81   char *oncheck;               /* target`name of the check that fires us */
82   u_int32_t period;            /* period of checks in milliseconds */
83   u_int32_t timeout;           /* timeout of check in milliseconds */
84   u_int32_t flags;             /* NP_KILLED, NP_RUNNING */
85
86   dep_list_t *causal_checks;
87   eventer_t fire_event;
88   struct timeval last_fire_time;
89   struct {
90     stats_t current;
91     stats_t previous;
92   } stats;
93   u_int32_t generation;        /* This can roll, we don't care */
94   void *closure;
95 } noit_check_t;
96
97 #define NOIT_CHECK_LIVE(a) ((a)->fire_event != NULL)
98
99 API_EXPORT(void) noit_poller_init();
100 API_EXPORT(void) noit_poller_load_checks();
101 API_EXPORT(void) noit_poller_process_checks(char *xpath);
102
103 API_EXPORT(void)
104   noit_check_fake_last_check(noit_check_t *check,
105                              struct timeval *lc, struct timeval *_now);
106 API_EXPORT(int) noit_check_max_initial_stutter();
107
108 API_EXPORT(int)
109   noit_poller_schedule(const char *target,
110                        const char *module,
111                        const char *name,
112                        noit_hash_table *config,
113                        u_int32_t period,
114                        u_int32_t timeout,
115                        const char *oncheck,
116                        noit_conf_boolean disabled,
117                        uuid_t in,
118                        uuid_t out);
119
120 API_EXPORT(int)
121   noit_check_update(noit_check_t *new_check,
122                     const char *target,
123                     const char *name,
124                     noit_hash_table *config,
125                     u_int32_t period,
126                     u_int32_t timeout,
127                     const char *oncheck,
128                     noit_conf_boolean disabled);
129
130 API_EXPORT(int)
131   noit_poller_deschedule(uuid_t in);
132
133 API_EXPORT(noit_check_t *)
134   noit_poller_lookup(uuid_t in);
135
136 API_EXPORT(noit_check_t *)
137   noit_poller_lookup_by_name(char *target, char *name);
138
139 struct _noit_module;
140 API_EXPORT(void)
141   noit_check_set_stats(struct _noit_module *self, noit_check_t *check,
142                         stats_t *newstate);
143
144 API_EXPORT(void)
145   noit_stats_set_metric_int(stats_t *newstate, char *name, int *value);
146 API_EXPORT(void)
147   noit_stats_set_metric_float(stats_t *newstate, char *name, float *value);
148 API_EXPORT(void)
149   noit_stats_set_metric_string(stats_t *newstate, char *name, char *value);
150
151 #endif
Note: See TracBrowser for help on using the browser.