Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
Classic UI: add possibility to acknowledge host and all its services …
Browse files Browse the repository at this point in the history
…with one command #3175

It is now possible to acknowledge a problem host and all its services
with one action. Available in extinfo.cgi and status.cgi with
multi select.

Refs: #3175
  • Loading branch information
bb-Ricardo committed May 7, 2015
1 parent de42341 commit 484c54a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion base/commands.c
Expand Up @@ -2507,7 +2507,7 @@ int cmd_acknowledge_problem(int cmd, char *args) {
persistent = (atoi(temp_ptr) > 0) ? TRUE : FALSE;

/* this acknowledegment will expire */
if (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM_EXPIRE || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM_EXPIRE) {
if (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM_EXPIRE || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM_EXPIRE || cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM) {
/* get end_time option */
if ((temp_ptr = my_strtok(NULL, ";")) == NULL)
return ERROR;
Expand Down
27 changes: 18 additions & 9 deletions cgi/cmd.c
Expand Up @@ -1028,13 +1028,13 @@ void print_form_element(int element, int cmd) {

case PRINT_PERSISTENT:

if (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM)
if (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM || cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM)
strcpy(help_text, "If you would like the comment to remain once the acknowledgement is removed, check this checkbox.");
else {
snprintf(help_text, sizeof(help_text), "If you uncheck this option, the comment will automatically be deleted the next time %s is restarted.", PROGRAM_NAME);
help_text[sizeof(help_text)-1] = '\x0';
}
printf("<tr><td class=\"objectDescription descriptionleft\">Persistent%s:", (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM) ? " Comment" : "");
printf("<tr><td class=\"objectDescription descriptionleft\">Persistent%s:", (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM || cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM) ? " Comment" : "");
print_help_box(help_text);
printf("</td><td align='left'>");
printf("<input type='checkbox' name='persistent' %s></td></tr>\n", (persistent_ack_comments == TRUE || cmd == CMD_ADD_HOST_COMMENT || cmd == CMD_ADD_SVC_COMMENT) ? "CHECKED" : "");
Expand Down Expand Up @@ -1300,7 +1300,8 @@ void request_command_data(int cmd) {

case CMD_ACKNOWLEDGE_HOST_PROBLEM:
case CMD_ACKNOWLEDGE_SVC_PROBLEM:
snprintf(action, sizeof(action), "Acknowledge %s problems", (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM) ? "host" : "service");
case CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM:
snprintf(action, sizeof(action), "Acknowledge %s problems%s", (cmd != CMD_ACKNOWLEDGE_SVC_PROBLEM) ? "host" : "service", (cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM) ? " and all services" : "");
break;

case CMD_START_EXECUTING_HOST_CHECKS:
Expand Down Expand Up @@ -1585,6 +1586,7 @@ void request_command_data(int cmd) {
case CMD_ACKNOWLEDGE_SVC_PROBLEM:
case CMD_ADD_HOST_COMMENT:
case CMD_ACKNOWLEDGE_HOST_PROBLEM:
case CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM:

if (cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM || cmd == CMD_ADD_SVC_COMMENT)
print_object_list(PRINT_SERVICE_LIST);
Expand All @@ -1596,7 +1598,7 @@ void request_command_data(int cmd) {
print_form_element(PRINT_COMMENT_BOX, cmd);
print_form_element(PRINT_PERSISTENT, cmd);

if (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM) {
if (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM || cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM) {
print_form_element(PRINT_EXPIRE_ACKNOWLEDGEMENT, cmd);
print_form_element(PRINT_STICKY_ACK, cmd);
print_form_element(PRINT_SEND_NOTFICATION, cmd);
Expand Down Expand Up @@ -2111,6 +2113,7 @@ void commit_command_data(int cmd) {
case CMD_ADD_SVC_COMMENT:
case CMD_ACKNOWLEDGE_HOST_PROBLEM:
case CMD_ACKNOWLEDGE_SVC_PROBLEM:
case CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM:
case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
case CMD_SEND_CUSTOM_SVC_NOTIFICATION:

Expand All @@ -2121,7 +2124,7 @@ void commit_command_data(int cmd) {
clean_comment_data(comment_author);
clean_comment_data(comment_data);

if (use_ack_end_time == TRUE && (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM)) {
if (use_ack_end_time == TRUE && (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM || cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM)) {

time(&start_time);

Expand All @@ -2139,7 +2142,7 @@ void commit_command_data(int cmd) {

/* see if the user is authorized to issue a command... */
is_authorized[x] = FALSE;
if (cmd == CMD_ADD_HOST_COMMENT || cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_SEND_CUSTOM_HOST_NOTIFICATION) {
if (cmd == CMD_ADD_HOST_COMMENT || cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM || cmd == CMD_SEND_CUSTOM_HOST_NOTIFICATION) {
temp_host = find_host(commands[x].host_name);
if (is_authorized_for_host_commands(temp_host, &current_authdata) == TRUE)
is_authorized[x] = TRUE;
Expand Down Expand Up @@ -2959,13 +2962,19 @@ int commit_command(int cmd) {
break;

case CMD_ACKNOWLEDGE_HOST_PROBLEM:
case CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM:
for (x = 0; x < NUMBER_OF_STRUCTS; x++) {
if (commands[x].host_name == NULL)
continue;
if (is_authorized[x]) {
if (end_time > 0) {
cmd = CMD_ACKNOWLEDGE_HOST_PROBLEM_EXPIRE;
asprintf(&temp_buffer, "%s - The acknowledgement expires at: %s.", comment_data, end_time_string);
if (end_time > 0 || cmd == CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM) {
if (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM)
cmd = CMD_ACKNOWLEDGE_HOST_PROBLEM_EXPIRE;
if (end_time > 0) {
asprintf(&temp_buffer, "%s - The acknowledgement expires at: %s.", comment_data, end_time_string);
} else {
asprintf(&temp_buffer, "%s", comment_data);
}
submit_result[x] = cmd_submitf(cmd, "%s;%d;%d;%d;%lu;%s;%s", commands[x].host_name, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, end_time, comment_author, temp_buffer);
my_free(temp_buffer);
} else
Expand Down
1 change: 1 addition & 0 deletions cgi/extcmd_list.c
Expand Up @@ -75,6 +75,7 @@ struct nagios_extcmd in_core_commands[] = {
CMD_DEF(READ_STATE_INFORMATION, 0, NULL),
CMD_DEF(ACKNOWLEDGE_HOST_PROBLEM, 0, NULL),
CMD_DEF(ACKNOWLEDGE_HOST_PROBLEM_EXPIRE, 0, NULL),
CMD_DEF(ACKNOWLEDGE_HOST_SVC_PROBLEM, 0, NULL),
CMD_DEF(ACKNOWLEDGE_SVC_PROBLEM, 0, NULL),
CMD_DEF(ACKNOWLEDGE_SVC_PROBLEM_EXPIRE, 0, NULL),
CMD_DEF(START_EXECUTING_SVC_CHECKS, 0, NULL),
Expand Down
5 changes: 3 additions & 2 deletions cgi/extinfo.c
Expand Up @@ -1704,9 +1704,10 @@ void show_host_info(void) {
printf("<tr class='command'><td><img src='%s%s' border='0' alt='Start Obsessing Over This Host' title='Start Obsessing Over This Host'></td><td class='command'><a href='%s?cmd_typ=%d&amp;host=%s'>Start obsessing over this host</a></td></tr>\n", url_images_path, ENABLED_ICON, CMD_CGI, CMD_START_OBSESSING_OVER_HOST, url_encode(host_name));

if (temp_hoststatus->status == HOST_DOWN || temp_hoststatus->status == HOST_UNREACHABLE) {
if (temp_hoststatus->problem_has_been_acknowledged == FALSE)
if (temp_hoststatus->problem_has_been_acknowledged == FALSE) {
printf("<tr class='command'><td><img src='%s%s' border='0' alt='Acknowledge This Host Problem' title='Acknowledge This Host Problem'></td><td class='command'><a href='%s?cmd_typ=%d&amp;host=%s'>Acknowledge this host problem</a></td></tr>\n", url_images_path, ACKNOWLEDGEMENT_ICON, CMD_CGI, CMD_ACKNOWLEDGE_HOST_PROBLEM, url_encode(host_name));
else
printf("<tr class='command'><td><img src='%s%s' border='0' alt='Acknowledge Problem For This Host And Its Services' title='Acknowledge Problem For This Host And Its Services'></td><td class='command'><a href='%s?cmd_typ=%d&amp;host=%s'>Acknowledge problem for this host and its services</a></td></tr>\n", url_images_path, ACKNOWLEDGEMENT_ICON, CMD_CGI, CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM, url_encode(host_name));
} else
printf("<tr class='command'><td><img src='%s%s' border='0' alt='Remove Problem Acknowledgement' title='Remove Problem Acknowledgement'></td><td class='command'><a href='%s?cmd_typ=%d&amp;host=%s'>Remove problem acknowledgement</a></td></tr>\n", url_images_path, REMOVE_ACKNOWLEDGEMENT_ICON, CMD_CGI, CMD_REMOVE_HOST_ACKNOWLEDGEMENT, url_encode(host_name));
}

Expand Down
9 changes: 5 additions & 4 deletions cgi/status.c
Expand Up @@ -7040,7 +7040,7 @@ void show_servicecommand_table(void) {
/* DropDown menu */
printf("<select style='display:none;width:400px' name='cmd_typ' id='cmd_typ_service' onchange='showValue(\"tableformservice\",this.value,%d,%d)' class='DropDownService'>\n", CMD_SCHEDULE_HOST_CHECK, CMD_SCHEDULE_SVC_CHECK);
printf("<option value='nothing'>Select command</option>\n");
printf("<option value='%d' title='%s%s' >Add a Comment to Checked Service(s)</option>\n", CMD_ADD_SVC_COMMENT, url_images_path, COMMENT_ICON);
printf("<option value='%d' title='%s%s'>Add a Comment to Checked Service(s)</option>\n", CMD_ADD_SVC_COMMENT, url_images_path, COMMENT_ICON);
printf("<option value='%d' title='%s%s'>Disable Active Checks Of Checked Service(s)</option>\n", CMD_DISABLE_SVC_CHECK, url_images_path, DISABLED_ICON);
printf("<option value='%d' title='%s%s'>Enable Active Checks Of Checked Service(s)</option>\n", CMD_ENABLE_SVC_CHECK, url_images_path, ENABLED_ICON);
printf("<option value='%d' title='%s%s'>Re-schedule Next Service Check</option>\n", CMD_SCHEDULE_SVC_CHECK, url_images_path, DELAY_ICON);
Expand Down Expand Up @@ -7101,14 +7101,15 @@ void show_hostcommand_table(void) {
printf("<option value='%d' title='%s%s' >Stop Obsessing Over Checked Host(s)</option>\n", CMD_STOP_OBSESSING_OVER_HOST, url_images_path, DISABLED_ICON);
printf("<option value='%d' title='%s%s' >Start Obsessing Over Checked Host(s)</option>\n", CMD_START_OBSESSING_OVER_HOST, url_images_path, ENABLED_ICON);
printf("<option value='%d' title='%s%s' >Acknowledge Checked Host(s) Problem</option>\n", CMD_ACKNOWLEDGE_HOST_PROBLEM, url_images_path, ACKNOWLEDGEMENT_ICON);
printf("<option value='%d' title='%s%s' >Acknowledge Checked Host(s) Problem And All Services</option>\n", CMD_ACKNOWLEDGE_HOST_SVC_PROBLEM, url_images_path, ACKNOWLEDGEMENT_ICON);
printf("<option value='%d' title='%s%s' >Remove Problem Acknowledgement</option>\n", CMD_REMOVE_HOST_ACKNOWLEDGEMENT, url_images_path, REMOVE_ACKNOWLEDGEMENT_ICON);
printf("<option value='%d' title='%s%s' >Disable Notifications For Checked Host(s)</option>\n", CMD_DISABLE_HOST_NOTIFICATIONS, url_images_path, DISABLED_ICON);
printf("<option value='%d' title='%s%s' >Enable Notifications For Checked Host(s)</option>\n", CMD_ENABLE_HOST_NOTIFICATIONS, url_images_path, ENABLED_ICON);
printf("<option value='%d' title='%s%s' >Send Custom Notification</option>\n", CMD_SEND_CUSTOM_HOST_NOTIFICATION, url_images_path, NOTIFICATION_ICON);
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 Downtime(s) For Checked Host(s) and All Services</option>\n", CMD_DEL_DOWNTIME_BY_HOST_NAME, url_images_path, DISABLED_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 Downtime(s) For Checked Host(s) And All Services</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);
Expand All @@ -7131,7 +7132,7 @@ void show_hostcommand_table(void) {
printf("checked = true;\n");
printf("checkAll(\"tableformhost\");\n");
printf("checked = false;\n");
printf("try { \n$(\".DropDownHost\").msDropDown({visibleRows:27}).data(\"dd\").visible(true);\n");
printf("try { \n$(\".DropDownHost\").msDropDown({visibleRows:28}).data(\"dd\").visible(true);\n");
printf("} catch(e) {\n");
printf("if (console) { console.log(e); }\n}\n");
printf("});\n");
Expand Down

0 comments on commit 484c54a

Please sign in to comment.