void noit_poller_init() { noit_check_tools_init(); noit_skiplist_init(&polls_by_name); noit_skiplist_set_compare(&polls_by_name, __check_name_compare, __check_name_compare); noit_skiplist_init(&watchlist); noit_skiplist_set_compare(&watchlist, __watchlist_compare, __watchlist_compare); register_console_check_commands(); eventer_name_callback("check_recycle_bin_processor", check_recycle_bin_processor); eventer_add_in_s_us(check_recycle_bin_processor, NULL, 60, 0); noit_poller_reload(NULL); }
noit_console_state_t * noit_console_state_alloc(void) { noit_console_state_t *s; s = calloc(1, sizeof(*s)); noit_skiplist_init(&s->cmds); noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek); noit_console_state_add_cmd(s, NCSCMD("apply", noit_console_generic_apply, NULL, NULL, NULL)); noit_console_state_add_cmd(s, &console_command_help); return s; }
void noit_console_add_help(const char *topic, console_cmd_func_t topic_func, console_opt_func_t ac) { noit_console_state_t *s = console_command_help.dstate; if(!s) { console_command_help.dstate = s = calloc(1, sizeof(*s)); noit_skiplist_init(&s->cmds); noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek); } noit_console_state_add_cmd(s, NCSCMD(topic, topic_func, ac, NULL, NULL)); }
static int check_test_onload(noit_image_t *self) { nlerr = noit_log_stream_find("error/checktest"); nldeb = noit_log_stream_find("debug/checktest"); if(!nlerr) nlerr = noit_stderr; if(!nldeb) nldeb = noit_debug; noit_skiplist_init(&in_progress); noit_skiplist_set_compare(&in_progress, check_complete_heap, check_complete_heap_key); return 0; }
void noit_check_transient_add_feed(noit_check_t *check, const char *feed) { char *feedcopy; if(!check->feeds) { check->feeds = calloc(1, sizeof(*check->feeds)); noit_skiplist_init(check->feeds); noit_skiplist_set_compare(check->feeds, (noit_skiplist_comparator_t)strcmp, (noit_skiplist_comparator_t)strcmp); } feedcopy = strdup(feed); /* No error on failure -- it's already there */ if(noit_skiplist_insert(check->feeds, feedcopy) == NULL) free(feedcopy); noitL(noit_debug, "check %s`%s @ %dms has %d feed(s): %s.\n", check->target, check->name, check->period, check->feeds->size, feed); }
void noit_check_resolver_init() { eventer_t e; if(dns_init(NULL, 0) < 0) noitL(noit_error, "dns initialization failed.\n"); dns_ctx = dns_new(NULL); if(dns_init(dns_ctx, 0) != 0 || dns_open(dns_ctx) < 0) { noitL(noit_error, "dns initialization failed.\n"); } eventer_name_callback("dns_cache_callback", dns_cache_callback); dns_set_tmcbck(dns_ctx, dns_cache_utm_fn, dns_ctx); e = eventer_alloc(); e->mask = EVENTER_READ | EVENTER_EXCEPTION; e->closure = dns_ctx; e->callback = dns_cache_callback; e->fd = dns_sock(dns_ctx); eventer_add(e); noit_skiplist_init(&nc_dns_cache); noit_skiplist_set_compare(&nc_dns_cache, name_lookup, name_lookup_k); noit_skiplist_add_index(&nc_dns_cache, refresh_idx, refresh_idx_k); noit_check_resolver_loop(NULL, 0, NULL, NULL); register_console_dns_cache_commands(); }