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