"Fossies" - the Fresh Open Source Software Archive

Member "ganglia-web-3.7.2/graph_all_periods.php" (12 Oct 2015, 9514 Bytes) of package /linux/www/ganglia-web-3.7.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "graph_all_periods.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.7.1_vs_3.7.2.

    1 <?php
    2 include_once "./eval_conf.php";
    3 include_once "./global.php";
    4 if (!isset($_REQUEST['embed']) && !isset($_REQUEST['mobile'])) {
    5 ?>
    6 <html>
    7 <head>
    8 <title>Ganglia: Graph all periods</title>
    9 <link rel="stylesheet" href="./styles.css" type="text/css" />
   10 <script type="text/javascript" src="<?php print $conf['jquery_js_path']; ?>"></script>
   11 <script>$.uiBackCompat = false;</script>
   12 <script type="text/javascript" src="<?php print $conf['jqueryui_js_path']; ?>"></script>
   13 <script type="text/javascript" src="js/jquery.livesearch.min.js"></script>
   14 <script type="text/javascript" src="js/ganglia.js"></script>
   15 <script type="text/javascript" src="js/jquery.gangZoom.js"></script>
   16 <script type="text/javascript" src="js/jquery.cookie.js"></script>
   17 <script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
   18 <script type="text/javascript" src="js/jquery.ba-bbq.min.js"></script>
   19 <link type="text/css" href="css/smoothness/jquery-ui-1.10.2.custom.min.css" rel="stylesheet" />
   20 <link rel="stylesheet" href="css/jquery.multiselect.css" type="text/css" />
   21 <?php
   22 } // if (!isset($_REQUEST['embed']) && !isset($_REQUEST['mobile'])) {
   23 ?>
   24 <script type="text/javascript">
   25   function openDecompose($url) {
   26     $.cookie("ganglia-selected-tab-" + window.name, 0);
   27     location.href="./index.php" + $url + "&amp;tab=m";
   28   }
   29 
   30   $(function() {
   31     initShowEvent();
   32     initTimeShift();
   33 <?php if (!isset($_REQUEST['embed']) && !isset($_REQUEST['mobile'])) { ?>
   34     initMetricActionsDialog();
   35     $("#popup-dialog").dialog({ autoOpen: false, 
   36                                 width:800, 
   37                                 height:500,
   38                                 position: { my: "top",
   39                                             at: "top+200",
   40                                             of: window } } );
   41 <?php } ?>
   42   });
   43 </script>
   44 
   45 <?php
   46 
   47 // build a query string but drop r and z since those designate time 
   48 // window and size. Also if the get arguments are an array rebuild them. 
   49 // For example with hreg (host regex)
   50 $ignore_keys_list = array("r", "z", "st", "cs", "ce", "hc");
   51 
   52 foreach ($_GET as $key => $value) {
   53   if (!in_array($key, $ignore_keys_list) && !is_array($value))
   54     $query_string_array[] = rawurlencode($key) . "=" . urlencode($value);
   55 
   56   // $_GET argument is an array. Rebuild it to pass it on
   57   if (is_array($value)) {
   58     foreach ($value as $index => $value2)
   59       $query_string_array[] = rawurlencode($key) . "[]=" . urlencode($value2);
   60   }
   61 }
   62 
   63 // If we are in the mobile mode set the proper graph sizes
   64 if ( isset($_GET['mobile'])) {
   65   $largesize = "mobile";
   66   $xlargesize = "mobile";
   67 } else {
   68   $largesize = "large";
   69   $xlargesize = "xlarge";  
   70 }
   71 
   72 // Join all the query_string arguments
   73 $query_string = "&amp;" . join("&amp;", $query_string_array);
   74 
   75 // Descriptive host/aggregate graph
   76 if (isset($_GET['h']) && ($_GET['h'] != ''))
   77   $description = htmlspecialchars($_GET['h']);
   78 else if (isset($_GET['c']) && ($_GET['c'] != ''))
   79   $description = htmlspecialchars($_GET['c']);
   80 else if (isset($_GET['hreg']) && is_array($_GET['hreg']))
   81   $description = htmlspecialchars( join(",", $_GET['hreg']) );
   82 else
   83   $description = "Unknown";
   84 
   85 if (isset($_GET['g'])) 
   86   $metric_description = htmlspecialchars($_GET['g']);
   87 else if ( isset($_GET['m'] ))
   88   $metric_description = htmlspecialchars($_GET['m']);
   89 else if (isset($_GET['mreg']) && is_array($_GET['mreg']) )
   90   $metric_description = htmlspecialchars( join(",", $_GET['mreg']) );
   91 else
   92   $metric_description = "Unknown";
   93 
   94 # Determine if it's aggregate graph
   95 if (preg_match("/aggregate=1/", $query_string))
   96   $is_aggregate = true;
   97 else
   98   $is_aggregate = false;
   99 
  100 if ($conf['graph_engine'] == "flot") {
  101 ?>
  102 <style type="text/css">
  103 .flotgraph {
  104   height: <?php print $conf['graph_sizes'][$largesize]["height"] ?>px;
  105   width:  <?php print $conf['graph_sizes'][$largesize]["width"] ?>px;
  106 }
  107 </style>
  108 <?php
  109 // Add JQuery and flot loading only if this is not embedded in the 
  110 // Aggregate Graphs Tab
  111 if (!isset($_GET['embed'])) { ?>
  112 <script language="javascript" type="text/javascript" src="<?php print $conf['jquery_flot_base_path']; ?>.min.js"></script>
  113 <script language="javascript" type="text/javascript" src="<?php print $conf['jquery_flot_base_path']; ?>.time.min.js"></script>
  114 <?php
  115 } // end of if (!isset($_GET['embed'])
  116 ?>
  117 <script type="text/javascript">
  118   var default_time = 'hour';
  119   var metric = "<?php if (isset($_GET['g'])) echo $_GET['g']; else echo $_GET['m']; ?>";
  120   var base_url = "<?php print 'graph.php?flot=1&amp;' . $_GET['m'] . $query_string ?>" + "&amp;r=" + default_time;
  121 </script>
  122 <script type="text/javascript" src="js/create-flot-graphs.js"></script>
  123 <?php 
  124 } // end of if ($conf['graph_engine'] == "flot") { 
  125 ?>
  126 
  127 <?php if (!isset($_REQUEST['embed']) && !isset($_REQUEST['mobile'])) { ?>
  128 </head>
  129 <body onSubmit="return false;">
  130 <?php } ?>
  131 
  132 <?php if (!isset($_REQUEST['embed']) && !isset($_REQUEST['mobile'])) { ?>
  133 <div id="popup-dialog" style="display: none" title="Inspect Graph">
  134   <div id="popup-dialog-content">
  135   </div>
  136 </div>
  137 <?php
  138 }
  139 ?>
  140 
  141 <?php if (!isset($_REQUEST['embed']) && !isset($_REQUEST['mobile'])) { ?>
  142 <div id="metric-actions-dialog" style="display: none" title="Metric Actions">
  143 <div id="metric-actions-dialog-content">
  144     Available Metric actions.
  145 </div>
  146 </div>
  147 <?php } ?>
  148 
  149 <form>
  150 <?php
  151 if (isset($_REQUEST['mobile'])) {
  152 ?>
  153     <div data-role="page" class="ganglia-mobile" id="view-home">
  154     <div data-role="header">
  155       <a href="#" class="ui-btn-left" data-icon="arrow-l" onclick="history.back(); return false">Back</a>
  156       <h3><?php if (isset($_GET['g'])) echo htmlspecialchars($_GET['g']); else echo htmlspecialchars($_GET['m']); ?></h3>
  157       <a href="#mobile-home">Home</a>
  158     </div>
  159     <div data-role="content">
  160 <?php
  161 }
  162 
  163 // Skip printing if this is an embedded graph e.g. from Aggregate graph screen
  164 if (!isset($_REQUEST['embed'])) {
  165 ?>
  166   <div><b>Host/Cluster/Host Regex: </b><?php print $description ?>&nbsp;<b>Metric/Graph/Metric Regex: </b><?php print $metric_description;?>&nbsp;&nbsp;
  167 <?php
  168 }
  169 
  170 if (!isset($_REQUEST['mobile'])) {
  171    print '<input title="Hide/Show Events" type="checkbox" id="show_all_events" onclick="showAllEvents(this.checked)"/><label class="show_event_text" for="show_all_events">Hide/Show Events All Graphs</label>';
  172    # Make sure it's not aggregate or composite graph
  173   if (!$is_aggregate && ! isset($_GET['g']) )
  174      print '<input title="Timeshift Overlay" type="checkbox" id="timeshift_overlay" onclick="showTimeshiftOverlay(this.checked)"/><label class="show_timeshift_text" for="timeshift_overlay">Timeshift Overlay</label><br />';
  175   print "</div>";
  176 } // end of if ( ! isset($_REQUEST['mobile'] )  ) {
  177 
  178 if (isset($_GET['embed'])) {
  179   print "<div style='height:10px;'/>";
  180 }
  181 
  182 foreach ($conf['time_ranges'] as $key => $value) {
  183   # Skip job 
  184   if ( $value == "job" )
  185     continue;
  186 
  187   print '<div class="img_view">';
  188   
  189   if (!isset($_REQUEST['mobile'])) {
  190 
  191   print '<span style="padding-left: 4em; padding-right: 4em; text-weight: bold;">' . $key . '</span>';
  192 
  193   // If this is for mobile hide some of the options
  194   // Check if it's an aggregate graph
  195   if ($is_aggregate) {
  196     print '<button class="cupid-green" title="Metric Actions - Add to View, etc" onclick="metricActionsAggregateGraph(\'' . $query_string . '\'); return false;">+</button>';
  197   }
  198   
  199   print ' <button title="Export to CSV" class="cupid-green" onclick="window.location=\'./graph.php?r=' . $key . $query_string . '&amp;csv=1\';return false">CSV</button> ';
  200   
  201   print ' <button title="Export to JSON" class="cupid-green" onclick="window.location=\'./graph.php?r=' . $key . $query_string . '&amp;json=1\';return false;">JSON</button> ';
  202   
  203   // Check if it's an aggregate graph
  204   if ($is_aggregate) {
  205     print ' <button title="Decompose aggregate graph" class="shiny-blue" onClick="openDecompose(\'?r=' . $key . $query_string  . '&amp;dg=1\');return false;">Decompose</button>';
  206   }
  207    
  208   print ' <button title="Inspect Graph" onClick="inspectGraph(\'r=' . $key . $query_string  . '\'); return false;" class="shiny-blue">Inspect</button>';
  209 
  210   $graphId = $GRAPH_BASE_ID . $key;
  211 
  212   print ' <input title="Hide/Show Events" type="checkbox" id="' . $SHOW_EVENTS_BASE_ID . $key . '" onclick="showEvents(\'' . $graphId . '\', this.checked)"/><label class="show_event_text" for="' . $SHOW_EVENTS_BASE_ID . $key . '">Hide/Show Events</label>';
  213   if (!$is_aggregate && !isset($_GET['g']))
  214     print ' <input title="Timeshift Overlay" type="checkbox" id="' . $TIME_SHIFT_BASE_ID . $key . '" onclick="showTimeShift(\'' . $graphId . '\', this.checked)"/><label class="show_timeshift_text" for="' . $TIME_SHIFT_BASE_ID . $key . '">Timeshift</label>';
  215   } 
  216 
  217   print  '<br />';
  218 
  219   // If we are using flot we need to use a div instead of an image reference
  220   if ( $conf['graph_engine'] == "flot" ) {
  221     print '<div id="placeholder_' . $key . '" class="flotgraph img_view"></div>';
  222     print '<div id="placeholder_' . $key . '_legend" class="flotlegend"></div>';
  223   } else {
  224     print '<a href="./graph.php?r=' . $key . '&amp;z=' . $xlargesize . $query_string . '"><img class="noborder" id="' . $graphId . '" style="margin-top:5px;" title="Last ' . $key . '" src="graph.php?r=' . $key . '&amp;z=' . $largesize . $query_string . '"></a>';
  225   }
  226   print "</div>";
  227 }
  228 // The div below needs to be added to clear float left since in aggregate 
  229 // view things will start looking goofy
  230 ?>
  231 <div style="clear: left"></div>
  232 </form>
  233 <?php
  234 if (!isset($_REQUEST['embed']) && !isset($_REQUEST['mobile'])) {
  235 ?>
  236 </body>
  237 </html>
  238 <?php } ?>