[icinga-checkins] icinga.org: icinga-core/mfriedrich/cgis: Added ability to combine host and service in one CGI parameter ( Aaron Brady) #1633
git at icinga.org
git at icinga.org
Thu Jun 16 18:17:12 CEST 2011
Module: icinga-core
Branch: mfriedrich/cgis
Commit: b6fd633774fc56a5aa8c49a6e0f147268b4fc3d6
URL: https://git.icinga.org/?p=icinga-core.git;a=commit;h=b6fd633774fc56a5aa8c49a6e0f147268b4fc3d6
Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date: Wed Jun 15 23:55:57 2011 +0200
Added ability to combine host and service in one CGI parameter (Aaron Brady) #1633
refs: #1633
refs: #1120
refs: #1644
* added parameter hostservice to cmd.cgi parameter
* fixed dropdown, causing error when not in status list of status.cgi
* changed dropdown from get to post, hopefully ollowing more
hosts and services to be sent.
* added missing Changlogentry for #1120
---
Changelog | 2 ++
cgi/cgiutils.c | 15 +--------------
cgi/cmd.c | 28 ++++++++++++++++++++++++++++
cgi/status.c | 43 ++++++++++++++++++++++++++++++++-----------
4 files changed, 63 insertions(+), 25 deletions(-)
diff --git a/Changelog b/Changelog
index 52e9463..30d85f3 100644
--- a/Changelog
+++ b/Changelog
@@ -11,6 +11,8 @@ ENHANCEMENTS
* classic ui: Added option to show partial hostgroups (Matthew Brooks) #1013
* classic ui: changing drop down menu in status.cgi to jquery-dd #1644
* classic ui: default downtime duration is configurable in cgi.cfg #1642
+* classic ui: Added ability to combine host and service in one CGI parameter (Aaron Brady) #1633
+* classic ui: Changed tac.cgi to distinct between active, passive and disabled properly #1120
FIXES
* core: remove duplicated unlinks for check result files with multiple results #1615
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index e9ad28e..8e235bd 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -1054,21 +1054,8 @@ void document_header(int cgi_id, int use_stylesheet){
if(cgi_id == STATUS_CGI_ID) {
/* Set everything in a form, so checkboxes can be searched after and checked. */
- printf("<form name='tableform' id='tableform'>\n");
+ printf("<form name='tableform' id='tableform' action='%s' method='POST'>\n",CMD_CGI);
printf("<input type=hidden name=hiddenforcefield><input type=hidden name=hiddencmdfield><input type=hidden name=buttonValidChoice><input type=hidden name=buttonCheckboxChecked>\n");
-
- /* Print out the activator for the dropdown (which must be between the body tags */
- printf("<script language='javascript'>\n");
- printf("$(document).ready(function() { \n");
- printf("try { \n oHandler = $(\".DropDown\").msDropDown({visibleRows:25}).data(\"dd\");\n");
- printf("oHandler.visible(true);\n");
- printf("$(\"#ver\").html($.msDropDown.version);\n");
- printf("} catch(e) {\n");
- printf("alert(\"Error: \"+e.message);\n}\n");
- printf("});\n");
- printf("</script>\n");
-
- /* Javascript lib to show tooltips */
}
if(cgi_id == STATUS_CGI_ID || cgi_id == CMD_CGI_ID) {
diff --git a/cgi/cmd.c b/cgi/cmd.c
index 81d5453..4fd0174 100644
--- a/cgi/cmd.c
+++ b/cgi/cmd.c
@@ -408,6 +408,7 @@ int main(void){
int process_cgivars(void){
char **variables;
+ char *temp_buffer=NULL;
int error=FALSE;
int x;
int z = 0;
@@ -554,6 +555,33 @@ int process_cgivars(void){
}
}
+ /* we found a combined host/service */
+ else if(!strcmp(variables[x],"hostservice")){
+ x++;
+ if(variables[x]==NULL){
+ error=TRUE;
+ break;
+ }
+
+ temp_buffer=strtok(variables[x],"^");
+
+ if((host_name=(char *)strdup(temp_buffer))==NULL)
+ host_name="";
+ else {
+ strip_html_brackets(host_name);
+ commands[x].host_name = host_name;
+ }
+
+ temp_buffer=strtok(NULL,"");
+
+ if((service_desc=(char *)strdup(temp_buffer))==NULL)
+ service_desc="";
+ else {
+ strip_html_brackets(service_desc);
+ commands[x].description = service_desc;
+ }
+ }
+
/* we found the servicegroup name */
else if(!strcmp(variables[x],"servicegroup")){
x++;
diff --git a/cgi/status.c b/cgi/status.c
index d48f158..d99a59c 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -1813,12 +1813,9 @@ void show_service_detail(void){
printf("<TD CLASS='status%s'>%s</TD>\n",status_bg_class,temp_status->attempts);
printf("<TD CLASS='status%s' valign='center'>%s</TD>\n",status_bg_class,temp_status->plugin_output);
- if (is_authorized_for_read_only(¤t_authdata)==FALSE){
- /* Checkbox for service(s) */
- printf("<TD CLASS='status%s' nowrap align='center'><input onclick=\"isValidForSubmit('tableform');\" type='checkbox' name='checkbox' value='&host=%s",status_bg_class,url_encode(temp_status->host_name));
- printf("&service=%s'></TD>\n",url_encode(temp_status->svc_description));
- }
-
+ /* Checkbox for service(s) */
+ if (is_authorized_for_read_only(¤t_authdata)==FALSE)
+ printf("<TD CLASS='status%s' nowrap align='center'><input onclick=\"isValidForSubmit('tableform');\" type='checkbox' name='hostservice' value='%s^%s'></TD>\n",status_bg_class,url_encode(temp_status->host_name),temp_status->svc_description);
if(enable_splunk_integration==TRUE)
display_splunk_service_url(temp_service);
@@ -2215,7 +2212,7 @@ void show_host_detail(void){
/* Checkbox for host(s) */
if (is_authorized_for_read_only(¤t_authdata)==FALSE)
- printf("<TD CLASS='status%s' valign='center' align='center'><input onClick=\"isValidForSubmit('tableform');\" type='checkbox' name='checkbox' value='&host=%s'></TD>\n",status_bg_class,url_encode(temp_statusdata->host_name));
+ printf("<TD CLASS='status%s' valign='center' align='center'><input onClick=\"isValidForSubmit('tableform');\" type='checkbox' name='host' value='%s'></TD>\n",status_bg_class,url_encode(temp_statusdata->host_name));
@@ -5826,7 +5823,7 @@ void show_servicecommand_table(void){
/* A new div for the command table */
printf("<DIV CLASS='serviceTotalsCommands'>Commands for checked services</DIV>\n");
/* DropDown menu */
- printf("<select style='display:none;width:400px' name='dropdown' onchange='showValue(this.value,%d,%d)' CLASS='DropDown'>",CMD_SCHEDULE_HOST_CHECK,CMD_SCHEDULE_SVC_CHECK);
+ printf("<select style='display:none;width:400px' name='cmd_typ' id='cmd_typ' onchange='showValue(this.value,%d,%d)' CLASS='DropDown'>",CMD_SCHEDULE_HOST_CHECK,CMD_SCHEDULE_SVC_CHECK);
printf("<option value='nothing'>Select command</option>");
printf("<option value='%d' title='%s%s' >Add a Comment to Checked Service(s)</option>",CMD_ADD_SVC_COMMENT,url_images_path,COMMENT_ICON);
printf("<option value='%d' title='%s%s'>Disable Active Checks Of Checked Service(s)</option>",CMD_DISABLE_SVC_CHECK,url_images_path,DISABLED_ICON);
@@ -5849,7 +5846,19 @@ void show_servicecommand_table(void){
printf("<option value='%d' title='%s%s'>Disable Flap Detection For Checked Service(s)</option>",CMD_DISABLE_SVC_FLAP_DETECTION,url_images_path,DISABLED_ICON);
printf("<option value='%d' title='%s%s'>Enable Flap Detection For Checked Service(s)</option>",CMD_ENABLE_SVC_FLAP_DETECTION,url_images_path,ENABLED_ICON);
printf("</select>");
- printf("<br><br><b><input type='button' name='CommandButton' value='Submit' class='serviceTotalsCommands' onClick=\"cmd_submit('tableform')\" disabled='disabled'></b>\n");
+
+ /* Print out the activator for the dropdown (which must be between the body tags */
+ printf("<script language='javascript'>\n");
+ printf("$(document).ready(function() { \n");
+ printf("try { \n oHandler = $(\".DropDown\").msDropDown({visibleRows:25}).data(\"dd\");\n");
+ printf("oHandler.visible(true);\n");
+ printf("$(\"#ver\").html($.msDropDown.version);\n");
+ printf("} catch(e) {\n");
+ printf("alert(\"Error: \"+e.message);\n}\n");
+ printf("});\n");
+ printf("</script>\n");
+
+ printf("<br><br><b><input type='submit' name='CommandButton' value='Submit' class='serviceTotalsCommands' disabled='disabled'></b>\n");
}
}
@@ -5859,7 +5868,7 @@ void show_hostcommand_table(void){
/* A new div for the command table */
printf("<DIV CLASS='hostTotalsCommands'>Commands for checked host(s)</DIV>\n");
/* DropDown menu */
- printf("<select style='display:none;width:400px' name='dropdown' onchange='showValue(this.value,%d,%d)' CLASS='DropDown'>",CMD_SCHEDULE_HOST_CHECK,CMD_SCHEDULE_SVC_CHECK);
+ printf("<select style='display:none;width:400px' name='cmd_typ' id='cmd_typ' onchange='showValue(this.value,%d,%d)' CLASS='DropDown'>",CMD_SCHEDULE_HOST_CHECK,CMD_SCHEDULE_SVC_CHECK);
printf("<option value='nothing'>Select command</option>");
printf("<option value='%d' title='%s%s' >Add a Comment to Checked Host(s)</option>",CMD_ADD_HOST_COMMENT,url_images_path,COMMENT_ICON);
printf("<option value='%d' title='%s%s' >Disable Active Checks Of Checked Host(s)</option>",CMD_DISABLE_HOST_CHECK,url_images_path,DISABLED_ICON);
@@ -5888,7 +5897,19 @@ void show_hostcommand_table(void){
printf("<option value='%d' title='%s%s' >Disable Flap Detection For Checked Host(s)</option>",CMD_DISABLE_HOST_FLAP_DETECTION,url_images_path,DISABLED_ICON);
printf("<option value='%d' title='%s%s' >Enable Flap Detection For Checked Host(s)</option>",CMD_ENABLE_HOST_FLAP_DETECTION,url_images_path,ENABLED_ICON);
printf("</select>");
- printf("<br><br><b><input type='button' name='CommandButton' value='Submit' class='hostsTotalsCommands' onClick=\"cmd_submit('tableform')\" disabled='disabled'></b>\n");
+
+ /* Print out the activator for the dropdown (which must be between the body tags */
+ printf("<script language='javascript'>\n");
+ printf("$(document).ready(function() { \n");
+ printf("try { \n oHandler = $(\".DropDown\").msDropDown({visibleRows:25}).data(\"dd\");\n");
+ printf("oHandler.visible(true);\n");
+ printf("$(\"#ver\").html($.msDropDown.version);\n");
+ printf("} catch(e) {\n");
+ printf("alert(\"Error: \"+e.message);\n}\n");
+ printf("});\n");
+ printf("</script>\n");
+
+ printf("<br><br><b><input type='submit' name='CommandButton' value='Submit' class='hostsTotalsCommands' disabled='disabled'></b>\n");
}
}
/* The cake is a lie! */
More information about the icinga-checkins
mailing list