Changeset 2ccf5eb9e64a6e89f4c8e0022eee38cde7e74717

Show
Ignore:
Timestamp:
05/14/08 19:09:15 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1210792155 +0000
git-parent:

[be8707fb024addfa6eb855a9d160e6f2b5afec3f]

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

I think this finishes up #15. I'll not close just yet as I'm not sure how safe it is to reload all the checks without regard if their are in-flight or not. refs #51

Files:

Legend:

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

    r01dbb0d r2ccf5eb  
    177177  if(cnt > 1) { 
    178178    parent_node = xmlXPathNodeSetItem(pobj->nodesetval, cnt-2); 
    179     noit_conf_get_into_hash(parent_node, (const char *)node->name, table); 
     179    if(parent_node != current_node) 
     180      noit_conf_get_into_hash(parent_node, (const char *)node->name, table); 
    180181  } 
    181182  /* 2. */ 
  • src/noit_conf_checks.c

    r2d2a012 r2ccf5eb  
    487487    return -1; 
    488488  } 
     489  if(!strcmp(argv[0], "config")) { 
     490    nc_printf(ncct, "use 'config' to set check config options\n"); 
     491    return -1; 
     492  } 
    489493  info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    490494  if(!strcmp(info->path, "/")) { 
     
    623627                         int argc, char **argv, 
    624628                         noit_console_state_t *state, void *closure) { 
     629  noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
     630  const char *k; 
     631  int klen; 
     632  void *data; 
    625633  int i, cnt, titled = 0, cliplen = 0; 
    626634  const char *path = "", *basepath = NULL; 
    627635  char xpath[1024]; 
    628636  noit_conf_t_userdata_t *info = NULL; 
     637  noit_hash_table *config; 
    629638  xmlXPathObjectPtr pobj = NULL; 
    630639  xmlXPathContextPtr xpath_ctxt = NULL, current_ctxt; 
     
    693702  xmlXPathFreeObject(pobj); 
    694703 
     704  /* Print out all the config settings */ 
     705  titled = 0; 
     706  config = noit_conf_get_hash(node, "config"); 
     707  while(noit_hash_next(config, &iter, &k, &klen, &data)) { 
     708    if(!titled++) nc_printf(ncct, "== Section [Aggregated] Config ==\n"); 
     709    nc_printf(ncct, "config::%s: %s\n", k, (const char *)data); 
     710  } 
     711  noit_hash_destroy(config, free, free); 
     712  free(config); 
     713 
    695714  /* _shorten string_ turning last { / @ * } to { / * } */ 
    696715  strlcpy(xpath + strlen(xpath) - 2, "*", 2); 
     
    705724    node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    706725    if(!strcmp((char *)node->name, "check")) continue; 
     726    if(!strcmp((char *)xmlGetNodePath(node) + cliplen, "config")) continue; 
    707727    if(!(node->children && node->children == xmlGetLastChild(node) && 
    708728         xmlNodeIsText(node->children))) { 
     
    833853 
    834854  noit_conf_xml_xpath(NULL, &xpath_ctxt); 
    835   if(1) { 
    836     /* Only if checks will fixate this attribute shall we check for 
    837      * child <check> nodes. 
    838      * NOTE: this return nothing and "seems" okay if we are _in_ 
    839      *       a <check> node.  That case is handled below. 
    840      */ 
    841     snprintf(xpath, sizeof(xpath), "/noit/%s//check[@uuid]", path); 
    842     pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    843     if(!pobj || pobj->type != XPATH_NODESET) goto out; 
    844     cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    845     for(i=0; i<cnt; i++) { 
    846       uuid_t checkid; 
    847       node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    848       if(noit_conf_get_uuid(node, "@uuid", checkid)) { 
    849         noit_check_t *check; 
    850         check = noit_poller_lookup(checkid); 
    851         if(NOIT_CHECK_LIVE(check)) active++; 
    852      
    853    
    854     if(pobj) xmlXPathFreeObject(pobj); 
    855   } 
     855 
     856  /* Only if checks will fixate this attribute shall we check for 
     857   * child <check> nodes. 
     858   * NOTE: this return nothing and "seems" okay if we are _in_ 
     859   *       a <check> node.  That case is handled below. 
     860   */ 
     861  snprintf(xpath, sizeof(xpath), "/noit/%s//check[@uuid]", path); 
     862  pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
     863  if(!pobj || pobj->type != XPATH_NODESET) goto out; 
     864  cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
     865  for(i=0; i<cnt; i++) { 
     866    uuid_t checkid; 
     867    node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
     868    if(noit_conf_get_uuid(node, "@uuid", checkid)) { 
     869      noit_check_t *check; 
     870      check = noit_poller_lookup(checkid); 
     871      if(NOIT_CHECK_LIVE(check)) active++; 
     872   
     873 
     874  if(pobj) xmlXPathFreeObject(pobj); 
     875 
    856876  snprintf(xpath, sizeof(xpath), "/noit/%s", path); 
    857877  pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
     
    875895    } 
    876896  } 
     897#ifdef UNSAFE_RECONFIG 
    877898  if(active) { 
    878899    nc_printf(ncct, "Cannot set '%s', it would effect %d live check(s)\n", 
     
    880901    goto out; 
    881902  } 
     903#endif 
    882904  if(pobj) xmlXPathFreeObject(pobj); 
    883905 
     
    918940    assert(confignode); 
    919941    /* Now we create a child */ 
    920     xmlNewChild(xmlXPathNodeSetItem(pobj->nodesetval, 0), 
    921                 NULL, (xmlChar *)name, (xmlChar *)value); 
     942    xmlNewChild(confignode, NULL, (xmlChar *)name, (xmlChar *)value); 
    922943     
    923944  } 
     
    11671188  ADD_CMD(_conf_t_state, "ls", noit_console_config_show, NULL, NULL); 
    11681189  ADD_CMD(_conf_t_state, "cd", noit_console_config_cd, NULL, NULL); 
     1190  ADD_CMD(_conf_t_state, "config", noit_console_config_setconfig, NULL, NULL); 
    11691191  ADD_CMD(_conf_t_state, "section", noit_console_config_section, NULL, (void *)0); 
    11701192  ADD_CMD(_conf_t_state, "check", noit_console_check, _conf_t_check_state, NULL);