Changeset f921b22e683e77376b8ad3a675d5a9a20e92e912
- Timestamp:
- 05/22/08 17:45:35
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1211478335 +0000
- git-parent:
[fc879b8ebfb9f5de9e38c553a69f55837e32a394]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1211478335 +0000
- Message:
implements filter sets, fixes #24
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| ra504323 |
rf921b22 |
|
| 30 | 30 | noit_check.o noit_check_log.o noit_check_tools.o \ |
|---|
| 31 | 31 | noit_module.o noit_conf.o noit_conf_checks.o noit_tokenizer.o \ |
|---|
| 32 | | noit_jlog_listener.o |
|---|
| | 32 | noit_jlog_listener.o noit_filters.o |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | STRATCON_OBJS=stratcond.o noit_listener.o \ |
|---|
| r497022e |
rf921b22 |
|
| 73 | 73 | </listener> |
|---|
| 74 | 74 | </listeners> |
|---|
| 75 | | <checks max_initial_stutter="30000"> |
|---|
| | 75 | <checks max_initial_stutter="30000" filterset="default"> |
|---|
| 76 | 76 | <check uuid="1b4e28ba-2fa1-11d2-883f-b9b761bde3fb" module="ping_icmp" target="10.80.116.4" period="15000" timeout="14000"/> |
|---|
| 77 | 77 | <dc1 timeout="5000" period="60000"> |
|---|
| … | … | |
| 122 | 122 | <check uuid="002d58ff-20ff-4db0-9420-782fc1748dc4" module="ssh2" target="10.80.117.2" period="60000" timeout="4000"/> |
|---|
| 123 | 123 | </checks> |
|---|
| | 124 | <filtersets> |
|---|
| | 125 | <filterset name="default"> |
|---|
| | 126 | <rule type="deny" module="^ping_icmp$" metric="^(?:minimum|maximum|count)$" /> |
|---|
| | 127 | </filterset> |
|---|
| | 128 | </filtersets> |
|---|
| 124 | 129 | <config_templates> |
|---|
| 125 | 130 | <config id="SwitchPort"> |
|---|
| r01dbb0d |
rf921b22 |
|
| 100 | 100 | char module[256]; |
|---|
| 101 | 101 | char name[256]; |
|---|
| | 102 | char filterset[256]; |
|---|
| 102 | 103 | char oncheck[1024] = ""; |
|---|
| 103 | 104 | int no_period = 0; |
|---|
| … | … | |
| 131 | 132 | busted = noit_true; |
|---|
| 132 | 133 | } |
|---|
| | 134 | |
|---|
| | 135 | if(!INHERIT(stringbuf, filterset, filterset, sizeof(filterset))) |
|---|
| | 136 | filterset[0] = '\0'; |
|---|
| 133 | 137 | |
|---|
| 134 | 138 | if(!MYATTR(stringbuf, name, name, sizeof(name))) |
|---|
| … | … | |
| 176 | 180 | existing_check->module = strdup(module); |
|---|
| 177 | 181 | } |
|---|
| 178 | | noit_check_update(existing_check, target, name, options, |
|---|
| | 182 | noit_check_update(existing_check, target, name, filterset, options, |
|---|
| 179 | 183 | period, timeout, oncheck[0] ? oncheck : NULL, |
|---|
| 180 | 184 | flags); |
|---|
| … | … | |
| 182 | 186 | } |
|---|
| 183 | 187 | else { |
|---|
| 184 | | noit_poller_schedule(target, module, name, options, |
|---|
| | 188 | noit_poller_schedule(target, module, name, filterset, options, |
|---|
| 185 | 189 | period, timeout, oncheck[0] ? oncheck : NULL, |
|---|
| 186 | 190 | flags, uuid, out_uuid); |
|---|
| … | … | |
| 326 | 330 | const char *target, |
|---|
| 327 | 331 | const char *name, |
|---|
| | 332 | const char *filterset, |
|---|
| 328 | 333 | noit_hash_table *config, |
|---|
| 329 | 334 | u_int32_t period, |
|---|
| … | … | |
| 359 | 364 | if(new_check->name) free(new_check->name); |
|---|
| 360 | 365 | new_check->name = name ? strdup(name): NULL; |
|---|
| | 366 | if(new_check->filterset) free(new_check->filterset); |
|---|
| | 367 | new_check->filterset = filterset ? strdup(filterset): NULL; |
|---|
| 361 | 368 | |
|---|
| 362 | 369 | if(config != NULL) { |
|---|
| … | … | |
| 396 | 403 | const char *module, |
|---|
| 397 | 404 | const char *name, |
|---|
| | 405 | const char *filterset, |
|---|
| 398 | 406 | noit_hash_table *config, |
|---|
| 399 | 407 | u_int32_t period, |
|---|
| … | … | |
| 414 | 422 | uuid_copy(new_check->checkid, in); |
|---|
| 415 | 423 | |
|---|
| 416 | | noit_check_update(new_check, target, name, config, |
|---|
| | 424 | noit_check_update(new_check, target, name, filterset, config, |
|---|
| 417 | 425 | period, timeout, oncheck, flags); |
|---|
| 418 | 426 | assert(noit_hash_store(&polls, |
|---|
| rf1a1f36 |
rf921b22 |
|
| 93 | 93 | char *module; |
|---|
| 94 | 94 | char *name; |
|---|
| | 95 | char *filterset; |
|---|
| 95 | 96 | noit_hash_table *config; |
|---|
| 96 | 97 | char *oncheck; /* target`name of the check that fires us */ |
|---|
| … | … | |
| 130 | 131 | const char *module, |
|---|
| 131 | 132 | const char *name, |
|---|
| | 133 | const char *filterset, |
|---|
| 132 | 134 | noit_hash_table *config, |
|---|
| 133 | 135 | u_int32_t period, |
|---|
| … | … | |
| 142 | 144 | const char *target, |
|---|
| 143 | 145 | const char *name, |
|---|
| | 146 | const char *filterset, |
|---|
| 144 | 147 | noit_hash_table *config, |
|---|
| 145 | 148 | u_int32_t period, |
|---|
| rb7d1fe9 |
rf921b22 |
|
| 10 | 10 | |
|---|
| 11 | 11 | #include "noit_check.h" |
|---|
| | 12 | #include "noit_filters.h" |
|---|
| 12 | 13 | #include "utils/noit_log.h" |
|---|
| 13 | 14 | #include "jlog/jlog.h" |
|---|
| … | … | |
| 69 | 70 | c = &check->stats.current; |
|---|
| 70 | 71 | while(noit_hash_next(&c->metrics, &iter, &key, &klen, (void **)&m)) { |
|---|
| | 72 | /* If we apply the filter set and it returns false, we don't log */ |
|---|
| | 73 | if(!noit_apply_filterset(check->filterset, check, m)) continue; |
|---|
| | 74 | |
|---|
| 71 | 75 | if(!m->metric_value.s) { /* they are all null */ |
|---|
| 72 | 76 | noitL(metrics_log, "M\t%lu.%03lu\t%s\t%s\t%c\t[[null]]\n", |
|---|
| rb4b4512 |
rf921b22 |
|
| 19 | 19 | #include "noit_conf_private.h" |
|---|
| 20 | 20 | #include "noit_check.h" |
|---|
| | 21 | #include "noit_filters.h" |
|---|
| 21 | 22 | #include "noit_console.h" |
|---|
| 22 | 23 | #include "utils/noit_hash.h" |
|---|
| … | … | |
| 40 | 41 | { "/checks", "oncheck", "@oncheck", 0 }, |
|---|
| 41 | 42 | { "/checks", "disable", "@disable", 0 }, |
|---|
| | 43 | { "/checks", "filterset", "@filterset", 0 }, |
|---|
| 42 | 44 | { "/checks", "module", "@module", 1 }, |
|---|
| | 45 | { "/filtersets/filterset", "target", "@target", 1 }, |
|---|
| | 46 | { "/filtersets/filterset", "module", "@module", 1 }, |
|---|
| | 47 | { "/filtersets/filterset", "name", "@name", 1 }, |
|---|
| | 48 | { "/filtersets/filterset", "metric", "@metric", 1 }, |
|---|
| 43 | 49 | }; |
|---|
| 44 | 50 | |
|---|
| … | … | |
| 377 | 383 | SHOW_ATTR(timeout); |
|---|
| 378 | 384 | SHOW_ATTR(oncheck); |
|---|
| | 385 | SHOW_ATTR(filterset); |
|---|
| 379 | 386 | SHOW_ATTR(disable); |
|---|
| 380 | 387 | /* Print out all the config settings */ |
|---|
| … | … | |
| 1072 | 1079 | * that are descendent-or-self of this node. |
|---|
| 1073 | 1080 | */ |
|---|
| 1074 | | refresh_subchecks(ncct, info); |
|---|
| | 1081 | if(!strncmp(info->path, "/checks", strlen("/checks"))) |
|---|
| | 1082 | refresh_subchecks(ncct, info); |
|---|
| | 1083 | if(!strncmp(info->path, "/filtersets", strlen("/filtersets"))) |
|---|
| | 1084 | noit_refresh_filtersets(ncct, info); |
|---|
| 1075 | 1085 | return 0; |
|---|
| 1076 | 1086 | } |
|---|
| … | … | |
| 1104 | 1114 | * that are descendent-or-self of this node. |
|---|
| 1105 | 1115 | */ |
|---|
| 1106 | | refresh_subchecks(ncct, info); |
|---|
| | 1116 | if(!strncmp(info->path, "/checks", strlen("/checks"))) |
|---|
| | 1117 | refresh_subchecks(ncct, info); |
|---|
| | 1118 | if(!strncmp(info->path, "/filterset", strlen("/filterest"))) |
|---|
| | 1119 | noit_refresh_filtersets(ncct, info); |
|---|
| 1107 | 1120 | return 0; |
|---|
| 1108 | 1121 | } |
|---|
| r06f58e6 |
rf921b22 |
|
| 17 | 17 | #include "noit_conf.h" |
|---|
| 18 | 18 | #include "noit_conf_checks.h" |
|---|
| | 19 | #include "noit_filters.h" |
|---|
| 19 | 20 | |
|---|
| 20 | 21 | #define APPNAME "noit" |
|---|
| … | … | |
| 105 | 106 | |
|---|
| 106 | 107 | noit_module_init(); |
|---|
| | 108 | noit_filters_init(); |
|---|
| 107 | 109 | noit_poller_init(); |
|---|
| 108 | 110 | noit_listener_init(APPNAME); |
|---|