root/src/noit_check.h

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

implement staggered start skilz

  • 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
17 /*
18  * Checks:
19  *  attrs:
20  *   UUID
21  *   host (target)
22  *   check (module)
23  *   name (identifying the check to the user if
24  *         multiple checks of the same module are specified)
25  *   config (params for the module)
26  *   period (ms)
27  *   timeout (ms)
28  *  transient:
29  *   eventer_t (fire)
30  *   stats_t [inprogress, last]
31  *   closure
32  */
33
34 #define NP_RUNNING  0x00000001
35 #define NP_KILLED   0x00000002
36 #define NP_DISABLED 0x00000004
37
38 #define NP_UNKNOWN 0               /* stats_t.{available,state} */
39 #define NP_AVAILABLE 1             /* stats_t.available */
40 #define NP_UNAVAILABLE -1          /* stats_t.available */
41 #define NP_BAD 1                   /* stats_t.state */
42 #define NP_GOOD 2                  /* stats_t.state */
43
44 typedef struct {
45   char *metric_name;
46   enum { METRIC_INT, METRIC_FLOAT, METRIC_STRING } metric_type;
47   union {
48     float *f;
49     int *i;
50     char *s;
51   } metric_value;
52 } metric_t;
53
54 typedef struct {
55   struct timeval whence;
56   int16_t available;
57   int16_t state;
58   u_int32_t duration;
59   char *status;
60   noit_hash_table metrics;
61 } stats_t;
62
63 typedef struct dep_list {
64   struct noit_check *check;
65   struct dep_list *next;
66 } dep_list_t;
67
68 typedef struct noit_check {
69   uuid_t checkid;
70   int8_t target_family;
71   union {
72     struct in_addr addr;
73     struct in6_addr addr6;
74   } target_addr;
75   char *target;
76   char *module;
77   char *name;
78   noit_hash_table *config;
79   char *oncheck;               /* target`name of the check that fires us */
80   u_int32_t period;            /* period of checks in milliseconds */
81   u_int32_t timeout;           /* timeout of check in milliseconds */
82   u_int32_t flags;             /* NP_KILLED, NP_RUNNING */
83
84   dep_list_t *causal_checks;
85   eventer_t fire_event;
86   struct timeval last_fire_time;
87   struct {
88     stats_t current;
89     stats_t previous;
90   } stats;
91   u_int32_t generation;        /* This can roll, we don't care */
92   void *closure;
93 } noit_check_t;
94
95 API_EXPORT(void) noit_poller_init();
96 API_EXPORT(void) noit_poller_load_checks();
97
98 API_EXPORT(void)
99   noit_check_fake_last_check(noit_check_t *check,
100                              struct timeval *lc, struct timeval *_now);
101 API_EXPORT(int) noit_check_max_initial_stutter();
102
103 API_EXPORT(int)
104   noit_poller_schedule(const char *target,
105                        const char *module,
106                        const char *name,
107                        noit_hash_table *config,
108                        u_int32_t period,
109                        u_int32_t timeout,
110                        const char *oncheck,
111                        uuid_t in,
112                        uuid_t out);
113
114 API_EXPORT(int)
115   noit_poller_deschedule(uuid_t in);
116
117 API_EXPORT(noit_check_t *)
118   noit_poller_lookup(uuid_t in);
119
120 API_EXPORT(noit_check_t *)
121   noit_poller_lookup_by_name(char *target, char *name);
122
123 struct _noit_module;
124 API_EXPORT(void)
125   noit_check_set_stats(struct _noit_module *self, noit_check_t *check,
126                         stats_t *newstate);
127
128 API_EXPORT(void)
129   noit_stats_set_metric_int(stats_t *newstate, char *name, int *value);
130 API_EXPORT(void)
131   noit_stats_set_metric_float(stats_t *newstate, char *name, float *value);
132 API_EXPORT(void)
133   noit_stats_set_metric_string(stats_t *newstate, char *name, char *value);
134
135 #endif
Note: See TracBrowser for help on using the browser.