[PATCH] hobbitgraph.cgi: adding support for stack (Was: [hobbit] ganglia-style graph aggregation with hobbit)

Gildas Le Nadan gn1 at sanger.ac.uk
Thu Oct 12 11:33:14 CEST 2006


Hi,

BEWARE: this patch has been tested on a machine with rrdtool 1.0.x. The 
values/behavior for rrdtool 1.2.x were taken from the online rrd documentation 
so they are hopefully correct. If someone was able to test it for me on a server 
with rrdtool 1.2, I would be very grateful!

Cheers,
Gildas

-- 

The following patch add support for a @STACKIT@ keyword in the graph definitions 
in hobbitgraph.cfg, allowing data to be stacked.

The STACK behavior changed between rrdtool 1.0.x and 1.2.x, hence the ifdef:
- in 1.0.x, you replace the graph type (AREA|LINE) for the graph you want to 
stack with the  STACK keyword
- in 1.2.x, you add the STACK keyword at the end of the definition

Please note that in both cases the first entry mustn't contain the keyword STACK 
at all, so  we need a different treatment for the first rrdidx

examples of valid hobbitgraph.cfg entries:

rrdtool 1.0.x
[la-multi]
         TITLE Multi-host CPU Load
         YAXIS Load
         FNPATTERN la.rrd
         DEF:avg at RRDIDX@=@RRDFN@:la:AVERAGE
         CDEF:la at RRDIDX@=avg at RRDIDX@,100,/
         @STACKIT@:la at RRDIDX@#@COLOR@:@RRDPARAM@
         -u 1.0
         GPRINT:la at RRDIDX@:LAST: \: %5.1lf (cur)
         GPRINT:la at RRDIDX@:MAX: \: %5.1lf (max)
         GPRINT:la at RRDIDX@:MIN: \: %5.1lf (min)
         GPRINT:la at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n

rrdtool 1.2.x
[la-multi]
         TITLE Multi-host CPU Load
         YAXIS Load
         FNPATTERN la.rrd
         DEF:avg at RRDIDX@=@RRDFN@:la:AVERAGE
         CDEF:la at RRDIDX@=avg at RRDIDX@,100,/
         AREA:la at RRDIDX@#@COLOR@:@RRDPARAM@:@STACKIT@
         -u 1.0
         GPRINT:la at RRDIDX@:LAST: \: %5.1lf (cur)
         GPRINT:la at RRDIDX@:MAX: \: %5.1lf (max)
         GPRINT:la at RRDIDX@:MIN: \: %5.1lf (min)
         GPRINT:la at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n


--- hobbit-4.2.0/web/hobbitgraph.c      2006-08-09 21:10:13.000000000 +0100
+++ hobbit-4.2.0.ganglia/web/hobbitgraph.c      2006-10-12 10:24:09.788773551 +0100
@@ -392,6 +392,42 @@
                         }
                         inp += 10;
                 }
+               else if (strncmp(inp, "@STACKIT@", 9) == 0) {
+                       /* the STACK behavior changed between rrdtool 1.0.x
+                        * and 1.2.x, hence the ifdef:
+                        * - in 1.0.x, you replace the graph type (AREA|LINE)
+                        *  for the graph you want to stack with the  STACK
+                        *  keyword
+                        * - in 1.2.x, you add the STACK keyword at the end
+                        *  of the definition
+                        *
+                        * Please note that in both cases the first entry
+                        * mustn't contain the keyword STACK at all, so
+                        * we need a different treatment for the first rrdidx
+                        *
+                        * examples of hobbitgraph.cfg entries:
+                        *
+                        * - rrdtool 1.0.x
+                        * @STACKIT@:la at RRDIDX@#@COLOR@:@RRDPARAM@
+                        *
+                        * - rrdtool 1.2.x
+                        * AREA::la at RRDIDX@#@COLOR@:@RRDPARAM@:@STACKIT@
+                        */
+                       char numstr[10];
+                       if (rrdidx == 0) {
+#ifdef RRDTOOL12
+                               sprintf(numstr, "");
+#else
+                               sprintf(numstr, "AREA");
+#endif
+                       }
+                       else {
+                               sprintf(numstr, "STACK");
+                       }
+                       strcpy(outp, numstr);
+                       outp += strlen(outp);
+                       inp += 9;
+               }
                 else if (strncmp(inp, "@RRDIDX@", 8) == 0) {
                         char numstr[10];



More information about the Xymon mailing list