Changeset 2ccf5eb9e64a6e89f4c8e0022eee38cde7e74717
- Timestamp:
- 05/14/08 19:09:15 (5 years ago)
- git-parent:
- Files:
-
- src/noit_conf.c (modified) (1 diff)
- src/noit_conf_checks.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/noit_conf.c
r01dbb0d r2ccf5eb 177 177 if(cnt > 1) { 178 178 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); 180 181 } 181 182 /* 2. */ src/noit_conf_checks.c
r2d2a012 r2ccf5eb 487 487 return -1; 488 488 } 489 if(!strcmp(argv[0], "config")) { 490 nc_printf(ncct, "use 'config' to set check config options\n"); 491 return -1; 492 } 489 493 info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA); 490 494 if(!strcmp(info->path, "/")) { … … 623 627 int argc, char **argv, 624 628 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; 625 633 int i, cnt, titled = 0, cliplen = 0; 626 634 const char *path = "", *basepath = NULL; 627 635 char xpath[1024]; 628 636 noit_conf_t_userdata_t *info = NULL; 637 noit_hash_table *config; 629 638 xmlXPathObjectPtr pobj = NULL; 630 639 xmlXPathContextPtr xpath_ctxt = NULL, current_ctxt; … … 693 702 xmlXPathFreeObject(pobj); 694 703 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 695 714 /* _shorten string_ turning last { / @ * } to { / * } */ 696 715 strlcpy(xpath + strlen(xpath) - 2, "*", 2); … … 705 724 node = (noit_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, i); 706 725 if(!strcmp((char *)node->name, "check")) continue; 726 if(!strcmp((char *)xmlGetNodePath(node) + cliplen, "config")) continue; 707 727 if(!(node->children && node->children == xmlGetLastChild(node) && 708 728 xmlNodeIsText(node->children))) { … … 833 853 834 854 noit_conf_xml_xpath(NULL, &xpath_ctxt); 835 if(1) { 836 /* Only if checks will fixate this attribute shall we check for837 * 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 856 876 snprintf(xpath, sizeof(xpath), "/noit/%s", path); 857 877 pobj = xmlXPathEval((xmlChar *)xpath, xpath_ctxt); … … 875 895 } 876 896 } 897 #ifdef UNSAFE_RECONFIG 877 898 if(active) { 878 899 nc_printf(ncct, "Cannot set '%s', it would effect %d live check(s)\n", … … 880 901 goto out; 881 902 } 903 #endif 882 904 if(pobj) xmlXPathFreeObject(pobj); 883 905 … … 918 940 assert(confignode); 919 941 /* 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); 922 943 923 944 } … … 1167 1188 ADD_CMD(_conf_t_state, "ls", noit_console_config_show, NULL, NULL); 1168 1189 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); 1169 1191 ADD_CMD(_conf_t_state, "section", noit_console_config_section, NULL, (void *)0); 1170 1192 ADD_CMD(_conf_t_state, "check", noit_console_check, _conf_t_check_state, NULL);
