Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
classic ui: fixed json output for comments and downtimes in extinfo.c…
Browse files Browse the repository at this point in the history
…gi sometimes invalid #2343

refs: #2343

* changes array names in json output of extinfo.c
        comments  -> host_comments  / service_comments
        downtimes -> host_downtimes / service_downtimes
  • Loading branch information
bb-Ricardo committed Feb 24, 2012
1 parent aab7998 commit 582ff40
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
1 change: 1 addition & 0 deletions Changelog
Expand Up @@ -24,6 +24,7 @@ FIXES
* classic ui: Done clean up document_header() and unused vars in cgi's #2252
* classic ui: Fixed status.cgi: host param not honoured with servicefilter #2262
* classic ui: fixed Tooltip from action_url interfering with pnp4nagios integration #2198
* classic ui: fixed json output for comments and downtimes in extinfo.cgi sometimes invalid #2343


1.6.0 - 30/11/2011
Expand Down
4 changes: 4 additions & 0 deletions Changelog_json
Expand Up @@ -2,6 +2,10 @@
Classic-UI JSON Change Log
#######################

1.7.0 - array names changed!!!! #2343
comments -> host_comments / service_comments
downtimes -> host_downtimes / service_downtimes

1.6.0 - only values added, no existing values changed
* add more info of (ack, downtime, ... ) status to json export in status.cgi (ivo) #1988

