Changeset 5f388ee20a06c319202cb070628c7bc827ffbb0a

Show
Ignore:
Timestamp:
02/26/08 03:46:53 (11 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1203997613 +0000
git-parent:

[2962688c237f289fcbac61c53e08fd0fb2c1021c]

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

split out the noit(check) specific conf stuff into its own file

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/Makefile.in

    r2962688 r5f388ee  
    2828        noit_console.o noit_console_state.o noit_console_telnet.o \ 
    2929        noit_check.o noit_check_log.o noit_check_tools.o \ 
    30         noit_module.o noit_conf.o noit_tokenizer.o 
     30        noit_module.o noit_conf.o noit_conf_checks.o noit_tokenizer.o 
    3131 
    3232all:    noitd testcerts 
  • src/noit_conf.c

    r4dccf83 r5f388ee  
    3939   * PLEASE: keep them alphabetically sorted. 
    4040   */ 
    41   { "/noit/modules/@directory", MODULES_DIR }, 
     41  { "/%s/modules/@directory", MODULES_DIR }, 
    4242 
    4343  { NULL, NULL } 
    4444}; 
    4545 
    46 static void register_console_config_commands(); 
    47  
    48 void noit_conf_init() { 
     46void noit_conf_init(const char *toplevel) { 
    4947  int i; 
     48  char keystr[256]; 
    5049  for(i = 0; config_info[i].key != NULL; i++) { 
     50    snprintf(keystr, sizeof(keystr), config_info[i].key, toplevel); 
    5151    noit_hash_store(&_compiled_fallback, 
    52                     strdup(config_info[i].key), strlen(config_info[i].key), 
     52                    strdup(keystr), strlen(keystr), 
    5353                    (void *)strdup(config_info[i].val)); 
    5454  } 
    5555  xmlInitParser(); 
    5656  xmlXPathInit(); 
    57   register_console_config_commands(); 
    5857} 
    5958 
     
    7170  } 
    7271  return -1; 
     72} 
     73int noit_conf_xml_xpath(xmlDocPtr *mc, xmlXPathContextPtr *xp) { 
     74  if(mc) *mc = master_config; 
     75  if(xp) *xp = xpath_ctxt; 
     76  return 0; 
    7377} 
    7478int noit_conf_save(const char *path) { 
     
    348352} 
    349353 
    350 static void 
    351 conf_t_userdata_free(void *data) { 
    352   noit_conf_t_userdata_t *info = data; 
    353   if(info) { 
    354     if(info->path) free(info->path); 
    355     free(info); 
    356   } 
    357 } 
    358354static int 
    359 noit_console_state_conf_terminal(noit_console_closure_t ncct, 
    360                                  int argc, char **argv, 
    361                                  noit_console_state_t *state, void *closure) { 
    362   noit_conf_t_userdata_t *info; 
    363   if(argc) { 
    364     nc_printf(ncct, "extra arguments not expected.\n"); 
    365     return -1; 
    366   } 
    367   info = calloc(1, sizeof(*info)); 
    368   info->path = strdup("/"); 
    369   noit_console_userdata_set(ncct, NOIT_CONF_T_USERDATA, info, 
    370                             conf_t_userdata_free); 
    371   noit_console_state_push_state(ncct, state); 
    372   noit_console_state_init(ncct); 
    373   return 0; 
     355noit_console_write_xml(void *vncct, const char *buffer, int len) { 
     356  noit_console_closure_t ncct = vncct; 
     357  return nc_write(ncct, buffer, len); 
    374358} 
    375359static int 
    376 noit_console_mkcheck_xpath(char *xpath, int len, 
    377                            noit_conf_t_userdata_t *info, 
    378                            const char *arg) { 
    379   uuid_t checkid; 
    380   char argcopy[1024], *target, *name; 
    381  
    382   argcopy[0] = '\0'; 
    383   if(arg) strlcpy(argcopy, arg, sizeof(argcopy)); 
    384  
    385   if(uuid_parse(argcopy, checkid) == 0) { 
    386     /* If they kill by uuid, we'll seek and destroy -- find it anywhere */ 
    387     snprintf(xpath, len, "/noit/checks//check[@uuid=\"%s\"]", 
    388              argcopy); 
    389   } 
    390   else if((name = strchr(argcopy, '`')) != NULL) { 
    391     noit_check_t *check; 
    392     char uuid_str[37]; 
    393     target = argcopy; 
    394     *name++ = '\0'; 
    395     check = noit_poller_lookup_by_name(target, name); 
    396     if(!check) { 
    397       return -1; 
    398     } 
    399     uuid_unparse_lower(check->checkid, uuid_str); 
    400     snprintf(xpath, len, "/noit/checks//check[@uuid=\"%s\"]", 
    401              uuid_str); 
    402   } 
    403   else { 
    404     char *path = (!info || !strcmp(info->path, "/")) ? "" : info->path; 
    405     snprintf(xpath, len, "/noit%s%s%s[@uuid]", 
    406              path, arg ? "/" : "", arg ? arg : ""); 
    407   } 
    408   return 0; 
    409 
    410 static void 
    411 nc_attr_show(noit_console_closure_t ncct, const char *name, xmlNodePtr cnode, 
    412              xmlNodePtr anode, const char *value) { 
    413   const char *cpath, *apath; 
    414   cpath = cnode ? (char *)xmlGetNodePath(cnode) : ""; 
    415   apath = anode ? (char *)xmlGetNodePath(anode) : ""; 
    416   nc_printf(ncct, " %s: %s", name, value ? value : "[undef]"); 
    417   if(value && cpath && apath) { 
    418     int clen = strlen(cpath); 
    419     int plen = strlen("/noit/checks/"); 
    420     if(!strncmp(cpath, apath, clen) && apath[clen] == '/') { 
    421       /* we have a match, which means it isn't inherited */ 
    422     } 
    423     else { 
    424       nc_printf(ncct, " [inherited from %s]", 
    425                 strlen(apath) > plen ? apath + plen : apath); 
    426     } 
    427   } 
    428   nc_write(ncct, "\n", 1); 
    429 
    430 static void  
    431 refresh_subchecks(noit_console_closure_t ncct, 
    432                   noit_conf_t_userdata_t *info) { 
    433   char *path; 
    434   char xpath[1024]; 
    435   
    436   path = info->path; 
    437   if(!strcmp(path, "/")) path = ""; 
    438  
    439   /* The first one is just a process_checks, the second is the reload. 
    440    * Reload does a lot of work and there is no need to do it twice. 
    441    */ 
    442   snprintf(xpath, sizeof(xpath), "/noit/%s[@uuid]", path); 
    443   noit_poller_process_checks(xpath); 
    444   snprintf(xpath, sizeof(xpath), "/noit/%s//check[@uuid]", path); 
    445   noit_poller_reload(xpath); 
    446 
    447 static int 
    448 noit_conf_mkcheck_under(const char *ppath, uuid_t out) { 
    449   int rv = -1; 
    450   const char *path; 
    451   char xpath[1024]; 
    452   xmlXPathObjectPtr pobj = NULL; 
    453   xmlNodePtr node = NULL, newnode; 
    454  
    455   path = strcmp(ppath, "/") ? ppath : ""; 
    456   snprintf(xpath, sizeof(xpath), "/noit%s", path); 
    457   pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    458   if(!pobj || pobj->type != XPATH_NODESET || 
    459      xmlXPathNodeSetGetLength(pobj->nodesetval) != 1) { 
    460     goto out; 
    461   } 
    462   node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, 0); 
    463   if((newnode = xmlNewChild(node, NULL, (xmlChar *)"check", NULL)) != NULL) { 
    464     char outstr[37]; 
    465     uuid_generate(out); 
    466     uuid_unparse_lower(out, outstr); 
    467     xmlSetProp(newnode, (xmlChar *)"uuid", (xmlChar *)outstr); 
    468     rv = 0; 
    469   } 
    470  out: 
    471   if(pobj) xmlXPathFreeObject(pobj); 
    472   return rv; 
    473 
    474 static int 
    475 noit_console_check(noit_console_closure_t ncct, 
    476                    int argc, char **argv, 
    477                    noit_console_state_t *state, void *closure) { 
    478   int cnt; 
    479   noit_conf_t_userdata_t *info; 
    480   char xpath[1024], newuuid_str[37]; 
    481   char *uuid_conf, *wanted; 
    482   uuid_t checkid; 
    483   xmlXPathObjectPtr pobj = NULL; 
    484   xmlNodePtr node = NULL; 
    485   noit_conf_boolean creating_new = noit_false; 
    486  
    487   if(argc > 1) { 
    488     nc_printf(ncct, "requires zero or one arguments\n"); 
    489     return -1; 
    490   } 
    491  
    492   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    493   wanted = argc ? argv[0] : NULL; 
    494   if(!wanted) { 
    495     /* We are creating a new node */ 
    496     uuid_t out; 
    497     creating_new = noit_true; 
    498     if(noit_conf_mkcheck_under(info->path, out)) { 
    499       nc_printf(ncct, "Error creating new check\n"); 
    500       return -1; 
    501     } 
    502     newuuid_str[0] = '\0'; 
    503     uuid_unparse_lower(out, newuuid_str); 
    504     wanted = newuuid_str; 
    505   } 
    506   /* We many not be in conf-t mode -- that's fine */ 
    507   if(noit_console_mkcheck_xpath(xpath, sizeof(xpath), info, wanted)) { 
    508     nc_printf(ncct, "could not find check '%s'\n", wanted); 
    509     return -1; 
    510   } 
    511  
    512   pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    513   if(!pobj || pobj->type != XPATH_NODESET || 
    514      xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    515     nc_printf(ncct, "no checks found\n"); 
    516     goto out; 
    517   } 
    518   cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    519   if(info && cnt != 1) { 
    520     nc_printf(ncct, "Ambiguous check specified\n"); 
    521     goto out; 
    522   } 
    523   node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, 0); 
    524   uuid_conf = (char *)xmlGetProp(node, (xmlChar *)"uuid"); 
    525   if(!uuid_conf || uuid_parse(uuid_conf, checkid)) { 
    526     nc_printf(ncct, "%s has invalid or missing UUID!\n", 
    527               (char *)xmlGetNodePath(node) + strlen("/noit")); 
    528     goto out; 
    529   } 
    530   if(info) { 
    531     if(info->path) free(info->path); 
    532     info->path = strdup((char *)xmlGetNodePath(node) + strlen("/noit")); 
    533     uuid_copy(info->current_check, checkid); 
    534     if(creating_new) refresh_subchecks(ncct, info); 
    535     noit_console_state_push_state(ncct, state); 
    536     noit_console_state_init(ncct); 
    537     goto out; 
    538   } 
    539  out: 
    540   if(pobj) xmlXPathFreeObject(pobj); 
    541   return 0; 
    542 
    543 static int 
    544 noit_console_show_check(noit_console_closure_t ncct, 
    545                         int argc, char **argv, 
    546                         noit_console_state_t *state, void *closure) { 
    547   int i, cnt; 
    548   noit_conf_t_userdata_t *info; 
    549   char xpath[1024]; 
    550   xmlXPathObjectPtr pobj = NULL; 
    551  
    552   if(argc > 1) { 
    553     nc_printf(ncct, "requires zero or one arguments\n"); 
    554     return -1; 
    555   } 
    556  
    557   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    558   /* We many not be in conf-t mode -- that's fine */ 
    559   if(noit_console_mkcheck_xpath(xpath, sizeof(xpath), info, 
    560                                 argc ? argv[0] : NULL)) { 
    561     nc_printf(ncct, "could not find check '%s'\n", argv[0]); 
    562     return -1; 
    563   } 
    564  
    565   pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    566   if(!pobj || pobj->type != XPATH_NODESET || 
    567      xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    568     nc_printf(ncct, "no checks found\n"); 
    569     goto out; 
    570   } 
    571   cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    572   if(info && cnt != 1) { 
    573     nc_printf(ncct, "Ambiguous check specified\n"); 
    574     goto out; 
    575   } 
    576   for(i=0; i<cnt; i++) { 
    577     uuid_t checkid; 
    578     noit_check_t *check; 
    579     xmlNodePtr node, anode, mnode = NULL; 
    580     char *uuid_conf; 
    581     char *module, *value; 
    582  
    583     node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    584     uuid_conf = (char *)xmlGetProp(node, (xmlChar *)"uuid"); 
    585     if(!uuid_conf || uuid_parse(uuid_conf, checkid)) { 
    586       nc_printf(ncct, "%s has invalid or missing UUID!\n", 
    587                 (char *)xmlGetNodePath(node) + strlen("/noit")); 
    588       continue; 
    589     } 
    590     nc_printf(ncct, "==== %s ====\n", uuid_conf); 
    591  
    592 #define MYATTR(a,n,b) _noit_conf_get_string(node, &(n), "@" #a, &(b)) 
    593 #define INHERIT(a,n,b) \ 
    594   _noit_conf_get_string(node, &(n), "ancestor-or-self::node()/@" #a, &(b)) 
    595 #define SHOW_ATTR(a) do { \ 
    596   anode = NULL; \ 
    597   value = NULL; \ 
    598   INHERIT(a, anode, value); \ 
    599   nc_attr_show(ncct, #a, node, anode, value); \ 
    600 } while(0) 
    601  
    602     if(!INHERIT(module, mnode, module)) module = NULL; 
    603     if(MYATTR(name, anode, value)) 
    604       nc_printf(ncct, " name: %s\n", value); 
    605     else 
    606       nc_printf(ncct, " name: %s [from module]\n", module ? module : "[undef]"); 
    607     nc_attr_show(ncct, "module", node, mnode, module); 
    608     SHOW_ATTR(target); 
    609     SHOW_ATTR(period); 
    610     SHOW_ATTR(timeout); 
    611     SHOW_ATTR(oncheck); 
    612     SHOW_ATTR(disable); 
    613     check = noit_poller_lookup(checkid); 
    614     if(!check) { 
    615       nc_printf(ncct, " ERROR: not in running system\n"); 
    616     } 
    617     else { 
    618       int idx = 0; 
    619       nc_printf(ncct, " currently: "); 
    620       if(NOIT_CHECK_RUNNING(check)) nc_printf(ncct, "%srunning", idx++?",":""); 
    621       if(NOIT_CHECK_KILLED(check)) nc_printf(ncct, "%skilled", idx++?",":""); 
    622       if(!NOIT_CHECK_CONFIGURED(check)) nc_printf(ncct, "%sunconfig", idx++?",":""); 
    623       if(NOIT_CHECK_DISABLED(check)) nc_printf(ncct, "%sdisabled", idx++?",":""); 
    624       nc_write(ncct, "\n", 1); 
    625       if(check->stats.current.status) 
    626         nc_printf(ncct, " recently: %s\n", check->stats.current.status); 
    627     } 
    628   } 
    629  out: 
    630   if(pobj) xmlXPathFreeObject(pobj); 
    631   return 0; 
    632 
    633 static int 
    634 noit_console_config_nocheck(noit_console_closure_t ncct, 
    635                             int argc, char **argv, 
    636                             noit_console_state_t *state, void *closure) { 
    637   int i, cnt; 
    638   const char *err = "internal error"; 
    639   noit_conf_t_userdata_t *info; 
    640   xmlXPathObjectPtr pobj = NULL; 
    641   char xpath[1024]; 
    642   uuid_t checkid; 
    643  
    644   if(argc != 1) { 
    645     nc_printf(ncct, "requires one argument\n"); 
    646     return -1; 
    647   } 
    648  
    649   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    650   if(noit_console_mkcheck_xpath(xpath, sizeof(xpath), info, argv[0])) { 
    651     nc_printf(ncct, "could not find check '%s'\n", argv[0]); 
    652     return -1; 
    653   } 
    654   pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    655   if(!pobj || pobj->type != XPATH_NODESET || 
    656      xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    657     err = "no checks found"; 
    658     goto bad; 
    659   } 
    660   cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    661   for(i=0; i<cnt; i++) { 
    662     xmlNodePtr node; 
    663     char *uuid_conf; 
    664     node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    665     uuid_conf = (char *)xmlGetProp(node, (xmlChar *)"uuid"); 
    666     if(!uuid_conf || uuid_parse(uuid_conf, checkid)) { 
    667       nc_printf(ncct, "%s has invalid or missing UUID!\n", 
    668                 (char *)xmlGetNodePath(node) + strlen("/noit")); 
    669     } 
    670     else { 
    671       nc_printf(ncct, "descheduling %s\n", uuid_conf); 
    672       noit_poller_deschedule(checkid); 
    673       xmlUnlinkNode(node); 
    674     } 
    675   } 
    676   nc_printf(ncct, "rebuilding causal map...\n"); 
    677   noit_poller_make_causal_map(); 
    678   if(pobj) xmlXPathFreeObject(pobj); 
    679   return 0; 
    680  bad: 
    681   if(pobj) xmlXPathFreeObject(pobj); 
    682   nc_printf(ncct, "%s\n", err); 
    683   return -1; 
    684 
    685 static int 
    686 noit_console_config_section(noit_console_closure_t ncct, 
    687                             int argc, char **argv, 
    688                             noit_console_state_t *state, void *closure) { 
    689   const char *err = "internal error"; 
    690   char *path, xpath[1024]; 
    691   noit_conf_t_userdata_t *info; 
    692   xmlXPathObjectPtr pobj = NULL; 
    693   xmlNodePtr node = NULL, newnode; 
    694   vpsized_int delete = (vpsized_int)closure; 
    695  
    696   if(argc != 1) { 
    697     nc_printf(ncct, "requires one argument\n"); 
    698     return -1; 
    699   } 
    700   if(strchr(argv[0], '/')) { 
    701     nc_printf(ncct, "invalid section name\n"); 
    702     return -1; 
    703   } 
    704   if(!strcmp(argv[0], "check")) { 
    705     nc_printf(ncct, "use 'check' to create checks\n"); 
    706     return -1; 
    707   } 
    708   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    709   if(!strcmp(info->path, "/")) { 
    710     nc_printf(ncct, "manipulation of toplevel section disallowed\n"); 
    711     return -1; 
    712   } 
    713  
    714   if(delete) { 
    715     /* We cannot delete if we have checks */ 
    716     snprintf(xpath, sizeof(xpath), "/noit%s/%s//check", info->path, argv[0]); 
    717     pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    718     if(!pobj || pobj->type != XPATH_NODESET || 
    719        !xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    720       err = "cannot delete section, has checks"; 
    721       goto bad; 
    722     } 
    723     if(pobj) xmlXPathFreeObject(pobj); 
    724   } 
    725  
    726   snprintf(xpath, sizeof(xpath), "/noit%s/%s", info->path, argv[0]); 
    727   pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    728   if(!pobj || pobj->type != XPATH_NODESET) { 
    729     err = "internal error: cannot detect section"; 
    730     goto bad; 
    731   } 
    732   if(!delete && !xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    733     err = "cannot create section"; 
    734     goto bad; 
    735   } 
    736   if(delete && xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    737     err = "no such section"; 
    738     goto bad; 
    739   } 
    740   if(delete) { 
    741     node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, 0); 
    742     xmlUnlinkNode(node); 
    743     return 0; 
    744   } 
    745   if(pobj) xmlXPathFreeObject(pobj); 
    746  
    747   path = strcmp(info->path, "/") ? info->path : ""; 
    748   snprintf(xpath, sizeof(xpath), "/noit%s", path); 
    749   pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    750   if(!pobj || pobj->type != XPATH_NODESET || 
    751      xmlXPathNodeSetGetLength(pobj->nodesetval) != 1) { 
    752     err = "path invalid?"; 
    753     goto bad; 
    754   } 
    755   node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, 0); 
    756   if((newnode = xmlNewChild(node, NULL, (xmlChar *)argv[0], NULL)) != NULL) 
    757     info->path = strdup((char *)xmlGetNodePath(newnode) + strlen("/noit")); 
    758   else { 
    759     err = "failed to create section"; 
    760     goto bad; 
    761   } 
    762   if(pobj) xmlXPathFreeObject(pobj); 
    763   return 0; 
    764  bad: 
    765   if(pobj) xmlXPathFreeObject(pobj); 
    766   nc_printf(ncct, "%s\n", err); 
    767   return -1; 
    768 
    769  
    770 static int 
    771 noit_console_config_cd(noit_console_closure_t ncct, 
    772                        int argc, char **argv, 
    773                        noit_console_state_t *state, void *closure) { 
    774   const char *err = "internal error"; 
    775   char *path, xpath[1024]; 
    776   noit_conf_t_userdata_t *info; 
    777   xmlXPathObjectPtr pobj = NULL; 
    778   xmlXPathContextPtr current_ctxt; 
    779   xmlNodePtr node = NULL; 
    780   char *dest; 
    781  
    782   if(argc != 1 && !closure) { 
    783     nc_printf(ncct, "requires one argument\n"); 
    784     return -1; 
    785   } 
    786   dest = argc ? argv[0] : (char *)closure; 
    787   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    788   if(dest[0] == '/') 
    789     snprintf(xpath, sizeof(xpath), "/noit%s", dest); 
    790   else { 
    791     snprintf(xpath, sizeof(xpath), "/noit%s/%s", info->path, dest); 
    792   } 
    793   if(xpath[strlen(xpath)-1] == '/') xpath[strlen(xpath)-1] = '\0'; 
    794  
    795   current_ctxt = xpath_ctxt; 
    796   pobj = xmlXPathEval((xmlChar *)xpath, current_ctxt); 
    797   if(!pobj || pobj->type != XPATH_NODESET || 
    798      xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    799     err = "no such section"; 
    800     goto bad; 
    801   } 
    802   if(xmlXPathNodeSetGetLength(pobj->nodesetval) > 1) { 
    803     err = "ambiguous section"; 
    804     goto bad; 
    805   } 
    806  
    807   node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, 0); 
    808   if(!strcmp((char *)node->name, "check")) { 
    809     err = "can't cd into a check, use 'check' instead"; 
    810     goto bad; 
    811   } 
    812   path = (char *)xmlGetNodePath(node); 
    813   if(strncmp(path, "/noit/", strlen("/noit/")) && strcmp(path, "/noit")) { 
    814     err = "new path outside out tree"; 
    815     goto bad; 
    816   } 
    817   free(info->path); 
    818   if(!strcmp(path, "/noit")) 
    819     info->path = strdup("/"); 
    820   else 
    821     info->path = strdup((char *)xmlGetNodePath(node) + strlen("/noit")); 
    822   if(pobj) xmlXPathFreeObject(pobj); 
    823   if(closure) noit_console_state_pop(ncct, argc, argv, NULL, NULL); 
    824   return 0; 
    825  bad: 
    826   if(pobj) xmlXPathFreeObject(pobj); 
    827   nc_printf(ncct, "%s\n", err); 
    828   return -1; 
    829 
    830 static int 
    831 noit_console_config_show(noit_console_closure_t ncct, 
    832                          int argc, char **argv, 
    833                          noit_console_state_t *state, void *closure) { 
    834   int i, cnt, titled = 0, cliplen = 0; 
    835   const char *path = "", *basepath = NULL; 
    836   char xpath[1024]; 
    837   noit_conf_t_userdata_t *info = NULL; 
    838   xmlXPathObjectPtr pobj = NULL; 
    839   xmlXPathContextPtr current_ctxt; 
    840   xmlNodePtr node; 
    841  
    842   if(argc > 1) { 
    843     nc_printf(ncct, "too many arguments\n"); 
    844     return -1; 
    845   } 
    846  
    847   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    848   if(info) path = basepath = info->path; 
    849   if(!info && argc == 0) { 
    850     nc_printf(ncct, "argument required when not in configuration mode\n"); 
    851     return -1; 
    852   } 
    853  
    854   if(argc == 1) path = argv[0]; 
    855   if(!basepath) basepath = path; 
    856  
    857   /* { / } is a special case */ 
    858   if(!strcmp(basepath, "/")) basepath = ""; 
    859   if(!strcmp(path, "/")) path = ""; 
    860  
    861   if(!master_config) { 
    862     nc_printf(ncct, "no config\n"); 
    863     return -1; 
    864   } 
    865  
    866   /* { / } is the only path that will end with a / 
    867    * in XPath { / / * } means something _entirely different than { / * } 
    868    * Ever notice how it is hard to describe xpath in C comments? 
    869    */ 
    870   /* We don't want to show the root node */ 
    871   cliplen = strlen("/noit/"); 
    872  
    873   /* If we are in configuration mode 
    874    * and we are without an argument or the argument is absolute, 
    875    * clip the current path off */ 
    876   if(info && (argc == 0 || path[0] != '/')) cliplen += strlen(basepath); 
    877   if(!path[0] || path[0] == '/') /* base only, or absolute path requested */ 
    878     snprintf(xpath, sizeof(xpath), "/noit%s/@*", path); 
    879   else 
    880     snprintf(xpath, sizeof(xpath), "/noit%s/%s/@*", basepath, path); 
    881  
    882   current_ctxt = xpath_ctxt; 
    883   pobj = xmlXPathEval((xmlChar *)xpath, current_ctxt); 
    884   if(!pobj || pobj->type != XPATH_NODESET) { 
    885     nc_printf(ncct, "no such object\n"); 
    886     goto bad; 
    887   } 
    888   cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    889   titled = 0; 
    890   for(i=0; i<cnt; i++) { 
    891     node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    892     if(!strcmp((char *)node->name, "check")) continue; 
    893     if(node->children && node->children == xmlGetLastChild(node) && 
    894       xmlNodeIsText(node->children)) { 
    895       if(!titled++) nc_printf(ncct, "== Section Settings ==\n"); 
    896       nc_printf(ncct, "%s: %s\n", xmlGetNodePath(node) + cliplen, 
    897                 xmlXPathCastNodeToString(node->children)); 
    898     } 
    899   } 
    900   xmlXPathFreeObject(pobj); 
    901  
    902   /* _shorten string_ turning last { / @ * } to { / * } */ 
    903   strlcpy(xpath + strlen(xpath) - 2, "*", 2); 
    904   pobj = xmlXPathEval((xmlChar *)xpath, current_ctxt); 
    905   if(!pobj || pobj->type != XPATH_NODESET) { 
    906     nc_printf(ncct, "no such object\n"); 
    907     goto bad; 
    908   } 
    909   cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    910   titled = 0; 
    911   for(i=0; i<cnt; i++) { 
    912     node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    913     if(!strcmp((char *)node->name, "check")) continue; 
    914     if(!(node->children && node->children == xmlGetLastChild(node) && 
    915          xmlNodeIsText(node->children))) { 
    916       if(!titled++) nc_printf(ncct, "== Subsections ==\n"); 
    917       nc_printf(ncct, "%s\n", xmlGetNodePath(node) + cliplen); 
    918     } 
    919   } 
    920  
    921   titled = 0; 
    922   for(i=0; i<cnt; i++) { 
    923     node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    924     if(!strcmp((char *)node->name, "check")) { 
    925       int busted = 1; 
    926       xmlAttr *attr; 
    927       char *uuid_str = "undefined";; 
    928  
    929       if(!titled++) nc_printf(ncct, "== Checks ==\n"); 
    930  
    931       for(attr=node->properties; attr; attr = attr->next) { 
    932         if(!strcmp((char *)attr->name, "uuid")) 
    933           uuid_str = (char *)xmlXPathCastNodeToString(attr->children); 
    934       } 
    935       if(uuid_str) { 
    936         uuid_t checkid; 
    937         nc_printf(ncct, "check[@uuid=\"%s\"] ", uuid_str); 
    938         if(uuid_parse(uuid_str, checkid) == 0) { 
    939           noit_check_t *check; 
    940           check = noit_poller_lookup(checkid); 
    941           if(check) { 
    942             busted = 0; 
    943             nc_printf(ncct, "%s`%s", check->target, check->name); 
    944           } 
    945         } 
    946       } 
    947       else 
    948         nc_printf(ncct, "%s ", xmlGetNodePath(node) + cliplen); 
    949       if(busted) nc_printf(ncct, "[check not in running system]"); 
    950       nc_write(ncct, "\n", 1); 
    951     } 
    952   } 
    953   xmlXPathFreeObject(pobj); 
    954   return 0; 
    955  bad: 
    956   if(pobj) xmlXPathFreeObject(pobj); 
    957   return -1; 
    958 
    959  
    960 static char * 
    961 conf_t_check_prompt(EditLine *el) { 
    962   noit_console_closure_t ncct; 
    963   noit_conf_t_userdata_t *info; 
    964   noit_check_t *check; 
    965   static char *tl = "noit(conf)# "; 
    966   static char *pfmt = "noit(conf:%s%s%s)# "; 
    967  
    968   el_get(el, EL_USERDATA, (void *)&ncct); 
    969   if(!ncct) return tl; 
    970   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    971   if(!info) return tl; 
    972  
    973   check = noit_poller_lookup(info->current_check); 
    974   if(check && 
    975      check->target && check->target[0] && 
    976      check->name && check->name[0]) 
    977     snprintf(info->prompt, sizeof(info->prompt), 
    978              pfmt, check->target, "`", check->name); 
    979   else { 
    980     char uuid_str[37]; 
    981     uuid_unparse_lower(info->current_check, uuid_str); 
    982     snprintf(info->prompt, sizeof(info->prompt), pfmt, "[", uuid_str, "]"); 
    983   } 
    984   return info->prompt; 
    985 
    986 static char * 
    987 conf_t_prompt(EditLine *el) { 
    988   noit_console_closure_t ncct; 
    989   noit_conf_t_userdata_t *info; 
    990   static char *tl = "noit(conf)# "; 
    991   static char *pfmt = "noit(conf:%s%s)# "; 
    992   int path_len, max_len; 
    993  
    994   el_get(el, EL_USERDATA, (void *)&ncct); 
    995   if(!ncct) return tl; 
    996   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    997   if(!info) return tl; 
    998  
    999   path_len = strlen(info->path); 
    1000   max_len = sizeof(info->prompt) - (strlen(pfmt) - 4 /* %s%s */) - 1 /* \0 */; 
    1001   if(path_len > max_len) 
    1002     snprintf(info->prompt, sizeof(info->prompt), 
    1003              pfmt, "...", info->path + path_len - max_len + 3 /* ... */); 
    1004   else 
    1005     snprintf(info->prompt, sizeof(info->prompt), pfmt, "", info->path); 
    1006   return info->prompt; 
    1007 
    1008 static int 
     360noit_console_close_xml(void *vncct) { 
     361  return 0; 
     362
     363 
     364int 
    1009365noit_conf_reload(noit_console_closure_t ncct, 
    1010366                 int argc, char **argv, 
     
    1014370    return -1; 
    1015371  } 
    1016   noit_poller_reload(NULL); 
    1017   return 0; 
    1018 
    1019 static int 
    1020 noit_console_write_xml(void *vncct, const char *buffer, int len) { 
    1021   noit_console_closure_t ncct = vncct; 
    1022   return nc_write(ncct, buffer, len); 
    1023 
    1024 static int 
    1025 noit_console_close_xml(void *vncct) { 
    1026   return 0; 
    1027 
    1028 static int 
     372  return 0; 
     373
     374int 
    1029375noit_conf_write_terminal(noit_console_closure_t ncct, 
    1030376                         int argc, char **argv, 
     
    1039385  return 0; 
    1040386} 
    1041 static int 
     387int 
    1042388noit_conf_write_file(noit_console_closure_t ncct, 
    1043389                     int argc, char **argv, 
     
    1078424} 
    1079425 
    1080 static struct _valid_attr_t { 
    1081   const char *scope; 
    1082   const char *name; 
    1083   const char *xpath; 
    1084   int checks_fixate; 
    1085 } valid_attrs[] = { 
    1086   { "/checks", "name", "@name", 0 }, 
    1087   { "/checks", "target", "@target", 0 }, 
    1088   { "/checks", "period", "@period", 0 }, 
    1089   { "/checks", "timeout", "@timeout", 0 }, 
    1090   { "/checks", "oncheck", "@oncheck", 0 }, 
    1091   { "/checks", "disable", "@disable", 0 }, 
    1092   { "/checks", "module", "@module", 1 }, 
    1093 }; 
    1094  
    1095426void 
    1096 noit_console_state_add_check_attrs(noit_console_state_t *state, 
    1097                                    console_cmd_func_t f) { 
    1098   int i; 
    1099   for(i = 0; 
    1100       i < sizeof(valid_attrs)/sizeof(valid_attrs[0]); 
    1101       i++) { 
    1102     noit_console_state_add_cmd(state, 
    1103       NCSCMD(valid_attrs[i].name, f, 
    1104              NULL, &valid_attrs[i])); 
    1105   } 
    1106 
    1107  
    1108 static int 
    1109 validate_attr_set_scope(noit_conf_t_userdata_t *info, 
    1110                         struct _valid_attr_t *attrinfo) { 
    1111   int len; 
    1112   len = strlen(attrinfo->scope); 
    1113   if(strncmp(info->path, attrinfo->scope, len) || 
    1114      (info->path[len] != '\0' && info->path[len] != '/')) { 
    1115     return -1; 
    1116   } 
    1117   return 0; 
    1118 
    1119 static int 
    1120 replace_attr(noit_console_closure_t ncct, 
    1121              noit_conf_t_userdata_t *info, struct _valid_attr_t *attrinfo, 
    1122              const char *value) { 
    1123   int i, cnt, rv = -1, active = 0; 
    1124   xmlXPathObjectPtr pobj = NULL; 
    1125   xmlNodePtr node; 
    1126   char xpath[1024], *path; 
    1127  
    1128   path = info->path; 
    1129   if(!strcmp(path, "/")) path = ""; 
    1130  
    1131   if(attrinfo->checks_fixate) { 
    1132     /* Only if checks will fixate this attribute shall we check for 
    1133      * child <check> nodes. 
    1134      * NOTE: this return nothing and "seems" okay if we are _in_ 
    1135      *       a <check> node.  That case is handled below. 
    1136      */ 
    1137     snprintf(xpath, sizeof(xpath), "/noit/%s//check[@uuid]", path); 
    1138     pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    1139     if(!pobj || pobj->type != XPATH_NODESET) goto out; 
    1140     cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    1141     for(i=0; i<cnt; i++) { 
    1142       uuid_t checkid; 
    1143       node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 
    1144       if(noit_conf_get_uuid(node, "@uuid", checkid)) { 
    1145         noit_check_t *check; 
    1146         check = noit_poller_lookup(checkid); 
    1147         if(NOIT_CHECK_LIVE(check)) active++; 
    1148       } 
    1149     } 
    1150     if(pobj) xmlXPathFreeObject(pobj); 
    1151   } 
    1152   snprintf(xpath, sizeof(xpath), "/noit/%s", path); 
    1153   pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); 
    1154   if(!pobj || pobj->type != XPATH_NODESET) goto out; 
    1155   cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 
    1156   if(cnt != 1) { 
    1157     nc_printf(ncct, "Internal error: context node disappeared\n"); 
    1158     goto out; 
    1159   } 
    1160   node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, 0); 
    1161   if(attrinfo->checks_fixate && 
    1162      !strcmp((const char *)node->name, "check")) { 
    1163     uuid_t checkid; 
    1164     /* Detect if  we are actually a <check> node and attempting to 
    1165      * change something we shouldn't. 
    1166      * This is the counterpart noted above. 
    1167      */ 
    1168     if(noit_conf_get_uuid(node, "@uuid", checkid)) { 
    1169       noit_check_t *check; 
    1170       check = noit_poller_lookup(checkid); 
    1171       if(NOIT_CHECK_LIVE(check)) active++; 
    1172     } 
    1173   } 
    1174   if(active) { 
    1175     nc_printf(ncct, "Cannot set '%s', it would effect %d live check(s)\n", 
    1176               attrinfo->name, active); 
    1177     goto out; 
    1178   } 
    1179   xmlUnsetProp(node, (xmlChar *)attrinfo->name); 
    1180   if(value) 
    1181     xmlSetProp(node, (xmlChar *)attrinfo->name, (xmlChar *)value); 
    1182   rv = 0; 
    1183  out: 
    1184   if(pobj) xmlXPathFreeObject(pobj); 
    1185   return rv; 
    1186 
    1187 int 
    1188 noit_conf_check_set_attr(noit_console_closure_t ncct, 
    1189                          int argc, char **argv, 
    1190                          noit_console_state_t *state, void *closure) { 
    1191   struct _valid_attr_t *attrinfo = closure; 
    1192   noit_conf_t_userdata_t *info; 
    1193  
    1194   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    1195   if(!info || validate_attr_set_scope(info, attrinfo)) { 
    1196     nc_printf(ncct, "'%s' attribute only valid in %s scope\n", 
    1197               attrinfo->name, attrinfo->scope); 
    1198     return -1; 
    1199   } 
    1200  
    1201   if(argc != 1) { 
    1202     nc_printf(ncct, "set requires exactly one value\n"); 
    1203     return -1; 
    1204   } 
    1205   /* Okay, we have an attribute and it should be set/replaced on the 
    1206    * current path. 
    1207    */ 
    1208   if(replace_attr(ncct, info, attrinfo, argv[0])) { 
    1209     return -1; 
    1210   } 
    1211  
    1212   /* So, we updated an attribute, so we need to reload all checks 
    1213    * that are descendent-or-self of this node. 
    1214    */ 
    1215   refresh_subchecks(ncct, info); 
    1216   return 0; 
    1217 
    1218  
    1219 int 
    1220 noit_conf_check_unset_attr(noit_console_closure_t ncct, 
    1221                            int argc, char **argv, 
    1222                            noit_console_state_t *state, void *closure) { 
    1223   struct _valid_attr_t *attrinfo = closure; 
    1224   noit_conf_t_userdata_t *info; 
    1225  
    1226   info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 
    1227   if(!info || validate_attr_set_scope(info, attrinfo)) { 
    1228     nc_printf(ncct, "'%s' attribute only valid in %s scope\n", 
    1229               attrinfo->name, attrinfo->scope); 
    1230     return -1; 
    1231   } 
    1232  
    1233   if(argc != 0) { 
    1234     nc_printf(ncct, "no arguments allowed to this command.\n"); 
    1235     return -1; 
    1236   } 
    1237   /* Okay, we have an attribute and it should be set/replaced on the 
    1238    * current path. 
    1239    */ 
    1240   if(replace_attr(ncct, info, attrinfo, NULL)) { 
    1241     return -1; 
    1242   } 
    1243  
    1244   /* So, we updated an attribute, so we need to reload all checks 
    1245    * that are descendent-or-self of this node. 
    1246    */ 
    1247   refresh_subchecks(ncct, info); 
    1248   return 0; 
    1249 
    1250  
    1251 #define NEW_STATE(a) (a) = calloc(1, sizeof(*(a))) 
    1252 #define ADD_CMD(a,cmd,func,ss,c) \ 
    1253   noit_console_state_add_cmd((a), \ 
    1254     NCSCMD(cmd, func, ss, c)) 
    1255 #define DELEGATE_CMD(a,cmd,ss) \ 
    1256   noit_console_state_add_cmd((a), \ 
    1257     NCSCMD(cmd, noit_console_state_delegate, ss, NULL)) 
    1258  
    1259 static 
    1260 void register_console_config_commands() { 
    1261   cmd_info_t *showcmd; 
    1262   noit_console_state_t *tl, *_conf_state, *_conf_t_state, 
    1263                        *_conf_t_check_state, 
    1264                        *_write_state, *_attr_state, 
    1265                        *_unset_state, *_uattr_state; 
    1266  
    1267   tl = noit_console_state_initial(); 
    1268  
    1269   /* write <terimal|memory|file> */ 
    1270   NEW_STATE(_write_state); 
    1271   ADD_CMD(_write_state, "terminal", noit_conf_write_terminal, NULL, NULL); 
    1272   ADD_CMD(_write_state, "file", noit_conf_write_file, NULL, NULL); 
    1273   /* write memory?  It's to a file, but I like router syntax */ 
    1274   ADD_CMD(_write_state, "memory", noit_conf_write_file, NULL, NULL); 
    1275  
    1276   /* attribute <attrname> <value> */ 
    1277   NEW_STATE(_attr_state); 
    1278   noit_console_state_add_check_attrs(_attr_state, noit_conf_check_set_attr); 
    1279   
    1280   /* no attribute <attrname> <value> */ 
    1281   NEW_STATE(_uattr_state); 
    1282   noit_console_state_add_check_attrs(_uattr_state, noit_conf_check_unset_attr); 
    1283   NEW_STATE(_unset_state); 
    1284   DELEGATE_CMD(_unset_state, "attribute", _uattr_state); 
    1285   ADD_CMD(_unset_state, "section", noit_console_config_section, NULL, (void *)1); 
    1286   ADD_CMD(_unset_state, "check", noit_console_config_nocheck, NULL, NULL); 
    1287   
    1288   NEW_STATE(_conf_t_check_state); 
    1289   _conf_t_check_state->console_prompt_function = conf_t_check_prompt; 
    1290   DELEGATE_CMD(_conf_t_check_state, "attribute", _attr_state); 
    1291   DELEGATE_CMD(_conf_t_check_state, "no", _unset_state); 
    1292   ADD_CMD(_conf_t_check_state, "status", noit_console_show_check, NULL, NULL); 
    1293   ADD_CMD(_conf_t_check_state, "exit", noit_console_config_cd, NULL, ".."); 
    1294  
    1295   NEW_STATE(_conf_t_state);  
    1296   _conf_t_state->console_prompt_function = conf_t_prompt; 
    1297   noit_console_state_add_cmd(_conf_t_state, &console_command_exit); 
    1298   ADD_CMD(_conf_t_state, "ls", noit_console_config_show, NULL, NULL); 
    1299   ADD_CMD(_conf_t_state, "cd", noit_console_config_cd, NULL, NULL); 
    1300   ADD_CMD(_conf_t_state, "section", noit_console_config_section, NULL, (void *)0); 
    1301   ADD_CMD(_conf_t_state, "check", noit_console_check, _conf_t_check_state, NULL); 
    1302  
    1303   showcmd = noit_console_state_get_cmd(tl, "show"); 
    1304   ADD_CMD(showcmd->dstate, "check", noit_console_show_check, NULL, NULL); 
    1305  
    1306   DELEGATE_CMD(_conf_t_state, "write", _write_state); 
    1307   DELEGATE_CMD(_conf_t_state, "attribute", _attr_state); 
    1308   DELEGATE_CMD(_conf_t_state, "no", _unset_state); 
    1309  
    1310   NEW_STATE(_conf_state); 
    1311   ADD_CMD(_conf_state, "terminal", noit_console_state_conf_terminal, _conf_t_state, NULL); 
    1312  
    1313   ADD_CMD(tl, "configure", noit_console_state_delegate, _conf_state, NULL); 
    1314   ADD_CMD(tl, "write", noit_console_state_delegate, _write_state, NULL); 
    1315   ADD_CMD(tl, "reload", noit_conf_reload, NULL, NULL); 
    1316 
    1317  
    1318 void 
    1319 noit_conf_log_init() { 
     427noit_conf_log_init(const char *toplevel) { 
    1320428  int i, cnt = 0, o, ocnt = 0; 
    1321429  noit_conf_section_t *log_configs, *outlets; 
    1322  
    1323   log_configs = noit_conf_get_sections(NULL, "/noit/logs//log", &cnt); 
    1324   noitL(noit_stderr, "Found %d /noit/logs//log stanzas\n", cnt); 
     430  char path[256]; 
     431 
     432  snprintf(path, sizeof(path), "/%s/logs//log", toplevel); 
     433  log_configs = noit_conf_get_sections(NULL, path, &cnt); 
     434  noitL(noit_stderr, "Found %d %s stanzas\n", cnt, path); 
    1325435  for(i=0; i<cnt; i++) { 
    1326436    noit_log_stream_t ls; 
  • src/noit_conf.h

    r1648bed r5f388ee  
    2121} noit_conf_t_userdata_t; 
    2222 
    23 API_EXPORT(void) noit_conf_init(); 
     23API_EXPORT(void) noit_conf_init(const char *toplevel); 
    2424API_EXPORT(int) noit_conf_load(const char *path); 
    2525API_EXPORT(int) noit_conf_save(const char *path); 
     
    3636API_EXPORT(int) noit_conf_get_string(noit_conf_section_t section, 
    3737                                     const char *path, char **value); 
     38 
    3839API_EXPORT(int) noit_conf_get_stringbuf(noit_conf_section_t section, 
    3940                                        const char *path, char *value, int len); 
     
    4445API_EXPORT(int) noit_conf_get_boolean(noit_conf_section_t section, 
    4546                                      const char *path, noit_conf_boolean *value); 
     47API_EXPORT(int) 
     48  noit_conf_get_uuid(noit_conf_section_t section, 
     49                     const char *path, uuid_t out); 
    4650 
    4751API_EXPORT(int) noit_conf_set_string(noit_conf_section_t section, 
     
    5559 
    5660API_EXPORT(int) 
    57   noit_conf_check_set_attr(noit_console_closure_t ncct, 
     61  noit_conf_reload(noit_console_closure_t ncct, 
     62                   int argc, char **argv, 
     63                   noit_console_state_t *state, void *closure); 
     64API_EXPORT(int) 
     65  noit_conf_write_terminal(noit_console_closure_t ncct, 
    5866                           int argc, char **argv, 
    5967                           noit_console_state_t *state, void *closure); 
     68API_EXPORT(int) 
     69  noit_conf_write_file(noit_console_closure_t ncct, 
     70                       int argc, char **argv, 
     71                       noit_console_state_t *state, void *closure); 
    6072 
    61 API_EXPORT(void) noit_conf_log_init(); 
     73API_EXPORT(void) noit_conf_log_init(const char *toplevel); 
    6274 
    6375#endif 
  • src/noitd.c

    r4dccf83 r5f388ee  
    1515#include "noit_module.h" 
    1616#include "noit_conf.h" 
     17#include "noit_conf_checks.h" 
    1718 
    1819static char *config_file = ETC_DIR "/noit.conf"; 
     
    6667 
    6768  /* Next load the configs */ 
    68   noit_conf_init(); 
     69  noit_conf_init("noit"); 
     70  noit_conf_checks_init("noit"); 
    6971  if(noit_conf_load(config_file) == -1) { 
    7072    fprintf(stderr, "Cannot load config: '%s'\n", config_file); 
     
    7274 
    7375  /* Reinitialize the logging system now that we have a config */ 
    74   noit_conf_log_init(); 
     76  noit_conf_log_init("noit"); 
    7577  if(debug) 
    7678    noit_debug->enabled = 1;