From: <st...@us...> - 2011-11-27 21:28:25
|
Revision: 6775 http://xymon.svn.sourceforge.net/xymon/?rev=6775&view=rev Author: storner Date: 2011-11-27 21:28:18 +0000 (Sun, 27 Nov 2011) Log Message: ----------- xymongen: New "vpage", "vsubpage" and "vsubparent" definitions in hosts.cfg for rotating a page 90 degrees, so that the hosts make up the columns across, and the tests are the rows down. Modified Paths: -------------- trunk/common/hosts.cfg.5 trunk/xymongen/loadlayout.c trunk/xymongen/pagegen.c trunk/xymongen/xymongen.h Modified: trunk/common/hosts.cfg.5 =================================================================== --- trunk/common/hosts.cfg.5 2011-11-05 10:55:01 UTC (rev 6774) +++ trunk/common/hosts.cfg.5 2011-11-27 21:28:18 UTC (rev 6775) @@ -176,6 +176,17 @@ the parent page in the "subparent" tag was what made it easy to implement. +.IP "vpage" "vsubpage" "vsubparent" +These are page-definitions similar to the "page", "subpage" and +"subparent" definitions. However, on these pages the rows are +the tests, and the columns are the hosts (normal pages have it +the other way around). This is useful if you have a very large +number of tests for a few hosts, and prefer to have them listed +on a page that can be scrolled vertically. +.br +Note that the "group" directives have no effect on these types +of pages. + .IP "group [group-title]" .IP "group-compress [group-title]" Defines a group of hosts, that appear together on the web page, Modified: trunk/xymongen/loadlayout.c =================================================================== --- trunk/xymongen/loadlayout.c 2011-11-05 10:55:01 UTC (rev 6774) +++ trunk/xymongen/loadlayout.c 2011-11-27 21:28:18 UTC (rev 6775) @@ -112,7 +112,7 @@ return result; /* This may be an empty string */ } -xymongen_page_t *init_page(char *name, char *title) +xymongen_page_t *init_page(char *name, char *title, int vertical) { xymongen_page_t *newpage = (xymongen_page_t *) calloc(1, sizeof(xymongen_page_t)); @@ -131,6 +131,7 @@ newpage->color = -1; newpage->oldage = 1; + newpage->vertical = vertical; newpage->pretitle = NULL; newpage->groups = NULL; newpage->hosts = NULL; @@ -416,6 +417,7 @@ xymongen_page_t *load_layout(char *pgset) { char pagetag[100], subpagetag[100], subparenttag[100], + vpagetag[100], vsubpagetag[100], vsubparenttag[100], grouptag[100], summarytag[100], titletag[100], hosttag[100]; char *name, *link, *onlycols, *exceptcols; char hostname[MAX_LINE_LEN]; @@ -457,12 +459,15 @@ sprintf(pagetag, "%spage", pgset); sprintf(subpagetag, "%ssubpage", pgset); sprintf(subparenttag, "%ssubparent", pgset); + sprintf(vpagetag, "v%spage", pgset); + sprintf(vsubpagetag, "v%ssubpage", pgset); + sprintf(vsubparenttag, "v%ssubparent", pgset); sprintf(grouptag, "%sgroup", pgset); sprintf(summarytag, "%ssummary", pgset); sprintf(titletag, "%stitle", pgset); sprintf(hosttag, "%s:", pgset); for (p=hosttag; (*p); p++) *p = toupper((int)*p); - toppage = init_page("", ""); + toppage = init_page("", "", 0); addtopagelist(toppage); curpage = NULL; cursubpage = NULL; @@ -485,14 +490,14 @@ dbgprintf("load_layout: -- got line '%s'\n", inbol); - if (strncmp(inbol, pagetag, strlen(pagetag)) == 0) { + if ((strncmp(inbol, pagetag, strlen(pagetag)) == 0) || (strncmp(inbol, vpagetag, strlen(vpagetag)) == 0)) { getnamelink(inbol, &name, &link); if (curpage == NULL) { /* First page - hook it on toppage as a subpage from there */ - curpage = toppage->subpages = init_page(name, link); + curpage = toppage->subpages = init_page(name, link, (strncmp(inbol, vpagetag, strlen(vpagetag)) == 0)); } else { - curpage = curpage->next = init_page(name, link); + curpage = curpage->next = init_page(name, link, (strncmp(inbol, vpagetag, strlen(vpagetag)) == 0)); } curpage->parent = toppage; @@ -506,7 +511,7 @@ curhost = NULL; addtopagelist(curpage); } - else if (strncmp(inbol, subpagetag, strlen(subpagetag)) == 0) { + else if ( (strncmp(inbol, subpagetag, strlen(subpagetag)) == 0) || (strncmp(inbol, vsubpagetag, strlen(vsubpagetag)) == 0) ) { if (curpage == NULL) { errprintf("'subpage' ignored, no preceding 'page' tag : %s\n", inbol); goto nextline; @@ -514,10 +519,10 @@ getnamelink(inbol, &name, &link); if (cursubpage == NULL) { - cursubpage = curpage->subpages = init_page(name, link); + cursubpage = curpage->subpages = init_page(name, link, (strncmp(inbol, vsubpagetag, strlen(vsubpagetag)) == 0)); } else { - cursubpage = cursubpage->next = init_page(name, link); + cursubpage = cursubpage->next = init_page(name, link, (strncmp(inbol, vsubpagetag, strlen(vsubpagetag)) == 0)); } cursubpage->parent = curpage; if (curtitle) { @@ -529,7 +534,7 @@ curhost = NULL; addtopagelist(cursubpage); } - else if (strncmp(inbol, subparenttag, strlen(subparenttag)) == 0) { + else if ( (strncmp(inbol, subparenttag, strlen(subparenttag)) == 0) || (strncmp(inbol, vsubparenttag, strlen(vsubparenttag)) == 0) ) { xymongen_page_t *parentpage, *walk; getparentnamelink(inbol, toppage, &parentpage, &name, &link); @@ -538,7 +543,7 @@ goto nextline; } - cursubparent = init_page(name, link); + cursubparent = init_page(name, link, (strncmp(inbol, vsubparenttag, strlen(vsubparenttag)) == 0)); if (parentpage->subpages == NULL) { parentpage->subpages = cursubparent; } Modified: trunk/xymongen/pagegen.c =================================================================== --- trunk/xymongen/pagegen.c 2011-11-05 10:55:01 UTC (rev 6774) +++ trunk/xymongen/pagegen.c 2011-11-27 21:28:18 UTC (rev 6775) @@ -314,6 +314,127 @@ return strcmp((*n1)->hostname, (*n2)->hostname); } +typedef struct vprec_t { + char *testname; + host_t **hosts; + entry_t **entries; +} vprec_t; + +void do_vertical(host_t *head, FILE *output, char *pagepath) +{ + /* + * This routine outputs the host part of a page or a group, + * but with the hosts going across the page, and the test going down. + * I.e. it generates buttons and links to all the hosts for + * a test, and the host docs. + */ + + host_t *h; + entry_t *e; + char *xymonskin; + int rowcount = 0, hostcount = 0; + int usetooltip = 0; + int width; + int hidx; + void *vptree; + xtreePos_t handle; + + if (head == NULL) + return; + + vptree = xtreeNew(strcmp); + + xymonskin = strdup(xgetenv("XYMONSKIN")); + + switch (tooltipuse) { + case TT_STDONLY: case TT_ALWAYS: usetooltip = 1; break; + case TT_NEVER: usetooltip = 0; break; + } + + width = atoi(xgetenv("DOTWIDTH")); + if ((width < 0) || (width > 50)) width = 16; + width += 4; + + /* Start the table ... */ + fprintf(output, "<CENTER><TABLE SUMMARY=\"Group Block\" BORDER=0 CELLPADDING=2>\n"); + + /* output column headings */ + fprintf(output, "<TR><td> </td>"); + for (h = head, hostcount = 0; (h); h = h->next, hostcount++) { + fprintf(output, " <TD>"); + fprintf(output, " <A HREF=\"%s\"><FONT %s><B>%s</B></FONT></A> </TD>\n", + hostsvcurl(h->hostname, xgetenv("INFOCOLUMN"), 1), + xgetenv("XYMONPAGECOLFONT"), h->hostname); + } + fprintf(output, "</TR>\n"); + fprintf(output, "<TR><td> </td><TD COLSPAN=%d><HR WIDTH=\"100%%\"></TD></TR>\n\n", hostcount); + + /* Create a tree indexed by the testname, and holding the show/noshow status of each test */ + for (h = head, hidx = 0; (h); h = h->next, hidx++) { + for (e = h->entries; (e); e = e->next) { + vprec_t *itm; + char *hptr; + + handle = xtreeFind(vptree, e->column->name); + if (handle == xtreeEnd(vptree)) { + itm = (vprec_t *)malloc(sizeof(vprec_t)); + itm->testname = e->column->name; + itm->hosts = (host_t **)calloc(hostcount, sizeof(host_t *)); + itm->entries = (entry_t **)calloc(hostcount, sizeof(entry_t *)); + xtreeAdd(vptree, itm->testname, itm); + } + else { + itm = xtreeData(vptree, handle); + } + + (itm->hosts)[hidx] = h; + (itm->entries)[hidx] = e; + } + } + + for (handle = xtreeFirst(vptree); (handle != xtreeEnd(vptree)); handle = xtreeNext(vptree, handle)) { + vprec_t *itm = xtreeData(vptree, handle); + + fprintf(output, "<tr>"); + fprintf(output, "<td valign=center align=left>%s</td>", itm->testname); + + for (hidx = 0; (hidx < hostcount); hidx++) { + char *skin, *htmlalttag; + host_t *h = (itm->hosts)[hidx]; + entry_t *e = (itm->entries)[hidx]; + + fprintf(output, "<td align=center>"); + if (e == NULL) { + fprintf(output, "-"); + } + else { + + if (strcmp(e->column->name, xgetenv("INFOCOLUMN")) == 0) { + /* show the host ip on the hint display of the "info" column */ + htmlalttag = alttag(e->column->name, COL_GREEN, 0, 1, h->ip); + } + else { + htmlalttag = alttag(e->column->name, e->color, e->acked, e->propagate, e->age); + } + + skin = (e->skin ? e->skin : xymonskin); + + fprintf(output, "<A HREF=\"%s\">", hostsvcurl(h->hostname, e->column->name, 1)); + fprintf(output, "<IMG SRC=\"%s/%s\" ALT=\"%s\" TITLE=\"%s\" HEIGHT=\"%s\" WIDTH=\"%s\" BORDER=0></A>", + skin, dotgiffilename(e->color, e->acked, e->oldage), + htmlalttag, htmlalttag, + xgetenv("DOTHEIGHT"), xgetenv("DOTWIDTH")); + } + fprintf(output, "</td>"); + } + + fprintf(output, "</tr>\n"); + } + + fprintf(output, "</TABLE></CENTER><BR>\n"); + xfree(xymonskin); +} + void do_hosts(host_t *head, int sorthosts, char *onlycols, char *exceptcols, FILE *output, FILE *rssoutput, char *grouptitle, int pagetype, char *pagepath) { /* @@ -883,8 +1004,13 @@ } if (!embedded && !hostsbeforepages && page->subpages) do_page_subpages(output, page->subpages, pagepath); - do_hosts(page->hosts, 0, NULL, NULL, output, rssoutput, "", PAGE_NORMAL, pagepath); - do_groups(page->groups, output, rssoutput, pagepath); + if (page->vertical) { + do_vertical(page->hosts, output, pagepath); + } + else { + do_hosts(page->hosts, 0, NULL, NULL, output, rssoutput, "", PAGE_NORMAL, pagepath); + do_groups(page->groups, output, rssoutput, pagepath); + } if (!embedded && hostsbeforepages && page->subpages) do_page_subpages(output, page->subpages, pagepath); /* Summaries on main page only */ Modified: trunk/xymongen/xymongen.h =================================================================== --- trunk/xymongen/xymongen.h 2011-11-05 10:55:01 UTC (rev 6774) +++ trunk/xymongen/xymongen.h 2011-11-27 21:28:18 UTC (rev 6775) @@ -198,6 +198,7 @@ int color; /* Calculated */ int oldage; char *pretitle; + int vertical; struct xymongen_page_t *next; struct xymongen_page_t *subpages; struct xymongen_page_t *parent; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |