Changeset b13e0b2a4f10bf3512ef2acdf53ae9e88b4a7ee5
- Timestamp:
- 01/27/09 22:37:59
(4 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1233095879 +0000
- git-parent:
[5247186dde2b336780cdbcfd42e944ae5730fcaf]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1233095879 +0000
- Message:
make these guys pass errors back, closes #73
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r7180374 |
rb13e0b2 |
|
| 36 | 36 | static void |
|---|
| 37 | 37 | handle_extra_feeds(noit_check_t *check, |
|---|
| 38 | | void (*log_f)(noit_log_stream_t ls, noit_check_t *check)) { |
|---|
| | 38 | int (*log_f)(noit_log_stream_t ls, noit_check_t *check)) { |
|---|
| 39 | 39 | noit_log_stream_t ls; |
|---|
| 40 | 40 | noit_skiplist_node *curr, *next; |
|---|
| … | … | |
| 50 | 50 | feed_name = (char *)curr->data; |
|---|
| 51 | 51 | ls = noit_log_stream_find(feed_name); |
|---|
| 52 | | if(ls) log_f(ls, check); |
|---|
| 53 | | else { |
|---|
| 54 | | noit_skiplisti_remove(check->feeds, curr, free); |
|---|
| | 52 | if(!ls || log_f(ls, check)) { |
|---|
| | 53 | noit_check_transient_remove_feed(check, feed_name); |
|---|
| | 54 | /* noit_skiplisti_remove(check->feeds, curr, free); */ |
|---|
| 55 | 55 | } |
|---|
| 56 | 56 | curr = next; |
|---|
| … | … | |
| 58 | 58 | /* We're done... we may have destroyed the last feed. |
|---|
| 59 | 59 | * that combined with transience means we should kill the check */ |
|---|
| 60 | | noit_check_transient_remove_feed(check, NULL); |
|---|
| 61 | | } |
|---|
| 62 | | |
|---|
| 63 | | static void |
|---|
| | 60 | /* noit_check_transient_remove_feed(check, NULL); */ |
|---|
| | 61 | } |
|---|
| | 62 | |
|---|
| | 63 | static int |
|---|
| 64 | 64 | _noit_check_log_check(noit_log_stream_t ls, |
|---|
| 65 | 65 | noit_check_t *check) { |
|---|
| … | … | |
| 69 | 69 | uuid_unparse_lower(check->checkid, uuid_str); |
|---|
| 70 | 70 | gettimeofday(&__now, NULL); |
|---|
| 71 | | noitL(ls, "C\t%lu.%03lu\t%s\t%s\t%s\t%s\n", |
|---|
| 72 | | SECPART(&__now), MSECPART(&__now), |
|---|
| 73 | | uuid_str, check->target, check->module, check->name); |
|---|
| | 71 | return noit_log(ls, &__now, __FILE__, __LINE__, |
|---|
| | 72 | "C\t%lu.%03lu\t%s\t%s\t%s\t%s\n", |
|---|
| | 73 | SECPART(&__now), MSECPART(&__now), |
|---|
| | 74 | uuid_str, check->target, check->module, check->name); |
|---|
| 74 | 75 | } |
|---|
| 75 | 76 | |
|---|
| … | … | |
| 83 | 84 | } |
|---|
| 84 | 85 | |
|---|
| 85 | | static void |
|---|
| | 86 | static int |
|---|
| 86 | 87 | _noit_check_log_status(noit_log_stream_t ls, |
|---|
| 87 | 88 | noit_check_t *check) { |
|---|
| … | … | |
| 91 | 92 | uuid_unparse_lower(check->checkid, uuid_str); |
|---|
| 92 | 93 | c = &check->stats.current; |
|---|
| 93 | | noitL(ls, "S\t%lu.%03lu\t%s\t%c\t%c\t%d\t%s\n", |
|---|
| 94 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 95 | | (char)c->state, (char)c->available, c->duration, c->status); |
|---|
| | 94 | return noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 95 | "S\t%lu.%03lu\t%s\t%c\t%c\t%d\t%s\n", |
|---|
| | 96 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 97 | (char)c->state, (char)c->available, c->duration, c->status); |
|---|
| 96 | 98 | } |
|---|
| 97 | 99 | void |
|---|
| … | … | |
| 103 | 105 | } |
|---|
| 104 | 106 | } |
|---|
| 105 | | static void |
|---|
| | 107 | static int |
|---|
| 106 | 108 | _noit_check_log_metrics(noit_log_stream_t ls, noit_check_t *check) { |
|---|
| | 109 | int rv = 0; |
|---|
| | 110 | int srv; |
|---|
| 107 | 111 | char uuid_str[37]; |
|---|
| 108 | 112 | noit_hash_iter iter = NOIT_HASH_ITER_ZERO; |
|---|
| … | … | |
| 117 | 121 | /* If we apply the filter set and it returns false, we don't log */ |
|---|
| 118 | 122 | if(!noit_apply_filterset(check->filterset, check, m)) continue; |
|---|
| 119 | | |
|---|
| | 123 | if(!ls->enabled) continue; |
|---|
| | 124 | |
|---|
| | 125 | srv = 0; |
|---|
| 120 | 126 | if(!m->metric_value.s) { /* they are all null */ |
|---|
| 121 | | noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t[[null]]\n", |
|---|
| 122 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 123 | | m->metric_name, m->metric_type); |
|---|
| | 127 | srv = noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 128 | "M\t%lu.%03lu\t%s\t%s\t%c\t[[null]]\n", |
|---|
| | 129 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 130 | m->metric_name, m->metric_type); |
|---|
| 124 | 131 | } |
|---|
| 125 | 132 | else { |
|---|
| 126 | 133 | switch(m->metric_type) { |
|---|
| 127 | 134 | case METRIC_INT32: |
|---|
| 128 | | noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%d\n", |
|---|
| 129 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 130 | | m->metric_name, m->metric_type, *(m->metric_value.i)); |
|---|
| | 135 | srv = noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 136 | "M\t%lu.%03lu\t%s\t%s\t%c\t%d\n", |
|---|
| | 137 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 138 | m->metric_name, m->metric_type, *(m->metric_value.i)); |
|---|
| 131 | 139 | break; |
|---|
| 132 | 140 | case METRIC_UINT32: |
|---|
| 133 | | noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%u\n", |
|---|
| 134 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 135 | | m->metric_name, m->metric_type, *(m->metric_value.I)); |
|---|
| | 141 | srv = noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 142 | "M\t%lu.%03lu\t%s\t%s\t%c\t%u\n", |
|---|
| | 143 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 144 | m->metric_name, m->metric_type, *(m->metric_value.I)); |
|---|
| 136 | 145 | break; |
|---|
| 137 | 146 | case METRIC_INT64: |
|---|
| 138 | | noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%lld\n", |
|---|
| 139 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 140 | | m->metric_name, m->metric_type, *(m->metric_value.l)); |
|---|
| | 147 | srv = noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 148 | "M\t%lu.%03lu\t%s\t%s\t%c\t%lld\n", |
|---|
| | 149 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 150 | m->metric_name, m->metric_type, *(m->metric_value.l)); |
|---|
| 141 | 151 | break; |
|---|
| 142 | 152 | case METRIC_UINT64: |
|---|
| 143 | | noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%llu\n", |
|---|
| 144 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 145 | | m->metric_name, m->metric_type, *(m->metric_value.L)); |
|---|
| | 153 | srv = noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 154 | "M\t%lu.%03lu\t%s\t%s\t%c\t%llu\n", |
|---|
| | 155 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 156 | m->metric_name, m->metric_type, *(m->metric_value.L)); |
|---|
| 146 | 157 | break; |
|---|
| 147 | 158 | case METRIC_DOUBLE: |
|---|
| 148 | | noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%.12e\n", |
|---|
| 149 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 150 | | m->metric_name, m->metric_type, *(m->metric_value.n)); |
|---|
| | 159 | srv = noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 160 | "M\t%lu.%03lu\t%s\t%s\t%c\t%.12e\n", |
|---|
| | 161 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 162 | m->metric_name, m->metric_type, *(m->metric_value.n)); |
|---|
| 151 | 163 | break; |
|---|
| 152 | 164 | case METRIC_STRING: |
|---|
| 153 | | noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%s\n", |
|---|
| 154 | | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| 155 | | m->metric_name, m->metric_type, m->metric_value.s); |
|---|
| | 165 | srv = noit_log(ls, &c->whence, __FILE__, __LINE__, |
|---|
| | 166 | "M\t%lu.%03lu\t%s\t%s\t%c\t%s\n", |
|---|
| | 167 | SECPART(&c->whence), MSECPART(&c->whence), uuid_str, |
|---|
| | 168 | m->metric_name, m->metric_type, m->metric_value.s); |
|---|
| 156 | 169 | break; |
|---|
| 157 | 170 | default: |
|---|
| … | … | |
| 160 | 173 | } |
|---|
| 161 | 174 | } |
|---|
| 162 | | } |
|---|
| | 175 | if(srv) rv = srv; |
|---|
| | 176 | } |
|---|
| | 177 | return rv; |
|---|
| 163 | 178 | } |
|---|
| 164 | 179 | void |
|---|