2 /* $Id: get_context.php 970 2008-02-14 19:16:19Z carenas $ */
4 $meta_designator = "Grid";
5 $cluster_designator = "Cluster Overview";
7 # Blocking malicious CGI input.
8 $clustername = isset($_GET["c"]) ?
9 escapeshellcmd( clean_string( rawurldecode($_GET["c"]) ) ) : NULL;
10 $gridname = isset($_GET["G"]) ?
11 escapeshellcmd( clean_string( rawurldecode($_GET["G"]) ) ) : NULL;
12 $hostname = isset($_GET["h"]) ?
13 escapeshellcmd( clean_string( rawurldecode($_GET["h"]) ) ) : NULL;
14 $range = isset( $_GET["r"] ) && in_array($_GET["r"], array_keys( $time_ranges ) ) ?
15 escapeshellcmd( rawurldecode($_GET["r"])) : NULL;
16 $metricname = isset($_GET["m"]) ?
17 escapeshellcmd( clean_string( rawurldecode($_GET["m"]) ) ) : NULL;
18 $sort = isset($_GET["s"]) ?
19 escapeshellcmd( clean_string( rawurldecode($_GET["s"]) ) ) : NULL;
20 $controlroom = isset($_GET["cr"]) ?
21 clean_number( rawurldecode($_GET["cr"]) ) : NULL;
22 $hostcols = isset($_GET["hc"]) ?
23 clean_number( $_GET["hc"] ) : NULL;
24 # Flag, whether or not to show a list of hosts
25 $showhosts = isset($_GET["sh"]) ?
26 clean_number( $_GET["sh"] ) : NULL;
27 # The 'p' variable specifies the verbosity level in the physical view.
28 $physical = isset($_GET["p"]) ?
29 clean_number( $_GET["p"] ) : NULL;
30 $tree = isset($_GET["t"]) ?
31 escapeshellcmd($_GET["t"] ) : NULL;
32 # A custom range value for job graphs, in -sec.
33 $jobrange = isset($_GET["jr"]) ?
34 clean_number( $_GET["jr"] ) : NULL;
35 # A red vertical line for various events. Value specifies the event time.
36 $jobstart = isset($_GET["js"]) ?
37 clean_number( $_GET["js"] ) : NULL;
38 # The direction we are travelling in the grid tree
39 $gridwalk = isset($_GET["gw"]) ?
40 escapeshellcmd( clean_string( $_GET["gw"] ) ) : NULL;
41 # Size of the host graphs in the cluster view
42 $clustergraphsize = isset($_GET["z"]) && in_array( $_GET[ 'z' ], $graph_sizes_keys ) ?
43 escapeshellcmd($_GET["z"]) : NULL;
44 # A stack of grid parents. Prefer a GET variable, default to cookie.
45 if (isset($_GET["gs"]) and $_GET["gs"])
46 $gridstack = explode(":", clean_string( rawurldecode($_GET["gs"] ) ) );
48 $gridstack = explode(":", clean_string( $_COOKIE["gs"] ) );
50 # Assume we are the first grid visited in the tree if there are no CGI variables,
51 # or gridstack is not well formed. Gridstack always has at least one element.
52 if (!count($_GET) or !strstr($gridstack[0], "http://"))
56 if (!is_numeric($hostcols)) $hostcols = 4;
57 if (!is_numeric($showhosts)) $showhosts = 1;
60 if(!$clustername && !$hostname && $controlroom)
68 else if(!$clustername and !$gridname and !$hostname)
76 else if ($clustername and !$hostname and $physical)
78 $context = "physical";
80 else if ($clustername and !$hostname and !$showhosts)
82 $context = "cluster-summary";
84 else if($clustername and !$hostname)
88 else if($clustername and $hostname and $physical)
92 else if($clustername and $hostname)
98 $range = "$default_range";
102 # $time_ranges defined in conf.php
103 if( $range == 'job' && isSet( $jobrange ) ) {
105 } else if( isSet( $time_ranges[ $range ] ) ) {
106 $start = $time_ranges[ $range ] * -1;
108 $start = $time_ranges[ $default_time_range ] * -1;
112 $metricname = "$default_metric";
115 $sort = "descending";
117 # Since cluster context do not have the option to sort "by hosts down" or
118 # "by hosts up", therefore change sort order to "descending" if previous
119 # sort order is either "by hosts down" or "by hosts up"
120 if ($context == "cluster") {
121 if ($sort == "by hosts up" ||
$sort == "by hosts down") {
122 $sort = "descending";
126 # A hack for pre-2.5.0 ganglia data sources.
127 $always_constant = array(
133 $always_timestamp = array(
134 "gmond_started" => 1,
140 # List of report graphs
142 "load_report" => "load_one",
145 "network_report" => 1,