Changeset 341415bb3a391e0f7d77ab9be37c158397b5c0aa

Show
Ignore:
Timestamp:
02/11/08 06:56:59 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1202713019 +0000
git-parent:

[b0614c34da02c0e3feb1f15373e84746729d693e]

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

make it 'cd'.. I can't seemt to type 'section'. Nav and listing.

Files:

Legend:

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

    r833a45e r341415b  
    1313 
    1414#include "noit_conf.h" 
     15#include "noit_check.h" 
    1516#include "noit_console.h" 
    1617#include "utils/noit_hash.h" 
     
    360361                         int argc, char **argv, 
    361362                         noit_console_state_t *state, void *closure) { 
    362   int i, cnt, cliplen = 0; 
     363  int i, cnt, titled = 0, cliplen = 0; 
    363364  const char *path; 
    364365  char xpath[1024]; 
     
    366367  xmlXPathObjectPtr pobj = NULL; 
    367368  xmlXPathContextPtr current_ctxt; 
     369  xmlNodePtr node; 
    368370 
    369371  if(argc > 1) { 
     
    409411  } 
    410412  cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
     413 
     414  titled = 0; 
    411415  for(i=0; i<cnt; i++) { 
    412     xmlNodePtr node; 
    413416    node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    414     nc_printf(ncct, "%s\n", xmlGetNodePath(node) + cliplen); 
    415   } 
     417    if(!strcmp((char *)node->name, "check")) continue; 
     418    if(node->children && node->children == xmlGetLastChild(node) && 
     419      xmlNodeIsText(node->children)) { 
     420      if(!titled++) nc_printf(ncct, "== Section Settings ==\n"); 
     421      nc_printf(ncct, "%s: %s\n", xmlGetNodePath(node) + cliplen, 
     422                xmlXPathCastNodeToString(node->children)); 
     423    } 
     424  } 
     425 
     426  titled = 0; 
     427  for(i=0; i<cnt; i++) { 
     428    node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
     429    if(!strcmp((char *)node->name, "check")) continue; 
     430    if(!(node->children && node->children == xmlGetLastChild(node) && 
     431         xmlNodeIsText(node->children))) { 
     432      if(!titled++) nc_printf(ncct, "== Subsections ==\n"); 
     433      nc_printf(ncct, "%s\n", xmlGetNodePath(node) + cliplen); 
     434    } 
     435  } 
     436 
     437  titled = 0; 
     438  for(i=0; i<cnt; i++) { 
     439    node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
     440    if(!strcmp((char *)node->name, "check")) { 
     441      int busted = 1; 
     442      xmlAttr *attr; 
     443      char *uuid_str = "undefined";; 
     444 
     445      if(!titled++) nc_printf(ncct, "== Checks ==\n"); 
     446 
     447      for(attr=node->properties; attr; attr = attr->next) { 
     448        if(!strcmp((char *)attr->name, "uuid")) 
     449          uuid_str = (char *)xmlXPathCastNodeToString(attr->children); 
     450      } 
     451      if(uuid_str) { 
     452        uuid_t checkid; 
     453        nc_printf(ncct, "check[@uuid=\"%s\"] ", uuid_str); 
     454        if(uuid_parse(uuid_str, checkid) == 0) { 
     455          noit_check_t *check; 
     456          check = noit_poller_lookup(checkid); 
     457          if(check) { 
     458            busted = 0; 
     459            nc_printf(ncct, "%s`%s", check->target, check->name); 
     460          } 
     461        } 
     462      } 
     463      else 
     464        nc_printf(ncct, "%s ", xmlGetNodePath(node) + cliplen); 
     465      if(busted) nc_printf(ncct, "[check not in running system]"); 
     466      nc_write(ncct, "\n", 1); 
     467    } 
     468  } 
     469  xmlXPathFreeObject(pobj); 
     470  return 0; 
    416471 bad: 
    417472  if(pobj) xmlXPathFreeObject(pobj); 
     
    454509    NCSCMD("ls", noit_console_config_show, NULL, NULL)); 
    455510  noit_console_state_add_cmd(_conf_t_state, 
    456     NCSCMD("section", noit_console_config_cd, NULL, NULL)); 
     511    NCSCMD("cd", noit_console_config_cd, NULL, NULL)); 
    457512 
    458513  _conf_state = calloc(1, sizeof(*_conf_state));