[icinga-checkins] icinga.org: icinga-core/rbartels/cgi-current: added cgi_json_version to json output and changed avail. cgi json vor average values #1217

git at icinga.org git at icinga.org
Fri Apr 29 00:04:45 CEST 2011


Module: icinga-core
Branch: rbartels/cgi-current
Commit: 5085c7332ce6b2df1a2c2f56e2307bea638b4d7d
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=5085c7332ce6b2df1a2c2f56e2307bea638b4d7d

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Thu Apr 28 23:18:15 2011 +0200

added cgi_json_version to json output and changed avail.cgi json vor average values #1217

refs #1217

---

 cgi/avail.c        |   12 ++++--------
 cgi/cgiutils.c     |    3 ++-
 include/cgiutils.h |    4 ++++
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/cgi/avail.c b/cgi/avail.c
index 9c8fe2b..d4ca6b9 100644
--- a/cgi/avail.c
+++ b/cgi/avail.c
@@ -3587,8 +3587,7 @@ void display_specific_hostgroup_availability(hostgroup *hg){
 		printf("</table>\n");
 		printf("</DIV>\n");
 	}else if (content_type==JSON_CONTENT){
-		printf(", {\"average_percent_times\": null, ");
-		printf("\"average_percent_time_up\": \"%2.3f\", ",average_percent_time_up);
+		printf(", { \"average_percent_time_up\": \"%2.3f\", ",average_percent_time_up);
 		printf("\"average_percent_time_up_known\": \"%2.3f\", ",average_percent_time_up_known);
 		printf("\"average_percent_time_down\": \"%2.3f\", ",average_percent_time_down);
 		printf("\"average_percent_time_down_known\": \"%2.3f\", ",average_percent_time_down_known);
@@ -4281,8 +4280,7 @@ void display_specific_servicegroup_availability(servicegroup *sg){
 		printf("</table>\n");
 		printf("</DIV>\n");
 	}else if (content_type==JSON_CONTENT){
-		printf(", {\"average_percent_times\": null, ");
-		printf("\"average_percent_time_ok\": \"%2.3f\", ",average_percent_time_ok);
+		printf(",{ \"average_percent_time_ok\": \"%2.3f\", ",average_percent_time_ok);
 		printf("\"average_percent_time_ok_known\": \"%2.3f\", ",average_percent_time_ok_known);
 		printf("\"average_percent_time_warning\": \"%2.3f\", ",average_percent_time_warning);
 		printf("\"average_percent_time_warning_known\": \"%2.3f\", ",average_percent_time_warning_known);
@@ -5013,8 +5011,7 @@ void display_host_availability(void){
 			printf("</table>\n");
 			printf("</DIV>\n");
 		}else if (content_type==JSON_CONTENT){
-			printf(", {\"average_percent_times\": null, ");
-			printf("\"average_percent_time_up\": \"%2.3f\", ",average_percent_time_up);
+			printf(",{ \"average_percent_time_up\": \"%2.3f\", ",average_percent_time_up);
 			printf("\"average_percent_time_up_known\": \"%2.3f\", ",average_percent_time_up_known);
 			printf("\"average_percent_time_down\": \"%2.3f\", ",average_percent_time_down);
 			printf("\"average_percent_time_down_known\": \"%2.3f\", ",average_percent_time_down_known);
@@ -5760,8 +5757,7 @@ void display_service_availability(void){
 			printf("</table>\n");
 			printf("</DIV>\n");
 		}else if (content_type==JSON_CONTENT){
-			printf(", {\"average_percent_times\": null, ");
-			printf("\"average_percent_time_ok\": \"%2.3f\", ",average_percent_time_ok);
+			printf(",{ \"average_percent_time_ok\": \"%2.3f\", ",average_percent_time_ok);
 			printf("\"average_percent_time_ok_known\": \"%2.3f\", ",average_percent_time_ok_known);
 			printf("\"average_percent_time_warning\": \"%2.3f\", ",average_percent_time_warning);
 			printf("\"average_percent_time_warning_known\": \"%2.3f\", ",average_percent_time_warning_known);
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 53b3db6..e40f729 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -921,7 +921,8 @@ void document_header(int cgi_id, int use_stylesheet){
 
 	if(content_type==JSON_CONTENT) {
 		printf("Content-type: text/json; charset=\"%s\"\r\n\r\n", http_charset);
-		printf("{ \"%s\": {\n",cgi_body_class);
+		printf("{ \"cgi_json_version\": \"%s\",\n",JSON_OUTPUT_VERSION);
+		printf("\"%s\": {\n",cgi_body_class);
 		return;
 	}
 
diff --git a/include/cgiutils.h b/include/cgiutils.h
index e97e733..7ce1049 100644
--- a/include/cgiutils.h
+++ b/include/cgiutils.h
@@ -490,6 +490,10 @@ extern "C" {
 
 #define DEFAULT_HTTP_CHARSET "utf-8"
 
+/************************** JSON OUTPUT VERSION ************************/
+
+#define JSON_OUTPUT_VERSION "1.4.0"
+
 
 /************************** BUFFER  ***************************************/
 





More information about the icinga-checkins mailing list