due_to_source_code_changing_2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
due_to_source_code_changing_2 [2013/07/25 16:27]
noskov
due_to_source_code_changing_2 [2013/08/16 15:53]
noskov
Line 2: Line 2:
 <file php maintenance_conf.php> <file php maintenance_conf.php>
    <?php    <?php
-   $maint_name = "maintenance"; +$maint_name = "maintenance"; 
-   $computer_metrics = array( + 
-     "load", +$computer_metrics = array( 
-     "mem" +    "load", 
-   ); +    "mem", 
-   $maintenance_metrics = array( +    "cpu
-     "rows", +); 
-     "rowscool", + 
-     "clcpwaterflow", +$maint_rrdfile = array( 
-     "pumptemp", +        "ROWS" => array( 
-     "pumpdp" +                "rows" => "Total_Power.rrd", 
-   ); +                "rowscool" => "Calc_total_lcp_cooling_power.rrd", 
-   ?>+                "clcpwaterflow" => "Calc_total_lcp_water_flow.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ), 
 +        "ROW_2" => array( 
 + "rows" => "Total_Row_Power.rrd", 
 +                "rowscool" => "Calc_row_lcp_cooling_power.rrd", 
 +                "clcpwaterflow" => "Calc_row_lcp_water_flow.rrd", 
 +                "rowsfan" => "Calc_row_lcp_fan_power.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ), 
 +        "ROW_3" => array( 
 + "rows" => "Total_Row_Power.rrd", 
 +                "rowscool" => "Calc_row_lcp_cooling_power.rrd", 
 +                "clcpwaterflow" => "Calc_row_lcp_water_flow.rrd", 
 +                "rowsfan" => "Calc_row_lcp_fan_power.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ), 
 +        "ROW_4" => array( 
 + "rows" => "Total_Row_Power.rrd", 
 +                "rowscool" => "Calc_row_lcp_cooling_power.rrd", 
 +                "clcpwaterflow" => "Calc_row_lcp_water_flow.rrd", 
 +                "rowsfan" => "Calc_row_lcp_fan_power.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ), 
 +        "ROW_5" => array( 
 + "rows" => "Total_Row_Power.rrd", 
 +                "rowscool" => "Calc_row_lcp_cooling_power.rrd", 
 +                "clcpwaterflow" => "Calc_row_lcp_water_flow.rrd", 
 +                "rowsfan" => "Calc_row_lcp_fan_power.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ), 
 +        "ROW_6" => array( 
 + "rows" => "Total_Row_Power.rrd", 
 +                "rowscool" => "Calc_row_lcp_cooling_power.rrd", 
 +                "clcpwaterflow" => "Calc_row_lcp_water_flow.rrd", 
 +                "rowsfan" => "Calc_row_lcp_fan_power.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ), 
 +        "ROW_7" => array( 
 + "rows" => "Total_Row_Power.rrd", 
 +                "rowscool" => "Calc_row_lcp_cooling_power.rrd", 
 +                "clcpwaterflow" => "Calc_row_lcp_water_flow.rrd", 
 +                "rowsfan" => "Calc_row_lcp_fan_power.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ), 
 +        "ROW_8" => array( 
 + "rows" => "Total_Row_Power.rrd", 
 +                "rowscool" => "Calc_row_lcp_cooling_power.rrd", 
 +                "clcpwaterflow" => "Calc_row_lcp_water_flow.rrd", 
 +                "rowsfan" => "Calc_row_lcp_fan_power.rrd", 
 +                "clcpairflow" => "Calc_row_lcp_water_flow.rrd" 
 +        ) 
 + 
 +); 
 + 
 +$mgroup_metrics = array( 
 + "ROWS" => array( 
 + "rows", 
 + "rowscool", 
 + "clcpwaterflow", 
 + "pumptemp", 
 + "pumpdp" 
 + ), 
 + "ROW_6" => array( 
 + "rows", 
 +                "rowscool", 
 + "clcpwaterflow", 
 + "clcpairflow", 
 + "rowsfan" 
 + ), 
 + "ROW_8" => array( 
 + "rows", 
 +                "rowscool", 
 + "clcpwaterflow", 
 + "clcpairflow", 
 + "rowsfan" 
 + ), 
 + "ROW_7" => array( 
 + "rows", 
 +                "rowscool", 
 + "clcpwaterflow", 
 + "clcpairflow", 
 + "rowsfan" 
 + ), 
 + "ROW_2" => array( 
 + "rows", 
 +                "rowscool", 
 + "clcpwaterflow", 
 + "clcpairflow", 
 + "rowsfan" 
 + ), 
 + "ROW_4" => array( 
 + "rows", 
 +                "rowscool", 
 + "clcpwaterflow", 
 + "clcpairflow", 
 + "rowsfan" 
 + ), 
 + "ROW_3" => array( 
 + "rows", 
 +                "rowscool", 
 + "clcpwaterflow", 
 + "clcpairflow", 
 + "rowsfan" 
 + ), 
 + "ROW_5" => array( 
 + "rows", 
 +                "rowscool", 
 + "clcpwaterflow", 
 + "clcpairflow", 
 + "rowsfan" 
 +
 + 
 +); 
 + 
 +function add_ipmi_metrics ($metrics, $rrddir){ 
 + $alledateien = scandir($rrddir); 
 + foreach ($alledateien as $datei) { // Ausgabeschleife 
 +                if (substr_compare($datei,"ipmi",0,4) == 0){ 
 +                        $dateiinfo = pathinfo($rrddir."/".$datei); 
 +                        if($dateiinfo['extension'] == 'rrd'){ 
 +                                $metrics[$dateiinfo['filename']]['NAME'] = $dateiinfo['filename']; 
 +                                $metrics[$dateiinfo['filename']]['TYPE'] = 'float'; 
 +                                $metrics[$dateiinfo['filename']]['VAL'] = 0; 
 +                                $metrics[$dateiinfo['filename']]['SLOPE'] = 'both'; 
 + $metrics[$dateiinfo['filename']]['UNITS'] = 'a.u.'; 
 + $metrics[$dateiinfo['filename']]['GROUP'] = array("ipmi"); 
 + #error_log("add ipmii".$dateiinfo['filename']); 
 +                        } 
 +                } 
 +            }; 
 + return $metrics; 
 +
 + 
 +function add_ipmi_metrics_cview($hostname,$metrics,$rrddir){ 
 + $alledateien = scandir($rrddir); 
 +        foreach ($alledateien as $datei) { // Ausgabeschleife 
 +                if (substr_compare($datei,"ipmi",0,4) == 0){ 
 +                        $dateiinfo = pathinfo($rrddir."/".$datei); 
 +                        if($dateiinfo['extension'] == 'rrd'){ 
 +                                $metrics[$hostname][$dateiinfo['filename']]['NAME'] = $dateiinfo['filename']; 
 +                                $metrics[$hostname][$dateiinfo['filename']]['TYPE'] = 'float'; 
 +                                $metrics[$hostname][$dateiinfo['filename']]['VAL'] = 0; 
 + $metrics[$hostname][$dateiinfo['filename']]['SLOPE'] = 'both'; 
 + $metrics[$hostname][$dateiinfo['filename']]['UNITS'] = 'a.u.'; 
 +                                $metrics[$hostname][$dateiinfo['filename']]['GROUP'] = array("ipmi"); 
 +                                #error_log("add ipmii".$dateiinfo['filename']); 
 +                        } 
 +                } 
 +            }; 
 +        return $metrics; 
 +
 +?> 
 </file>    </file>   
-in the <GANGLIA HOME>/graph.d/ directory (files archive {{:graph_d.zip|}})+in the <GANGLIA HOME>/graph.d/ directory (files archive {{:graph_d.tar.bz2|}})
      
-   **pumpdp_report.php** +   4241 Aug 13 18:27 clcpairflow_report.php 
-   **pumptemp_report.php** +   4247 Aug 13 18:27 clcpwaterflow_report.php 
-   **rows_report.php** +   3011 Feb 17  2010 cpu_report.php 
-   **rowscool_report.php** +   4388 Aug  6 17:06 cputemp_report.php 
-   **clcpwaterflow_report.php**+   1481 Feb 17  2010 load_report.php 
 +   2284 Feb 17  2010 mem_report.php 
 +   3659 Aug 14 11:55 metric.php 
 +   6481 Jul 18 16:50 my_report.php 
 +   1109 Jul 19 11:52 network_report.php 
 +   1107 Feb 17  2010 packet_report.php 
 +   4369 Jul 19 16:12 pump1_report.php 
 +   4561 Jul 24 14:38 pumpdp_report.php 
 +   4752 Jul 24 16:34 pumptemp_report.php 
 +   4079 Aug 13 18:26 rows_report.php 
 +   4154 Aug 13 18:25 rowscool_report.php 
 +   4089 Aug 13 18:26 rowsfan_report.php 
 +   6481 Feb 17  2010 sample_report.php 
 + 
 + 
 +correction of the file metric.php in order to take new DS in to account: 
 +<file metric.php> 
 +... 
 +$DSname="sum"; 
 +//# the actual graph... 
 +    if (substr_compare($metricname,"ipmi",0,4) == 0) 
 + $DSname="ipmi"; 
 +    $series  = "DEF:'sum'='$rrd_dir/$metricname.rrd:$DSname':AVERAGE "; 
 +    $series .= "AREA:'sum'#$default_metric_color:'$subtitle_one'"; 
 +    $series .= ":STACK: COMMENT:'$subtitle_two'"; 
 +... 
 +</file> 
  
 **in the file conf.php (in "/etc/ganglia/") was inserted:** **in the file conf.php (in "/etc/ganglia/") was inserted:**
 <code php> <code php>
 +...
 include_once "./maintenance_conf.php"; include_once "./maintenance_conf.php";
 +...
 +# Set timezone
 +date_default_timezone_set ( 'Europe/Berlin' );
 +...
 </code> </code>
  
 in the template file <GANGLIA HOME>/templates/default/meta_view.tpl the block "public" was changed: in the template file <GANGLIA HOME>/templates/default/meta_view.tpl the block "public" was changed:
 +
 <code php> <code php>
 ... ...
Line 46: Line 232:
   <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=top>   <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=top>
      
 +    <table cellspacing=1 cellpadding=1 width=100% border=0>
 +  <!-- START BLOCK : graph_group -->
 +     <tr>
 +       <td>
   <!-- START BLOCK : metric_graphs -->   <!-- START BLOCK : metric_graphs -->
-  <A HREF="{url}"> +          <A HREF="{url}"> 
-   <IMG SRC="./graph.php?{graph_url}&g={metricname}_report&z=medium&r={range}" +             <IMG SRC="./graph.php?{graph_url}&g={metricname}_report&maint={m_name}&z=smedium&r={range}" 
-       ALT="{name} Load" BORDER="0"> +              ALT="{name} Load" BORDER="0"> 
-  </A>+           </A>
   <!-- END BLOCK : metric_graphs -->   <!-- END BLOCK : metric_graphs -->
 +       </td>
 +     </tr>
 +  <!-- END BLOCK : graph_group -->
 +  </table>
      
    </TD>    </TD>
Line 58: Line 252:
 </code> </code>
  
-to+in the file <GANGLIA HOME>/meta_view.php the following was changed: 
 +<code php public cluster code is altered> 
 +... 
 +foreach ( $sorted_sources as $source => $val ) 
 +  {
  
-<code php> 
 ... ...
-<!-- START BLOCK : public --> +    if (!isset($private[$source]) or !$private[$source])  
- <TD ALIGN="LEFTVALIGN="TOP"> +         { 
-<table cellspacing=1 cellpadding=1 width="100%border=0> +            $tpl->assign("alt_view""<FONT SIZE=\"-2\">$alt_url</FONT>"); 
- <tr><td>CPUs Total:</td><td align=left><B>{cpu_num}</B></td></tr+            # Each block has a different namespace, so we need to redefine variables. 
- <tr><td width="80%">Hosts up:</td><td align=left><B>{num_nodes}</B></td></tr+            $tpl->newBlock("public"); 
- <tr><td>Hosts down:</td><td align=left><B>{num_dead_nodes}</B></td></tr+            if ($localtime) 
- <tr><td>&nbsp;</td></tr+               $tpl->assign("localtime",  "<font size=-1>Localtime:</font><br>&nbsp;&nbsp;"  
- <tr><td class=footer colspan=2>{cluster_load}</td></tr+                  . date("Y-m-d H:i", $localtime) ); 
- <tr><td class=footer colspan=2>{localtime}</td></tr+              
-</table+             $tpl->assign("num_nodes", $grid[$source]["HOSTS_UP"] ); 
-  </TD>+             $tpl->assign("num_dead_nodes", $grid[$source]["HOSTS_DOWN"] ); 
 +             
 +             
 +             if ($name == $maint_name){ 
 + foreach ($mgroup_metrics as $mname =&$mgrp) { 
 +   $hostname $mname; 
 +                  $tpl->newBlock("graph_group"); 
 +                  foreach ($mgrp as $g) { 
 +                      $tpl->newBlock("metric_graphs"); 
 +                       
 +                      $tpl->assign("range", $range); 
 +                      $tpl->assign("name", $name ); 
 +       $tpl->assign("m_name", $hostname ); 
 +                      $tpl->assign("url", "./graph.php?c=$name&amp;r=$range&amp;g=${g}_report&amp;maint=${hostname}&amp;z=large"); 
 +                      $tpl->assign("graph_url", $graph_url); 
 +                      $tpl->assign("metricname", $g); 
 +                  } 
 +                 } 
 +             } else { 
 +                 if ($cluster_load) 
 +                     $tpl->assign("cluster_load", "<font size=-1>Avg Load (15, 5, 1m):</font>" 
 +                                  ."<br>&nbsp;&nbsp;$cluster_load"); 
 +                 $tpl->assign("cpu_num", $m["cpu_num"]['SUM']); 
 + $tpl->newBlock("graph_group"); 
 +                 foreach ($computer_metrics as $g) { 
 +                      
 +                     $tpl->newBlock("metric_graphs"); 
 +                      
 +                     $tpl->assign("range", $range); 
 +                     $tpl->assign("name", $name ); 
 +                     $tpl->assign("url", $url); 
 +                     $tpl->assign("graph_url", $graph_url); 
 +                     $tpl->assign("metricname", $g); 
 +                 } 
 +             }
  
-  <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=top> 
-   
-  <!-- START BLOCK : metric_graphs --> 
-  <A HREF="{url}"> 
-   <IMG SRC="./graph.php?{graph_url}&g={metricname}_report&z=medium&r={range}" 
-       ALT="{name} Load" BORDER="0"> 
-  </A> 
-  <!-- END BLOCK : metric_graphs --> 
-   
-   </TD> 
-<!-- END BLOCK : public --> 
 ... ...
 </code> </code>
 +in order to see the "last reported" metric by default in the "maintenance" overview the line 118 was changed:
 +<code php>
 +if ($name == $maint_name)
 +          $tpl->assign("url", "./?c=$name&amp;m=last_reported&amp;r=$range");
 +      else
 +          $tpl->assign("url", $url);
 +</code>
 +
 +in order to list new IPMI metrics additionally in the cluster overview page the function start_cluster was changed to ganglia.php
 +<file changing ganglia.php>
 +...
 +function start_cluster ($parser, $tagname, $attrs)
 +{
 +   global $clustername, $rrds, $metrics, $cluster, $self, $grid, $hosts_up, $hosts_down;
 +   static $hostname;
 +
 +   switch ($tagname)
 +      {
 +         case "GANGLIA_XML":
 +            preamble($attrs);
 +            break;
 +         case "GRID":
 +            $self = $attrs['NAME'];
 +            $grid = $attrs;
 +            break;
 +
 +         case "CLUSTER":
 +            $cluster = $attrs;
 +            break;
 +
 +         case "HOST":
 +            $hostname = $attrs['NAME'];
 +
 +            if (host_alive($attrs, $cluster))
 +               {
 +   isset($cluster['HOSTS_UP']) or $cluster['HOSTS_UP'] = 0;
 +                  $cluster['HOSTS_UP']++;
 +                  $hosts_up[$hostname] = $attrs;
 +               }
 +            else
 +               {
 +   isset($cluster['HOSTS_DOWN']) or $cluster['HOSTS_DOWN'] = 0;
 +                  $cluster['HOSTS_DOWN']++;
 +                  $hosts_down[$hostname] = $attrs;
 +               }
 +            # Pseudo metrics - add useful HOST attributes like gmond_started & last_reported to the metrics list:
 +            $metrics[$hostname]['gmond_started']['NAME'] = "GMOND_STARTED";
 +            $metrics[$hostname]['gmond_started']['VAL'] = $attrs['GMOND_STARTED'];
 +            $metrics[$hostname]['gmond_started']['TYPE'] = "timestamp";
 +            $metrics[$hostname]['last_reported']['NAME'] = "REPORTED";
 +            $metrics[$hostname]['last_reported']['VAL'] = uptime($cluster['LOCALTIME'] - $attrs['REPORTED']);
 +            $metrics[$hostname]['last_reported']['TYPE'] = "string";
 +            $metrics[$hostname]['ip_address']['NAME'] = "IP";
 +            $metrics[$hostname]['ip_address']['VAL'] = $attrs['IP'];
 +            $metrics[$hostname]['ip_address']['TYPE'] = "string";
 +            $metrics[$hostname]['location']['NAME'] = "LOCATION";
 +            $metrics[$hostname]['location']['VAL'] = $attrs['LOCATION'];
 +            $metrics[$hostname]['location']['TYPE'] = "string";
 +
 +     /* Addition of IPMI metrics */
 +     $rrddir = "$rrds/$clustername/$hostname";
 +     $metrics=add_ipmi_metrics_cview($hostname,$metrics,$rrddir);
 +     #error_log("rrd= $rrddir");
 +
 +            break;
 +
 +         case "METRIC":
 +            $metricname = $attrs['NAME'];
 +            $metrics[$hostname][$metricname] = $attrs;
 +            break;
 +
 +         default:
 +            break;
 +      }
 +}
 +...
 +</file>
 +
 +in order to see the IPMI metrics in the host overview the file host_view.php was changed as following:
 +<file host_view.php>
 +...
 +$g_metrics_group = array();
 +
 +/* Addition of IPMI metrics */
 +$rrddir = "$rrds/$clustername/$hostname";
 +$metrics=add_ipmi_metrics($metrics,$rrddir);
 +...
 +</file>