[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: event profiling to cgi view

git at icinga.org git at icinga.org
Tue May 25 12:46:53 CEST 2010


Module: icinga-core
Branch: mfriedrich/core
Commit: 141a029ce044fcd5b6c271a33950079d57aae6b3
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=141a029ce044fcd5b6c271a33950079d57aae6b3

Author: hirenp <hirenp at firebird.(none)>
Date:   Fri May 21 23:25:37 2010 +0200

event profiling to cgi view

---

 base/icingastats.c |    2 +-
 cgi/Makefile.in    |   38 +++++++++++++++++++-------------------
 cgi/extinfo.c      |   36 ++++++++++++++++++++++++++++++++++++
 xdata/xsddefault.c |   14 +++++++++++++-
 4 files changed, 69 insertions(+), 21 deletions(-)

diff --git a/base/icingastats.c b/base/icingastats.c
index 2b28300..926d794 100644
--- a/base/icingastats.c
+++ b/base/icingastats.c
@@ -1360,7 +1360,7 @@ int read_status_file(void){
                 		else if(strstr(var,"PROFILE_") && !strstr(var,"null"))
                 		{
                     			if(strstr(var,"COUNTER"))
-                        		profile_object_update_count(var+strlen("PROFILE_COUNTER_"),strtod(val,NULL));
+                        			profile_object_update_count(var+strlen("PROFILE_COUNTER_"),strtod(val,NULL));
 
                     			if(strstr(var,"ELAPSED"))
                         			profile_object_update_elapsed(var+strlen("PROFILE_ELAPSED_"),atoi(val));
diff --git a/cgi/Makefile.in b/cgi/Makefile.in
index 40cdb82..2df6e39 100644
--- a/cgi/Makefile.in
+++ b/cgi/Makefile.in
@@ -60,7 +60,7 @@ ODATAHDRS=
 ODATADEPS=$(ODATALIBS)
 
 # Host, service, and program status functions
-SDATALIBS=statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o
+SDATALIBS=statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o 
 SDATAHDRS=
 SDATADEPS=$(SDATALIBS)
 
@@ -107,7 +107,7 @@ statusdata-cgi.o: $(SRC_COMMON)/statusdata.c $(SRC_INCLUDE)/statusdata.h
 	$(CC) $(CFLAGS) -c -o $@ $(SRC_COMMON)/statusdata.c
 
 xstatusdata-cgi.o: $(SRC_XDATA)/$(XSDC) $(SRC_XDATA)/$(XSDH)
-	$(CC) $(CFLAGS) -c -o $@ $(SRC_XDATA)/$(XSDC)
+	$(CC) $(CFLAGS) -c -o $@ $(SRC_XDATA)/$(XSDC) 
 
 comments-cgi.o: $(SRC_COMMON)/comments.c $(SRC_INCLUDE)/comments.h
 	$(CC) $(CFLAGS) -c -o $@ $(SRC_COMMON)/comments.c
@@ -127,58 +127,58 @@ $(SRC_COMMON)/shared.o: $(SRC_COMMON)/shared.c
 ########## CGIS ##########
 
 avail.cgi: avail.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ avail.c $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ avail.c ../base/statsprofiler.c $(CGILIBS) $(LIBS)
 
 checksanity.cgi: checksanity.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ checksanity.c $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS)
 
 cmd.cgi: cmd.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS) extcmd_list.o
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ cmd.c extcmd_list.o $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ cmd.c ../base/statsprofiler.c extcmd_list.o $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS)
 
 config.cgi: config.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ config.c  $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ config.c ../base/statsprofiler.c  $(CGILIBS) $(LIBS)
 
 extinfo.cgi: extinfo.c $(CGIDEPS) $(CDATADEPS) $(DDATADEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ extinfo.c $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ extinfo.c ../base/statsprofiler.c $(CGILIBS) $(CDATALIBS) $(DDATALIBS) $(LIBS)
 
 history.cgi: history.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ history.c $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ history.c ../base/statsprofiler.c $(CGILIBS) $(LIBS)
 
 ministatus.cgi: ministatus.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ ministatus.c $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ ministatus.c ../base/statsprofiler.c $(CGILIBS) $(LIBS)
 
 notifications.cgi: notifications.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ notifications.c $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ notifications.c ../base/statsprofiler.c $(CGILIBS) $(LIBS)
 
 outages.cgi: outages.c $(CGIDEPS) $(CDATADEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ outages.c $(CGILIBS) $(CDATALIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ outages.c ../base/statsprofiler.c $(CGILIBS) $(CDATALIBS) $(LIBS)
 
 showlog.cgi: showlog.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ showlog.c $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ showlog.c ../base/statsprofiler.c $(CGILIBS) $(LIBS)
 
 status.cgi: status.c $(CGIDEPS) $(CDATADEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ status.c $(CGILIBS) $(CDATALIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ status.c ../base/statsprofiler.c $(CGILIBS) $(CDATALIBS) $(LIBS)
 
 statuswml.cgi: statuswml.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswml.c $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswml.c ../base/statsprofiler.c $(CGILIBS) $(LIBS)
 
 statusmap.cgi: statusmap.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ statusmap.c $(CGILIBS) $(GDLIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ statusmap.c ../base/statsprofiler.c $(CGILIBS) $(GDLIBS) $(LIBS)
 
 statuswrl.cgi: statuswrl.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswrl.c $(CGILIBS) $(MATHLIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswrl.c ../base/statsprofiler.c $(CGILIBS) $(MATHLIBS) $(LIBS)
 
 summary.cgi: summary.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ summary.c $(CGILIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ summary.c ../base/statsprofiler.c $(CGILIBS) $(LIBS)
 
 tac.cgi: tac.c $(CGIDEPS) $(CDATADEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ tac.c $(CGILIBS) $(CDATALIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ tac.c ../base/statsprofiler.c $(CGILIBS) $(CDATALIBS) $(LIBS)
 
 trends.cgi: trends.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ trends.c $(CGILIBS) $(GDLIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ trends.c ../base/statsprofiler.c $(CGILIBS) $(GDLIBS) $(LIBS)
 
 histogram.cgi: histogram.c $(CGIDEPS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ histogram.c $(CGILIBS) $(GDLIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ histogram.c ../base/statsprofiler.c $(CGILIBS) $(GDLIBS) $(LIBS)
 
 clean:
 	rm -f $(CGIS)
diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index 56f6e28..95df29a 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -30,6 +30,7 @@
 #include "../include/comments.h"
 #include "../include/downtime.h"
 #include "../include/statusdata.h"
+#include "../include/statsprofiler.h"
 
 #include "../include/cgiutils.h"
 #include "../include/getcgi.h"
@@ -56,6 +57,7 @@ extern int              obsess_over_hosts;
 extern int              enable_flap_detection;
 extern int              enable_failure_prediction;
 extern int              process_performance_data;
+extern int		event_profiling_enabled;
 
 extern int              buffer_stats[1][3];
 extern int              program_stats[MAX_CHECK_STATS_TYPES][3];
@@ -79,6 +81,7 @@ extern hoststatus *hoststatus_list;
 extern servicestatus *servicestatus_list;
 extern hostgroup *hostgroup_list;
 extern servicegroup *servicegroup_list;
+extern profile_object* profiled_data;
 
 
 #define MAX_MESSAGE_BUFFER		4096
@@ -2063,6 +2066,10 @@ void show_performance_data(void){
 	int passive_host_checks_start=0;
 	int passive_host_checks_ever=0;
 	time_t current_time;
+	profile_object *t, *p = profiled_data;
+	int count=0;
+	double elapsed=0.0, total_time=0.0;
+	char *name;
 
 
 	time(&current_time);
@@ -2486,6 +2493,35 @@ void show_performance_data(void){
 	printf("</TD></TR>\n");
 	printf("</TABLE>\n");
 
+	if (event_profiling_enabled){
+		printf("<tr>\n");
+		printf("<td valign=center><div class='perfTypeTitle'>Event profiling:</div></td>\n");
+		printf("<td valign=top colspan='2'>\n");
+
+		printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
+		printf("<TR><TD class='stateInfoTable1'>\n");
+		printf("<TABLE BORDER=0>\n");
+
+
+		printf("<tr class='data'><th class='data'>EVENT PROFILE DATA:</th><th class='data'>total seconds spent</th><th class='data'>number of events</th><th class='data'>avg time per event</th><th class='data'>events per second</th></tr>\n");
+		while(p){
+			name = p->name;
+       			count = p->count;
+       			elapsed = p->elapsed;
+    			t=profile_object_find_by_name("EVENT_LOOP_COMPLETION");
+    			total_time = t->elapsed;
+
+       			printf("<tr><td class='dataVar'>%s </td><td class='dataVal'>%f</td><td class='dataVal'>%d</td><td class='dataVal'>%f</td><td class='dataVal'>%f</td></tr>",name,elapsed,count,safe_divide(elapsed,count,0),safe_divide(total_time,count,1));
+       			p = p->next;
+		}
+
+
+		printf("</TABLE>\n");
+		printf("</TD></TR>\n");
+		printf("</TABLE>\n");
+	}
+
+
 	printf("</td>\n");
 	printf("</tr>\n");
 
diff --git a/xdata/xsddefault.c b/xdata/xsddefault.c
index 6bd7d08..7c16a37 100644
--- a/xdata/xsddefault.c
+++ b/xdata/xsddefault.c
@@ -35,7 +35,7 @@
 #include "../include/macros.h"
 #include "../include/skiplist.h"
 
-#include "../include/profiler.h"
+#include "../include/statsprofiler.h"
 
 #ifdef NSCORE
 #include "../include/icinga.h"
@@ -72,6 +72,8 @@ int process_performance_data;
 int nagios_pid;
 int buffer_stats[1][3];
 int program_stats[MAX_CHECK_STATS_TYPES][3];
+int event_profiling_enabled;
+profile_object* profiled_data = NULL;
 #endif
 
 #ifdef NSCORE
@@ -992,6 +994,16 @@ int xsddefault_read_status_data(char *config_file,int options){
 					enable_failure_prediction=(atoi(val)>0)?TRUE:FALSE;
 				else if(!strcmp(var,"process_performance_data"))
 					process_performance_data=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"event_profiling_enabled"))
+					event_profiling_enabled=atoi(val);
+
+				else if(strstr(var,"PROFILE_")){
+                                        if(strstr(var,"COUNTER"))
+                                                profile_object_update_count(var+strlen("PROFILE_COUNTER_"),strtod(val,NULL));
+
+                                        if(strstr(var,"ELAPSED"))
+                                                profile_object_update_elapsed(var+strlen("PROFILE_ELAPSED_"),atoi(val));
+                                }
 
 				else if (!strcmp(var,"total_external_command_buffer_slots"))
 					buffer_stats[0][0]=atoi(val);





More information about the icinga-checkins mailing list