From: Matthias Eble
When extinfo.cgi displays a host's status, parent and/or child hosts
get displayed also. New cgi.cfg variables have been added to prevent
flooding in case of too many parents/children:
child_host_display_len
parent_host_display_len
---
Hi all,
so after some tinkering I thought that it'd be a good idea to display
parent/child hosts on extinfo.cgi rather linking to config.cgi.
So here's the patch including doc updates.
Matthias
cgi/cgiutils.c | 8 ++++
cgi/extinfo.c | 59 +++++++++++++++++++++++++++++
html/docs/configcgi.html | 93 ++++++++++++++++++++++++++++++++++++++++++++++
sample-config/cgi.cfg.in | 9 ++++
4 files changed, 169 insertions(+), 0 deletions(-)
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index a373ec3..1f3b985 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -109,6 +109,8 @@ int refresh_rate=DEFAULT_REFRESH_RATE;
int escape_html_tags=FALSE;
int use_ssl_authentication=FALSE;
+int child_host_display_len=200;
+int parent_host_display_len=200;
int default_statusmap_layout_method=0;
int default_statuswrl_layout_method=0;
@@ -410,6 +412,12 @@ int read_cgi_config_file(char *filename){
else if(!strcmp(var,"use_ssl_authentication"))
use_ssl_authentication=(atoi(val)>0)?TRUE:FALSE;
+
+ else if(!strcmp(var,"child_host_display_len"))
+ child_host_display_len=atoi(val);
+
+ else if(!strcmp(var,"parent_host_display_len"))
+ parent_host_display_len=atoi(val);
}
/* free memory and close the file */
diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index c3f2e83..6168399 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -67,6 +67,8 @@ extern char url_logo_images_path[MAX_FILENAME_LENGTH];
extern char log_file[MAX_FILENAME_LENGTH];
extern int enable_splunk_integration;
+extern int child_host_display_len;
+extern int parent_host_display_len;
extern char *notes_url_target;
extern char *action_url_target;
@@ -77,6 +79,7 @@ extern hoststatus *hoststatus_list;
extern servicestatus *servicestatus_list;
extern hostgroup *hostgroup_list;
extern servicegroup *servicegroup_list;
+extern host *host_list;
#define MAX_MESSAGE_BUFFER 4096
@@ -121,6 +124,8 @@ char *servicegroup_name="";
char *service_desc="";
int display_type=DISPLAY_PROCESS_INFO;
+int display_all_parents=FALSE;
+int display_all_children=FALSE;
int sort_type=SORT_ASCENDING;
int sort_option=SORT_NEXTCHECKTIME;
@@ -133,9 +138,13 @@ int display_header=TRUE;
int main(void){
int result=OK;
int found=FALSE;
+ int len=0;
char temp_buffer[MAX_INPUT_BUFFER]="";
char *processed_string=NULL;
+ char *query_string=NULL;
host *temp_host=NULL;
+ host *temp_host2=NULL;
+ hostsmember *temp_parenthost=NULL;
hostgroup *temp_hostgroup=NULL;
service *temp_service=NULL;
servicegroup *temp_servicegroup=NULL;
@@ -143,6 +152,8 @@ int main(void){
/* get the arguments passed in the URL */
process_cgivars();
+ if(!(query_string = getenv("QUERY_STRING")))
+ query_string="";
/* reset internal variables */
reset_cgi_vars();
@@ -325,6 +336,45 @@ int main(void){
printf("Host\n");
printf("%s\n",temp_host->alias);
printf("(%s)\n",temp_host->name);
+
+ if (temp_host->parent_hosts != NULL) {
+ /* display parent hosts */
+ printf("Parent Hosts:\n");
+ printf("\n");
+ for(temp_parenthost=temp_host->parent_hosts;temp_parenthost!=NULL;temp_parenthost=temp_parenthost->next){
+ len += strlen(temp_parenthost->host_name);
+ if(len > parent_host_display_len && !display_all_parents) {
+ printf("...",EXTINFO_CGI,query_string);
+ break;
+ }
+ printf("%s\n",STATUS_CGI, url_encode(temp_parenthost->host_name),temp_parenthost->host_name);
+ }
+ printf("\n");
+ }
+
+ len=0;
+ /* look
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]