====== WML Patch ======
^ Author | [[Jemimah.Ruhala@pmsionline.com|Jemimah Ruhala]] |
^ Compatibility | Xymon 4.2 |
^ Requirements | Gnu Patch, GCC |
^ Download | {{addons:wmlgen.patch|wmlgen.patch}} |
^ Last Update | 2007-12-07 |
===== Description =====
This is a patch to wmlgen.c to create simplified html output suitable for smartphones such as Blackberry instead of WML, which is too basic to be useful on these phones. It allows access to hobbit webpages and graphs sized for small screens.
===== Installation =====
Copy wmlgen.patch into the hobbit-4.2.0/bbdisplay directory.
\n");
! fprintf(fd, " \n");
fprintf(fd, "%s.%s \n", host->hostname, entry->column->name);
/*
* We need to parse the logfile a bit to get a decent WML
* card that contains the logfile. bbd does this for
--- 114,132 ----
wml_header(fd, "name", 1);
fprintf(fd, " \n");
! fprintf(fd, "%s\n", timestamp);
! fprintf(fd, " \n");
fprintf(fd, "%s.%s \n", host->hostname, entry->column->name);
+ fprintf(fd,"
patch -p1 < wmlgen.patch
Recompile Xymon.
Reinstall, or just copy the new **//bbgen//** executable into hobbit’s server/bin directory.
Enable wml in the hobbitserver.cfg file
Update bb-hosts with WML:test1, test2,etc to include all the tests you want to see on your phone.
Create a directory called gif under your wml output directory, and copy the gif files from the main www/gifs directory to wml/gif...you may just want to try a symlink.
If everything worked, you should see html files appear in your wml directory.
===== Source =====
==== wmlgen.patch ====
*** wmlgen.c Tue Dec 18 10:53:15 2007
--- wmlgen.c.htmlversion Tue Dec 18 10:53:07 2007
***************
*** 59,70 ****
static char *wml_colorname(int color)
{
switch (color) {
! case COL_GREEN: return "GR"; break;
! case COL_RED: return "RE"; break;
! case COL_YELLOW: return "YE"; break;
! case COL_PURPLE: return "PU"; break;
! case COL_CLEAR: return "CL"; break;
! case COL_BLUE: return "BL"; break;
}
return "";
--- 59,70 ----
static char *wml_colorname(int color)
{
switch (color) {
! case COL_GREEN: return ""; break;
! case COL_RED: return ""; break;
! case COL_YELLOW: return ""; break;
! case COL_PURPLE: return ""; break;
! case COL_CLEAR: return ""; break;
! case COL_BLUE: return ""; break;
}
return "";
***************
*** 72,84 ****
static void wml_header(FILE *output, char *cardid, int idpart)
{
! fprintf(output, "\n");
! fprintf(output, "\n");
! fprintf(output, "
\n", host->hostname);
! fprintf(fd, "%s
Host
\n", host->hostname);
! fprintf(fd, "Hourly Graph
\n", host->hostname,entry->column->name);
! fprintf(fd, "Daily Graph
\n", host->hostname,entry->column->name);
! fprintf(fd, "Weekly Graph
\n", host->hostname,entry->column->name);
! fprintf(fd, "Monthly Graph
\n", host->hostname,entry->column->name);
! fprintf(fd, "
", entry->column->name,host->hostname );
+
+
/*
* We need to parse the logfile a bit to get a decent WML
* card that contains the logfile. bbd does this for
***************
*** 184,217 ****
p = endtag+1;
}
}
else if (*p == '>') {
strcpy(outp, ">");
outp += 4; p++;
}
else if (strncmp(p, "&red", 4) == 0) {
! strcpy(outp, "red");
! outp += 10; p += 4;
}
else if (strncmp(p, "&green", 6) == 0) {
! strcpy(outp, "green");
! outp += 12; p += 6;
}
else if (strncmp(p, "&purple", 7) == 0) {
! strcpy(outp, "purple");
! outp += 13; p += 7;
}
else if (strncmp(p, "&yellow", 7) == 0) {
! strcpy(outp, "yellow");
! outp += 13; p += 7;
}
else if (strncmp(p, "&clear", 6) == 0) {
! strcpy(outp, "clear");
! outp += 12; p += 6;
}
else if (strncmp(p, "&blue", 5) == 0) {
! strcpy(outp, "blue");
! outp += 11; p += 5;
}
else if (*p == '&') {
strcpy(outp, "&");
outp += 5; p++;
--- 186,241 ----
p = endtag+1;
}
}
+
else if (*p == '>') {
strcpy(outp, ">");
outp += 4; p++;
}
else if (strncmp(p, "&red", 4) == 0) {
! strcpy(outp, "");
! outp += 23; p += 4;
}
else if (strncmp(p, "&green", 6) == 0) {
! strcpy(outp, "");
! outp += 25; p += 6;
}
else if (strncmp(p, "&purple", 7) == 0) {
! strcpy(outp, "");
! outp += 26; p += 7;
}
else if (strncmp(p, "&yellow", 7) == 0) {
! strcpy(outp, "");
! outp += 26; p += 7;
}
else if (strncmp(p, "&clear", 6) == 0) {
! strcpy(outp, "");
! outp += 25; p += 6;
}
else if (strncmp(p, "&blue", 5) == 0) {
! strcpy(outp, "");
! outp += 24; p += 5;
}
+
+ else if (strncmp(p, "red", 3) == 0) {
+ strcpy(outp, "");
+ outp += 18; p += 3;
+ }
+ else if (strncmp(p, "yellow", 6) == 0) {
+ strcpy(outp, "");
+ outp += 21; p += 6;
+ }
+ else if (strncmp(p, "purple", 6) == 0) {
+ strcpy(outp, "");
+ outp += 21; p += 6;
+ }
+ else if (strncmp(p, "blue", 4) == 0) {
+ strcpy(outp, "");
+ outp += 19; p += 4;
+ }
+ else if (strncmp(p, "green", 6) == 0) {
+ strcpy(outp, "");
+ outp += 21; p += 6;
+ }
else if (*p == '&') {
strcpy(outp, "&");
outp += 5; p++;
***************
*** 233,239 ****
*outp = '\0';
if (strlen(lineout)) fprintf(fd, "%s\n
\n", lineout);
}
! fprintf(fd, "
\n"); ! fprintf(bb2fd, "%s
\n", timestamp); ! fprintf(bb2fd, "\n");
! fprintf(bb2fd, "Summary Status
%s
\n", colorname(bb2wapcolor));
- /* All green ? Just say so */
- if (bb2wapcolor == COL_GREEN) {
- fprintf(bb2fd, "All is OK
\n");
- }
/* Now loop through the hostlist again, and generate the bb2wap links and host pages */
for (h = hostlistBegin(); (h); h = hostlistNext()) {
--- 331,338 ----
/* Standard BB2 wap header */
wml_header(bb2fd, "card", bb2part);
fprintf(bb2fd, "
\n");
! fprintf(bb2fd, "Summary Status
%s
" , colorname(bb2wapcolor), colorname(bb2wapcolor));
/* Now loop through the hostlist again, and generate the bb2wap links and host pages */
for (h = hostlistBegin(); (h); h = hostlistNext()) {
***************
*** 328,334 ****
if (h->hostentry->anywaps) {
/* Create the host WAP card, with links to individual test results */
! sprintf(hostfn, "%s/%s.wml", wmldir, h->hostentry->hostname);
hostfd = fopen(hostfn, "w");
if (hostfd == NULL) {
errprintf("Cannot create file %s\n", hostfn);
--- 339,345 ----
if (h->hostentry->anywaps) {
/* Create the host WAP card, with links to individual test results */
! sprintf(hostfn, "%s/%s.html", wmldir, h->hostentry->hostname);
hostfd = fopen(hostfn, "w");
if (hostfd == NULL) {
errprintf("Cannot create file %s\n", hostfn);
***************
*** 337,408 ****
wml_header(hostfd, "name", 1);
fprintf(hostfd, "
\n");
- fprintf(hostfd, "
\n");
fprintf(hostfd, "%s
\n");
fprintf(hostfd, "%s
\n", h->hostentry->hostname);
for (t = h->hostentry->entries; (t); t = t->next) {
if (t->onwap) {
! fprintf(hostfd, "
\n",
t->column->name,
wml_colorname(t->color),
! (t->acked ? "x" : ""),
! h->hostentry->hostname, t->column->name,
t->column->name);
}
}
! fprintf(hostfd, "\n
\n");
- fprintf(bb2fd, "
\n", oldbb2fn);
- fprintf(bb2fd, "%s
\n");
- fprintf(bb2fd, "Summary Status
%s
\n", colorname(bb2wapcolor));
- }
}
}
! fprintf(bb2fd, "
\n"); fprintf(hostfd, "%s
\n", timestamp); + fprintf(hostfd, " Overall\n");
fprintf(hostfd, "%s
\n", h->hostentry->hostname);
+ fprintf(hostfd,"