| 1416 | } |
| 1417 | |
| 1418 | static int |
| 1419 | print_html_status(pe_working_set_t * data_set, const char *filename, gboolean web_cgi) |
| 1420 | { |
| 1421 | FILE *stream; |
| 1422 | GListPtr gIter = NULL; |
| 1423 | node_t *dc = NULL; |
| 1424 | static int updates = 0; |
| 1425 | char *filename_tmp = NULL; |
| 1426 | |
| 1427 | if (web_cgi) { |
| 1428 | stream = stdout; |
| 1429 | fprintf(stream, "Content-type: text/html\n\n"); |
| 1430 | |
| 1431 | } else { |
| 1432 | filename_tmp = crm_concat(filename, "tmp", '.'); |
| 1433 | stream = fopen(filename_tmp, "w"); |
| 1434 | if (stream == NULL) { |
| 1435 | crm_perror(LOG_ERR, "Cannot open %s for writing", filename_tmp); |
| 1436 | free(filename_tmp); |
| 1437 | return -1; |
| 1438 | } |
| 1439 | } |
| 1440 | |
| 1441 | updates++; |
| 1442 | dc = data_set->dc_node; |
| 1443 | |
| 1444 | fprintf(stream, "<html>"); |
| 1445 | fprintf(stream, "<head>"); |
| 1446 | fprintf(stream, "<title>Cluster status</title>"); |
| 1447 | /* content="%d;url=http://webdesign.about.com" */ |
| 1448 | fprintf(stream, "<meta http-equiv=\"refresh\" content=\"%d\">", reconnect_msec / 1000); |
| 1449 | fprintf(stream, "</head>"); |
| 1450 | |
| 1451 | /*** SUMMARY ***/ |
| 1452 | |
| 1453 | fprintf(stream, "<h2>Cluster summary</h2>"); |
| 1454 | { |
| 1455 | char *now_str = NULL; |
| 1456 | time_t now = time(NULL); |
| 1457 | |
| 1458 | now_str = ctime(&now); |
| 1459 | now_str[24] = EOS; /* replace the newline */ |
| 1460 | fprintf(stream, "Last updated: <b>%s</b><br/>\n", now_str); |
| 1461 | } |
| 1462 | |
| 1463 | if (dc == NULL) { |
| 1464 | fprintf(stream, "Current DC: <font color=\"red\"><b>NONE</b></font><br/>"); |
| 1465 | } else { |
| 1466 | fprintf(stream, "Current DC: %s (%s)<br/>", dc->details->uname, dc->details->id); |
| 1467 | } |
| 1468 | fprintf(stream, "%d Nodes configured.<br/>", g_list_length(data_set->nodes)); |
| 1469 | fprintf(stream, "%d Resources configured.<br/>", count_resources(data_set, NULL)); |
| 1470 | |
| 1471 | /*** CONFIG ***/ |
| 1472 | |
| 1473 | fprintf(stream, "<h3>Config Options</h3>\n"); |
| 1474 | |
| 1475 | fprintf(stream, "<table>\n"); |
no test coverage detected