Changeset 57a327349609ef60a33dc6da15017c5d6642320a
- Timestamp:
- 02/02/08 19:10:26
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1201979426 +0000
- git-parent:
[ee84f469e10bfc29803bd472e4d06ea090574f12]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1201979426 +0000
- Message:
renaming something before it becomes crazy painful
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd091766 |
r57a3273 |
|
| 25 | 25 | SUBS=utils jlog eventer modules |
|---|
| 26 | 26 | |
|---|
| 27 | | OBJS=noitd.o noit_listener.o noit_console.o noit_poller.o \ |
|---|
| | 27 | OBJS=noitd.o noit_listener.o noit_console.o noit_check.o \ |
|---|
| 28 | 28 | noit_module.o noit_conf.o |
|---|
| 29 | 29 | |
|---|
| r5f413b7 |
r57a3273 |
|
| 17 | 17 | |
|---|
| 18 | 18 | #include "noit_module.h" |
|---|
| 19 | | #include "noit_poller.h" |
|---|
| | 19 | #include "noit_check.h" |
|---|
| 20 | 20 | #include "utils/noit_log.h" |
|---|
| 21 | 21 | #include "utils/noit_hash.h" |
|---|
| … | … | |
| 30 | 30 | typedef struct { |
|---|
| 31 | 31 | noit_hash_table *options; |
|---|
| 32 | | void (*results)(noit_module_t *, noit_check_t); |
|---|
| | 32 | void (*results)(noit_module_t *, noit_check_t *); |
|---|
| 33 | 33 | } serf_module_conf_t; |
|---|
| 34 | 34 | |
|---|
| … | … | |
| 50 | 50 | |
|---|
| 51 | 51 | noit_module_t *self; |
|---|
| 52 | | noit_check_t check; |
|---|
| | 52 | noit_check_t *check; |
|---|
| 53 | 53 | } handler_baton_t; |
|---|
| 54 | 54 | |
|---|
| … | … | |
| 89 | 89 | typedef struct { |
|---|
| 90 | 90 | noit_module_t *self; |
|---|
| 91 | | noit_check_t check; |
|---|
| | 91 | noit_check_t *check; |
|---|
| 92 | 92 | void *serf_baton; |
|---|
| 93 | 93 | apr_socket_t *skt; |
|---|
| … | … | |
| 100 | 100 | static int serf_recur_handler(eventer_t e, int mask, void *closure, |
|---|
| 101 | 101 | struct timeval *now); |
|---|
| 102 | | static void serf_log_results(noit_module_t *self, noit_check_t check); |
|---|
| 103 | | static void resmon_log_results(noit_module_t *self, noit_check_t check); |
|---|
| 104 | | static void resmon_part_log_results(noit_module_t *self, noit_check_t check, |
|---|
| 105 | | noit_check_t parent); |
|---|
| | 102 | static void serf_log_results(noit_module_t *self, noit_check_t *check); |
|---|
| | 103 | static void resmon_log_results(noit_module_t *self, noit_check_t *check); |
|---|
| | 104 | static void resmon_part_log_results(noit_module_t *self, noit_check_t *check, |
|---|
| | 105 | noit_check_t *parent); |
|---|
| 106 | 106 | |
|---|
| 107 | 107 | static int serf_config(noit_module_t *self, noit_hash_table *options) { |
|---|
| … | … | |
| 124 | 124 | return 0; |
|---|
| 125 | 125 | } |
|---|
| 126 | | static void generic_log_results(noit_module_t *self, noit_check_t check) { |
|---|
| | 126 | static void generic_log_results(noit_module_t *self, noit_check_t *check) { |
|---|
| 127 | 127 | serf_module_conf_t *module_conf; |
|---|
| 128 | 128 | module_conf = noit_module_get_userdata(self); |
|---|
| 129 | 129 | module_conf->results(self, check); |
|---|
| 130 | 130 | } |
|---|
| 131 | | static void serf_log_results(noit_module_t *self, noit_check_t check) { |
|---|
| | 131 | static void serf_log_results(noit_module_t *self, noit_check_t *check) { |
|---|
| 132 | 132 | serf_check_info_t *ci = check->closure; |
|---|
| 133 | 133 | struct timeval duration; |
|---|
| … | … | |
| 161 | 161 | current.status = human_buffer; |
|---|
| 162 | 162 | if(current.available == NP_AVAILABLE) { |
|---|
| 163 | | noit_poller_set_metric_int(¤t, "code", &ci->status.code); |
|---|
| 164 | | noit_poller_set_metric_int(¤t, "bytes", &ci->body.l); |
|---|
| | 163 | noit_stats_set_metric_int(¤t, "code", &ci->status.code); |
|---|
| | 164 | noit_stats_set_metric_int(¤t, "bytes", &ci->body.l); |
|---|
| 165 | 165 | } |
|---|
| 166 | 166 | else { |
|---|
| 167 | | noit_poller_set_metric_int(¤t, "code", NULL); |
|---|
| 168 | | noit_poller_set_metric_int(¤t, "bytes", NULL); |
|---|
| 169 | | } |
|---|
| 170 | | noit_poller_set_state(self, check, ¤t); |
|---|
| | 167 | noit_stats_set_metric_int(¤t, "code", NULL); |
|---|
| | 168 | noit_stats_set_metric_int(¤t, "bytes", NULL); |
|---|
| | 169 | } |
|---|
| | 170 | noit_check_set_stats(self, check, ¤t); |
|---|
| 171 | 171 | } |
|---|
| 172 | 172 | static void resmon_part_log_results_xml(noit_module_t *self, |
|---|
| 173 | | noit_check_t check, |
|---|
| | 173 | noit_check_t *check, |
|---|
| 174 | 174 | xmlDocPtr xml) { |
|---|
| 175 | 175 | resmon_check_info_t *rci = check->closure; |
|---|
| … | … | |
| 213 | 213 | noitL(nldeb, "resmon_part(%s/%s/%s) [%s]\n", check->target, |
|---|
| 214 | 214 | rci->resmod, rci->resserv, current.status); |
|---|
| 215 | | noit_poller_set_state(self, check, ¤t); |
|---|
| 216 | | } |
|---|
| 217 | | static void resmon_part_log_results(noit_module_t *self, noit_check_t check, |
|---|
| 218 | | noit_check_t parent) { |
|---|
| | 215 | noit_check_set_stats(self, check, ¤t); |
|---|
| | 216 | } |
|---|
| | 217 | static void resmon_part_log_results(noit_module_t *self, noit_check_t *check, |
|---|
| | 218 | noit_check_t *parent) { |
|---|
| 219 | 219 | resmon_check_info_t *rci = parent->closure; |
|---|
| 220 | 220 | resmon_part_log_results_xml(self, check, rci->xml_doc); |
|---|
| 221 | 221 | } |
|---|
| 222 | | static void resmon_log_results(noit_module_t *self, noit_check_t check) { |
|---|
| | 222 | static void resmon_log_results(noit_module_t *self, noit_check_t *check) { |
|---|
| 223 | 223 | serf_check_info_t *ci = check->closure; |
|---|
| 224 | 224 | resmon_check_info_t *rci = check->closure; |
|---|
| … | … | |
| 273 | 273 | current.status = human_buffer; |
|---|
| 274 | 274 | |
|---|
| 275 | | noit_poller_set_metric_int(¤t, "services", &services); |
|---|
| | 275 | noit_stats_set_metric_int(¤t, "services", &services); |
|---|
| 276 | 276 | if(services) { |
|---|
| 277 | 277 | int i; |
|---|
| … | … | |
| 304 | 304 | /* The first is integer */ |
|---|
| 305 | 305 | intval = (int)(atof(value) * 1000.0); |
|---|
| 306 | | noit_poller_set_metric_int(¤t, attr, &intval); |
|---|
| | 306 | noit_stats_set_metric_int(¤t, attr, &intval); |
|---|
| 307 | 307 | break; |
|---|
| 308 | 308 | case 1: |
|---|
| 309 | 309 | case 2: |
|---|
| 310 | | noit_poller_set_metric_string(¤t, attr, (char *)value); |
|---|
| | 310 | noit_stats_set_metric_string(¤t, attr, (char *)value); |
|---|
| 311 | 311 | break; |
|---|
| 312 | 312 | } |
|---|
| … | … | |
| 316 | 316 | } |
|---|
| 317 | 317 | |
|---|
| 318 | | noit_poller_set_state(self, check, ¤t); |
|---|
| | 318 | noit_check_set_stats(self, check, ¤t); |
|---|
| 319 | 319 | |
|---|
| 320 | 320 | out: |
|---|
| … | … | |
| 605 | 605 | } |
|---|
| 606 | 606 | |
|---|
| 607 | | static int serf_initiate(noit_module_t *self, noit_check_t check) { |
|---|
| | 607 | static int serf_initiate(noit_module_t *self, noit_check_t *check) { |
|---|
| 608 | 608 | serf_closure_t *ccl; |
|---|
| 609 | 609 | serf_check_info_t *ci; |
|---|
| … | … | |
| 718 | 718 | } |
|---|
| 719 | 719 | static int serf_schedule_next(noit_module_t *self, |
|---|
| 720 | | eventer_t e, noit_check_t check, |
|---|
| | 720 | eventer_t e, noit_check_t *check, |
|---|
| 721 | 721 | struct timeval *now) { |
|---|
| 722 | 722 | eventer_t newe; |
|---|
| … | … | |
| 762 | 762 | return 0; |
|---|
| 763 | 763 | } |
|---|
| 764 | | static int serf_initiate_check(noit_module_t *self, noit_check_t check, |
|---|
| 765 | | int once, noit_check_t cause) { |
|---|
| | 764 | static int serf_initiate_check(noit_module_t *self, noit_check_t *check, |
|---|
| | 765 | int once, noit_check_t *cause) { |
|---|
| 766 | 766 | if(!check->closure) check->closure = calloc(1, sizeof(serf_check_info_t)); |
|---|
| 767 | 767 | if(once) { |
|---|
| … | … | |
| 774 | 774 | return 0; |
|---|
| 775 | 775 | } |
|---|
| 776 | | static int resmon_initiate_check(noit_module_t *self, noit_check_t check, |
|---|
| 777 | | int once, noit_check_t parent) { |
|---|
| | 776 | static int resmon_initiate_check(noit_module_t *self, noit_check_t *check, |
|---|
| | 777 | int once, noit_check_t *parent) { |
|---|
| 778 | 778 | /* resmon_check_info_t gives us a bit more space */ |
|---|
| 779 | 779 | if(!check->closure) check->closure = calloc(1, sizeof(resmon_check_info_t)); |
|---|
| … | … | |
| 787 | 787 | } |
|---|
| 788 | 788 | |
|---|
| 789 | | static int resmon_part_initiate_check(noit_module_t *self, noit_check_t check, |
|---|
| 790 | | int once, noit_check_t parent) { |
|---|
| | 789 | static int resmon_part_initiate_check(noit_module_t *self, noit_check_t *check, |
|---|
| | 790 | int once, noit_check_t *parent) { |
|---|
| 791 | 791 | char xpathexpr[1024]; |
|---|
| 792 | 792 | const char *resmod, *resserv; |
|---|
| r5f413b7 |
r57a3273 |
|
| 18 | 18 | |
|---|
| 19 | 19 | #include "noit_module.h" |
|---|
| 20 | | #include "noit_poller.h" |
|---|
| | 20 | #include "noit_check.h" |
|---|
| 21 | 21 | #include "utils/noit_log.h" |
|---|
| 22 | 22 | |
|---|
| … | … | |
| 41 | 41 | struct ping_closure { |
|---|
| 42 | 42 | noit_module_t *self; |
|---|
| 43 | | noit_check_t check; |
|---|
| | 43 | noit_check_t *check; |
|---|
| 44 | 44 | void *payload; |
|---|
| 45 | 45 | int payload_len; |
|---|
| … | … | |
| 59 | 59 | return 0; |
|---|
| 60 | 60 | } |
|---|
| 61 | | static int ping_icmp_is_complete(noit_module_t *self, noit_check_t check) { |
|---|
| | 61 | static int ping_icmp_is_complete(noit_module_t *self, noit_check_t *check) { |
|---|
| 62 | 62 | int i; |
|---|
| 63 | 63 | struct check_info *data; |
|---|
| … | … | |
| 71 | 71 | return 1; |
|---|
| 72 | 72 | } |
|---|
| 73 | | static void ping_icmp_log_results(noit_module_t *self, noit_check_t check) { |
|---|
| | 73 | static void ping_icmp_log_results(noit_module_t *self, noit_check_t *check) { |
|---|
| 74 | 74 | struct check_info *data; |
|---|
| 75 | 75 | float avail, min = MAXFLOAT, max = 0.0, avg = 0.0, cnt; |
|---|
| … | … | |
| 109 | 109 | current.state = (avail < 1.0) ? NP_BAD : NP_GOOD; |
|---|
| 110 | 110 | current.status = human_buffer; |
|---|
| 111 | | noit_poller_set_metric_int(¤t, "count", &data->expected_count); |
|---|
| | 111 | noit_stats_set_metric_int(¤t, "count", &data->expected_count); |
|---|
| 112 | 112 | avail *= 100.0; |
|---|
| 113 | | noit_poller_set_metric_float(¤t, "available", &avail); |
|---|
| 114 | | noit_poller_set_metric_float(¤t, "minimum", avail > 0.0 ? &min : NULL); |
|---|
| 115 | | noit_poller_set_metric_float(¤t, "maximum", avail > 0.0 ? &max : NULL); |
|---|
| 116 | | noit_poller_set_metric_float(¤t, "average", avail > 0.0 ? &avg : NULL); |
|---|
| 117 | | noit_poller_set_state(self, check, ¤t); |
|---|
| | 113 | noit_stats_set_metric_float(¤t, "available", &avail); |
|---|
| | 114 | noit_stats_set_metric_float(¤t, "minimum", avail > 0.0 ? &min : NULL); |
|---|
| | 115 | noit_stats_set_metric_float(¤t, "maximum", avail > 0.0 ? &max : NULL); |
|---|
| | 116 | noit_stats_set_metric_float(¤t, "average", avail > 0.0 ? &avg : NULL); |
|---|
| | 117 | noit_check_set_stats(self, check, ¤t); |
|---|
| 118 | 118 | } |
|---|
| 119 | 119 | static int ping_icmp_timeout(eventer_t e, int mask, |
|---|
| … | … | |
| 145 | 145 | while(1) { |
|---|
| 146 | 146 | int inlen, iphlen; |
|---|
| 147 | | noit_check_t check; |
|---|
| | 147 | noit_check_t *check; |
|---|
| 148 | 148 | struct timeval tt; |
|---|
| 149 | 149 | |
|---|
| … | … | |
| 321 | 321 | return 0; |
|---|
| 322 | 322 | } |
|---|
| 323 | | static int ping_icmp_send(noit_module_t *self, noit_check_t check) { |
|---|
| | 323 | static int ping_icmp_send(noit_module_t *self, noit_check_t *check) { |
|---|
| 324 | 324 | struct timeval when, p_int; |
|---|
| 325 | 325 | struct icmp *icp; |
|---|
| … | … | |
| 415 | 415 | } |
|---|
| 416 | 416 | static int ping_icmp_schedule_next(noit_module_t *self, |
|---|
| 417 | | eventer_t e, noit_check_t check, |
|---|
| | 417 | eventer_t e, noit_check_t *check, |
|---|
| 418 | 418 | struct timeval *now) { |
|---|
| 419 | 419 | eventer_t newe; |
|---|
| … | … | |
| 459 | 459 | return 0; |
|---|
| 460 | 460 | } |
|---|
| 461 | | static int ping_icmp_initiate_check(noit_module_t *self, noit_check_t check, |
|---|
| 462 | | int once, noit_check_t cause) { |
|---|
| | 461 | static int ping_icmp_initiate_check(noit_module_t *self, noit_check_t *check, |
|---|
| | 462 | int once, noit_check_t *cause) { |
|---|
| 463 | 463 | if(!check->closure) check->closure = calloc(1, sizeof(struct check_info)); |
|---|
| 464 | 464 | if(once) { |
|---|
| rcaa7b86 |
r57a3273 |
|
| 12 | 12 | #include "utils/noit_log.h" |
|---|
| 13 | 13 | #include "noit_listener.h" |
|---|
| 14 | | #include "noit_poller.h" |
|---|
| 15 | 14 | #include "noit_console.h" |
|---|
| 16 | 15 | |
|---|
| r5f413b7 |
r57a3273 |
|
| 9 | 9 | #include "noit_defines.h" |
|---|
| 10 | 10 | #include "utils/noit_hash.h" |
|---|
| 11 | | #include "noit_poller.h" |
|---|
| | 11 | #include "noit_check.h" |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | #define NOIT_MODULE_MAGIC 0x4017DA7A |
|---|
| … | … | |
| 22 | 22 | int (*config)(struct _noit_module *, noit_hash_table *options); |
|---|
| 23 | 23 | int (*init)(struct _noit_module *); |
|---|
| 24 | | int (*initiate_check)(struct _noit_module *, noit_check_t check, |
|---|
| 25 | | int once, noit_check_t cause); |
|---|
| | 24 | int (*initiate_check)(struct _noit_module *, noit_check_t *check, |
|---|
| | 25 | int once, noit_check_t *cause); |
|---|
| 26 | 26 | void *opaque_handle; |
|---|
| 27 | 27 | } noit_module_t; |
|---|