Changeset 4dccf830640c308658d62f7896f78488734381bc
- Timestamp:
- 02/24/08 16:05:26 (5 years ago)
- git-parent:
- Files:
-
- src/noit_check.c (modified) (1 diff)
- src/noit_conf.c (modified) (4 diffs)
- src/noit_listener.c (modified) (1 diff)
- src/noit_module.c (modified) (1 diff)
- src/noitd.c (modified) (1 diff)
- src/sample.conf (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/noit_check.c
rf1a1f36 r4dccf83 158 158 timeout = period/2; 159 159 } 160 options = noit_conf_get_hash(sec[i], " ancestor-or-self::node()/config/*");160 options = noit_conf_get_hash(sec[i], "config"); 161 161 162 162 INHERIT(boolean, disable, &disabled); src/noit_conf.c
ra136e61 r4dccf83 76 76 } 77 77 78 noit_hash_table *noit_conf_get_hash(noit_conf_section_t section, 79 const char *path) { 78 void noit_conf_get_elements_into_hash(noit_conf_section_t section, 79 const char *path, 80 noit_hash_table *table) { 80 81 int i, cnt; 81 noit_hash_table *table = NULL;82 82 xmlXPathObjectPtr pobj = NULL; 83 83 xmlXPathContextPtr current_ctxt; … … 94 94 if(pobj->type != XPATH_NODESET) goto out; 95 95 if(xmlXPathNodeSetIsEmpty(pobj->nodesetval)) goto out; 96 table = calloc(1, sizeof(*table));97 96 cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 98 97 for(i=0; i<cnt; i++) { … … 108 107 if(current_ctxt && current_ctxt != xpath_ctxt) 109 108 xmlXPathFreeContext(current_ctxt); 109 } 110 void noit_conf_get_into_hash(noit_conf_section_t section, 111 const char *path, 112 noit_hash_table *table) { 113 int cnt; 114 xmlXPathObjectPtr pobj = NULL; 115 xmlXPathContextPtr current_ctxt; 116 xmlNodePtr current_node = (xmlNodePtr)section; 117 xmlNodePtr node, parent_node; 118 char xpath_expr[1024]; 119 char *inheritid; 120 121 current_ctxt = xpath_ctxt; 122 if(current_node) { 123 current_ctxt = xmlXPathNewContext(master_config); 124 current_ctxt->node = current_node; 125 } 126 if(path[0] == '/') 127 strlcpy(xpath_expr, path, sizeof(xpath_expr)); 128 else 129 snprintf(xpath_expr, sizeof(xpath_expr), 130 "ancestor-or-self::node()/%s", path); 131 pobj = xmlXPathEval((xmlChar *)xpath_expr, current_ctxt); 132 if(!pobj) goto out; 133 if(pobj->type != XPATH_NODESET) goto out; 134 if(xmlXPathNodeSetIsEmpty(pobj->nodesetval)) goto out; 135 cnt = xmlXPathNodeSetGetLength(pobj->nodesetval); 136 /* These are in the order of root to leaf 137 * We want to recurse... apply: 138 * 1. our parent's config 139 * 2. our "inherit" config if it exists. 140 * 3. our config. 141 */ 142 node = xmlXPathNodeSetItem(pobj->nodesetval, cnt-1); 143 /* 1. */ 144 if(cnt > 1) { 145 parent_node = xmlXPathNodeSetItem(pobj->nodesetval, cnt-2); 146 noit_conf_get_into_hash(parent_node, (const char *)node->name, table); 147 } 148 /* 2. */ 149 inheritid = (char *)xmlGetProp(node, (xmlChar *)"inherit"); 150 if(inheritid) { 151 snprintf(xpath_expr, sizeof(xpath_expr), "//*[@id=\"%s\"]", inheritid); 152 noit_conf_get_into_hash(NULL, xpath_expr, table); 153 } 154 /* 3. */ 155 noit_conf_get_elements_into_hash(node, "*", table); 156 157 out: 158 if(pobj) xmlXPathFreeObject(pobj); 159 if(current_ctxt && current_ctxt != xpath_ctxt) 160 xmlXPathFreeContext(current_ctxt); 161 } 162 noit_hash_table *noit_conf_get_hash(noit_conf_section_t section, 163 const char *path) { 164 noit_hash_table *table = NULL; 165 166 table = calloc(1, sizeof(*table)); 167 noit_conf_get_into_hash(section, path, table); 110 168 return table; 111 169 } … … 1296 1354 } 1297 1355 1298 noitL(noit_debug, "[%d] configuring log %s[%s:%s]\n", i, name, type, path);1299 1300 1356 if(noit_conf_get_boolean(log_configs[i], 1301 1357 "ancestor-or-self::node()/@disabled", src/noit_listener.c
ra136e61 r4dccf83 294 294 backlog = 5; 295 295 296 sslconfig = noit_conf_get_hash(listener_configs[i], "sslconfig /*");297 config = noit_conf_get_hash(listener_configs[i], "config /*");296 sslconfig = noit_conf_get_hash(listener_configs[i], "sslconfig"); 297 config = noit_conf_get_hash(listener_configs[i], "config"); 298 298 299 299 noit_listener(address, port, SOCK_STREAM, backlog, src/noit_module.c
r8a88818 r4dccf83 104 104 continue; 105 105 } 106 config = noit_conf_get_hash(sections[i], " ancestor-or-self::node()/config/*");106 config = noit_conf_get_hash(sections[i], "config"); 107 107 module = noit_module_lookup(module_name); 108 108 if(module->config && module->config(module, config)) { src/noitd.c
ra136e61 r4dccf83 39 39 int rv = 0; 40 40 noit_hash_table *table; 41 table = noit_conf_get_hash(NULL, "/noit/eventer/config /*");41 table = noit_conf_get_hash(NULL, "/noit/eventer/config"); 42 42 if(table) { 43 43 noit_hash_iter iter = NOIT_HASH_ITER_ZERO; src/sample.conf
rc04dcf5 r4dccf83 82 82 </resmon> 83 83 <switches module="snmp" period="30000"> 84 <config> 84 <config inherit="SwitchPort" /> 85 <switch target="10.80.116.3"> 86 <check uuid="1b4e28ba-2fa1-11d2-883f-e9b761bde3fb" name="1" /> 87 <check uuid="1b4e28ba-3fa1-11d2-883f-e9b761bde3fb" name="2" /> 88 <check uuid="1b4e29ba-3fa1-11d2-883f-e9b761bde3fb" name="3" /> 89 </switch> 90 </switches> 91 </dc1> 92 </checks> 93 <config_templates> 94 <config id="SwitchPort"> 85 95 <oid_description>IF-MIB::ifDescr.%[name]</oid_description> 86 96 <oid_alias>IF-MIB::ifAlias.%[name]</oid_alias> … … 98 108 <oid_innucastpkts>IF-MIB::ifInNUcastPkts.%[name]</oid_innucastpkts> 99 109 <oid_outnucastpkts>IF-MIB::ifOutNUcastPkts.%[name]</oid_outnucastpkts> 100 </config> 101 <switch target="10.80.116.3"> 102 <check uuid="1b4e28ba-2fa1-11d2-883f-e9b761bde3fb" name="1" /> 103 <check uuid="1b4e28ba-3fa1-11d2-883f-e9b761bde3fb" name="2" /> 104 <check uuid="1b4e29ba-3fa1-11d2-883f-e9b761bde3fb" name="3" /> 105 </switch> 106 </switches> 107 </dc1> 108 </checks> 110 </config> 111 </config_templates> 109 112 </noit>
