PATCH: Proper labeling of multi-target graphs

Norman Elton <[email protected]> Fri, 5 Jun 2009 10:25:53 -0400
Newsgroups gmane.network.cricket.user
Message-ID <[email protected]>
Multitarget graphs normally label each line using the datasource name,
ignoring any display_name. This meant that individual graphs used the
"friendly" name, while multitarget graphs were somewhat cryptic. We
assigned this to one of our ace undergraduate programming students,
who whipped up a patch to fix the problem. I'll attach below. Once
applied, multitarget graphs will use the display_name.

Enjoy!

Norman Elton
College of William & Mary

========

diff -Naur ./cricket-1.0.5/grapher.cgi ./cricket-1.0.5.work/grapher.cgi
--- cricket-1.0.5/grapher.cgi	2004-02-06 11:27:34.000000000 -0500
+++ cricket-1.0.5.work/grapher.cgi	2009-06-05 09:42:36.000000000 -0400
@@ -941,7 +941,11 @@

         if ($rrd && $rrd->loadHeader()) {
             if (($isMTargets) && (!$isMTargetsOps))  {
-                print "Values at last update for $tname:<br>";
+                if(exists($targRef->{'display-name'})) {
+                    print "Values at last update for
$targRef->{'display-name'}:<br>";
+                } else {
+                    print "Values at last update for $tname:<br>";
+                }
             }  elsif (!$printOnce)  {
                 print "Values at last update:<br>";
                 $printOnce = 1;
@@ -1509,7 +1513,11 @@
             $legend = graphParam($gRef, 'legend', $ds);

             if (($isMTarget) && (!$isMTargetsOps)) {
-                $legend .= " ($thisTname)";
+                if(exists($targRef->{'display-name'})) {
+                    $legend .= " ($targRef->{'display-name'})";
+		} else {
+                    $legend .= " ($thisTname)";
+		}
             }

             $color = graphParam($gRef, 'color', nextColor($colorRef));
[

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get