[icinga-checkins] icinga.org: icinga-core/dev/core: classic-ui: don' t be ambiguous about display_name in JSON and CSV output #2681

git at icinga.org git at icinga.org
Thu Jun 21 10:00:02 CEST 2012


Module: icinga-core
Branch: dev/core
Commit: 985bd5a92a98effabbbec8cc4e7b685115c85ebe
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=985bd5a92a98effabbbec8cc4e7b685115c85ebe

Author: Torsten Rehn <trehn at nagify.com>
Date:   Tue Jun 12 23:25:55 2012 +0200

classic-ui: don't be ambiguous about display_name in JSON and CSV output #2681

refs: #2681

Signed-off-by: Ricardo Bartels <ricardo at bitchbrothers.com>

---

 Changelog          |    1 +
 Changelog_json     |    4 ++++
 cgi/status.c       |   27 +++++++++++++++++++++------
 include/cgiutils.h |    2 +-
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/Changelog b/Changelog
index da90341..56d19b7 100644
--- a/Changelog
+++ b/Changelog
@@ -9,6 +9,7 @@ Thanks to all contributers, testers and developers. Please read AUTHORS and THAN
 FIXES
 * classic ui: Fixed status.cgi time out when displaying hostgroups in large environments #2617 - RB
 * classic ui: Fixed Invalid JSON output for hostgroup overview #2680 - trehn
+* classic ui: Fixed Confusing use of display_name in JSON and CSV output #2681 - trehn
 
 
 1.7.0 - 15/05/2012
diff --git a/Changelog_json b/Changelog_json
index 39c4d73..d1ef1c3 100644
--- a/Changelog_json
+++ b/Changelog_json
@@ -2,6 +2,10 @@
 Classic-UI JSON Change Log
 #######################
 
+1.7.1 - only values added, no existing values changed
+* added host_display_name to host and service status data
+* added service_display_name to service status data
+
 1.7.0 - array names changed!!!! #2343
 	comments  -> host_comments  / service_comments
 	downtimes -> host_downtimes / service_downtimes
diff --git a/cgi/status.c b/cgi/status.c
index 2474170..43e6bf1 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -2546,8 +2546,8 @@ void show_service_detail(void) {
 			if (json_start == FALSE)
 				printf(",\n");
 			json_start = FALSE;
-			printf("{ \"host\": \"%s\", ", (temp_host->display_name != NULL) ? json_encode(temp_host->display_name) : json_encode(temp_host->name));
-			printf("\"service\": \"%s\", ", (temp_service->display_name != NULL) ? json_encode(temp_service->display_name) : json_encode(temp_service->description));
+			printf("{ \"host\": \"%s\", ", json_encode(temp_host->name));
+			printf("\"service\": \"%s\", ", json_encode(temp_service->description));
 			printf("\"status\": \"%s\", ", temp_status->status_string);
 			printf("\"last_check\": \"%s\", ", temp_status->last_check);
 			printf("\"duration\": \"%s\", ", temp_status->state_duration);
@@ -2559,6 +2559,16 @@ void show_service_detail(void) {
 			printf("\"notifications_enabled\": %s, ", (temp_status->notifications_enabled == TRUE) ? "true" : "false");
 			printf("\"has_been_acknowledged\": %s, ", (temp_status->problem_has_been_acknowledged == TRUE) ? "true" : "false");
 
+			if (temp_host->display_name == NULL)
+				printf("\"host_display_name\": null, ");
+			else
+				printf("\"host_display_name\": \"%s\", ", json_encode(temp_host->display_name));
+
+			if (temp_service->display_name == NULL)
+				printf("\"service_display_name\": null, ");
+			else
+				printf("\"service_display_name\": \"%s\", ", json_encode(temp_service->display_name));
+
 			if (temp_status->plugin_output == NULL)
 				printf("\"status_information\": null }");
 			else
@@ -2566,8 +2576,8 @@ void show_service_detail(void) {
 
 			/* print list in csv format */
 		} else if (content_type == CSV_CONTENT) {
-			printf("%s%s%s%s", csv_data_enclosure, (temp_host->display_name != NULL) ? temp_host->display_name : temp_host->name, csv_data_enclosure, csv_delimiter);
-			printf("%s%s%s%s", csv_data_enclosure, (temp_service->display_name != NULL) ? temp_service->display_name : temp_service->description, csv_data_enclosure, csv_delimiter);
+			printf("%s%s%s%s", csv_data_enclosure, temp_host->name, csv_data_enclosure, csv_delimiter);
+			printf("%s%s%s%s", csv_data_enclosure, temp_service->description, csv_data_enclosure, csv_delimiter);
 
 			printf("%s%s%s%s", csv_data_enclosure, temp_status->status_string, csv_data_enclosure, csv_delimiter);
 			printf("%s%s%s%s", csv_data_enclosure, temp_status->last_check, csv_data_enclosure, csv_delimiter);
@@ -2958,7 +2968,7 @@ void show_host_detail(void) {
 			if (json_start == FALSE)
 				printf(",\n");
 			json_start = FALSE;
-			printf("{ \"host\": \"%s\", ", (temp_host->display_name != NULL) ? json_encode(temp_host->display_name) : json_encode(temp_host->name));
+			printf("{ \"host\": \"%s\", ", json_encode(temp_host->name));
 			printf("\"status\": \"%s\", ", temp_statusdata->status_string);
 			printf("\"last_check\": \"%s\", ", temp_statusdata->last_check);
 			printf("\"duration\": \"%s\", ", temp_statusdata->state_duration);
@@ -2970,6 +2980,11 @@ void show_host_detail(void) {
 			printf("\"notifications_enabled\": %s, ", (temp_statusdata->notifications_enabled == TRUE) ? "true" : "false");
 			printf("\"has_been_acknowledged\": %s, ", (temp_statusdata->problem_has_been_acknowledged == TRUE) ? "true" : "false");
 
+			if (temp_host->display_name == NULL)
+				printf("\"host_display_name\": null, ");
+			else
+				printf("\"host_display_name\": \"%s\", ", json_encode(temp_host->display_name));
+
 			if (temp_statusdata->plugin_output == NULL)
 				printf("\"status_information\": null }");
 			else
@@ -2977,7 +2992,7 @@ void show_host_detail(void) {
 
 			/* print list in csv format */
 		} else if (content_type == CSV_CONTENT) {
-			printf("%s%s%s%s", csv_data_enclosure, (temp_host->display_name != NULL) ? temp_host->display_name : temp_host->name, csv_data_enclosure, csv_delimiter);
+			printf("%s%s%s%s", csv_data_enclosure, temp_host->name, csv_data_enclosure, csv_delimiter);
 
 			printf("%s%s%s%s", csv_data_enclosure, temp_statusdata->status_string, csv_data_enclosure, csv_delimiter);
 			printf("%s%s%s%s", csv_data_enclosure, temp_statusdata->last_check, csv_data_enclosure, csv_delimiter);
diff --git a/include/cgiutils.h b/include/cgiutils.h
index 2b35972..bce2f14 100644
--- a/include/cgiutils.h
+++ b/include/cgiutils.h
@@ -529,7 +529,7 @@ extern "C" {
 
 /************************** JSON OUTPUT VERSION ************************/
 
-#define JSON_OUTPUT_VERSION "1.7.0"
+#define JSON_OUTPUT_VERSION "1.7.1"
 
 
 /************************** BUFFER  ***************************************/





More information about the icinga-checkins mailing list