[icinga-checkins] icinga.org: icinga-core/test/ido: * 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
Wed Oct 3 01:18:35 CEST 2012


Module: icinga-core
Branch: test/ido
Commit: 6dc8bcca7b20bee608bcffe332407405a8e0c787
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=6dc8bcca7b20bee608bcffe332407405a8e0c787

Author: Rune Darrud <theflyingcorpse at gmail.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 752b677..edca7c2 100644
--- a/cgi/cmd.c
+++ b/cgi/cmd.c
@@ -1380,6 +1380,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. "
@@ -1509,7 +1514,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;
 	}
@@ -1606,6 +1611,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:
 
@@ -2316,6 +2333,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 */
@@ -2441,7 +2459,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;
 	}
@@ -2763,6 +2781,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 3343028..3d923fe 100644
--- a/cgi/extcmd_list.c
+++ b/cgi/extcmd_list.c
@@ -99,6 +99,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 704c9c5..8f75530 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -1680,6 +1680,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 5c0e3c1..299c393 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -6794,6 +6794,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