Changeset 3862f7ec50e174f1457653a8555eb245145913f9

Show
Ignore:
Timestamp:
02/01/10 19:24:22 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1265052262 +0000
git-parent:

[77784a878a8f3a8c86917b1d903f38484914aaff]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1265052262 +0000
Message:

create better output for configured noits in the /noits/show xml REST call, refs #248

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stratcon_jlog_streamer.c

    r77784a8 r3862f7e  
    835835  noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
    836836  char path[256]; 
    837   void *key_id; 
     837  void *key_id, *vtype; 
     838  const char *type = NULL; 
    838839  int klen, n = 0, i, di, cnt; 
    839840  void *vconn; 
     
    842843  struct timeval now, diff, last; 
    843844  xmlNodePtr node; 
     845 
     846  noit_http_process_querystring(&restc->http_ctx->req); 
     847  if(noit_hash_retrieve(&restc->http_ctx->req.querystring, "type", 4, &vtype)) 
     848    type = vtype; 
    844849 
    845850  gettimeofday(&now, NULL); 
     
    865870    noit_connection_ctx_t *ctx = ctxs[i]; 
    866871    jlog_streamer_ctx_t *jctx = ctx->consumer_ctx; 
     872 
     873    feedtype = feed_type_to_str(ntohl(jctx->jlog_feed_cmd)); 
     874 
     875    /* If the user requested a specific type and we're not it, skip. */ 
     876    if(type && strcmp(feedtype, type)) continue; 
    867877 
    868878    node = xmlNewNode(NULL, (xmlChar *)"noit"); 
     
    903913                      0, free, NULL); 
    904914    xmlSetProp(node, (xmlChar *)"remote", (xmlChar *)ctx->remote_str); 
    905     feedtype = feed_type_to_str(ntohl(jctx->jlog_feed_cmd)); 
    906915    xmlSetProp(node, (xmlChar *)"type", (xmlChar *)feedtype); 
    907916    if(ctx->timeout_event) { 
     
    958967  free(ctxs); 
    959968 
    960   snprintf(path, sizeof(path), "//noits//noit"); 
    961   noit_configs = noit_conf_get_sections(NULL, path, &cnt); 
    962   for(di=0; di<cnt; di++) { 
    963     char address[64], port_str[32], remote_str[98]; 
    964     if(noit_conf_get_stringbuf(noit_configs[di], "self::node()/@address", 
    965                                address, sizeof(address))) { 
    966       void *v; 
    967       if(!noit_conf_get_stringbuf(noit_configs[di], "self::node()/@port", 
    968                                  port_str, sizeof(port_str))) 
    969         strlcpy(port_str, "43191", sizeof(port_str)); 
    970       snprintf(remote_str, sizeof(remote_str), "%s:%s", address, port_str); 
    971       if(!noit_hash_retrieve(&seen, remote_str, strlen(remote_str), &v)) { 
    972         node = xmlNewNode(NULL, (xmlChar *)"noit"); 
    973         xmlSetProp(node, (xmlChar *)"remote", (xmlChar *)remote_str); 
    974         xmlSetProp(node, (xmlChar *)"type", (xmlChar *)"durable/inactive"); 
    975         xmlAddChild(root, node); 
     969  if(type && !strcmp(type, "configured")) { 
     970    snprintf(path, sizeof(path), "//noits//noit"); 
     971    noit_configs = noit_conf_get_sections(NULL, path, &cnt); 
     972    for(di=0; di<cnt; di++) { 
     973      char address[64], port_str[32], remote_str[98]; 
     974      if(noit_conf_get_stringbuf(noit_configs[di], "self::node()/@address", 
     975                                 address, sizeof(address))) { 
     976        void *v; 
     977        if(!noit_conf_get_stringbuf(noit_configs[di], "self::node()/@port", 
     978                                   port_str, sizeof(port_str))) 
     979          strlcpy(port_str, "43191", sizeof(port_str)); 
     980        snprintf(remote_str, sizeof(remote_str), "%s:%s", address, port_str); 
     981        if(!noit_hash_retrieve(&seen, remote_str, strlen(remote_str), &v)) { 
     982          char expected_cn[256]; 
     983          node = xmlNewNode(NULL, (xmlChar *)"noit"); 
     984          xmlSetProp(node, (xmlChar *)"remote", (xmlChar *)remote_str); 
     985          xmlSetProp(node, (xmlChar *)"type", (xmlChar *)"configured"); 
     986          if(noit_conf_get_stringbuf(noit_configs[di], "self::node()/config/cn", 
     987                                     expected_cn, sizeof(expected_cn))) 
     988            xmlSetProp(node, (xmlChar *)"cn", (xmlChar *)expected_cn); 
     989          xmlAddChild(root, node); 
     990        } 
    976991      } 
    977992    } 
    978   } 
    979   free(noit_configs); 
     993    free(noit_configs); 
     994  } 
    980995  noit_hash_destroy(&seen, free, NULL); 
    981996