Expand Down
50 changes: 26 additions & 24 deletions cgi/extinfo.c
Expand Up @@ -764,6 +764,8 @@ int main(void) {
else {
if (content_type == CSV_CONTENT || content_type == JSON_CONTENT) {
show_comments(HOST_COMMENT);
if (content_type == JSON_CONTENT)
printf(",\n");
show_comments(SERVICE_COMMENT);
} else {
printf("<BR />\n");
Expand All @@ -781,6 +783,8 @@ int main(void) {
else {
if (content_type == CSV_CONTENT || content_type == JSON_CONTENT) {
show_downtime(HOST_DOWNTIME);
if (content_type == JSON_CONTENT)
printf(",\n");
show_downtime(SERVICE_DOWNTIME);
} else {
printf("<BR />\n");
Expand Down Expand Up @@ -1458,13 +1462,14 @@ void show_host_info(void) {
printf("\"event_handler_enabled\": %s,\n", (temp_hoststatus->event_handler_enabled == TRUE) ? "true" : "false");
printf("\"flap_detection_enabled\": %s\n", (temp_hoststatus->flap_detection_enabled == TRUE) ? "true" : "false");
if (is_authorized_for_read_only(&current_authdata) == FALSE) {

/* display comments */
printf(", \"comments\": [\n");
printf(",\n");
show_comments(HOST_COMMENT);
printf("], \"downtimes\": [\n");

/* display downtimes */
printf(",\n");
show_downtime(HOST_DOWNTIME);
printf("]\n");
}
printf(" }\n");
}
Expand Down Expand Up @@ -1872,13 +1877,14 @@ void show_service_info(void) {
printf("\"event_handler_enabled\": %s,\n", (temp_svcstatus->event_handler_enabled == TRUE) ? "true" : "false");
printf("\"flap_detection_enabled\": %s\n", (temp_svcstatus->flap_detection_enabled == TRUE) ? "true" : "false");
if (is_authorized_for_read_only(&current_authdata) == FALSE) {

/* display comments */
printf(", \"comments\": [\n");
printf(",\n");
show_comments(SERVICE_COMMENT);
printf("], \"downtimes\": [\n");

/* display downtimes */
printf(",\n");
show_downtime(SERVICE_DOWNTIME);
printf("]\n");
}
printf(" }\n");
}
Expand Down Expand Up @@ -2874,15 +2880,14 @@ void show_comments(int type) {
int json_start = TRUE;

/* define colspan */
if (display_type == DISPLAY_COMMENTS) {
if (display_type == DISPLAY_COMMENTS)
colspan = (type != SERVICE_COMMENT) ? 9 : 10;
}

if (content_type == JSON_CONTENT) {
if (display_type == DISPLAY_COMMENTS && type == HOST_COMMENT)
printf("\"comments\": [\n");
if (display_type == DISPLAY_COMMENTS && type == SERVICE_COMMENT)
json_start = FALSE;
if (type == HOST_COMMENT)
printf("\"host_comments\": [\n");
if (type == SERVICE_COMMENT)
printf("\"service_comments\": [\n");
} else if (content_type == CSV_CONTENT) {
/* csv header */
if (display_type == DISPLAY_COMMENTS && type == HOST_COMMENT) {
Expand Down Expand Up @@ -3006,7 +3011,6 @@ void show_comments(int type) {
printf("\"host_name\": \"%s\", ", json_encode(temp_host->name));
if (type == SERVICE_COMMENT)
printf("\"service_description\": \"%s\", ", json_encode(temp_service->description));
printf("\"comment_type\": \"%s\", ", (type == HOST_COMMENT) ? "HOST" : "SERVICE");
}
printf("\"entry_time\": \"%s\", ", date_time);
printf("\"author\": \"%s\", ", json_encode(temp_comment->author));
Expand Down Expand Up @@ -3062,8 +3066,8 @@ void show_comments(int type) {
}
printf("</TABLE></FORM></DIV>\n");
}
if (content_type == JSON_CONTENT && display_type == DISPLAY_COMMENTS && type == SERVICE_COMMENT)
printf("\n]\n");
if (content_type == JSON_CONTENT)
printf("]");

return;
}
Expand All @@ -3085,15 +3089,14 @@ void show_downtime(int type) {
int json_start = TRUE;

/* define colspan */
if (display_type == DISPLAY_DOWNTIME) {
if (display_type == DISPLAY_DOWNTIME)
colspan = (type != SERVICE_DOWNTIME) ? 11 : 12;
}

if (content_type == JSON_CONTENT) {
if (display_type == DISPLAY_DOWNTIME && type == HOST_DOWNTIME)
printf("\"downtimes\": [\n");
if (display_type == DISPLAY_DOWNTIME && type == SERVICE_DOWNTIME)
json_start = FALSE;
if (type == HOST_DOWNTIME)
printf("\"host_downtimes\": [\n");
if (type == SERVICE_DOWNTIME)
printf("\"service_downtimes\": [\n");
} else if (content_type == CSV_CONTENT) {
/* csv header */
if (display_type == DISPLAY_DOWNTIME && type == HOST_DOWNTIME) {
Expand Down Expand Up @@ -3199,7 +3202,6 @@ void show_downtime(int type) {
printf("\"host_name\": \"%s\", ", json_encode(temp_host->name));
if (type == SERVICE_DOWNTIME)
printf("\"service_description\": \"%s\", ", json_encode(temp_service->description));
printf("\"downtime_type\": \"%s\", ", (type == HOST_DOWNTIME) ? "HOST" : "SERVICE");
}
} else if (content_type == CSV_CONTENT) {
if (display_type == DISPLAY_DOWNTIME) {
Expand Down Expand Up @@ -3313,8 +3315,8 @@ void show_downtime(int type) {
}
printf("</TABLE></FORM></DIV>\n");
}
if (content_type == JSON_CONTENT && display_type == DISPLAY_DOWNTIME && type == SERVICE_DOWNTIME)
printf("\n]\n");
if (content_type == JSON_CONTENT)
printf("]");

return;
}
Expand Down
2 changes: 1 addition & 1 deletion include/cgiutils.h
Expand Up @@ -524,7 +524,7 @@ extern "C" {

/************************** JSON OUTPUT VERSION ************************/

#define JSON_OUTPUT_VERSION "1.6.0"
#define JSON_OUTPUT_VERSION "1.7.0"


/************************** BUFFER ***************************************/
Expand Down

0 comments on commit 582ff40

Please sign in to comment.