Changeset 811c412ce800f3a4eeaa9c2bc4d5c35fe9982384
- Timestamp:
- 08/12/11 04:47:29
(2 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1313124449 -0400
- git-parent:
[7b999849cdf5ce592e0b1813f5f4800b1854fecd]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1313124449 -0400
- Message:
selfcheck introspection on when data is pulled by stratcon
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rf91ddca |
r811c412 |
|
| 43 | 43 | #include "noit_check.h" |
|---|
| 44 | 44 | #include "noit_check_tools.h" |
|---|
| | 45 | #include "noit_jlog_listener.h" |
|---|
| 45 | 46 | #include "utils/noit_log.h" |
|---|
| 46 | 47 | #include "utils/noit_hash.h" |
|---|
| … | … | |
| 72 | 73 | snprintf(buffer, sizeof(buffer), "%s_threads", jobq->queue_name); |
|---|
| 73 | 74 | noit_stats_set_metric(current, buffer, METRIC_INT32, &s32); |
|---|
| | 75 | } |
|---|
| | 76 | static int selfcheck_feed_details(jlog_feed_stats_t *s, void *vcurrent) { |
|---|
| | 77 | char buff[256]; |
|---|
| | 78 | uint64_t ms; |
|---|
| | 79 | struct timeval now, diff; |
|---|
| | 80 | stats_t *current = (stats_t *)vcurrent; |
|---|
| | 81 | gettimeofday(&now, NULL); |
|---|
| | 82 | |
|---|
| | 83 | if(s->last_connection.tv_sec > 0) { |
|---|
| | 84 | sub_timeval(now, s->last_connection, &diff); |
|---|
| | 85 | ms = diff.tv_sec * 1000 + diff.tv_usec / 1000; |
|---|
| | 86 | snprintf(buff, sizeof(buff), "feed`%s`last_connection_ms", s->feed_name); |
|---|
| | 87 | noit_stats_set_metric(current, buff, METRIC_UINT64, &ms); |
|---|
| | 88 | } |
|---|
| | 89 | |
|---|
| | 90 | if(s->last_checkpoint.tv_sec > 0) { |
|---|
| | 91 | sub_timeval(now, s->last_checkpoint, &diff); |
|---|
| | 92 | ms = diff.tv_sec * 1000 + diff.tv_usec / 1000; |
|---|
| | 93 | snprintf(buff, sizeof(buff), "feed`%s`last_checkpoint_ms", s->feed_name); |
|---|
| | 94 | noit_stats_set_metric(current, buff, METRIC_UINT64, &ms); |
|---|
| | 95 | } |
|---|
| | 96 | return 1; |
|---|
| 74 | 97 | } |
|---|
| 75 | 98 | static void selfcheck_log_results(noit_module_t *self, noit_check_t *check) { |
|---|
| … | … | |
| 113 | 136 | u64 = noit_check_completion_count(); |
|---|
| 114 | 137 | noit_stats_set_metric(¤t, "checks_run", METRIC_UINT64, &u64); |
|---|
| | 138 | /* feed pull info */ |
|---|
| | 139 | noit_jlog_foreach_feed_stats(selfcheck_feed_details, ¤t); |
|---|
| 115 | 140 | |
|---|
| 116 | 141 | noit_check_set_stats(self, check, ¤t); |
|---|
| r8fc8902 |
r811c412 |
|
| 65 | 65 | jlog_id start; |
|---|
| 66 | 66 | jlog_id finish; |
|---|
| | 67 | jlog_feed_stats_t *feed_stats; |
|---|
| 67 | 68 | int count; |
|---|
| 68 | 69 | int wants_shutdown; |
|---|
| … | … | |
| 89 | 90 | } |
|---|
| 90 | 91 | |
|---|
| | 92 | static noit_hash_table feed_stats = NOIT_HASH_EMPTY; |
|---|
| | 93 | |
|---|
| | 94 | jlog_feed_stats_t * |
|---|
| | 95 | noit_jlog_feed_stats(const char *sub) { |
|---|
| | 96 | void *vs = NULL; |
|---|
| | 97 | jlog_feed_stats_t *s = NULL; |
|---|
| | 98 | if(noit_hash_retrieve(&feed_stats, sub, strlen(sub), &vs)) |
|---|
| | 99 | return (jlog_feed_stats_t *)vs; |
|---|
| | 100 | s = calloc(1, sizeof(*s)); |
|---|
| | 101 | s->feed_name = strdup(sub); |
|---|
| | 102 | noit_hash_store(&feed_stats, s->feed_name, strlen(s->feed_name), s); |
|---|
| | 103 | return s; |
|---|
| | 104 | } |
|---|
| | 105 | int |
|---|
| | 106 | noit_jlog_foreach_feed_stats(int (*f)(jlog_feed_stats_t *, void *), |
|---|
| | 107 | void *c) { |
|---|
| | 108 | noit_hash_iter iter = NOIT_HASH_ITER_ZERO; |
|---|
| | 109 | const char *key; |
|---|
| | 110 | int klen, cnt = 0; |
|---|
| | 111 | void *vs; |
|---|
| | 112 | while(noit_hash_next(&feed_stats, &iter, &key, &klen, &vs)) { |
|---|
| | 113 | cnt += f((jlog_feed_stats_t *)vs, c); |
|---|
| | 114 | } |
|---|
| | 115 | return cnt; |
|---|
| | 116 | } |
|---|
| 91 | 117 | static int |
|---|
| 92 | 118 | __safe_Ewrite(eventer_t e, void *b, int l, int *mask) { |
|---|
| … | … | |
| 214 | 240 | goto alldone; |
|---|
| 215 | 241 | } |
|---|
| | 242 | gettimeofday(&jcl->feed_stats->last_checkpoint, NULL); |
|---|
| 216 | 243 | jlog_ctx_read_checkpoint(jcl->jlog, &jcl->chkpt); |
|---|
| 217 | 244 | } |
|---|
| … | … | |
| 242 | 269 | alldone: |
|---|
| 243 | 270 | e->opset->close(e->fd, &mask, e); |
|---|
| | 271 | noit_atomic_dec32(&jcl->feed_stats->connections); |
|---|
| 244 | 272 | if(jcl) noit_jlog_closure_free(jcl); |
|---|
| 245 | 273 | if(ac) acceptor_closure_free(ac); |
|---|
| … | … | |
| 310 | 338 | } |
|---|
| 311 | 339 | strlcpy(subscriber, ac->remote_cn, sizeof(subscriber)); |
|---|
| | 340 | jcl->feed_stats = noit_jlog_feed_stats(subscriber); |
|---|
| 312 | 341 | } |
|---|
| 313 | 342 | else { |
|---|
| | 343 | jcl->feed_stats = noit_jlog_feed_stats("~"); |
|---|
| 314 | 344 | snprintf(subscriber, sizeof(subscriber), |
|---|
| 315 | 345 | "~%07d", noit_atomic_inc32(&tmpfeedcounter)); |
|---|
| … | … | |
| 354 | 384 | pthread_attr_init(&tattr); |
|---|
| 355 | 385 | pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
|---|
| | 386 | gettimeofday(&jcl->feed_stats->last_connection, NULL); |
|---|
| | 387 | noit_atomic_inc32(&jcl->feed_stats->connections); |
|---|
| 356 | 388 | if(pthread_create(&tid, &tattr, noit_jlog_thread_main, newe) == 0) { |
|---|
| 357 | 389 | return 0; |
|---|
| r88a7178 |
r811c412 |
|
| 40 | 40 | #define NOIT_JLOG_DATA_TEMP_FEED 0x7e66feed |
|---|
| 41 | 41 | |
|---|
| | 42 | typedef struct { |
|---|
| | 43 | char *feed_name; |
|---|
| | 44 | noit_atomic32_t connections; |
|---|
| | 45 | struct timeval last_connection; |
|---|
| | 46 | struct timeval last_checkpoint; |
|---|
| | 47 | } jlog_feed_stats_t; |
|---|
| | 48 | |
|---|
| 42 | 49 | API_EXPORT(void) |
|---|
| 43 | 50 | noit_jlog_listener_init(void); |
|---|
| … | … | |
| 47 | 54 | struct timeval *now); |
|---|
| 48 | 55 | |
|---|
| | 56 | /* This API call is only safe from the eventer thread */ |
|---|
| | 57 | API_EXPORT(jlog_feed_stats_t *) |
|---|
| | 58 | noit_jlog_feed_stats(const char *sub); |
|---|
| | 59 | |
|---|
| | 60 | API_EXPORT(int) |
|---|
| | 61 | noit_jlog_foreach_feed_stats(int (*f)(jlog_feed_stats_t *, void *), |
|---|
| | 62 | void *); |
|---|
| | 63 | |
|---|
| 49 | 64 | #endif |
|---|