On Tue, Jun 24, 2008 at 02:44:01PM -0400, Jesse Becker wrote:
> I just committed r1460 to trunk.  This adds the $use_fqdn_hostname
> setting to conf.php.  The default behavior is to *not* show the FQDN.

for backward compatibility reasons we should keep the default as it was before
(which is to show the FQDN) or more specifically to use the exact hostname
that was being reported by gmetad without any post processing or formatting.

> The patch adds a small utility function to remove everything after the
> first "." character in a hostname, and then adds checks for
> $use_fqdn_hostname in the various graphing functions.

a better name might be $strip_domainname as it will reflect better what
it is doing.

> It is possible to turn this option on, so that the FQDN is shown, but
> hosts that report themselves using only a short hostname will still be
> displayed as such, since we can't magically conjure an arbitrary
> domain for hosts that lack them.

making up a domain name isn't needed or desirable, but as I explained before
this functionality should be instead seen as some means to reformat the name
of the nodes so that they can be better represented in the graphs/reports.

attached backported version of your patch to 3.1 that includes the changes
explained above and some small formatting fixes.

Carlo

---
Index: web/graph.d/mem_report.php
===================================================================
--- web/graph.d/mem_report.php  (revision 1464)
+++ web/graph.d/mem_report.php  (working copy)
@@ -14,13 +14,18 @@
            $cpu_num_color,
            $range,
            $rrd_dir,
-           $size;
+           $size,
+           $strip_domainname;
 
+    if ($strip_domainname) {
+       $hostname = strip_domainname($hostname);
+    }
+
     $title = 'Memory'; 
     if ($context = 'host') {
        $rrdtool_graph['title'] = $title;
     } else {
-       $rrdtool_graph['title'] = "$hostname $title last $range";
+       $rrdtool_graph['title'] = "$title last $range";
     }
     $rrdtool_graph['lower-limit']    = '0';
     $rrdtool_graph['vertical-label'] = 'Bytes';
Index: web/graph.d/load_report.php
===================================================================
--- web/graph.d/load_report.php (revision 1464)
+++ web/graph.d/load_report.php (working copy)
@@ -13,14 +13,19 @@
            $proc_run_color,
            $range, 
            $rrd_dir,
-           $size;
+           $size,
+           $strip_domainname;
     
+    if ($strip_domainname) {
+       $hostname = strip_domainname($hostname);
+    }
+
     $rrdtool_graph['height']        += $size == 'medium' ? 28 : 0 ;
     $title = 'Load';
     if ($context = 'host') {
        $rrdtool_graph['title'] = $title;
     } else {
-       $rrdtool_graph['title'] = "$hostname $title last $range";
+       $rrdtool_graph['title'] = "$title last $range";
     }
     $rrdtool_graph['lower-limit']    = '0';
     $rrdtool_graph['vertical-label'] = 'Load/Procs';
Index: web/graph.d/sample_report.php
===================================================================
--- web/graph.d/sample_report.php       (revision 1464)
+++ web/graph.d/sample_report.php       (working copy)
@@ -71,7 +71,13 @@
            $hostname,
            $range,
            $rrd_dir,
-           $size;
+           $size,
+           $strip_domainname;
+
+    if ($strip_domainname) {
+       $hostname = strip_domainname($hostname);
+    }
+
     //
     // You *MUST* set at least the 'title', 'vertical-label', and 'series' 
variables.
     // Otherwise, the graph *will not work*.  
@@ -82,7 +88,7 @@
                              //  This will be turned into:   
                              //  "Clustername $TITLE last $timerange", so keep 
it short
     } else {
-       $rrdtool_graph['title']  = "$hostname $title last $range";
+       $rrdtool_graph['title']  = "$title last $range";
     }
     $rrdtool_graph['vertical-label'] = 'Sample Percent';
     $rrdtool_graph['height']        += $size == 'medium' ? 28 : 0 ;   // Fudge 
to account for number of lines in the chart legend
Index: web/graph.d/cpu_report.php
===================================================================
--- web/graph.d/cpu_report.php  (revision 1464)
+++ web/graph.d/cpu_report.php  (working copy)
@@ -13,14 +13,19 @@
            $hostname,
            $range,
            $rrd_dir,
-           $size;
+           $size,
+           $strip_domainname;
     
