It always bugged me that you couldn't customize the nagios
host/service summary screens, so I hacked cgi/status.c as attached
(.20080401.133208.status.c is the original, status.c is my change).

You put host-specific annotations in
/usr/local/etc/nagios/annotate/$host/hostinfo.txt, and
service-specific annotations in
/usr/local/etc/nagios/annotate/$host/$service

This is EXTREMELY rudimentary and bad for many reasons (the
information is hardcoded, the path is not tied to where you install
nagios, etc), and my main goal is to convince someone to improve it.

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
--- status.c    2008-11-14 10:55:13.000000000 -0700
+++ .20080401.133208.status.c   2008-04-01 13:32:08.000000000 -0600
@@ -1365,8 +1365,6 @@
 
        printf("<TH CLASS='status'>Attempt&nbsp;<A 
HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by 
current attempt (ascending)' TITLE='Sort by current attempt (ascending)'></A><A 
HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by 
current attempt (descending)' TITLE='Sort by current attempt 
(descending)'></A></TH>",temp_url,SORT_ASCENDING,SORT_CURRENTATTEMPT,url_images_path,UP_ARROW_ICON,temp_url,SORT_DESCENDING,SORT_CURRENTATTEMPT,url_images_path,DOWN_ARROW_ICON);
 
-       printf("<TH CLASS='status'>Annotations</TH>\n");
-
        printf("<TH CLASS='status'>Status Information</TH>\n");
        printf("</TR>\n");
 
@@ -1759,29 +1757,6 @@
                        printf("<TD CLASS='status%s' 
nowrap>%s</TD>\n",status_bg_class,date_time);
                        printf("<TD CLASS='status%s' 
nowrap>%s</TD>\n",status_bg_class,state_duration);
                        printf("<TD 
CLASS='status%s'>%d/%d</TD>\n",status_bg_class,temp_status->current_attempt,temp_status->max_attempts);
-
-                       /* changes (excluding table header hack) start here */
-                       
-                       // name of annotation file
-                       char *ann_file;
-                       char ann[255];
-                       asprintf(&ann_file, 
"/usr/local/etc/nagios/annotate/%s/%s",temp_status->host_name,temp_status->description);
-                       // read data in annotation file
-                       FILE *res = fopen(ann_file,"r");
-
-                       if (!res) {
-                         sprintf(ann, "NOFILE: %s", ann_file);
-                       } else {
-                         int i = fread(ann, 1, 254, res);
-                         ann[i] = '\0';
-                         fclose(res);
-                       }
-
-                       printf("<TD 
CLASS='status%s'>%s</TD>\n",status_bg_class,ann);
-
-                       /* changes end here */
-
-
                        printf("<TD CLASS='status%s' 
valign='center'>",status_bg_class);
                        
printf("%s&nbsp;",(temp_status->plugin_output==NULL)?"":html_encode(temp_status->plugin_output,TRUE));
                        /*
@@ -1957,8 +1932,6 @@
 
        printf("<TH CLASS='status'>Duration&nbsp;<A 
HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by state 
duration (ascending)' TITLE='Sort by state duration (ascending)'></A><A 
HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by state 
duration time (descending)' TITLE='Sort by state duration time 
(descending)'></A></TH>",temp_url,SORT_ASCENDING,SORT_STATEDURATION,url_images_path,UP_ARROW_ICON,temp_url,SORT_DESCENDING,SORT_STATEDURATION,url_images_path,DOWN_ARROW_ICON);
 
-       printf("<TH CLASS='status'>Annotations</TH>\n");
-
        printf("<TH CLASS='status'>Status Information</TH>\n");
        printf("</TR>\n");
 
@@ -2185,28 +2158,6 @@
                        printf("<TD 
CLASS='status%s'>%s</TD>\n",status_class,status);
                        printf("<TD CLASS='status%s' 
nowrap>%s</TD>\n",status_bg_class,date_time);
                        printf("<TD CLASS='status%s' 
nowrap>%s</TD>\n",status_bg_class,state_duration);
-
-                       /* changes start (excluding trivial other changes) */
-
-                       // name of annotation file
-                       char *ann_file;
-                       char ann[255];
-                       asprintf(&ann_file, 
"/usr/local/etc/nagios/annotate/%s/hostinfo.txt",temp_status->host_name);
-
-                       // read data in annotation file
-                       FILE *res = fopen(ann_file,"r");
-
-                       if (!res) {
-                         sprintf(ann, "NOFILE: %s", ann_file);
-                       } else {
-                         int i = fread(ann, 1, 254, res);
-                         ann[i] = '\0';
-                         fclose(res);
-                       }
-
-                       printf("<TD CLASS='status%s' 
nowrap>%s</TD>\n",status_bg_class,ann);
-                       /* changes end */
-
                        printf("<TD CLASS='status%s' 
valign='center'>",status_bg_class);
                        
printf("%s&nbsp;",(temp_status->plugin_output==NULL)?"":html_encode(temp_status->plugin_output,TRUE));
                        /*
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to