diff --git a/functions.php b/functions.php index 0e15607a..4d853291 100644 --- a/functions.php +++ b/functions.php @@ -1330,7 +1330,7 @@ function retrieve_metrics_cache () { } } - if ( ! isset($index_array) ) { + if ( ! isset($index_array) || sizeof($index_array) == 0 ) { if ( $debug == 1 ) { echo("DEBUG: Querying GMond for new data\n"); diff --git a/ganglia.php b/ganglia.php index 873e0dde..7f43d59c 100644 --- a/ganglia.php +++ b/ganglia.php @@ -9,7 +9,9 @@ # information as we need to make the page. # -include_once($conf['ganglia_dir'] . "/version.php"); +$ganglia_dir = dirname(__FILE__); + +include_once($ganglia_dir . "/version.php"); $error=""; @@ -35,7 +37,7 @@ $version = array(); # The web frontend version, from conf.php. -$version["webfrontend"] = "$ganglia_version"; +$version["webfrontend"] = $GLOBALS["ganglia_version"]; # Get rrdtool version $rrdtool_version = array(); diff --git a/get_context.php b/get_context.php index 0cb08dca..00b508dc 100644 --- a/get_context.php +++ b/get_context.php @@ -1,16 +1,24 @@ assign("server_utc_offset", date('Z')); +// $data->assign("page_title", $title); $data->assign("refresh", $conf['default_refresh']); @@ -125,24 +128,19 @@ $data->assign("cluster_url", $cluster_url); $alt_view = ""; -if ($context=="cluster") - { - $alt_view = "Physical View"; - } -elseif ($context=="physical") - { - $alt_view = "Full View"; - } -elseif ($context=="node") - { - $alt_view = - "Host View"; - } -elseif ($context=="host") - { - $alt_view = - "Node View"; +if ($context == "cluster") { + $alt_view = "Physical View"; +} elseif ($context == "physical") { + $alt_view = "Full View"; +} elseif ($context=="node") { + $alt_view = "Host View"; +} elseif ($context=="host") { + $alt_view = "Node View"; +} elseif ( $context = "views") { + if( checkAccess( GangliaAcl::ALL_VIEWS, GangliaAcl::EDIT, $conf ) ) { + $alt_view = 'Create View'; } +} $data->assign("alt_view", $alt_view); @@ -164,76 +162,100 @@ if ($physical) $node_menu .= hiddenvar("p", $physical); -if ( $clustername ) - { - $url = rawurlencode($clustername); - $node_menu .= "$clustername "; - $node_menu .= ">\n"; - $node_menu .= hiddenvar("c", $clustername); - } -else - { - # No cluster has been specified, so drop in a list - $node_menu .= "\n"; - $node_menu .= "--Choose a Source\n"; - ksort($grid); - foreach( $grid as $k => $v ) - { - if ($k==$self) continue; - if (isset($v['GRID']) and $v['GRID']) - { - $url = $v['AUTHORITY']; - $node_menu .="$k $meta_designator\n"; - } - else - { - $url = rawurlencode($k); - $node_menu .="$k\n"; - } - } - $node_menu .= "\n"; - } - -if ( $clustername && !$hostname ) - { - # Drop in a host list if we have hosts - if (!$showhosts) { - $node_menu .= "[Summary Only]"; +////////////////////////////////////////////////////////////////////////////// +// Cluster name has been specified. It comes right after +// Grid > +////////////////////////////////////////////////////////////////////////////// +if ( $clustername ) { + $url = rawurlencode($clustername); + $node_menu .= "$clustername "; + $node_menu .= ">\n"; + $node_menu .= hiddenvar("c", $clustername); +} else if ( $viewname) { + $url = "Views"; + $node_menu .= "Views "; + $node_menu .= ">\n"; +} else { + # No cluster has been specified, so drop in a list + $node_menu .= "\n"; + $node_menu .= "--Choose a Source\n"; + $node_menu .= "Views\n"; + ksort($grid); + foreach( $grid as $k => $v ) + { + if ($k==$self) continue; + if (isset($v['GRID']) and $v['GRID']) + { + $url = $v['AUTHORITY']; + $node_menu .="$k $meta_designator\n"; + } + else + { + $url = rawurlencode($k); + $node_menu .="$k\n"; + } } - elseif (is_array($hosts_up) || is_array($hosts_down)) - { - $node_menu .= ""; - $node_menu .= "--Choose a Node\n"; - if(is_array($hosts_up)) - { - uksort($hosts_up, "strnatcmp"); - foreach($hosts_up as $k=> $v) - { - $url = rawurlencode($k); - $node_menu .= "$k\n"; - } - } - if(is_array($hosts_down)) - { - uksort($hosts_down, "strnatcmp"); - foreach($hosts_down as $k=> $v) - { - $url = rawurlencode($k); - $node_menu .= "$k\n"; - } - } - $node_menu .= "\n"; - } - else - { - $node_menu .= "No Hosts\n"; - } + $node_menu .= "\n"; +} + +if ( $context == "views" ) { + + $node_menu .= ""; + $node_menu .= "--Choose a View"; + + $available_views = get_available_views(); + + foreach ( $available_views as $index => $view ) { + if ( $viewname == $view["view_name"]) + $extra_options = "selected"; + $node_menu .= "" . $view['view_name'] . ""; + unset($extra_options); } -else - { - $node_menu .= "$hostname\n"; - $node_menu .= hiddenvar("h", $hostname); + + $node_menu .= ""; + +} + +///////////////////////////////////////////////////////////////////////////////// +// We are in the cluster view pop up a list box of nodes +///////////////////////////////////////////////////////////////////////////////// +if ( $clustername && !$hostname ) { + # Drop in a host list if we have hosts + if (!$showhosts) { + $node_menu .= "[Summary Only]"; } + elseif (is_array($hosts_up) || is_array($hosts_down)) + { + $node_menu .= ""; + $node_menu .= "--Choose a Node"; + if(is_array($hosts_up)) + { + uksort($hosts_up, "strnatcmp"); + foreach($hosts_up as $k=> $v) + { + $url = rawurlencode($k); + $node_menu .= "$k\n"; + } + } + if(is_array($hosts_down)) + { + uksort($hosts_down, "strnatcmp"); + foreach($hosts_down as $k=> $v) + { + $url = rawurlencode($k); + $node_menu .= "$k\n"; + } + } + $node_menu .= "\n"; + } + else + { + $node_menu .= "No Hosts\n"; + } +} else { + $node_menu .= "$hostname\n"; + $node_menu .= hiddenvar("h", $hostname); +} # Save other CGI variables $node_menu .= hiddenvar("cr", $controlroom); @@ -390,14 +412,14 @@ $custom_time = ""; -if ($context == "meta" or $context == "cluster" or $context == "host") +if ($context == "meta" or $context == "cluster" or $context == "host" or $context == "views") { $examples = "Feb 27 2007 00:00, 2/27/2007, 27.2.2007, now -1 week," . " -2 days, start + 1 hour, etc."; - $custom_time = " or from from \n"; diff --git a/index.php b/index.php index aca89ea4..d04472b0 100644 --- a/index.php +++ b/index.php @@ -74,6 +74,12 @@ include_once "./header.php"; include_once "./host_view.php"; } +else if ($context == "views") + { + $title = "$viewname view"; + include_once "./header.php"; + include_once "./views_view.php"; + } else { $title = "Unknown Context"; diff --git a/js/ganglia.js b/js/ganglia.js index f7c07904..b9538180 100644 --- a/js/ganglia.js +++ b/js/ganglia.js @@ -51,11 +51,13 @@ $(function(){ $( "#datepicker-cs" ).datepicker({ showOn: "button", + constrainInput: false, buttonImage: "img/calendar.gif", buttonImageOnly: true }); $( "#datepicker-ce" ).datepicker({ showOn: "button", + constrainInput: false, buttonImage: "img/calendar.gif", buttonImageOnly: true }); @@ -213,3 +215,17 @@ function ganglia_submit(clearonly) { if (! clearonly) document.ganglia_form.submit(); } + +/* ---------------------------------------------------------------------------- + Enlarges a graph using Flot +-----------------------------------------------------------------------------*/ +function enlargeGraph(graphArgs) { + $("#enlarge-graph-dialog").dialog('open'); + $("#enlarge-graph-dialog").bind( "dialogbeforeclose", function(event, ui) { + $("#enlargeTooltip").remove(); + }); +// $('#enlarge-graph-dialog-content').html(''); + $.get('enlarge_graph.php', "flot=1&" + graphArgs, function(data) { + $('#enlarge-graph-dialog-content').html(data); + }) +} diff --git a/templates/default/host_view.tpl b/templates/default/host_view.tpl index f9248d52..fefa64be 100644 --- a/templates/default/host_view.tpl +++ b/templates/default/host_view.tpl @@ -128,17 +128,6 @@ function toggleMetricGroup(mgId, mgDiv) { document.ganglia_form.submit(); } -function enlargeGraph(graphArgs) { - $("#enlarge-graph-dialog").dialog('open'); - $("#enlarge-graph-dialog").bind( "dialogbeforeclose", function(event, ui) { - $("#enlargeTooltip").remove(); - }); -// $('#enlarge-graph-dialog-content').html(''); - $.get('enlarge_graph.php', "flot=1&" + graphArgs, function(data) { - $('#enlarge-graph-dialog-content').html(data); - }) -} - $(function() { // Modified from http://jqueryui.com/demos/toggle/ //run the currently selected effect diff --git a/templates/default/meta_view.tpl b/templates/default/meta_view.tpl index a7cb751d..06f16d2b 100644 --- a/templates/default/meta_view.tpl +++ b/templates/default/meta_view.tpl @@ -21,6 +21,11 @@ {/if} + + + Views {$source.alt_view} + + {foreach $sources source} diff --git a/templates/default/views_view.tpl b/templates/default/views_view.tpl new file mode 100644 index 00000000..cbdb89c5 --- /dev/null +++ b/templates/default/views_view.tpl @@ -0,0 +1,33 @@ + + + + + {if $number_of_view_items == 0 } + + + + No graphs defined for this view. Please add some + + + + {else} + {foreach $view_items view_item} + + CSV + JSON + {if $view_item.aggregate_graph == 1} + Decompose + {/if} + Enlarge + + + {/foreach} + {/if} + + + diff --git a/version.php.in b/version.php.in index 2809f321..4bd43901 100644 --- a/version.php.in +++ b/version.php.in @@ -1,6 +1,6 @@ diff --git a/views_view.php b/views_view.php new file mode 100644 index 00000000..92d9b13e --- /dev/null +++ b/views_view.php @@ -0,0 +1,60 @@ +assign("range",$range); + +if( ! checkAccess(GangliaAcl::ALL_VIEWS, GangliaAcl::VIEW, $conf) ) { + die("You do not have access to view views."); +} + +$available_views = get_available_views(); +// Pop up a warning message if there are no available views +// (Disable temporarily, otherwise we can't create views) +if ( sizeof($available_views) == -1 ) { + $error_msg = ' + + + + Alert: There are no views defined. + + + '; +} + + +foreach ( $available_views as $view_id => $view ) { + + if ( $view['view_name'] == $user["viewname"] ) { + + $view_elements = get_view_graph_elements($view); + + $view_items = array(); + + if ( count($view_elements) != 0 ) { + + $graphargs = ""; + if ($cs) + $graphargs .= "&cs=" . rawurlencode($cs); + if ($ce) + $graphargs .= "&ce=" . rawurlencode($ce); + + foreach ( $view_elements as $id => $element ) { + $view_items[] = array ( "legend" => isset($element['hostname']) ? $element['hostname'] : "Aggregate graph", + "url_args" => htmlentities($element['graph_args']) . "&z=medium&r=" . $range . $graphargs, + "aggregate_graph" => isset($element['aggregate_graph']) ? 1 : 0 + ); + } + } + + + $data->assign("number_of_view_items", sizeof($view_items)); + break; + + } // end of if ( $view['view_name'] == $view_name +} // end of foreach ( $views as $view_id + +$data->assign("view_items", $view_items); +$dwoo->output($tpl, $data); + +?>
+ No graphs defined for this view. Please add some +
+ Alert: There are no views defined.