+    if ($strip_domainname) {
+       $hostname = strip_domainname($hostname);
+    }
+
     $rrdtool_graph['height']        += $size == 'medium' ? 14 : 0 ;
     $title = 'CPU';
     if ($context = 'host') {
        $rrdtool_graph['title'] = $title;
     } else {
-       $rrdtool_graph['title'] = "$hostname $title last $range";
+       $rrdtool_graph['title'] = "$title last $range";
 
     }
     $rrdtool_graph['upper-limit']    = '100';
Index: web/graph.d/packet_report.php
===================================================================
--- web/graph.d/packet_report.php       (revision 1464)
+++ web/graph.d/packet_report.php       (working copy)
@@ -11,14 +11,19 @@
            $cpu_num_color,
            $range,
            $rrd_dir,
-           $size;
+           $size,
+           $strip_domainname;
    
+    if ($strip_domainname) {
+       $hostname = strip_domainname($hostname);
+    }
+
     $title = 'Packets'; 
     $rrdtool_graph['height']        += $size == 'medium' ? 28 : 0 ;
     if ($context = 'host') {
        $rrdtool_graph['title'] = $title;
     } else {
-       $rrdtool_graph['title'] = "$hostname $title last $range";
+       $rrdtool_graph['title'] = "$title last $range";
     }
     $rrdtool_graph['lower-limit']    = '0';
     $rrdtool_graph['vertical-label'] = 'Packets/sec';
Index: web/graph.d/metric.php
===================================================================
--- web/graph.d/metric.php      (revision 1464)
+++ web/graph.d/metric.php      (working copy)
@@ -20,8 +20,13 @@
            $size,
            $summary,
            $value,
-           $vlabel;
+           $vlabel,
+           $strip_domainname;
 
+    if ($strip_domainname) {
+        $hostname = strip_domainname($hostname);
+    }
+
     $rrdtool_graph['height']  +=  0 ; //no fudge needed
 
     switch ($context) {
Index: web/graph.d/network_report.php
===================================================================
--- web/graph.d/network_report.php      (revision 1464)
+++ web/graph.d/network_report.php      (working copy)
@@ -11,14 +11,19 @@
            $cpu_num_color,
            $range,
            $rrd_dir,
-           $size;
+           $size,
+           $strip_domainname;
    
+    if ($strip_domainname) {
+       $hostname = strip_domainname($hostname);
+    }
+
     $title = 'Network';
     $rrdtool_graph['height']        += $size == 'medium' ? 28 : 0 ;
     if ($context = 'host') {
        $rrdtool_graph['title'] = $title;
     } else {
-       $rrdtool_graph['title'] = "$hostname Network last $range";
+       $rrdtool_graph['title'] = "$title last $range";
     }
     $rrdtool_graph['lower-limit']    = '0';
     $rrdtool_graph['vertical-label'] = 'Bytes/sec';
Index: web/graph.php
===================================================================
--- web/graph.php       (revision 1464)
+++ web/graph.php       (working copy)
@@ -175,10 +175,18 @@
    $rrdtool_graph['title'] = $rrdtool_graph['title'] . " last $range";
 }
 
-if (isset($title)) {
-    $rrdtool_graph['title'] = "$title " . $rrdtool_graph['title'];
+
+if ($strip_domainname) {
+   $hostname = strip_domainname($hostname);
 }
 
+
+if ( preg_match('/_report/', $graph) ) {
+   $rrdtool_graph['title'] = "$title $hostname ". $rrdtool_graph['title'];
+} else if (isset($title)) {
+   $rrdtool_graph['title'] = "$title " . $rrdtool_graph['title'];
+}
+
 
//--------------------------------------------------------------------------------------
 
 // We must have a 'series' value, or this is all for naught
Index: web/functions.php
===================================================================
--- web/functions.php   (revision 1464)
+++ web/functions.php   (working copy)
@@ -444,4 +444,16 @@
   return $return_value;
     
 }
+
+#-------------------------------------------------------------------------------
+# Return a shortened version of an FQDN 
+function strip_domainname( $hostname ) {
+    $postition = strpos($hostname, '.');
+    if ( FALSE === $postition ) {
+        return $hostname;
+    } else {
+        return substr( $hostname , 0, $postition );
+    }
+}
+
 ?>
Index: web/conf.php
===================================================================
--- web/conf.php        (revision 1464)
+++ web/conf.php        (working copy)
@@ -125,6 +125,12 @@
 $default_metric = "load_one";
 
 #
+# remove the domainname from the FQDN hostnames in graphs (to help with long
+# hostnames in small charts)
+#
+$strip_domainname = false;
+
+#
 # Optional summary graphs
 #
 #$optional_graphs = array('packet');
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to