[icinga-checkins] icinga.org: icinga-core/master: New option to icinga: -S option functions much like -s option but will dump the entire scheduling queue as it would run , in addition to providing the summary data.

git at icinga.org git at icinga.org
Wed May 19 13:41:54 CEST 2010


Module: icinga-core
Branch: master
Commit: 725083ae9fcabfad2ce78b2e669d633a918f43b5
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=725083ae9fcabfad2ce78b2e669d633a918f43b5

Author: Massimo Forni <forni.massimo at gmail.com>
Date:   Sun May 16 20:40:57 2010 +0200

New option to icinga: -S option functions much like -s option but will dump the entire scheduling queue as it would run, in addition to providing the summary data.

fixes #310

---

 base/events.c |  142 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 base/icinga.c |   16 ++++++-
 2 files changed, 156 insertions(+), 2 deletions(-)

diff --git a/base/events.c b/base/events.c
index 6010286..76f2bd9 100644
--- a/base/events.c
+++ b/base/events.c
@@ -614,7 +614,149 @@ void init_timing_loop(void){
 	return;
         }
 
+/*gives information about a particular event*/
+void display_event_data(timed_event* event, int priority)
+{
+
+    printf("\t\tEvent:");
+
+
+   	switch(event->event_type){
+
+        case EVENT_SERVICE_CHECK:
+            printf("\t\t(service check)\n");
+            service* temp_service=(service *)event->event_data;
+            printf("\t\tService Description: %s\n",temp_service->description);
+            printf("\t\tAssociated Host:     %s\n",temp_service->host_name);
+        break;
+
+        case EVENT_HOST_CHECK:
+            printf("\t\t(host check)\n");
+            host* temp_host=(host *)event->event_data;
+            printf("\t\tHost:     %s\n",temp_host->name);
+            /* run a host check */
+        break;
+
+        case EVENT_COMMAND_CHECK:
+            printf("\t\t(external command check)\n");
+        break;
+
+        case EVENT_LOG_ROTATION:
+            printf("\t\t(log file rotation)\n");
+        break;
+
+        case EVENT_PROGRAM_SHUTDOWN:
+            printf("\t\t(program shutdown)\n");
+        break;
+
+        case EVENT_PROGRAM_RESTART:
+            printf("\t\t(program restart)\n");
+        break;
+
+        case EVENT_CHECK_REAPER:
+            printf("\t\t(service check reaper)\n");
+        break;
+
+        case EVENT_ORPHAN_CHECK:
+            printf("\t\t(orphaned service check)\n");
+        break;
+
+        case EVENT_RETENTION_SAVE:
+            printf("\t\t(retention save)\n");
+        break;
+
+        case EVENT_STATUS_SAVE:
+            printf("\t\t(status save)\n");
+        break;
+
+        case EVENT_SCHEDULED_DOWNTIME:
+            printf("\t\t(scheduled downtime)\n");
+        break;
+
+        case EVENT_SFRESHNESS_CHECK:
+            printf("\t\t(service result freshness check)\n");
+        break;
+
+        case EVENT_HFRESHNESS_CHECK:
+            printf("\t\t(host result freshness check)\n");
+        break;
+
+        case EVENT_EXPIRE_DOWNTIME:
+            printf("\t\t(expire downtime)\n");
+        break;
+
+        case EVENT_RESCHEDULE_CHECKS:
+            printf("\t\t(reschedule checks)\n");
+        break;
+
+        case EVENT_EXPIRE_COMMENT:
+            printf("\t\t(expire comment)\n");
+        break;
+
+        case EVENT_CHECK_PROGRAM_UPDATE:
+            printf("\t\t(check for Nagios updates)");
+        break;
+
+        case EVENT_USER_FUNCTION:
+            printf("\t\t(user function)\n");
+        break;
+
+        default:
+            printf("\t\t(Unknown!!!)\n");
+        break;
+    }
+    printf("\t\tPriority %s\n", (priority == 0 ?"Low":"High"));
+    printf("\t\tInterval: %lu\n",event->event_interval);
+    printf("\t\tEvent Time: %s\n",ctime(&event->run_time));
+    printf("\n\n");
+}
+
+/* displays the service check scheduling queue */
+void display_schedule(void)
+{
+    timed_event* high_event;
+    timed_event* low_event;
+    timed_event* event;
+    int priority;
+    printf("*** The current scheduling queue is listed below ***\n");
+
+    high_event = event_list_high;
+    low_event = event_list_low;
+
+    while(high_event || low_event)
+    {
+        if(low_event && high_event)
+        {
+            if(low_event->run_time < high_event->run_time)
+            {
+                event = low_event;
+                low_event = low_event->next;
+                priority = 0;
+            }else{
+                event = high_event;
+                high_event = high_event->next;
+                priority = 1;
+            }
+        }else{
+            if(high_event)
+            {
+                event = high_event;
+                high_event = high_event->next;
+                priority =1;
+            }
+
+            if(low_event)
+            {
+                event = low_event;
+                low_event = low_event->next;
+                priority =0;
+            }
 
+        }
+
+        display_event_data(event, priority);
+    }
+ }
 
 /* displays service check scheduling information */
 void display_scheduling_info(void){
diff --git a/base/icinga.c b/base/icinga.c
index c444d0e..89ae30a 100644
--- a/base/icinga.c
+++ b/base/icinga.c
@@ -184,6 +184,7 @@ int             verify_config=FALSE;
 int             verify_object_relationships=TRUE;
 int             verify_circular_paths=TRUE;
 int             test_scheduling=FALSE;
+int             show_schedule=FALSE;
 int             precache_objects=FALSE;
 int             use_precached_objects=FALSE;
 
@@ -297,6 +298,7 @@ int main(int argc, char **argv, char **env){
 		{"verify-config",no_argument,0,'v'},
 		{"daemon",no_argument,0,'d'},
 		{"test-scheduling",no_argument,0,'s'},
+		{"show-scheduling",no_argument,0,'S'},
 		{"dont-verify-objects",no_argument,0,'o'},
 		{"dont-verify-paths",no_argument,0,'x'},
 		{"precache-objects",no_argument,0,'p'},
@@ -314,9 +316,9 @@ int main(int argc, char **argv, char **env){
 	while(1){
 
 #ifdef HAVE_GETOPT_H
-		c=getopt_long(argc,argv,"+hVvdsoxpu",long_options,&option_index);
+		c=getopt_long(argc,argv,"+hVvdsoxpuS",long_options,&option_index);
 #else
-		c=getopt(argc,argv,"+hVvdsoxpu");
+		c=getopt(argc,argv,"+hVvdsoxpuS");
 #endif
 
 		if(c==-1 || c==EOF)
@@ -341,6 +343,11 @@ int main(int argc, char **argv, char **env){
 			test_scheduling=TRUE;
 			break;
 
+        case 'S': /* scheduling check and show queue*/
+            show_schedule=TRUE;
+			test_scheduling=TRUE;
+			break;
+
 		case 'd': /* daemon mode */
 			daemon_mode=TRUE;
 			break;
@@ -418,6 +425,7 @@ int main(int argc, char **argv, char **env){
 		printf("  -v, --verify-config          Verify all configuration data\n");
 		printf("  -s, --test-scheduling        Shows projected/recommended check scheduling and other\n");
 		printf("                               diagnostic info based on the current configuration files.\n");
+		printf("  -S, --show-scheduling        Same as -s, but also show the scheduling queue\n");
 		/*printf("  -o, --dont-verify-objects    Don't verify object relationships - USE WITH CAUTION!\n");*/
 		printf("  -x, --dont-verify-paths      Don't check for circular object paths - USE WITH CAUTION!\n");
 		printf("  -p, --precache-objects       Precache object configuration - use with -v or -s options\n");
@@ -590,6 +598,10 @@ int main(int argc, char **argv, char **env){
 			/* initialize the event timing loop */
 			init_timing_loop();
 
+            /* display schedule */
+			if(show_schedule == TRUE)
+                display_schedule();
+
 			/* display scheduling information */
 			display_scheduling_info();
 





More information about the icinga-checkins mailing list