Changeset c0606177e96ca2dd9ca395a81715892807816f5c
- Timestamp:
- 05/22/12 12:14:21
(1 year ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1337688861 -0400
- git-parent:
[f22ed556234ab8522cbdd79c7fa6da2cf9d7b302]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1337688861 -0400
- Message:
add a sample check. change atoi() to strtod(). Do in-place metrics updating for performance reasons.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rc04fc7f |
rc060617 |
|
| 132 | 132 | update_check(noit_check_t *check, const char *key, char type, |
|---|
| 133 | 133 | double diff, double sample) { |
|---|
| 134 | | u_int32_t count = 1; |
|---|
| | 134 | u_int32_t one = 1; |
|---|
| 135 | 135 | char buff[256]; |
|---|
| 136 | 136 | statsd_closure_t *ccl; |
|---|
| … | … | |
| 143 | 143 | snprintf(buff, sizeof(buff), "%s`count", key); |
|---|
| 144 | 144 | m = noit_stats_get_metric(check, &ccl->current, buff); |
|---|
| 145 | | if(m && m->metric_type == METRIC_UINT32 && m->metric_value.I != NULL) |
|---|
| 146 | | count = *m->metric_value.I + 1; |
|---|
| 147 | | noit_stats_set_metric(check, &ccl->current, buff, METRIC_UINT32, &count); |
|---|
| | 145 | if(!m) ccl->stats_count++; |
|---|
| | 146 | if(m && m->metric_type == METRIC_UINT32 && m->metric_value.I != NULL) { |
|---|
| | 147 | (*m->metric_value.I)++; |
|---|
| | 148 | check_stats_set_metric_hook_invoke(check, &ccl->current, m); |
|---|
| | 149 | } |
|---|
| | 150 | else |
|---|
| | 151 | noit_stats_set_metric(check, &ccl->current, buff, METRIC_UINT32, &one); |
|---|
| 148 | 152 | |
|---|
| 149 | 153 | /* Next the actual data */ |
|---|
| 150 | | m = noit_stats_get_metric(check, &ccl->current, key); |
|---|
| | 154 | snprintf(buff, sizeof(buff), "%s`%s", key, |
|---|
| | 155 | (type == 'c') ? "counter" : (type == 'g') ? "gauge" : "timing"); |
|---|
| | 156 | m = noit_stats_get_metric(check, &ccl->current, buff); |
|---|
| 151 | 157 | if(type == 'c') { |
|---|
| 152 | 158 | double v = diff * (1.0 / sample); |
|---|
| 153 | | if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) |
|---|
| 154 | | v += (*m->metric_value.n); |
|---|
| 155 | | noit_stats_set_metric(check, &ccl->current, key, METRIC_DOUBLE, &v); |
|---|
| | 159 | if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) { |
|---|
| | 160 | (*m->metric_value.n) += v; |
|---|
| | 161 | check_stats_set_metric_hook_invoke(check, &ccl->current, m); |
|---|
| | 162 | } |
|---|
| | 163 | else |
|---|
| | 164 | noit_stats_set_metric(check, &ccl->current, buff, METRIC_DOUBLE, &v); |
|---|
| 156 | 165 | } |
|---|
| 157 | 166 | else if(type == 'g' || type == 'm') { |
|---|
| 158 | 167 | double v = diff; |
|---|
| 159 | | noit_stats_set_metric(check, &ccl->current, key, METRIC_DOUBLE, &v); |
|---|
| | 168 | if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) { |
|---|
| | 169 | (*m->metric_value.n) = v; |
|---|
| | 170 | check_stats_set_metric_hook_invoke(check, &ccl->current, m); |
|---|
| | 171 | } |
|---|
| | 172 | else |
|---|
| | 173 | noit_stats_set_metric(check, &ccl->current, buff, METRIC_DOUBLE, &v); |
|---|
| 160 | 174 | } |
|---|
| 161 | 175 | } |
|---|
| … | … | |
| 218 | 232 | } |
|---|
| 219 | 233 | } |
|---|
| 220 | | diff = atoi(value); |
|---|
| | 234 | diff = strtod(value, NULL); |
|---|
| 221 | 235 | } |
|---|
| 222 | 236 | if(type == NULL) type = COUNTER_STRING; |
|---|
| r94228ea |
rc060617 |
|
| 164 | 164 | </dc1> |
|---|
| 165 | 165 | <check uuid="002d58ff-20ff-4db0-9420-782fc1748dc4" module="ssh2" target="10.80.117.2" period="60000" timeout="4000"/> |
|---|
| | 166 | <check uuid="ff4f1de8-a405-11e1-8770-9347de0fce85" module="statsd" target="127.0.0.1" period="60000" timeout="59999"/> |
|---|
| 166 | 167 | </checks> |
|---|
| 167 | 168 | <filtersets> |
|---|