diff -Naur nagios-3.2.3+SmallPatches/cgi/cgiutils.c nagios-3.2.3+SP+MU/cgi/cgiutils.c
--- nagios-3.2.3+SmallPatches/cgi/cgiutils.c 2010-11-05 21:47:02.000000000 +0100
+++ nagios-3.2.3+SP+MU/cgi/cgiutils.c 2010-11-10 16:02:13.000000000 +0100
@@ -28,6 +28,7 @@
#include "../include/objects.h"
#include "../include/statusdata.h"
+#define SKIP_MULTIURL_DEFS
#include "../include/cgiutils.h"
char main_config_file[MAX_FILENAME_LENGTH];
@@ -121,6 +122,7 @@
int tab_friendly_titles=FALSE;
int add_notif_num_hard=0;
int add_notif_num_soft=0;
+int use_multiurls=0;
extern hostgroup *hostgroup_list;
extern contactgroup *contactgroup_list;
@@ -444,6 +446,9 @@
else if(!strcmp(var,"add_notif_num_soft"))
add_notif_num_soft=atoi(val);
+
+ else if(!strcmp(var,"use_multiurls"))
+ use_multiurls=(atoi(val)>0)?TRUE:FALSE;
}
/* free memory and close the file */
diff -Naur nagios-3.2.3+SmallPatches/cgi/extinfo.c nagios-3.2.3+SP+MU/cgi/extinfo.c
--- nagios-3.2.3+SmallPatches/cgi/extinfo.c 2010-11-05 20:23:24.000000000 +0100
+++ nagios-3.2.3+SP+MU/cgi/extinfo.c 2010-11-10 15:55:18.000000000 +0100
@@ -439,25 +439,29 @@
if(display_type==DISPLAY_HOST_INFO && temp_host!=NULL){
printf("
\n");
if(temp_host->action_url!=NULL && strcmp(temp_host->action_url,"")){
+ process_macros_r(mac, temp_host->action_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("\n");
printf(" \n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,ACTION_ICON);
+ printf("' TARGET='%s'> \n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,MU_iconstr,ACTION_ICON);
printf(" Extra Actions
\n");
printf(" |
\n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->notes_url!=NULL && strcmp(temp_host->notes_url,"")){
+ process_macros_r(mac, temp_host->notes_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("\n");
printf(" \n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,NOTES_ICON);
+ printf("' TARGET='%s'> \n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,MU_iconstr,NOTES_ICON);
printf(" Extra Notes
\n");
printf(" |
\n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
printf("
\n");
}
@@ -465,20 +469,24 @@
else if(display_type==DISPLAY_SERVICE_INFO && temp_service!=NULL){
printf("\n");
if(temp_service->action_url!=NULL && strcmp(temp_service->action_url,"")){
- printf(" \n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,ACTION_ICON);
+ printf("' TARGET='%s'> \n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,MU_iconstr,ACTION_ICON);
printf(" Extra Actions
\n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_service->notes_url!=NULL && strcmp(temp_service->notes_url,"")){
- printf(" \n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,NOTES_ICON);
+ printf("' TARGET='%s'> \n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,MU_iconstr,NOTES_ICON);
printf(" Extra Notes
\n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
printf(" |
\n");
}
diff -Naur nagios-3.2.3+SmallPatches/cgi/status.c nagios-3.2.3+SP+MU/cgi/status.c
--- nagios-3.2.3+SmallPatches/cgi/status.c 2010-11-05 21:55:21.000000000 +0100
+++ nagios-3.2.3+SP+MU/cgi/status.c 2010-11-10 15:56:01.000000000 +0100
@@ -1629,26 +1629,30 @@
printf(" | ",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_status->host_name),url_images_path,SCHEDULED_DOWNTIME_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT);
}
if(temp_host->notes_url!=NULL){
+ process_macros_r(mac, temp_host->notes_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("");
printf("",(notes_url_target==NULL)?"_blank":notes_url_target);
- printf(" ",url_images_path,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
+ printf(" ",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
printf("");
printf(" | \n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->action_url!=NULL){
+ process_macros_r(mac, temp_host->action_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("");
printf("",(action_url_target==NULL)?"_blank":action_url_target);
- printf(" ",url_images_path,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
+ printf(" ",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
printf("");
printf(" | \n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->icon_image!=NULL){
printf("");
@@ -1723,26 +1727,30 @@
printf("&service=%s'> | ",url_encode(temp_status->description),url_images_path,SCHEDULED_DOWNTIME_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT);
}
if(temp_service->notes_url!=NULL){
+ process_macros_r(mac, temp_service->notes_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("");
printf("",(notes_url_target==NULL)?"_blank":notes_url_target);
- printf(" ",url_images_path,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Service Notes","View Extra Service Notes");
+ printf(" ",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Service Notes","View Extra Service Notes");
printf("");
printf(" | \n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_service->action_url!=NULL){
+ process_macros_r(mac, temp_service->action_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("");
printf("",(action_url_target==NULL)?"_blank":action_url_target);
- printf(" ",url_images_path,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Service Actions","Perform Extra Service Actions");
+ printf(" ",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Service Actions","Perform Extra Service Actions");
printf("");
printf(" | \n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_service->icon_image!=NULL){
printf("");
@@ -2125,26 +2133,30 @@
printf(" |  | ",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_status->host_name),url_images_path,SCHEDULED_DOWNTIME_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT);
}
if(temp_host->notes_url!=NULL){
+ process_macros_r(mac, temp_host->notes_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("");
printf("",(notes_url_target==NULL)?"_blank":notes_url_target);
- printf(" ",url_images_path,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
+ printf(" ",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
printf("");
printf(" | \n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->action_url!=NULL){
+ process_macros_r(mac, temp_host->action_url,&processed_string,0);
+ BEGIN_MULTIURL_LOOP
printf("");
printf("",(action_url_target==NULL)?"_blank":action_url_target);
- printf(" ",url_images_path,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
+ printf(" ",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
printf("");
printf(" | \n");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->icon_image!=NULL){
printf("");
@@ -3252,22 +3264,26 @@
printf("");
if(temp_host->notes_url!=NULL){
- printf("",(notes_url_target==NULL)?"_blank":notes_url_target);
- printf(" ",url_images_path,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
+ printf(" ",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
printf("");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->action_url!=NULL){
- printf("",(action_url_target==NULL)?"blank":action_url_target);
- printf(" ",url_images_path,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
+ printf(" ",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
printf("");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
printf(" \n",STATUS_CGI,url_encode(temp_host->name),url_images_path,STATUS_DETAIL_ICON);
@@ -3556,22 +3572,26 @@
printf(" | ",status_bg_class);
printf(" \n",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(hststatus->host_name),url_images_path,DETAIL_ICON);
if(temp_host->notes_url!=NULL){
- printf("",(notes_url_target==NULL)?"_blank":notes_url_target);
- printf(" ",url_images_path,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
+ printf(" ",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
printf("");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->action_url!=NULL){
- printf("",(action_url_target==NULL)?"_blank":action_url_target);
- printf(" ",url_images_path,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
+ printf(" ",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
printf("");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
printf(" \n",STATUS_CGI,url_encode(hststatus->host_name),url_images_path,STATUS_DETAIL_ICON);
#ifdef USE_STATUSMAP
@@ -4481,22 +4501,26 @@
printf("");
if(temp_host->notes_url!=NULL){
- printf("",(notes_url_target==NULL)?"_blank":notes_url_target);
- printf(" ",url_images_path,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
+ printf(" ",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Host Notes","View Extra Host Notes");
printf("");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
if(temp_host->action_url!=NULL){
- printf("",(action_url_target==NULL)?"_blank":action_url_target);
- printf(" ",url_images_path,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
+ printf(" ",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Host Actions","Perform Extra Host Actions");
printf("");
+ END_MULTIURL_LOOP
+ free(processed_string);
}
printf(" \n",STATUS_CGI,url_encode(temp_host->name),url_images_path,STATUS_DETAIL_ICON);
diff -Naur nagios-3.2.3+SmallPatches/include/cgiutils.h nagios-3.2.3+SP+MU/include/cgiutils.h
--- nagios-3.2.3+SmallPatches/include/cgiutils.h 2010-10-28 14:31:40.000000000 +0200
+++ nagios-3.2.3+SP+MU/include/cgiutils.h 2010-11-10 16:13:42.000000000 +0100
@@ -480,6 +480,48 @@
int push_lifo(char *);
char *pop_lifo(void);
+/******************************** MULTIURL PATCH *******************************/
+
+/* Note that, unlike the version of this patch for 3.2.1, this one can be
+ enabled and disabled by a cgi.cfg statement, rather than being a compile-
+ time decision. However, I still left it as code inside #defines within a
+ *.h (yuck!) so as to keep providing a "tear line" for easier removal. */
+
+#ifndef SKIP_MULTIURL_DEFS
+extern int use_multiurls;
+int MU_lasturl, MU_thisurl;
+char MU_iconstr[16], *MU_origstr, *MU_ptr;
+
+/* Have process_macros() generate processed_string *BEFORE* starting the loop */
+
+#define BEGIN_MULTIURL_LOOP \
+ /* Init counters */ MU_lasturl=0; MU_iconstr[0]='\0'; \
+ /* MAIN LOOP */ for (MU_origstr=MU_ptr=processed_string; (*MU_ptr)!='\0'; ) { \
+ /* Internal init */ MU_thisurl=MU_lasturl; \
+ /* If enabled: */ if (use_multiurls) { \
+ /* Skip whitespace */ for (;isspace(*MU_ptr);MU_ptr++) ; \
+ /* Detect+skip ap. */ for (;(*MU_ptr)=='\'';MU_ptr++)MU_thisurl=MU_lasturl+1;}\
+ /* Enabled&&found? */ if (MU_thisurl>MU_lasturl) { \
+ /* yes->split str */ sprintf(MU_iconstr,"%u-",MU_thisurl); \
+ processed_string=MU_ptr; \
+ for (;((*MU_ptr)!='\0')&&((*MU_ptr)!='\'');MU_ptr++) ; \
+ if ((*MU_ptr)=='\'') { (*MU_ptr)='\0'; MU_ptr++; \
+ for (;isspace(*MU_ptr);MU_ptr++) ; } \
+ } else { \
+ /* no->end loop */ MU_iconstr[0]='\0'; MU_ptr=""; \
+ }
+
+/* Do the original printf()s, additionally inserting MU_iconstr between icon path and icon (file)name */
+
+#define END_MULTIURL_LOOP \
+ /* Int -> ext ctr */ MU_lasturl=MU_thisurl; processed_string=MU_ptr; \
+ /* MAIN LOOP */ } \
+ /* Hide evidence */ processed_string=MU_origstr;
+
+/* Do the free(processed_string) *AFTER* ending the loop */
+
+#endif /* ndef SKIP_MULTIURL_DEFS */
+
#ifdef __cplusplus
}
#endif
diff -Naur nagios-3.2.3+SmallPatches/sample-config/cgi.cfg.in nagios-3.2.3+SP+MU/sample-config/cgi.cfg.in
--- nagios-3.2.3+SmallPatches/sample-config/cgi.cfg.in 2010-11-05 21:52:15.000000000 +0100
+++ nagios-3.2.3+SP+MU/sample-config/cgi.cfg.in 2010-11-10 15:01:41.000000000 +0100
@@ -398,3 +398,30 @@
#add_notif_num_soft=0
+
+
+# MULTIURL PATCH
+# Activating the patch changes the parsing of notes_url and
+# action_url for hosts and services. (Changing it for
+# hostgroups and servicegroups as well would require a far
+# more aggressive rewrite of the CGIs, I'm afraid.) Example:
+# notes_url 'foo' 'bar' baz' class='tips' rel='org
+# will result in the following three (!) hyperlinks being
+# displayed (edited for brevity):
+#
+#
+#
+# Note the use of the escape character "'" *within* the *last*
+# URL (which has been inspired by PNP4Nagios' preview popups),
+# and how the icon filename gets varied. If the config were:
+# notes_url 'foo' 'bar' 'baz'
+# instead, then the third URL would change to:
+#
+# Also note that it's up to you to provide the *-notes.gif
+# and/or *-action.gif files.
+
+#use_multiurls=1
+
+
+
|