[icinga-checkins] icinga.org: icinga-core/rdarrud/cgifix: * Modified the CGI' s for support to delete all downtimes associated with a host as an external command .

git at icinga.org git at icinga.org
Tue Aug 7 03:14:46 CEST 2012


Module: icinga-core
Branch: rdarrud/cgifix
Commit: fd5ac34f2dd52ca8b0a4f1570e2e18fb82abacbb
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=fd5ac34f2dd52ca8b0a4f1570e2e18fb82abacbb

Author: root <root at icinga-sles11sp1-64.darrud-family.com>
Date:   Tue Aug  7 03:06:14 2012 +0200

* Modified the CGI's for support to delete all downtimes associated with a host as an external command.
* Upon testing this command (already present in core), the core segfaults. It does successfully remove the downtime while running in some tests, though never saving to status and retention even if core does not segfault.
refs #1572

---

 cgi/cmd.c         |   31 +++++++++++++++++++++++++++++--
 cgi/extcmd_list.c |    1 +
 cgi/extinfo.c     |    2 ++
 cgi/status.c      |    1 +
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/cgi/cmd.c b/cgi/cmd.c
index fab15aa..b6991dc 100644
--- a/cgi/cmd.c
+++ b/cgi/cmd.c
@@ -1252,6 +1252,11 @@ void request_command_data(int cmd) {
 		snprintf(action, sizeof(action), "Schedule downtime for these %s", (cmd == CMD_SCHEDULE_HOST_DOWNTIME) ? "hosts" : "services");
 		break;
 
+	case CMD_DEL_DOWNTIME_BY_HOST_NAME:
+                snprintf(help_text, sizeof(help_text), "This command is used to delete all downtime specified by the host name already supplied.");
+		snprintf(action, sizeof(action), "Remove all downtime for these hosts");
+                break;
+
 	case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
 		snprintf(help_text, sizeof(help_text), "This command is used to schedule downtime for a particular host and all of its services.	During the specified downtime, %s will not send notifications out about the host. "
 		         "Normally, a host in downtime will not send alerts about any services in a failed state. This option will explicitly set downtime for all services for this host. "
@@ -1381,7 +1386,7 @@ void request_command_data(int cmd) {
 		break;
 
 	default:
-		print_generic_error_message("Sorry Dave, I can't let you do that...", "Executing an unknown command? Shame on you!", 2);
+		print_generic_error_message("Sorry Dave2, I can't let you do that...", "Executing an unknown command? Shame on you!", 2);
 
 		return;
 	}
@@ -1478,6 +1483,18 @@ void request_command_data(int cmd) {
 
 		break;
 
+	case CMD_DEL_DOWNTIME_BY_HOST_NAME:
+                print_object_list(PRINT_HOST_LIST);
+
+                print_form_element(PRINT_COMMON_HEADER, cmd);
+
+                if (enforce_comments_on_actions == TRUE) {
+                        print_form_element(PRINT_AUTHOR, cmd);
+                        print_form_element(PRINT_COMMENT_BOX, cmd);
+                }
+
+                break;
+
 	case CMD_DELAY_SVC_NOTIFICATION:
 	case CMD_DELAY_HOST_NOTIFICATION:
 
@@ -2174,6 +2191,7 @@ void commit_command_data(int cmd) {
 	case CMD_SCHEDULE_HOST_CHECK:
 	case CMD_START_OBSESSING_OVER_HOST:
 	case CMD_STOP_OBSESSING_OVER_HOST:
+	case CMD_DEL_DOWNTIME_BY_HOST_NAME:
 
 		if (cmd == CMD_SCHEDULE_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOST_SVC_DOWNTIME || enforce_comments_on_actions == TRUE) {
 			/* make sure we have author and comment data */
@@ -2299,7 +2317,7 @@ void commit_command_data(int cmd) {
 		break;
 
 	default:
-		print_generic_error_message("Sorry Dave, I can't let you do that...", "Executing an unknown command? Shame on you!", 2);
+		print_generic_error_message("Sorry Dave3, I can't let you do that...", "Executing an unknown command? Shame on you!", 2);
 
 		return;
 	}
@@ -2621,6 +2639,15 @@ int commit_command(int cmd) {
 		}
 		break;
 
+	case CMD_DEL_DOWNTIME_BY_HOST_NAME:
+		for (x = 0; x < NUMBER_OF_STRUCTS; x++) {
+			if (commands[x].host_name == NULL)
+				continue;
+			if (is_authorized[x])
+				submit_result[x] = cmd_submitf(cmd, "%s", commands[x].host_name);
+		}
+		break;
+
 	case CMD_DELAY_HOST_NOTIFICATION:
 		for (x = 0; x < NUMBER_OF_STRUCTS; x++) {
 			if (commands[x].host_name == NULL)
diff --git a/cgi/extcmd_list.c b/cgi/extcmd_list.c
index 987882b..dd2cca0 100644
--- a/cgi/extcmd_list.c
+++ b/cgi/extcmd_list.c
@@ -98,6 +98,7 @@ struct nagios_extcmd in_core_commands[] = {
 	CMD_DEF(SCHEDULE_FORCED_SVC_CHECK, 0, NULL),
 	CMD_DEF(SCHEDULE_HOST_DOWNTIME, 0, NULL),
 	CMD_DEF(SCHEDULE_SVC_DOWNTIME, 0, NULL),
+	CMD_DEF(DEL_DOWNTIME_BY_HOST_NAME, 0, NULL),
 	CMD_DEF(ENABLE_HOST_FLAP_DETECTION, 0, NULL),
 	CMD_DEF(DISABLE_HOST_FLAP_DETECTION, 0, NULL),
 	CMD_DEF(ENABLE_SVC_FLAP_DETECTION, 0, NULL),
diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index 8c8901c..68030bd 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -1671,6 +1671,8 @@ void show_host_info(void) {
 
 			printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For This Host and All Services' TITLE='Schedule Downtime For This Host and All Services'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Schedule downtime for this host and all services</a></td></tr>\n", url_images_path, DOWNTIME_ICON, CMD_CGI, CMD_SCHEDULE_HOST_SVC_DOWNTIME, url_encode(host_name));
 
+			printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Remove All Downtime for this host' TITLE='Remove All Downtime for this host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Remove All Downtime for this host</a></td></tr>\n", url_images_path, DISABLED_ICON, CMD_CGI, CMD_DEL_DOWNTIME_BY_HOST_NAME, url_encode(host_name));
+
 			printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For All Services On This Host' TITLE='Disable Notifications For All Services On This Host'></td><td CLASS='command' NOWRAP><a href='%s?cmd_typ=%d&host=%s'>Disable notifications for all services on this host</a></td></tr>\n", url_images_path, DISABLED_ICON, CMD_CGI, CMD_DISABLE_HOST_SVC_NOTIFICATIONS, url_encode(host_name));
 
 			printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For All Services On This Host' TITLE='Enable Notifications For All Services On This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Enable notifications for all services on this host</a></td></tr>\n", url_images_path, ENABLED_ICON, CMD_CGI, CMD_ENABLE_HOST_SVC_NOTIFICATIONS, url_encode(host_name));
diff --git a/cgi/status.c b/cgi/status.c
index b6a0bab..a900b1e 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -6796,6 +6796,7 @@ void show_hostcommand_table(void) {
 		printf("<option value='%d' title='%s%s' >Delay Next Host Notification</option>\n", CMD_DELAY_HOST_NOTIFICATION, url_images_path, DELAY_ICON);
 		printf("<option value='%d' title='%s%s' >Schedule Downtime For Checked Host(s)</option>\n", CMD_SCHEDULE_HOST_DOWNTIME, url_images_path, DOWNTIME_ICON);
 		printf("<option value='%d' title='%s%s' >Schedule Downtime For Checked Host(s) and All Services</option>\n", CMD_SCHEDULE_HOST_SVC_DOWNTIME, url_images_path, DOWNTIME_ICON);
+		printf("<option value='%d' title='%s%s' >Remove All Scheduled downtime of Selected Host(s)</option>\n", CMD_DEL_DOWNTIME_BY_HOST_NAME, url_images_path, DISABLED_ICON);
 		printf("<option value='%d' title='%s%s' >Disable Notifications For All Services On Checked Host(s)</option>\n", CMD_DISABLE_HOST_SVC_NOTIFICATIONS, url_images_path, DISABLED_ICON);
 		printf("<option value='%d' title='%s%s' >Enable Notifications For All Services On Checked Host(s)</option>\n", CMD_ENABLE_HOST_SVC_NOTIFICATIONS, url_images_path, ENABLED_ICON);
 		printf("<option value='%d' title='%s%s' >Schedule A Check Of All Services On Checked Host(s)</option>\n", CMD_SCHEDULE_HOST_SVC_CHECKS, url_images_path, DELAY_ICON);





More information about the icinga-checkins mailing list