[Reconnoiter-devel] [reconnoiter commit] r566 - trunk/src
svn-commit at lists.omniti.com
svn-commit at lists.omniti.com
Tue Jan 27 17:37:59 EST 2009
Author: jesus
Date: 2009-01-27 17:37:59 -0500 (Tue, 27 Jan 2009)
New Revision: 566
Modified:
trunk/src/noit_check_log.c
Log:
make these guys pass errors back, closes #73
Modified: trunk/src/noit_check_log.c
===================================================================
--- trunk/src/noit_check_log.c 2009-01-27 22:37:23 UTC (rev 565)
+++ trunk/src/noit_check_log.c 2009-01-27 22:37:59 UTC (rev 566)
@@ -35,7 +35,7 @@
static void
handle_extra_feeds(noit_check_t *check,
- void (*log_f)(noit_log_stream_t ls, noit_check_t *check)) {
+ int (*log_f)(noit_log_stream_t ls, noit_check_t *check)) {
noit_log_stream_t ls;
noit_skiplist_node *curr, *next;
const char *feed_name;
@@ -49,18 +49,18 @@
noit_skiplist_next(check->feeds, &next);
feed_name = (char *)curr->data;
ls = noit_log_stream_find(feed_name);
- if(ls) log_f(ls, check);
- else {
- noit_skiplisti_remove(check->feeds, curr, free);
+ if(!ls || log_f(ls, check)) {
+ noit_check_transient_remove_feed(check, feed_name);
+ /* noit_skiplisti_remove(check->feeds, curr, free); */
}
curr = next;
}
/* We're done... we may have destroyed the last feed.
* that combined with transience means we should kill the check */
- noit_check_transient_remove_feed(check, NULL);
+ /* noit_check_transient_remove_feed(check, NULL); */
}
-static void
+static int
_noit_check_log_check(noit_log_stream_t ls,
noit_check_t *check) {
struct timeval __now;
@@ -68,9 +68,10 @@
uuid_unparse_lower(check->checkid, uuid_str);
gettimeofday(&__now, NULL);
- noitL(ls, "C\t%lu.%03lu\t%s\t%s\t%s\t%s\n",
- SECPART(&__now), MSECPART(&__now),
- uuid_str, check->target, check->module, check->name);
+ return noit_log(ls, &__now, __FILE__, __LINE__,
+ "C\t%lu.%03lu\t%s\t%s\t%s\t%s\n",
+ SECPART(&__now), MSECPART(&__now),
+ uuid_str, check->target, check->module, check->name);
}
void
@@ -82,7 +83,7 @@
}
}
-static void
+static int
_noit_check_log_status(noit_log_stream_t ls,
noit_check_t *check) {
stats_t *c;
@@ -90,9 +91,10 @@
uuid_unparse_lower(check->checkid, uuid_str);
c = &check->stats.current;
- noitL(ls, "S\t%lu.%03lu\t%s\t%c\t%c\t%d\t%s\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- (char)c->state, (char)c->available, c->duration, c->status);
+ return noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "S\t%lu.%03lu\t%s\t%c\t%c\t%d\t%s\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ (char)c->state, (char)c->available, c->duration, c->status);
}
void
noit_check_log_status(noit_check_t *check) {
@@ -102,8 +104,10 @@
_noit_check_log_status(status_log, check);
}
}
-static void
+static int
_noit_check_log_metrics(noit_log_stream_t ls, noit_check_t *check) {
+ int rv = 0;
+ int srv;
char uuid_str[37];
noit_hash_iter iter = NOIT_HASH_ITER_ZERO;
const char *key;
@@ -116,50 +120,61 @@
while(noit_hash_next(&c->metrics, &iter, &key, &klen, (void **)&m)) {
/* If we apply the filter set and it returns false, we don't log */
if(!noit_apply_filterset(check->filterset, check, m)) continue;
+ if(!ls->enabled) continue;
+ srv = 0;
if(!m->metric_value.s) { /* they are all null */
- noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t[[null]]\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- m->metric_name, m->metric_type);
+ srv = noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "M\t%lu.%03lu\t%s\t%s\t%c\t[[null]]\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ m->metric_name, m->metric_type);
}
else {
switch(m->metric_type) {
case METRIC_INT32:
- noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%d\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- m->metric_name, m->metric_type, *(m->metric_value.i));
+ srv = noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "M\t%lu.%03lu\t%s\t%s\t%c\t%d\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ m->metric_name, m->metric_type, *(m->metric_value.i));
break;
case METRIC_UINT32:
- noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%u\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- m->metric_name, m->metric_type, *(m->metric_value.I));
+ srv = noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "M\t%lu.%03lu\t%s\t%s\t%c\t%u\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ m->metric_name, m->metric_type, *(m->metric_value.I));
break;
case METRIC_INT64:
- noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%lld\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- m->metric_name, m->metric_type, *(m->metric_value.l));
+ srv = noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "M\t%lu.%03lu\t%s\t%s\t%c\t%lld\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ m->metric_name, m->metric_type, *(m->metric_value.l));
break;
case METRIC_UINT64:
- noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%llu\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- m->metric_name, m->metric_type, *(m->metric_value.L));
+ srv = noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "M\t%lu.%03lu\t%s\t%s\t%c\t%llu\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ m->metric_name, m->metric_type, *(m->metric_value.L));
break;
case METRIC_DOUBLE:
- noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%.12e\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- m->metric_name, m->metric_type, *(m->metric_value.n));
+ srv = noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "M\t%lu.%03lu\t%s\t%s\t%c\t%.12e\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ m->metric_name, m->metric_type, *(m->metric_value.n));
break;
case METRIC_STRING:
- noitL(ls, "M\t%lu.%03lu\t%s\t%s\t%c\t%s\n",
- SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
- m->metric_name, m->metric_type, m->metric_value.s);
+ srv = noit_log(ls, &c->whence, __FILE__, __LINE__,
+ "M\t%lu.%03lu\t%s\t%s\t%c\t%s\n",
+ SECPART(&c->whence), MSECPART(&c->whence), uuid_str,
+ m->metric_name, m->metric_type, m->metric_value.s);
break;
default:
noitL(noit_error, "Unknown metric type '%c' 0x%x\n",
m->metric_type, m->metric_type);
}
}
+ if(srv) rv = srv;
}
+ return rv;
}
void
noit_check_log_metrics(noit_check_t *check) {
More information about the Reconnoiter-devel
mailing list