On Tuesday 19 April 2011, Alex Dean wrote:
> On Apr 19, 2011, at 8:34 AM, Markus Köberl wrote:
> > { "metric": "cpu_num", "color": "00FF00", "label": "Nodes", "line_width":
> > "2", "type": "line", "DS": "num", "context": { "cluster": true, "meta":
> > true } }
>
> This seems like a good idea to me.
>
> What about formatting like this:
> { "metric": "cpu_num", "color": "00FF00", "label": "Nodes", "line_width":
> "2", "type": "line", "DS": "num", "contexts": ["cluster", "meta"] }
>
> You could implement with:
> if ( isSet($item[ 'contexts' ]) && array_key_exists($context,
> $item['contexts']) ) { continue;
> }
>
> The context names seem like data here, not keys, so I just thought an array
> might be more appropriate.

Yes, it is much simpler now.

Markus
-- 
Markus Köberl
Graz University of Technology
Signal Processing and Speech Communication Laboratory
E-mail: markus.koeb...@tugraz.at
Index: graph.d/load_report.json
===================================================================
--- graph.d/load_report.json	(revision 2574)
+++ graph.d/load_report.json	(working copy)
@@ -5,6 +5,8 @@
    "vertical_label" : "Loads/Procs",
    "series" : [
       { "metric": "load_one", "color": "BBBBBB", "label": "1-min", "type": "stack" },
+      { "metric": "cpu_num", "color": "00FF00", "label": "Nodes", "line_width": "2", "type": "line", "DS": "num", "contexts": [ "cluster", "meta" ] },
+      { "metric": "cpu_num", "color": "FF0000", "label": "CPUs", "line_width": "2", "type": "line" },
       { "metric": "proc_run", "color": "2030F4", "label": "Procs", "line_width": "2", "type": "line" }
    ]
 }
Index: functions.php
===================================================================
--- functions.php	(revision 2574)
+++ functions.php	(working copy)
@@ -870,7 +870,10 @@

   // Loop through all the graph items
   foreach( $graph_config[ 'series' ] as $index => $item ) {
-
+     // ignore item if context is not defined in json template
+     if ( isSet($item[ 'contexts' ]) and in_array($context, $item['contexts'])==false )
+         continue;
+
      $rrd_dir = $conf['rrds'] . "/" . $item['clustername'] . "/" . $item['hostname'];

      $metric = sanitize( $item[ 'metric' ] );
@@ -884,8 +887,14 @@
       $unique_id = "a" . $index;

        $label = str_pad( sanitize( $item[ 'label' ] ), $max_label_length );
-       $series .= " DEF:'$unique_id'='$metric_file':'sum':AVERAGE ";
-
+
+       // use custom DS defined in json template (default = 'sum')
+       $DS = sanitize( $item[ 'DS' ] );
+       if($DS!='')
+           $series .= " DEF:'$unique_id'='$metric_file':'$DS':AVERAGE ";
+       else
+           $series .= " DEF:'$unique_id'='$metric_file':'sum':AVERAGE ";
+
        // By default graph is a line graph
        isset( $item['type']) ? $item_type = $item['type'] : $item_type = "line";
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to