[icinga-checkins] icinga.org: icinga-core/test/cgis: add a check for status data freshness into cgis #1667

git at icinga.org git at icinga.org
Mon Jun 20 22:31:01 CEST 2011


Module: icinga-core
Branch: test/cgis
Commit: 487cdaab9e72fe7b4f48dd7a2c37f22b8e2cb690
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=487cdaab9e72fe7b4f48dd7a2c37f22b8e2cb690

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Mon Jun 20 22:25:40 2011 +0200

add a check for status data freshness into cgis #1667

fixes: #1667

* gives a warining of outdated status data with a 10 second delay

---

 cgi/cgiutils.c     |   12 +++++++++++-
 xdata/xsddefault.c |    5 +++++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 8e235bd..89a029d 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -85,6 +85,7 @@ extern int      enable_failure_prediction;
 extern int      process_performance_data;
 extern time_t   last_command_check;
 extern time_t   last_log_rotation;
+extern time_t	status_file_creation_time;
 
 /** readlogs.c **/
 int		log_rotation_method=LOG_ROTATION_NONE;
@@ -94,7 +95,7 @@ extern time_t	next_scheduled_log_rotation;
 char		log_file[MAX_INPUT_BUFFER];
 char		log_archive_path[MAX_INPUT_BUFFER];
 
-
+int		status_update_interval=60;
 int             check_external_commands=0;
 
 int             log_external_commands_user=FALSE;
@@ -641,6 +642,12 @@ int read_main_config_file(char *filename){
 			interval_length=(temp_buffer==NULL)?60:atoi(temp_buffer);
 		        }
 
+		else if(strstr(input,"status_update_interval=")==input){
+			temp_buffer=strtok(input,"=");
+			temp_buffer=strtok(NULL,"\x0");
+			status_update_interval=(temp_buffer==NULL)?60:atoi(temp_buffer);
+		        }
+
 		else if(strstr(input,"log_file=")==input){
 			temp_buffer=strtok(input,"=");
 			temp_buffer=strtok(NULL,"\x0");
@@ -1774,6 +1781,9 @@ void display_info_table(char *title,int refresh, authdata *current_authdata, int
 			printf("<DIV CLASS='infoBoxBadProcStatus'>- Service checks are disabled</DIV>");
 	}
 
+	if(status_file_creation_time<(current_time-status_update_interval-10))
+		printf("<DIV CLASS='infoBoxBadProcStatus'>Warning: Status data OUTDATED! Last status data update was %d seconds ago!</DIV>",(int)(current_time-status_file_creation_time));
+
 	printf("</TD></TR>\n");
 	printf("</TABLE>\n");
 
diff --git a/xdata/xsddefault.c b/xdata/xsddefault.c
index 3769b50..b175d16 100644
--- a/xdata/xsddefault.c
+++ b/xdata/xsddefault.c
@@ -60,6 +60,7 @@ time_t program_start;
 int daemon_mode;
 time_t last_command_check;
 time_t last_log_rotation;
+time_t status_file_creation_time;
 int enable_notifications;
 int execute_service_checks;
 int accept_passive_service_checks;
@@ -967,6 +968,10 @@ int xsddefault_read_status_data(char *config_file,int options){
 			switch(data_type){
 
 			case XSDDEFAULT_INFO_DATA:
+#ifdef NSCGI
+				if(!strcmp(var,"created"))
+					status_file_creation_time=strtoul(val,NULL,10);
+#endif
 				break;
 
 			case XSDDEFAULT_PROGRAMSTATUS_DATA:





More information about the icinga-checkins mailing list