1 | <?php |
---|
2 | |
---|
3 | if ( !empty( $_GET ) ) { |
---|
4 | extract( $_GET ); |
---|
5 | } |
---|
6 | |
---|
7 | $my_dir = getcwd(); |
---|
8 | |
---|
9 | include_once "./libtoga.php"; |
---|
10 | |
---|
11 | global $GANGLIA_PATH; |
---|
12 | chdir( $GANGLIA_PATH ); |
---|
13 | |
---|
14 | include_once "./class.TemplatePower.inc.php"; |
---|
15 | chdir( $my_dir ); |
---|
16 | |
---|
17 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
18 | $clustername = $httpvars->getClusterName(); |
---|
19 | $view = $httpvars->getHttpVar( "view" ); |
---|
20 | |
---|
21 | $filter = array(); |
---|
22 | |
---|
23 | if( !isset($view) ) $view = "overview"; |
---|
24 | if( !isset($sortorder) ) $sortorder = "asc"; |
---|
25 | if( !isset($sortby) ) $sortby = "id"; |
---|
26 | if( isset($id) && ($id!='')) $filter[id]=$id; |
---|
27 | if( isset($state) && ($state!='')) $filter[state]=$state; |
---|
28 | if( isset($user) && ($user!='')) $filter[user]=$user; |
---|
29 | if( isset($queue) && ($queue!='')) $filter[queue]=$queue; |
---|
30 | |
---|
31 | function makeHeader() { |
---|
32 | |
---|
33 | global $tpl, $grid, $context, $initgrid; |
---|
34 | global $jobrange, $jobstart, $title; |
---|
35 | global $page, $gridwalk, $clustername; |
---|
36 | global $parentgrid, $physical, $hostname; |
---|
37 | global $self, $filter; |
---|
38 | |
---|
39 | if ( $context == "control" && $controlroom < 0 ) |
---|
40 | $header = "header-nobanner"; |
---|
41 | else |
---|
42 | $header = "header"; |
---|
43 | |
---|
44 | # Maintain our path through the grid tree. |
---|
45 | $me = $self . "@" . $grid[$self][AUTHORITY]; |
---|
46 | |
---|
47 | if ($initgrid) { |
---|
48 | $gridstack = array(); |
---|
49 | $gridstack[] = $me; |
---|
50 | } else if ($gridwalk=="fwd") { |
---|
51 | # push our info on gridstack, format is "name@url>name2@url". |
---|
52 | if (end($gridstack) != $me) { |
---|
53 | $gridstack[] = $me; |
---|
54 | } |
---|
55 | } else if ($gridwalk=="back") { |
---|
56 | # pop a single grid off stack. |
---|
57 | if (end($gridstack) != $me) { |
---|
58 | array_pop($gridstack); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | $gridstack_str = join(">", $gridstack); |
---|
63 | $gridstack_url = rawurlencode($gridstack_str); |
---|
64 | |
---|
65 | if ($initgrid or $gridwalk) { |
---|
66 | # Use cookie so we dont have to pass gridstack around within this site. |
---|
67 | # Cookie values are automatically urlencoded. Expires in a day. |
---|
68 | setcookie("gs", $gridstack_str, time() + 86400); |
---|
69 | } |
---|
70 | |
---|
71 | # Invariant: back pointer is second-to-last element of gridstack. Grid stack never |
---|
72 | # has duplicate entries. |
---|
73 | list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]); |
---|
74 | |
---|
75 | # Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell |
---|
76 | # destination server that we're walking foward in the grid tree. |
---|
77 | if (strstr($clustername, "http://")) { |
---|
78 | $tpl->assign("refresh", "0"); |
---|
79 | $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url"); |
---|
80 | echo "<h2>Redirecting, please wait...</h2>"; |
---|
81 | $tpl->printToScreen(); |
---|
82 | exit; |
---|
83 | } |
---|
84 | |
---|
85 | $tpl->assign( "refresh", $default_refresh ); |
---|
86 | $tpl->assign( "date", date("r") ); |
---|
87 | $tpl->assign( "page_title", $title ); |
---|
88 | |
---|
89 | # The page to go to when "Get Fresh Data" is pressed. |
---|
90 | if (isset($page)) |
---|
91 | $tpl->assign("page",$page); |
---|
92 | else |
---|
93 | $tpl->assign("page","./"); |
---|
94 | |
---|
95 | # Templated Logo image |
---|
96 | $tpl->assign("images","./templates/$template_name/images"); |
---|
97 | |
---|
98 | # |
---|
99 | # Used when making graphs via graph.php. Included in most URLs |
---|
100 | # |
---|
101 | $sort_url=rawurlencode($sort); |
---|
102 | $get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols"; |
---|
103 | |
---|
104 | if ($jobrange and $jobstart) |
---|
105 | $get_metric_string .= "&jr=$jobrange&js=$jobstart"; |
---|
106 | |
---|
107 | # Set the Alternate view link. |
---|
108 | $cluster_url=rawurlencode($clustername); |
---|
109 | $node_url=rawurlencode($hostname); |
---|
110 | |
---|
111 | # Make some information available to templates. |
---|
112 | $tpl->assign("cluster_url", $cluster_url); |
---|
113 | # Build the node_menu |
---|
114 | $node_menu = ""; |
---|
115 | |
---|
116 | if ($parentgrid) { |
---|
117 | $node_menu .= "<B>$parentgrid $meta_designator</B> "; |
---|
118 | $node_menu .= "<B>></B>\n"; |
---|
119 | } |
---|
120 | |
---|
121 | # Show grid. |
---|
122 | $mygrid = ($self == "unspecified") ? "" : $self; |
---|
123 | $node_menu .= "<B>$mygrid $meta_designator</B> "; |
---|
124 | $node_menu .= "<B>></B>\n"; |
---|
125 | |
---|
126 | if ($physical) |
---|
127 | $node_menu .= hiddenvar("p", $physical); |
---|
128 | |
---|
129 | if ( $clustername ) { |
---|
130 | $url = rawurlencode($clustername); |
---|
131 | $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">$clustername</A></B> "; |
---|
132 | //$node_menu .= "<B>></B>\n"; |
---|
133 | $node_menu .= hiddenvar("c", $clustername); |
---|
134 | } |
---|
135 | |
---|
136 | if( count( $filter ) > 0 ) { |
---|
137 | |
---|
138 | foreach( $filter as $filtername => $filterval ) { |
---|
139 | |
---|
140 | $node_menu .= "<B>></B>\n"; |
---|
141 | $node_menu .= "<B>'$filtername': $filterval</B> "; |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | $tpl->assign("node_menu", $node_menu); |
---|
146 | |
---|
147 | # Make sure that no data is cached.. |
---|
148 | header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Date in the past |
---|
149 | header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified |
---|
150 | header ("Cache-Control: no-cache, must-revalidate"); # HTTP/1.1 |
---|
151 | header ("Pragma: no-cache"); # HTTP/1.0 |
---|
152 | } |
---|
153 | |
---|
154 | function makeFooter() { |
---|
155 | global $tpl, $version, $parsetime; |
---|
156 | |
---|
157 | $tpl->assign("webfrontend-version",$version["webfrontend"]); |
---|
158 | $tpl->assign("togaweb-version", "0.1"); |
---|
159 | $tpl->assign("togaarch-version", "0.1"); |
---|
160 | $tpl->assign("togaplug-version", "0.1"); |
---|
161 | |
---|
162 | if ($version["gmetad"]) { |
---|
163 | $tpl->assign("webbackend-component", "gmetad"); |
---|
164 | $tpl->assign("webbackend-version",$version["gmetad"]); |
---|
165 | } else if ($version["gmond"]) { |
---|
166 | $tpl->assign("webbackend-component", "gmond"); |
---|
167 | $tpl->assign("webbackend-version", $version["gmond"]); |
---|
168 | } |
---|
169 | |
---|
170 | $tpl->assign("parsetime", sprintf("%.4f", $parsetime) . "s"); |
---|
171 | } |
---|
172 | |
---|
173 | function includeJobview() { |
---|
174 | global $tpl; |
---|
175 | |
---|
176 | $tpl->assignInclude( "main", "templates/jobview.tpl" ); |
---|
177 | } |
---|
178 | |
---|
179 | function includeOverview() { |
---|
180 | global $tpl; |
---|
181 | |
---|
182 | $tpl->assignInclude( "main", "templates/overview.tpl" ); |
---|
183 | } |
---|
184 | |
---|
185 | function makeJobview() { |
---|
186 | |
---|
187 | } |
---|
188 | |
---|
189 | $tpl = new TemplatePower( "templates/index.tpl" ); |
---|
190 | |
---|
191 | $tpl->assignInclude( "header", "templates/header.tpl" ); |
---|
192 | |
---|
193 | switch( $view ) { |
---|
194 | |
---|
195 | case "overview": |
---|
196 | |
---|
197 | includeOverview(); |
---|
198 | break; |
---|
199 | |
---|
200 | case "jobview": |
---|
201 | |
---|
202 | includeJobview(); |
---|
203 | break; |
---|
204 | |
---|
205 | default: |
---|
206 | |
---|
207 | includeOverview(); |
---|
208 | break; |
---|
209 | } |
---|
210 | |
---|
211 | $tpl->assignInclude( "footer", "templates/footer.tpl" ); |
---|
212 | $tpl->prepare(); |
---|
213 | |
---|
214 | $title = "Torque Report"; |
---|
215 | makeHeader(); |
---|
216 | |
---|
217 | switch( $view ) { |
---|
218 | |
---|
219 | case "overview": |
---|
220 | |
---|
221 | include "./overview.php"; |
---|
222 | makeOverview(); |
---|
223 | break; |
---|
224 | |
---|
225 | case "jobview": |
---|
226 | |
---|
227 | makeJobview(); |
---|
228 | break; |
---|
229 | |
---|
230 | default: |
---|
231 | |
---|
232 | makeOverview(); |
---|
233 | break; |
---|
234 | } |
---|
235 | |
---|
236 | makeFooter(); |
---|
237 | |
---|
238 | $tpl->printToScreen(); |
---|
239 | ?> |
---|