| 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; |
|---|