Esempio n. 1
0
static void
rest_test_check_result(struct check_test_closure *cl) {
  mtev_http_session_ctx *ctx = cl->restc->http_ctx;

  mtevL(nlerr, "Flushing check test result\n");

  if(cl->restc->call_closure_free)
    cl->restc->call_closure_free(cl->restc->call_closure);
  cl->restc->call_closure_free = NULL;
  cl->restc->call_closure = NULL;
  cl->restc->fastpath = NULL;

  if(ctx) {
    eventer_t conne;

    if(cl->output == WANTS_JSON) {
      struct json_object *doc;
      const char *jsonstr;

      doc = noit_check_state_as_json(cl->check, 1);
      mtev_http_response_ok(ctx, "application/json");
      jsonstr = json_object_to_json_string(doc);
      mtev_http_response_append(ctx, jsonstr, strlen(jsonstr));
      mtev_http_response_append(ctx, "\n", 1);
      json_object_put(doc);
    } else {
      xmlDocPtr doc = NULL;
      xmlNodePtr root, state;
  
      doc = xmlNewDoc((xmlChar *)"1.0");
      root = xmlNewDocNode(doc, NULL, (xmlChar *)"check", NULL);
      xmlDocSetRootElement(doc, root);
      state = noit_check_state_as_xml(cl->check, 1);
      xmlAddChild(root, state);
      mtev_http_response_ok(ctx, "text/xml");
      mtev_http_response_xml(ctx, doc);
      xmlFreeDoc(doc);
    }
    mtev_http_response_end(ctx);
  
    conne = mtev_http_connection_event(mtev_http_session_connection(ctx));
    if(conne) {
      // The event already exists, why re-add it?  Did we want to update it?
      //eventer_add(conne);
      eventer_trigger(conne, EVENTER_READ | EVENTER_WRITE);
    }
  }

  noit_poller_free_check(cl->check);
  free(cl);
}
Esempio n. 2
0
int
noit_poller_deschedule(uuid_t in) {
  void *vcheck;
  noit_check_t *checker;
  if(noit_hash_retrieve(&polls,
                        (char *)in, UUID_SIZE,
                        &vcheck) == 0) {
    return -1;
  }
  checker = (noit_check_t *)vcheck;
  checker->flags |= (NP_DISABLED|NP_KILLED);

  noit_skiplist_remove(&polls_by_name, checker, NULL);
  noit_hash_delete(&polls, (char *)in, UUID_SIZE, NULL, NULL);

  noit_poller_free_check(checker);
  return 0;
}
Esempio n. 3
0
static int
check_recycle_bin_processor(eventer_t e, int mask, void *closure,
                            struct timeval *now) {
  static struct timeval one_minute = { 60L, 0L };
  struct _checker_rcb *prev = NULL, *curr = checker_rcb;
  noitL(noit_debug, "Scanning check recycle bin\n");
  while(curr) {
    if(!(curr->checker->flags & NP_RUNNING)) {
      noitL(noit_debug, "Check is ready to free.\n");
      noit_poller_free_check(curr->checker);
      if(prev) prev->next = curr->next;
      else checker_rcb = curr->next;
      free(curr);
      curr = prev ? prev->next : checker_rcb;
    }
    else {
      prev = curr;
      curr = curr->next;
    }
  }
  add_timeval(*now, one_minute, &e->whence);
  return EVENTER_TIMER;
}
Esempio n. 4
0
static void
rest_test_check_result(struct check_test_closure *cl) {
  xmlDocPtr doc = NULL;
  xmlNodePtr root, state;
  noit_http_session_ctx *ctx = cl->restc->http_ctx;

  noitL(nlerr, "Flushing check test result\n");

  if(cl->restc->call_closure_free)
    cl->restc->call_closure_free(cl->restc->call_closure);
  cl->restc->call_closure_free = NULL;
  cl->restc->call_closure = NULL;
  cl->restc->fastpath = NULL;

  if(ctx) {
    eventer_t conne = noit_http_connection_event(noit_http_session_connection(ctx));

    doc = xmlNewDoc((xmlChar *)"1.0");
    root = xmlNewDocNode(doc, NULL, (xmlChar *)"check", NULL);
    xmlDocSetRootElement(doc, root);
    state = noit_check_state_as_xml(cl->check);
    xmlAddChild(root, state);
    noit_http_response_ok(ctx, "text/xml");
    noit_http_response_xml(ctx, doc);
    noit_http_response_end(ctx);
  
    if(conne) {
      // The event already exists, why re-add it?  Did we want to update it?
      //eventer_add(conne);
      eventer_trigger(conne, EVENTER_READ | EVENTER_WRITE);
    }
  }

  noit_poller_free_check(cl->check);
  xmlFreeDoc(doc);
  free(cl);
}