static int mtev_rest_eventer_jobq(mtev_http_rest_closure_t *restc, int n, char **p) { const char *jsonstr; struct json_object *doc; doc = json_object_new_object(); eventer_jobq_process_each(json_spit_jobq, doc); mtev_http_response_ok(restc->http_ctx, "application/json"); jsonstr = json_object_to_json_string(doc); mtev_http_response_append(restc->http_ctx, jsonstr, strlen(jsonstr)); mtev_http_response_append(restc->http_ctx, "\n", 1); json_object_put(doc); mtev_http_response_end(restc->http_ctx); return 0; }
static int noit_console_eventer_jobq(noit_console_closure_t ncct, int argc, char **argv, noit_console_state_t *dstate, void *unused) { eventer_jobq_t *jobq; if(argc != 1) { eventer_jobq_process_each(noit_console_spit_jobq, (void *)ncct); return 0; } jobq = eventer_jobq_retrieve(argv[0]); if(!jobq) { nc_printf(ncct, "no jobq found for '%s'\n", argv[0] ? argv[0] : ""); return 0; } noit_console_spit_jobq(jobq, ncct); return 0; }
static void selfcheck_log_results(noit_module_t *self, noit_check_t *check) { char buff[128]; u_int64_t u64; int64_t s64; int32_t s32; struct threadq_crutch crutch; struct timeval duration, epoch, diff; selfcheck_info_t *ci = check->closure; crutch.check = check; noit_check_stats_clear(check, &check->stats.inprogress); gettimeofday(&check->stats.inprogress.whence, NULL); sub_timeval(check->stats.inprogress.whence, check->last_fire_time, &duration); check->stats.inprogress.duration = duration.tv_sec * 1000 + duration.tv_usec / 1000; check->stats.inprogress.available = NP_UNAVAILABLE; check->stats.inprogress.state = NP_BAD; if(ci->timed_out) check->stats.inprogress.status = "timeout"; else { check->stats.inprogress.available = NP_AVAILABLE; check->stats.inprogress.state = NP_GOOD; check->stats.inprogress.status = "ok"; } /* Set all the metrics here */ s64 = (int64_t)ci->logsize; noit_stats_set_metric(check, &check->stats.inprogress, "feed_bytes", METRIC_INT64, &s64); s32 = noit_poller_check_count(); noit_stats_set_metric(check, &check->stats.inprogress, "check_cnt", METRIC_INT32, &s32); s32 = noit_poller_transient_check_count(); noit_stats_set_metric(check, &check->stats.inprogress, "transient_cnt", METRIC_INT32, &s32); if(eventer_get_epoch(&epoch)) s64 = 0; else { sub_timeval(check->stats.inprogress.whence, epoch, &diff); s64 = diff.tv_sec; } noit_stats_set_metric(check, &check->stats.inprogress, "uptime", METRIC_INT64, &s64); eventer_jobq_process_each(jobq_thread_helper, &crutch); noit_build_version(buff, sizeof(buff)); noit_stats_set_metric(check, &check->stats.inprogress, "version", METRIC_STRING, buff); u64 = noit_check_completion_count(); noit_stats_set_metric(check, &check->stats.inprogress, "checks_run", METRIC_UINT64, &u64); /* feed pull info */ noit_jlog_foreach_feed_stats(selfcheck_feed_details, &crutch); noit_check_set_stats(check, &check->stats.inprogress); noit_check_stats_clear(check, &check->stats.inprogress); }